package m9; import c9.p; import d9.t; import k9.a0; import k9.d2; import k9.w2; import kotlin.coroutines.jvm.internal.h; import kotlinx.coroutines.internal.c0; import kotlinx.coroutines.internal.x; import s8.n; import s8.o; import v8.d; import v8.g; /* loaded from: classes2.dex */ public abstract class b { public static final void a(p pVar, Object obj, d dVar) { Object c10; d a10 = h.a(dVar); try { g context = dVar.getContext(); Object c11 = c0.c(context, null); try { Object invoke = ((p) t.a(pVar, 2)).invoke(obj, a10); c10 = w8.d.c(); if (invoke != c10) { a10.resumeWith(n.b(invoke)); } } finally { c0.a(context, c11); } } catch (Throwable th) { n.a aVar = n.f14096b; a10.resumeWith(n.b(o.a(th))); } } public static final Object b(x xVar, Object obj, p pVar) { Object a0Var; Object c10; Object c11; Object c12; try { a0Var = ((p) t.a(pVar, 2)).invoke(obj, xVar); } catch (Throwable th) { a0Var = new a0(th, false, 2, null); } c10 = w8.d.c(); if (a0Var == c10) { c12 = w8.d.c(); return c12; } Object Y = xVar.Y(a0Var); if (Y == d2.f11323b) { c11 = w8.d.c(); return c11; } if (Y instanceof a0) { throw ((a0) Y).f11296a; } return d2.h(Y); } public static final Object c(x xVar, Object obj, p pVar) { Object a0Var; Object c10; Object c11; Object c12; try { a0Var = ((p) t.a(pVar, 2)).invoke(obj, xVar); } catch (Throwable th) { a0Var = new a0(th, false, 2, null); } c10 = w8.d.c(); if (a0Var == c10) { c12 = w8.d.c(); return c12; } Object Y = xVar.Y(a0Var); if (Y == d2.f11323b) { c11 = w8.d.c(); return c11; } if (Y instanceof a0) { Throwable th2 = ((a0) Y).f11296a; if (((th2 instanceof w2) && ((w2) th2).f11402a == xVar) ? false : true) { throw th2; } if (a0Var instanceof a0) { throw ((a0) a0Var).f11296a; } } else { a0Var = d2.h(Y); } return a0Var; } }