package kotlinx.coroutines;

/* JADX INFO: Access modifiers changed from: package-private */
/* JADX INFO: compiled from: Builders.kt */
/* JADX INFO: loaded from: classes.dex */
public final /* synthetic */ class j {
    public static final <T> T a(h.u.g gVar, h.x.c.p<? super n0, ? super h.u.d<? super T>, ? extends Object> pVar) throws Throwable {
        f1 f1VarA;
        h.u.g gVarC;
        Thread threadCurrentThread = Thread.currentThread();
        h.u.e eVar = (h.u.e) gVar.b(h.u.e.a);
        if (eVar == null) {
            f1VarA = j2.a.b();
            gVarC = h0.c(l1.b, gVar.j(f1VarA));
        } else {
            f1 f1Var = null;
            f1 f1Var2 = eVar instanceof f1 ? (f1) eVar : null;
            if (f1Var2 != null && f1Var2.a0()) {
                f1Var = f1Var2;
            }
            f1VarA = f1Var == null ? j2.a.a() : f1Var;
            gVarC = h0.c(l1.b, gVar);
        }
        g gVar2 = new g(gVarC, threadCurrentThread, f1VarA);
        gVar2.G0(p0.DEFAULT, gVar2, pVar);
        return (T) gVar2.H0();
    }

    public static /* synthetic */ Object b(h.u.g gVar, h.x.c.p pVar, int i2, Object obj) throws InterruptedException {
        if ((i2 & 1) != 0) {
            gVar = h.u.h.b;
        }
        return i.c(gVar, pVar);
    }
}
