package v;

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

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

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public e5.a f24688a;

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

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public C2975E0 f24690c;

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

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

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public final /* synthetic */ C2975E0 f24693f;

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

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    /* JADX WARN: Multi-variable type inference failed */
    public C2971C0(C2975E0 c2975e0, J4.c cVar, A4.d dVar) {
        super(2, dVar);
        z0 z0Var = z0.f24987a;
        this.f24693f = c2975e0;
        this.f24694j = (C4.j) cVar;
    }

    /* JADX WARN: Type inference failed for: r1v0, types: [C4.j, J4.c] */
    @Override // C4.a
    public final A4.d create(Object obj, A4.d dVar) {
        ?? r12 = this.f24694j;
        z0 z0Var = z0.f24987a;
        C2971C0 c2971c0 = new C2971C0(this.f24693f, r12, dVar);
        c2971c0.f24692e = obj;
        return c2971c0;
    }

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

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Type inference failed for: r1v0, types: [int] */
    /* JADX WARN: Type inference failed for: r3v10 */
    /* JADX WARN: Type inference failed for: r3v2 */
    /* JADX WARN: Type inference failed for: r3v3, types: [J4.c] */
    @Override // C4.a
    public final Object invokeSuspend(Object obj) {
        C2975E0 c2975e0;
        ?? r32;
        C2969B0 c2969b0;
        e5.a aVar;
        e5.a aVar2;
        C2975E0 c2975e02;
        Throwable th;
        C2969B0 c2969b02;
        AtomicReference atomicReference;
        e5.a aVar3;
        AtomicReference atomicReference2;
        B4.a aVar4 = B4.a.f492a;
        ?? r12 = this.f24691d;
        try {
            try {
                if (r12 == 0) {
                    AbstractC2467b.l(obj);
                    A4.h hVar = ((V4.C) this.f24692e).getCoroutineContext().get(C0763h0.f8306a);
                    kotlin.jvm.internal.o.e(hVar);
                    C2969B0 c2969b03 = new C2969B0(z0.f24987a, (InterfaceC0765i0) hVar);
                    c2975e0 = this.f24693f;
                    C2975E0.a(c2975e0, c2969b03);
                    this.f24692e = c2969b03;
                    e5.c cVar = c2975e0.f24718b;
                    this.f24688a = cVar;
                    C4.j jVar = this.f24694j;
                    this.f24689b = jVar;
                    this.f24690c = c2975e0;
                    this.f24691d = 1;
                    if (cVar.e(this) != aVar4) {
                        r32 = jVar;
                        c2969b0 = c2969b03;
                        aVar = cVar;
                    }
                    return aVar4;
                }
                if (r12 != 1) {
                    if (r12 != 2) {
                        throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                    }
                    c2975e02 = (C2975E0) this.f24689b;
                    e5.a aVar5 = this.f24688a;
                    c2969b02 = (C2969B0) this.f24692e;
                    try {
                        AbstractC2467b.l(obj);
                        aVar3 = aVar5;
                        atomicReference2 = c2975e02.f24717a;
                        while (!atomicReference2.compareAndSet(c2969b02, null) && atomicReference2.get() == c2969b02) {
                        }
                        ((e5.c) aVar3).g(null);
                        return obj;
                    } catch (Throwable th2) {
                        th = th2;
                        atomicReference = c2975e02.f24717a;
                        while (!atomicReference.compareAndSet(c2969b02, null)) {
                        }
                        throw th;
                    }
                }
                C2975E0 c2975e03 = this.f24690c;
                J4.c cVar2 = (J4.c) this.f24689b;
                e5.a aVar6 = this.f24688a;
                c2969b0 = (C2969B0) this.f24692e;
                AbstractC2467b.l(obj);
                c2975e0 = c2975e03;
                r32 = cVar2;
                aVar = aVar6;
                this.f24692e = c2969b0;
                this.f24688a = aVar2;
                this.f24689b = c2975e0;
                this.f24690c = null;
                this.f24691d = 2;
                Object objInvoke = r32.invoke(this);
                if (objInvoke != aVar4) {
                    c2975e02 = c2975e0;
                    obj = objInvoke;
                    c2969b02 = c2969b0;
                    aVar3 = aVar2;
                    atomicReference2 = c2975e02.f24717a;
                    while (!atomicReference2.compareAndSet(c2969b02, null)) {
                    }
                    ((e5.c) aVar3).g(null);
                    return obj;
                }
                return aVar4;
            } catch (Throwable th3) {
                c2975e02 = c2975e0;
                th = th3;
                c2969b02 = c2969b0;
                atomicReference = c2975e02.f24717a;
                while (!atomicReference.compareAndSet(c2969b02, null) && atomicReference.get() == c2969b02) {
                }
                throw th;
            }
            aVar2 = aVar;
        } catch (Throwable th4) {
            ((e5.c) r12).g(null);
            throw th4;
        }
    }
}
