package d;

import d.q;

/* JADX INFO: compiled from: DeepRecursive.kt */
/* JADX INFO: loaded from: classes.dex */
@n
final class d<T, R> extends c<T, R> implements d.k0.a<R> {

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    private d.n0.b.q<? super c<?, ?>, Object, ? super d.k0.a<Object>, ? extends Object> f2569c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    private Object f2570d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    private d.k0.a<Object> f2571e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    private Object f2572f;

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

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

    public final R b() throws Throwable {
        while (true) {
            R r = (R) this.f2572f;
            d.k0.a<Object> aVar = this.f2571e;
            if (aVar == null) {
                r.b(r);
                return r;
            }
            if (q.b(b.f2564a, r)) {
                try {
                    d.n0.b.q<? super c<?, ?>, Object, ? super d.k0.a<Object>, ? extends Object> qVar = this.f2569c;
                    Object obj = this.f2570d;
                    d.n0.c.s.c(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?>");
                    Object objD = ((d.n0.b.q) d.n0.c.b0.a(qVar, 3)).d(this, obj, aVar);
                    if (objD != d.k0.e.d.a()) {
                        q.a aVar2 = q.f2687c;
                        aVar.c(q.a(objD));
                    }
                } catch (Throwable th) {
                    q.a aVar3 = q.f2687c;
                    aVar.c(q.a(r.a(th)));
                }
            } else {
                this.f2572f = b.f2564a;
                aVar.c(r);
            }
        }
    }

    @Override // d.k0.a
    public void c(Object obj) {
        this.f2571e = null;
        this.f2572f = obj;
    }

    @Override // d.k0.a
    public d.k0.c f() {
        return d.k0.d.f2603c;
    }
}
