package i0;

import V4.C;
import V4.E;
import V4.InterfaceC0765i0;
import java.util.concurrent.atomic.AtomicReference;
import m3.AbstractC2467b;
import w4.C3137A;

/* JADX INFO: renamed from: i0.v, reason: case insensitive filesystem */
/* JADX INFO: loaded from: classes.dex */
public final class C2258v extends C4.j implements J4.e {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public int f18823a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public /* synthetic */ Object f18824b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final /* synthetic */ kotlin.jvm.internal.p f18825c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public final /* synthetic */ AtomicReference f18826d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public final /* synthetic */ C4.j f18827e;

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    /* JADX WARN: Multi-variable type inference failed */
    public C2258v(J4.c cVar, AtomicReference atomicReference, J4.e eVar, A4.d dVar) {
        super(2, dVar);
        this.f18825c = (kotlin.jvm.internal.p) cVar;
        this.f18826d = atomicReference;
        this.f18827e = (C4.j) eVar;
    }

    /* JADX WARN: Type inference failed for: r2v0, types: [C4.j, J4.e] */
    /* JADX WARN: Type inference failed for: r3v0, types: [J4.c, kotlin.jvm.internal.p] */
    @Override // C4.a
    public final A4.d create(Object obj, A4.d dVar) {
        C2258v c2258v = new C2258v(this.f18825c, this.f18826d, this.f18827e, dVar);
        c2258v.f18824b = obj;
        return c2258v;
    }

    @Override // J4.e
    public final Object invoke(Object obj, Object obj2) {
        return ((C2258v) create((C) obj, (A4.d) obj2)).invokeSuspend(C3137A.f25453a);
    }

    /* JADX WARN: Type inference failed for: r7v0, types: [J4.c, kotlin.jvm.internal.p] */
    /* JADX WARN: Type inference failed for: r9v9, types: [C4.j, J4.e] */
    @Override // C4.a
    public final Object invokeSuspend(Object obj) throws Throwable {
        C2257u c2257u;
        C2257u c2257u2;
        B4.a aVar = B4.a.f492a;
        int i6 = this.f18823a;
        AtomicReference atomicReference = this.f18826d;
        try {
            if (i6 == 0) {
                AbstractC2467b.l(obj);
                C c6 = (C) this.f18824b;
                c2257u = new C2257u(E.q(c6.getCoroutineContext()), this.f18825c.invoke(c6));
                C2257u c2257u3 = (C2257u) atomicReference.getAndSet(c2257u);
                if (c2257u3 != null) {
                    InterfaceC0765i0 interfaceC0765i0 = c2257u3.f18821a;
                    this.f18824b = c2257u;
                    this.f18823a = 1;
                    if (E.j(interfaceC0765i0, this) != aVar) {
                    }
                    return aVar;
                }
            } else {
                if (i6 != 1) {
                    if (i6 != 2) {
                        throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                    }
                    c2257u2 = (C2257u) this.f18824b;
                    try {
                        AbstractC2467b.l(obj);
                        while (!atomicReference.compareAndSet(c2257u2, null) && atomicReference.get() == c2257u2) {
                        }
                        return obj;
                    } catch (Throwable th) {
                        th = th;
                        while (!atomicReference.compareAndSet(c2257u2, null)) {
                        }
                        throw th;
                    }
                }
                c2257u = (C2257u) this.f18824b;
                AbstractC2467b.l(obj);
            }
            ?? r9 = this.f18827e;
            Object obj2 = c2257u.f18822b;
            this.f18824b = c2257u;
            this.f18823a = 2;
            obj = r9.invoke(obj2, this);
            if (obj != aVar) {
                c2257u2 = c2257u;
                while (!atomicReference.compareAndSet(c2257u2, null)) {
                }
                return obj;
            }
            return aVar;
        } catch (Throwable th2) {
            th = th2;
            c2257u2 = c2257u;
            while (!atomicReference.compareAndSet(c2257u2, null) && atomicReference.get() == c2257u2) {
            }
            throw th;
        }
    }
}
