package h.u.i;

import h.m;
import h.r;
import h.u.g;
import h.u.j.a.h;
import h.u.j.a.j;
import h.x.c.l;
import h.x.c.p;
import h.x.d.k;
import h.x.d.y;

/* JADX INFO: Access modifiers changed from: package-private */
/* JADX INFO: compiled from: IntrinsicsJvm.kt */
/* JADX INFO: loaded from: classes.dex */
public class c {

    /* JADX INFO: compiled from: IntrinsicsJvm.kt */
    public static final class a extends j {

        /* JADX INFO: renamed from: e, reason: collision with root package name */
        private int f973e;

        /* JADX INFO: renamed from: f, reason: collision with root package name */
        final /* synthetic */ l f974f;

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        public a(h.u.d dVar, l lVar) {
            super(dVar);
            this.f974f = lVar;
        }

        @Override // h.u.j.a.a
        protected Object i(Object obj) throws Throwable {
            int i2 = this.f973e;
            if (i2 != 0) {
                if (i2 != 1) {
                    throw new IllegalStateException("This coroutine had already completed".toString());
                }
                this.f973e = 2;
                m.b(obj);
                return obj;
            }
            this.f973e = 1;
            m.b(obj);
            l lVar = this.f974f;
            y.b(lVar, 1);
            return lVar.invoke(this);
        }
    }

    /* JADX INFO: compiled from: IntrinsicsJvm.kt */
    public static final class b extends h.u.j.a.d {

        /* JADX INFO: renamed from: g, reason: collision with root package name */
        private int f975g;

        /* JADX INFO: renamed from: h, reason: collision with root package name */
        final /* synthetic */ l f976h;

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        public b(h.u.d dVar, g gVar, l lVar) {
            super(dVar, gVar);
            this.f976h = lVar;
        }

        @Override // h.u.j.a.a
        protected Object i(Object obj) throws Throwable {
            int i2 = this.f975g;
            if (i2 != 0) {
                if (i2 != 1) {
                    throw new IllegalStateException("This coroutine had already completed".toString());
                }
                this.f975g = 2;
                m.b(obj);
                return obj;
            }
            this.f975g = 1;
            m.b(obj);
            l lVar = this.f976h;
            y.b(lVar, 1);
            return lVar.invoke(this);
        }
    }

    /* JADX INFO: renamed from: h.u.i.c$c, reason: collision with other inner class name */
    /* JADX INFO: compiled from: IntrinsicsJvm.kt */
    public static final class C0061c extends j {

        /* JADX INFO: renamed from: e, reason: collision with root package name */
        private int f977e;

        /* JADX INFO: renamed from: f, reason: collision with root package name */
        final /* synthetic */ p f978f;

        /* JADX INFO: renamed from: g, reason: collision with root package name */
        final /* synthetic */ Object f979g;

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        public C0061c(h.u.d dVar, p pVar, Object obj) {
            super(dVar);
            this.f978f = pVar;
            this.f979g = obj;
        }

        @Override // h.u.j.a.a
        protected Object i(Object obj) throws Throwable {
            int i2 = this.f977e;
            if (i2 != 0) {
                if (i2 != 1) {
                    throw new IllegalStateException("This coroutine had already completed".toString());
                }
                this.f977e = 2;
                m.b(obj);
                return obj;
            }
            this.f977e = 1;
            m.b(obj);
            p pVar = this.f978f;
            y.b(pVar, 2);
            return pVar.a(this.f979g, this);
        }
    }

    /* JADX INFO: compiled from: IntrinsicsJvm.kt */
    public static final class d extends h.u.j.a.d {

        /* JADX INFO: renamed from: g, reason: collision with root package name */
        private int f980g;

        /* JADX INFO: renamed from: h, reason: collision with root package name */
        final /* synthetic */ p f981h;

        /* JADX INFO: renamed from: i, reason: collision with root package name */
        final /* synthetic */ Object f982i;

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        public d(h.u.d dVar, g gVar, p pVar, Object obj) {
            super(dVar, gVar);
            this.f981h = pVar;
            this.f982i = obj;
        }

        @Override // h.u.j.a.a
        protected Object i(Object obj) throws Throwable {
            int i2 = this.f980g;
            if (i2 != 0) {
                if (i2 != 1) {
                    throw new IllegalStateException("This coroutine had already completed".toString());
                }
                this.f980g = 2;
                m.b(obj);
                return obj;
            }
            this.f980g = 1;
            m.b(obj);
            p pVar = this.f981h;
            y.b(pVar, 2);
            return pVar.a(this.f982i, this);
        }
    }

    /* JADX WARN: Multi-variable type inference failed */
    public static <T> h.u.d<r> a(l<? super h.u.d<? super T>, ? extends Object> lVar, h.u.d<? super T> dVar) {
        k.d(lVar, "<this>");
        k.d(dVar, "completion");
        h.a(dVar);
        if (lVar instanceof h.u.j.a.a) {
            ((h.u.j.a.a) lVar).d(dVar);
            throw null;
        }
        g context = dVar.getContext();
        return context == h.u.h.b ? new a(dVar, lVar) : new b(dVar, context, lVar);
    }

    /* JADX WARN: Multi-variable type inference failed */
    public static <R, T> h.u.d<r> b(p<? super R, ? super h.u.d<? super T>, ? extends Object> pVar, R r, h.u.d<? super T> dVar) {
        k.d(pVar, "<this>");
        k.d(dVar, "completion");
        h.a(dVar);
        if (pVar instanceof h.u.j.a.a) {
            return ((h.u.j.a.a) pVar).b(r, dVar);
        }
        g context = dVar.getContext();
        return context == h.u.h.b ? new C0061c(dVar, pVar, r) : new d(dVar, context, pVar, r);
    }

    /* JADX WARN: Multi-variable type inference failed */
    public static <T> h.u.d<T> c(h.u.d<? super T> dVar) {
        h.u.d<T> dVar2;
        k.d(dVar, "<this>");
        h.u.j.a.d dVar3 = dVar instanceof h.u.j.a.d ? (h.u.j.a.d) dVar : null;
        return (dVar3 == null || (dVar2 = (h.u.d<T>) dVar3.l()) == null) ? dVar : dVar2;
    }
}
