package tp;

import rm.x;

/* loaded from: classes3.dex */
public abstract class z0 {
    public static final void a(y0 y0Var, int i10) {
        vm.d c10 = y0Var.c();
        boolean z10 = i10 == 4;
        if (z10 || !(c10 instanceof zp.j) || b(i10) != b(y0Var.f36601r)) {
            d(y0Var, c10, z10);
            return;
        }
        i0 i0Var = ((zp.j) c10).f53553s;
        vm.g context = c10.getContext();
        if (i0Var.L(context)) {
            i0Var.C(context, y0Var);
        } else {
            e(y0Var);
        }
    }

    public static final boolean b(int i10) {
        return i10 == 1 || i10 == 2;
    }

    public static final boolean c(int i10) {
        return i10 == 2;
    }

    public static final void d(y0 y0Var, vm.d dVar, boolean z10) {
        Object e10;
        Object g10 = y0Var.g();
        Throwable d10 = y0Var.d(g10);
        if (d10 != null) {
            x.a aVar = rm.x.f34910p;
            e10 = rm.y.a(d10);
        } else {
            x.a aVar2 = rm.x.f34910p;
            e10 = y0Var.e(g10);
        }
        Object a10 = rm.x.a(e10);
        if (!z10) {
            dVar.resumeWith(a10);
            return;
        }
        kotlin.jvm.internal.t.e(dVar, "null cannot be cast to non-null type kotlinx.coroutines.internal.DispatchedContinuation<T of kotlinx.coroutines.DispatchedTaskKt.resume>");
        zp.j jVar = (zp.j) dVar;
        vm.d dVar2 = jVar.f53554t;
        Object obj = jVar.f53556v;
        vm.g context = dVar2.getContext();
        Object c10 = zp.l0.c(context, obj);
        w2 g11 = c10 != zp.l0.f53561a ? h0.g(dVar2, context, c10) : null;
        try {
            jVar.f53554t.resumeWith(a10);
            rm.n0 n0Var = rm.n0.f34904a;
        } finally {
            if (g11 == null || g11.X0()) {
                zp.l0.a(context, c10);
            }
        }
    }

    private static final void e(y0 y0Var) {
        e1 b10 = t2.f36590a.b();
        if (b10.n0()) {
            b10.e0(y0Var);
            return;
        }
        b10.j0(true);
        try {
            d(y0Var, y0Var.c(), true);
            do {
            } while (b10.q0());
        } finally {
            try {
            } finally {
            }
        }
    }
}
