package j;

import j.q;

/* JADX INFO: compiled from: DeepRecursive.kt */
/* JADX INFO: loaded from: classes.dex */
final class d<T, R> extends c<T, R> implements j.m0.a<R> {
    private j.p0.c.q<? super c<?, ?>, Object, ? super j.m0.a<Object>, ? extends Object> b;
    private Object d;
    private j.m0.a<Object> e;
    private Object f;

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    /* JADX WARN: Multi-variable type inference failed */
    public d(j.p0.c.q<? super c<T, R>, ? super T, ? super j.m0.a<? super R>, ? extends Object> qVar, T t) {
        super(null);
        j.p0.d.r.f(qVar, "block");
        this.b = qVar;
        this.d = t;
        j.p0.d.r.d(this, "null cannot be cast to non-null type kotlin.coroutines.Continuation<kotlin.Any?>");
        this.e = this;
        this.f = b.a;
    }

    @Override // j.m0.a
    public void a(Object obj) {
        this.e = null;
        this.f = obj;
    }

    @Override // j.c
    public Object b(T t, j.m0.a<? super R> aVar) {
        j.p0.d.r.d(aVar, "null cannot be cast to non-null type kotlin.coroutines.Continuation<kotlin.Any?>");
        this.e = aVar;
        this.d = t;
        Object objA = j.m0.e.d.a();
        if (objA == j.m0.e.d.a()) {
            j.m0.f.a.f.b(aVar);
        }
        return objA;
    }

    @Override // j.m0.a
    public j.m0.c c() {
        return j.m0.d.b;
    }

    public final R d() throws Throwable {
        while (true) {
            R r = (R) this.f;
            j.m0.a<Object> aVar = this.e;
            if (aVar == null) {
                r.b(r);
                return r;
            }
            if (q.b(b.a, r)) {
                try {
                    j.p0.c.q<? super c<?, ?>, Object, ? super j.m0.a<Object>, ? extends Object> qVar = this.b;
                    Object obj = this.d;
                    j.p0.d.r.d(qVar, "null cannot be cast to non-null type kotlin.Function3<R of kotlin.coroutines.intrinsics.IntrinsicsKt__IntrinsicsJvmKt.startCoroutineUninterceptedOrReturn, P of kotlin.coroutines.intrinsics.IntrinsicsKt__IntrinsicsJvmKt.startCoroutineUninterceptedOrReturn, kotlin.coroutines.Continuation<T of kotlin.coroutines.intrinsics.IntrinsicsKt__IntrinsicsJvmKt.startCoroutineUninterceptedOrReturn>, kotlin.Any?>");
                    j.p0.d.h0.b(qVar, 3);
                    Object objB = qVar.b(this, obj, aVar);
                    if (objB != j.m0.e.d.a()) {
                        q.a aVar2 = q.b;
                        q.a(objB);
                        aVar.a(objB);
                    }
                } catch (Throwable th) {
                    q.a aVar3 = q.b;
                    Object objA = r.a(th);
                    q.a(objA);
                    aVar.a(objA);
                }
            } else {
                this.f = b.a;
                aVar.a(r);
            }
        }
    }
}
