package G4;

import B4.A;
import B4.AbstractC0025v;
import B4.H;
import B4.O;
import B4.m0;
import d4.C0547f;
import e4.C0563g;
import j4.AbstractC0801c;
import j4.InterfaceC0802d;
import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;

/* JADX INFO: loaded from: classes.dex */
public final class f extends H implements InterfaceC0802d, h4.c {

    /* JADX INFO: renamed from: r, reason: collision with root package name */
    public static final /* synthetic */ AtomicReferenceFieldUpdater f840r = AtomicReferenceFieldUpdater.newUpdater(f.class, Object.class, "_reusableCancellableContinuation$volatile");
    private volatile /* synthetic */ Object _reusableCancellableContinuation$volatile;

    /* JADX INFO: renamed from: n, reason: collision with root package name */
    public final AbstractC0025v f841n;

    /* JADX INFO: renamed from: o, reason: collision with root package name */
    public final AbstractC0801c f842o;
    public Object p;
    public final Object q;

    public f(AbstractC0025v abstractC0025v, AbstractC0801c abstractC0801c) {
        super(-1);
        this.f841n = abstractC0025v;
        this.f842o = abstractC0801c;
        this.p = a.f829b;
        this.q = a.k(abstractC0801c.getContext());
    }

    @Override // j4.InterfaceC0802d
    public final InterfaceC0802d getCallerFrame() {
        return this.f842o;
    }

    @Override // h4.c
    public final h4.h getContext() {
        return this.f842o.getContext();
    }

    @Override // B4.H
    public final Object h() {
        Object obj = this.p;
        this.p = a.f829b;
        return obj;
    }

    @Override // h4.c
    public final void resumeWith(Object obj) {
        Throwable thA = C0547f.a(obj);
        Object rVar = thA == null ? obj : new B4.r(thA, false);
        AbstractC0801c abstractC0801c = this.f842o;
        h4.h context = abstractC0801c.getContext();
        AbstractC0025v abstractC0025v = this.f841n;
        if (abstractC0025v.r(context)) {
            this.p = rVar;
            this.f204m = 0;
            abstractC0025v.o(abstractC0801c.getContext(), this);
            return;
        }
        O oA = m0.a();
        if (oA.f210m >= 4294967296L) {
            this.p = rVar;
            this.f204m = 0;
            C0563g c0563g = oA.f212o;
            if (c0563g == null) {
                c0563g = new C0563g();
                oA.f212o = c0563g;
            }
            c0563g.addLast(this);
            return;
        }
        oA.w(true);
        try {
            h4.h context2 = abstractC0801c.getContext();
            Object objL = a.l(context2, this.q);
            try {
                abstractC0801c.resumeWith(obj);
                while (oA.y()) {
                }
            } finally {
                a.g(context2, objL);
            }
        } finally {
            try {
            } finally {
            }
        }
    }

    public final String toString() {
        return "DispatchedContinuation[" + this.f841n + ", " + A.m(this.f842o) + ']';
    }

    @Override // B4.H
    public final h4.c d() {
        return this;
    }
}
