package b7;

import Z6.AbstractC0385z;
import Z6.B0;
import Z6.C0369i;
import Z6.F;
import Z6.InterfaceC0367g;
import com.google.android.gms.internal.measurement.C1;
import d3.V0;
import d5.AbstractC0844a;
import e7.AbstractC0892a;
import h7.C1040e;
import h7.EnumC1044i;
import h7.InterfaceC1041f;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.concurrent.CancellationException;
import java.util.concurrent.atomic.AtomicLongFieldUpdater;
import java.util.concurrent.atomic.AtomicReferenceArray;
import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;

/* JADX INFO: renamed from: b7.f, reason: case insensitive filesystem */
/* JADX INFO: loaded from: classes.dex */
public class C0556f implements InterfaceC0560j {

    /* JADX INFO: renamed from: r, reason: collision with root package name */
    public static final /* synthetic */ AtomicLongFieldUpdater f9230r = AtomicLongFieldUpdater.newUpdater(C0556f.class, "sendersAndCloseStatus$volatile");

    /* JADX INFO: renamed from: s, reason: collision with root package name */
    public static final /* synthetic */ AtomicLongFieldUpdater f9231s = AtomicLongFieldUpdater.newUpdater(C0556f.class, "receivers$volatile");

    /* JADX INFO: renamed from: t, reason: collision with root package name */
    public static final /* synthetic */ AtomicLongFieldUpdater f9232t = AtomicLongFieldUpdater.newUpdater(C0556f.class, "bufferEnd$volatile");

    /* JADX INFO: renamed from: u, reason: collision with root package name */
    public static final /* synthetic */ AtomicLongFieldUpdater f9233u = AtomicLongFieldUpdater.newUpdater(C0556f.class, "completedExpandBuffersAndPauseFlag$volatile");

    /* JADX INFO: renamed from: v, reason: collision with root package name */
    public static final /* synthetic */ AtomicReferenceFieldUpdater f9234v = AtomicReferenceFieldUpdater.newUpdater(C0556f.class, Object.class, "sendSegment$volatile");

    /* JADX INFO: renamed from: w, reason: collision with root package name */
    public static final /* synthetic */ AtomicReferenceFieldUpdater f9235w = AtomicReferenceFieldUpdater.newUpdater(C0556f.class, Object.class, "receiveSegment$volatile");

    /* JADX INFO: renamed from: x, reason: collision with root package name */
    public static final /* synthetic */ AtomicReferenceFieldUpdater f9236x = AtomicReferenceFieldUpdater.newUpdater(C0556f.class, Object.class, "bufferEndSegment$volatile");

    /* JADX INFO: renamed from: y, reason: collision with root package name */
    public static final /* synthetic */ AtomicReferenceFieldUpdater f9237y = AtomicReferenceFieldUpdater.newUpdater(C0556f.class, Object.class, "_closeCause$volatile");

    /* JADX INFO: renamed from: z, reason: collision with root package name */
    public static final /* synthetic */ AtomicReferenceFieldUpdater f9238z = AtomicReferenceFieldUpdater.newUpdater(C0556f.class, Object.class, "closeHandler$volatile");
    private volatile /* synthetic */ Object _closeCause$volatile;
    private volatile /* synthetic */ long bufferEnd$volatile;
    private volatile /* synthetic */ Object bufferEndSegment$volatile;
    private volatile /* synthetic */ Object closeHandler$volatile;
    private volatile /* synthetic */ long completedExpandBuffersAndPauseFlag$volatile;

    /* JADX INFO: renamed from: q, reason: collision with root package name */
    public final int f9239q;
    private volatile /* synthetic */ Object receiveSegment$volatile;
    private volatile /* synthetic */ long receivers$volatile;
    private volatile /* synthetic */ Object sendSegment$volatile;
    private volatile /* synthetic */ long sendersAndCloseStatus$volatile;

    public C0556f(int i) {
        this.f9239q = i;
        if (i < 0) {
            throw new IllegalArgumentException(I1.a.k(i, "Invalid channel capacity: ", ", should be >=0").toString());
        }
        n nVar = AbstractC0558h.f9241a;
        this.bufferEnd$volatile = i != 0 ? i != Integer.MAX_VALUE ? i : Long.MAX_VALUE : 0L;
        this.completedExpandBuffersAndPauseFlag$volatile = f9232t.get(this);
        n nVar2 = new n(0L, null, this, 3);
        this.sendSegment$volatile = nVar2;
        this.receiveSegment$volatile = nVar2;
        if (w()) {
            nVar2 = AbstractC0558h.f9241a;
            P6.g.c(nVar2, "null cannot be cast to non-null type kotlinx.coroutines.channels.ChannelSegment<E of kotlinx.coroutines.channels.BufferedChannel>");
        }
        this.bufferEndSegment$volatile = nVar2;
        this._closeCause$volatile = AbstractC0558h.f9258s;
    }

    public static final n a(C0556f c0556f, long j8, n nVar) {
        Object objB;
        C0556f c0556f2;
        c0556f.getClass();
        n nVar2 = AbstractC0558h.f9241a;
        C0557g c0557g = C0557g.f9240y;
        loop0: while (true) {
            objB = AbstractC0892a.b(nVar, j8, c0557g);
            if (!AbstractC0892a.e(objB)) {
                e7.r rVarC = AbstractC0892a.c(objB);
                while (true) {
                    AtomicReferenceFieldUpdater atomicReferenceFieldUpdater = f9234v;
                    e7.r rVar = (e7.r) atomicReferenceFieldUpdater.get(c0556f);
                    if (rVar.f12574s >= rVarC.f12574s) {
                        break loop0;
                    }
                    if (!rVarC.j()) {
                        break;
                    }
                    while (!atomicReferenceFieldUpdater.compareAndSet(c0556f, rVar, rVarC)) {
                        if (atomicReferenceFieldUpdater.get(c0556f) != rVar) {
                            if (rVarC.f()) {
                                rVarC.e();
                            }
                        }
                    }
                    if (rVar.f()) {
                        rVar.e();
                    }
                }
            } else {
                break;
            }
        }
        boolean zE = AbstractC0892a.e(objB);
        AtomicLongFieldUpdater atomicLongFieldUpdater = f9231s;
        if (zE) {
            c0556f.u();
            if (nVar.f12574s * ((long) AbstractC0558h.f9242b) < atomicLongFieldUpdater.get(c0556f)) {
                nVar.a();
                return null;
            }
        } else {
            n nVar3 = (n) AbstractC0892a.c(objB);
            long j9 = nVar3.f12574s;
            if (j9 <= j8) {
                return nVar3;
            }
            long j10 = ((long) AbstractC0558h.f9242b) * j9;
            while (true) {
                AtomicLongFieldUpdater atomicLongFieldUpdater2 = f9230r;
                long j11 = atomicLongFieldUpdater2.get(c0556f);
                long j12 = 1152921504606846975L & j11;
                if (j12 >= j10) {
                    c0556f2 = c0556f;
                    break;
                }
                c0556f2 = c0556f;
                if (atomicLongFieldUpdater2.compareAndSet(c0556f2, j11, j12 + (((long) ((int) (j11 >> 60))) << 60))) {
                    break;
                }
                c0556f = c0556f2;
            }
            if (j9 * ((long) AbstractC0558h.f9242b) < atomicLongFieldUpdater.get(c0556f2)) {
                nVar3.a();
            }
        }
        return null;
    }

    public static final void c(C0556f c0556f, Object obj, C0369i c0369i) throws IllegalAccessException, F, InvocationTargetException {
        c0556f.getClass();
        c0369i.i(C1.j(c0556f.p()));
    }

    public static final int d(C0556f c0556f, n nVar, int i, Object obj, long j8, Object obj2, boolean z8) {
        c0556f.getClass();
        nVar.n(i, obj);
        if (z8) {
            return c0556f.D(nVar, i, obj, j8, obj2, z8);
        }
        Object objL = nVar.l(i);
        if (objL == null) {
            if (c0556f.f(j8)) {
                if (nVar.k(null, i, AbstractC0558h.f9244d)) {
                    return 1;
                }
            } else {
                if (obj2 == null) {
                    return 3;
                }
                if (nVar.k(null, i, obj2)) {
                    return 2;
                }
            }
        } else if (objL instanceof B0) {
            nVar.n(i, null);
            if (c0556f.A(objL, obj)) {
                nVar.o(i, AbstractC0558h.i);
                return 0;
            }
            B3.f fVar = AbstractC0558h.f9250k;
            if (nVar.f9266v.getAndSet((i * 2) + 1, fVar) == fVar) {
                return 5;
            }
            nVar.m(i, true);
            return 5;
        }
        return c0556f.D(nVar, i, obj, j8, obj2, z8);
    }

    public static void r(C0556f c0556f) {
        c0556f.getClass();
        AtomicLongFieldUpdater atomicLongFieldUpdater = f9233u;
        if ((atomicLongFieldUpdater.addAndGet(c0556f, 1L) & 4611686018427387904L) != 0) {
            while ((atomicLongFieldUpdater.get(c0556f) & 4611686018427387904L) != 0) {
            }
        }
    }

    public final boolean A(Object obj, Object obj2) throws F {
        if (obj instanceof InterfaceC1041f) {
            return ((C1040e) ((InterfaceC1041f) obj)).g(this, obj2);
        }
        if (!(obj instanceof C0553c)) {
            if (!(obj instanceof InterfaceC0367g)) {
                throw new IllegalStateException(("Unexpected receiver type: " + obj).toString());
            }
            P6.g.c(obj, "null cannot be cast to non-null type kotlinx.coroutines.CancellableContinuation<E of kotlinx.coroutines.channels.BufferedChannel>");
            InterfaceC0367g interfaceC0367g = (InterfaceC0367g) obj;
            n nVar = AbstractC0558h.f9241a;
            B3.f fVarD = interfaceC0367g.d(obj2, null);
            if (fVarD == null) {
                return false;
            }
            interfaceC0367g.o(fVarD);
            return true;
        }
        P6.g.c(obj, "null cannot be cast to non-null type kotlinx.coroutines.channels.BufferedChannel.BufferedChannelIterator<E of kotlinx.coroutines.channels.BufferedChannel>");
        C0553c c0553c = (C0553c) obj;
        C0369i c0369i = c0553c.f9226r;
        P6.g.b(c0369i);
        c0553c.f9226r = null;
        c0553c.f9225q = obj2;
        Boolean bool = Boolean.TRUE;
        c0553c.f9227s.getClass();
        n nVar2 = AbstractC0558h.f9241a;
        B3.f fVarD2 = c0369i.d(bool, null);
        if (fVarD2 == null) {
            return false;
        }
        c0369i.o(fVarD2);
        return true;
    }

    public final boolean B(Object obj, n nVar, int i) {
        EnumC1044i enumC1044i;
        boolean z8 = obj instanceof InterfaceC0367g;
        A6.n nVar2 = A6.n.f457a;
        if (z8) {
            P6.g.c(obj, "null cannot be cast to non-null type kotlinx.coroutines.CancellableContinuation<kotlin.Unit>");
            InterfaceC0367g interfaceC0367g = (InterfaceC0367g) obj;
            n nVar3 = AbstractC0558h.f9241a;
            B3.f fVarD = interfaceC0367g.d(nVar2, null);
            if (fVarD == null) {
                return false;
            }
            interfaceC0367g.o(fVarD);
            return true;
        }
        if (!(obj instanceof InterfaceC1041f)) {
            throw new IllegalStateException(("Unexpected waiter: " + obj).toString());
        }
        P6.g.c(obj, "null cannot be cast to non-null type kotlinx.coroutines.selects.SelectImplementation<*>");
        int iH = ((C1040e) obj).h(this, nVar2);
        EnumC1044i enumC1044i2 = EnumC1044i.f13470q;
        EnumC1044i enumC1044i3 = EnumC1044i.f13471r;
        if (iH == 0) {
            enumC1044i = enumC1044i2;
        } else if (iH == 1) {
            enumC1044i = enumC1044i3;
        } else if (iH == 2) {
            enumC1044i = EnumC1044i.f13472s;
        } else {
            if (iH != 3) {
                throw new IllegalStateException(("Unexpected internal result: " + iH).toString());
            }
            enumC1044i = EnumC1044i.f13473t;
        }
        if (enumC1044i == enumC1044i3) {
            nVar.n(i, null);
        }
        return enumC1044i == enumC1044i2;
    }

    public final Object C(n nVar, int i, long j8, Object obj) {
        Object objL = nVar.l(i);
        AtomicReferenceArray atomicReferenceArray = nVar.f9266v;
        AtomicLongFieldUpdater atomicLongFieldUpdater = f9230r;
        if (objL == null) {
            if (j8 >= (atomicLongFieldUpdater.get(this) & 1152921504606846975L)) {
                if (obj == null) {
                    return AbstractC0558h.f9253n;
                }
                if (nVar.k(objL, i, obj)) {
                    j();
                    return AbstractC0558h.f9252m;
                }
            }
        } else if (objL == AbstractC0558h.f9244d && nVar.k(objL, i, AbstractC0558h.i)) {
            j();
            Object obj2 = atomicReferenceArray.get(i * 2);
            nVar.n(i, null);
            return obj2;
        }
        while (true) {
            Object objL2 = nVar.l(i);
            if (objL2 == null || objL2 == AbstractC0558h.f9245e) {
                if (j8 < (atomicLongFieldUpdater.get(this) & 1152921504606846975L)) {
                    if (nVar.k(objL2, i, AbstractC0558h.f9248h)) {
                        j();
                        return AbstractC0558h.f9254o;
                    }
                } else {
                    if (obj == null) {
                        return AbstractC0558h.f9253n;
                    }
                    if (nVar.k(objL2, i, obj)) {
                        j();
                        return AbstractC0558h.f9252m;
                    }
                }
            } else if (objL2 != AbstractC0558h.f9244d) {
                B3.f fVar = AbstractC0558h.f9249j;
                if (objL2 == fVar) {
                    return AbstractC0558h.f9254o;
                }
                if (objL2 == AbstractC0558h.f9248h) {
                    return AbstractC0558h.f9254o;
                }
                if (objL2 == AbstractC0558h.f9251l) {
                    j();
                    return AbstractC0558h.f9254o;
                }
                if (objL2 != AbstractC0558h.f9247g && nVar.k(objL2, i, AbstractC0558h.f9246f)) {
                    boolean z8 = objL2 instanceof x;
                    if (z8) {
                        objL2 = ((x) objL2).f9274a;
                    }
                    if (B(objL2, nVar, i)) {
                        nVar.o(i, AbstractC0558h.i);
                        j();
                        Object obj3 = atomicReferenceArray.get(i * 2);
                        nVar.n(i, null);
                        return obj3;
                    }
                    nVar.o(i, fVar);
                    nVar.i();
                    if (z8) {
                        j();
                    }
                    return AbstractC0558h.f9254o;
                }
            } else if (nVar.k(objL2, i, AbstractC0558h.i)) {
                j();
                Object obj4 = atomicReferenceArray.get(i * 2);
                nVar.n(i, null);
                return obj4;
            }
        }
    }

    public final int D(n nVar, int i, Object obj, long j8, Object obj2, boolean z8) {
        while (true) {
            Object objL = nVar.l(i);
            if (objL == null) {
                if (!f(j8) || z8) {
                    if (z8) {
                        if (nVar.k(null, i, AbstractC0558h.f9249j)) {
                            nVar.i();
                            return 4;
                        }
                    } else {
                        if (obj2 == null) {
                            return 3;
                        }
                        if (nVar.k(null, i, obj2)) {
                            return 2;
                        }
                    }
                } else if (nVar.k(null, i, AbstractC0558h.f9244d)) {
                    break;
                }
            } else {
                if (objL != AbstractC0558h.f9245e) {
                    B3.f fVar = AbstractC0558h.f9250k;
                    if (objL == fVar) {
                        nVar.n(i, null);
                        return 5;
                    }
                    if (objL == AbstractC0558h.f9248h) {
                        nVar.n(i, null);
                        return 5;
                    }
                    if (objL == AbstractC0558h.f9251l) {
                        nVar.n(i, null);
                        u();
                        return 4;
                    }
                    nVar.n(i, null);
                    if (objL instanceof x) {
                        objL = ((x) objL).f9274a;
                    }
                    if (A(objL, obj)) {
                        nVar.o(i, AbstractC0558h.i);
                        return 0;
                    }
                    if (nVar.f9266v.getAndSet((i * 2) + 1, fVar) != fVar) {
                        nVar.m(i, true);
                    }
                    return 5;
                }
                if (nVar.k(objL, i, AbstractC0558h.f9244d)) {
                    break;
                }
            }
        }
        return 1;
    }

    public final void E(long j8) {
        AtomicLongFieldUpdater atomicLongFieldUpdater;
        C0556f c0556f = this;
        if (c0556f.w()) {
            return;
        }
        while (true) {
            atomicLongFieldUpdater = f9232t;
            if (atomicLongFieldUpdater.get(c0556f) > j8) {
                break;
            } else {
                c0556f = this;
            }
        }
        int i = AbstractC0558h.f9243c;
        int i5 = 0;
        while (true) {
            AtomicLongFieldUpdater atomicLongFieldUpdater2 = f9233u;
            if (i5 < i) {
                long j9 = atomicLongFieldUpdater.get(c0556f);
                if (j9 == (4611686018427387903L & atomicLongFieldUpdater2.get(c0556f)) && j9 == atomicLongFieldUpdater.get(c0556f)) {
                    return;
                } else {
                    i5++;
                }
            } else {
                while (true) {
                    long j10 = atomicLongFieldUpdater2.get(c0556f);
                    if (atomicLongFieldUpdater2.compareAndSet(c0556f, j10, (j10 & 4611686018427387903L) + 4611686018427387904L)) {
                        break;
                    } else {
                        c0556f = this;
                    }
                }
                while (true) {
                    long j11 = atomicLongFieldUpdater.get(c0556f);
                    long j12 = atomicLongFieldUpdater2.get(c0556f);
                    long j13 = j12 & 4611686018427387903L;
                    boolean z8 = (j12 & 4611686018427387904L) != 0;
                    if (j11 == j13 && j11 == atomicLongFieldUpdater.get(c0556f)) {
                        break;
                    }
                    if (!z8) {
                        atomicLongFieldUpdater2.compareAndSet(this, j12, 4611686018427387904L + j13);
                    }
                    c0556f = this;
                }
                while (true) {
                    long j14 = atomicLongFieldUpdater2.get(c0556f);
                    if (atomicLongFieldUpdater2.compareAndSet(c0556f, j14, j14 & 4611686018427387903L)) {
                        return;
                    } else {
                        c0556f = this;
                    }
                }
            }
        }
    }

    @Override // b7.v
    public final void b(CancellationException cancellationException) {
        if (cancellationException == null) {
            cancellationException = new CancellationException("Channel was cancelled");
        }
        g(cancellationException, true);
    }

    /* JADX WARN: Removed duplicated region for block: B:22:0x0068  */
    /* JADX WARN: Removed duplicated region for block: B:57:0x00be A[SYNTHETIC] */
    @Override // b7.w
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public Object e(Object obj) throws IllegalAccessException, F, InvocationTargetException {
        int iD;
        AtomicLongFieldUpdater atomicLongFieldUpdater = f9230r;
        boolean z8 = false;
        long j8 = 1152921504606846975L;
        boolean z9 = s(atomicLongFieldUpdater.get(this), false) ? false : !f(r1 & 1152921504606846975L);
        C0562l c0562l = m.f9263b;
        if (z9) {
            return c0562l;
        }
        Object obj2 = AbstractC0558h.f9249j;
        n nVar = (n) f9234v.get(this);
        while (true) {
            long andIncrement = atomicLongFieldUpdater.getAndIncrement(this);
            long j9 = andIncrement & j8;
            boolean zS = s(andIncrement, z8);
            int i = AbstractC0558h.f9242b;
            long j10 = i;
            long j11 = j9 / j10;
            int i5 = (int) (j9 % j10);
            if (nVar.f12574s == j11) {
                iD = d(this, nVar, i5, obj, j9, obj2, zS);
                A6.n nVar2 = A6.n.f457a;
                if (iD != 0) {
                    nVar.a();
                    return nVar2;
                }
                if (iD == 1) {
                    return nVar2;
                }
                if (iD == 2) {
                    if (zS) {
                        nVar.i();
                        return new C0561k(p());
                    }
                    B0 b02 = obj2 instanceof B0 ? (B0) obj2 : null;
                    if (b02 != null) {
                        b02.a(nVar, i5 + i);
                    }
                    nVar.i();
                    return c0562l;
                }
                if (iD == 3) {
                    throw new IllegalStateException("unexpected");
                }
                if (iD == 4) {
                    if (j9 < f9231s.get(this)) {
                        nVar.a();
                    }
                    return new C0561k(p());
                }
                if (iD == 5) {
                    nVar.a();
                }
                z8 = false;
            } else {
                n nVarA = a(this, j11, nVar);
                if (nVarA != null) {
                    nVar = nVarA;
                    iD = d(this, nVar, i5, obj, j9, obj2, zS);
                    A6.n nVar22 = A6.n.f457a;
                    if (iD != 0) {
                    }
                } else {
                    if (zS) {
                        return new C0561k(p());
                    }
                    z8 = false;
                }
            }
            j8 = 1152921504606846975L;
        }
    }

    public final boolean f(long j8) {
        return j8 < f9232t.get(this) || j8 < f9231s.get(this) + ((long) this.f9239q);
    }

    public final boolean g(Throwable th, boolean z8) {
        C0556f c0556f;
        boolean z9;
        long j8;
        long j9;
        long j10;
        Object obj;
        long j11;
        long j12;
        AtomicLongFieldUpdater atomicLongFieldUpdater = f9230r;
        if (!z8) {
            c0556f = this;
            break;
        }
        do {
            j12 = atomicLongFieldUpdater.get(this);
            if (((int) (j12 >> 60)) != 0) {
                c0556f = this;
                break;
            }
            n nVar = AbstractC0558h.f9241a;
            c0556f = this;
        } while (!atomicLongFieldUpdater.compareAndSet(c0556f, j12, (j12 & 1152921504606846975L) + (((long) 1) << 60)));
        B3.f fVar = AbstractC0558h.f9258s;
        while (true) {
            AtomicReferenceFieldUpdater atomicReferenceFieldUpdater = f9237y;
            if (atomicReferenceFieldUpdater.compareAndSet(this, fVar, th)) {
                z9 = true;
                break;
            }
            if (atomicReferenceFieldUpdater.get(this) != fVar) {
                z9 = false;
                break;
            }
        }
        if (z8) {
            do {
                j11 = atomicLongFieldUpdater.get(this);
            } while (!atomicLongFieldUpdater.compareAndSet(c0556f, j11, (((long) 3) << 60) + (j11 & 1152921504606846975L)));
        } else {
            do {
                j8 = atomicLongFieldUpdater.get(this);
                int i = (int) (j8 >> 60);
                if (i == 0) {
                    j9 = j8 & 1152921504606846975L;
                    j10 = 2;
                } else {
                    if (i != 1) {
                        break;
                    }
                    j9 = j8 & 1152921504606846975L;
                    j10 = 3;
                }
            } while (!atomicLongFieldUpdater.compareAndSet(c0556f, j8, (j10 << 60) + j9));
        }
        u();
        if (z9) {
            loop3: while (true) {
                AtomicReferenceFieldUpdater atomicReferenceFieldUpdater2 = f9238z;
                obj = atomicReferenceFieldUpdater2.get(this);
                B3.f fVar2 = obj == null ? AbstractC0558h.f9256q : AbstractC0558h.f9257r;
                while (!atomicReferenceFieldUpdater2.compareAndSet(this, obj, fVar2)) {
                    if (atomicReferenceFieldUpdater2.get(this) != obj) {
                        break;
                    }
                }
            }
            if (obj != null) {
                P6.p.b(1, obj);
                ((O6.l) obj).b(n());
                return z9;
            }
        }
        return z9;
    }

    /* JADX WARN: Code restructure failed: missing block: B:37:0x008f, code lost:
    
        r1 = (b7.n) ((e7.b) e7.b.f12541r.get(r1));
     */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final n h(long j8) throws IllegalAccessException, F, InvocationTargetException {
        Object objF;
        long j9;
        AtomicReferenceFieldUpdater atomicReferenceFieldUpdater;
        Object obj = f9236x.get(this);
        n nVar = (n) f9234v.get(this);
        if (nVar.f12574s > ((n) obj).f12574s) {
            obj = nVar;
        }
        n nVar2 = (n) f9235w.get(this);
        if (nVar2.f12574s > ((n) obj).f12574s) {
            obj = nVar2;
        }
        e7.b bVar = (e7.b) obj;
        loop0: while (true) {
            bVar.getClass();
            Object obj2 = e7.b.f12540q.get(bVar);
            B3.f fVar = AbstractC0892a.f12533a;
            objF = null;
            if (obj2 == fVar) {
                break;
            }
            e7.b bVar2 = (e7.b) obj2;
            if (bVar2 == null) {
                do {
                    atomicReferenceFieldUpdater = e7.b.f12540q;
                    if (atomicReferenceFieldUpdater.compareAndSet(bVar, null, fVar)) {
                        break loop0;
                    }
                } while (atomicReferenceFieldUpdater.get(bVar) == null);
            } else {
                bVar = bVar2;
            }
        }
        n nVar3 = (n) bVar;
        if (v()) {
            n nVar4 = nVar3;
            loop2: do {
                int i = AbstractC0558h.f9242b - 1;
                while (true) {
                    if (-1 >= i) {
                        break;
                    }
                    j9 = (nVar4.f12574s * ((long) AbstractC0558h.f9242b)) + ((long) i);
                    if (j9 < f9231s.get(this)) {
                        break loop2;
                    }
                    while (true) {
                        Object objL = nVar4.l(i);
                        if (objL != null && objL != AbstractC0558h.f9245e) {
                            if (objL == AbstractC0558h.f9244d) {
                                break loop2;
                            }
                        } else {
                            if (nVar4.k(objL, i, AbstractC0558h.f9251l)) {
                                nVar4.i();
                                break;
                            }
                        }
                    }
                    i--;
                }
            } while (nVar4 != null);
            j9 = -1;
            if (j9 != -1) {
                i(j9);
            }
        }
        loop5: for (n nVar5 = nVar3; nVar5 != null; nVar5 = (n) ((e7.b) e7.b.f12541r.get(nVar5))) {
            for (int i5 = AbstractC0558h.f9242b - 1; -1 < i5; i5--) {
                if ((nVar5.f12574s * ((long) AbstractC0558h.f9242b)) + ((long) i5) < j8) {
                    break loop5;
                }
                while (true) {
                    Object objL2 = nVar5.l(i5);
                    if (objL2 != null && objL2 != AbstractC0558h.f9245e) {
                        if (!(objL2 instanceof x)) {
                            if (!(objL2 instanceof B0)) {
                                break;
                            }
                            if (nVar5.k(objL2, i5, AbstractC0558h.f9251l)) {
                                objF = AbstractC0892a.f(objF, objL2);
                                nVar5.m(i5, true);
                                break;
                            }
                        } else {
                            if (nVar5.k(objL2, i5, AbstractC0558h.f9251l)) {
                                objF = AbstractC0892a.f(objF, ((x) objL2).f9274a);
                                nVar5.m(i5, true);
                                break;
                            }
                        }
                    } else {
                        if (nVar5.k(objL2, i5, AbstractC0558h.f9251l)) {
                            nVar5.i();
                            break;
                        }
                    }
                }
            }
        }
        if (objF != null) {
            if (!(objF instanceof ArrayList)) {
                z((B0) objF, true);
                return nVar3;
            }
            ArrayList arrayList = (ArrayList) objF;
            for (int size = arrayList.size() - 1; -1 < size; size--) {
                z((B0) arrayList.get(size), true);
            }
        }
        return nVar3;
    }

    public final void i(long j8) {
        n nVar = (n) f9235w.get(this);
        while (true) {
            AtomicLongFieldUpdater atomicLongFieldUpdater = f9231s;
            long j9 = atomicLongFieldUpdater.get(this);
            if (j8 < Math.max(((long) this.f9239q) + j9, f9232t.get(this))) {
                return;
            }
            if (atomicLongFieldUpdater.compareAndSet(this, j9, 1 + j9)) {
                long j10 = AbstractC0558h.f9242b;
                long j11 = j9 / j10;
                int i = (int) (j9 % j10);
                if (nVar.f12574s != j11) {
                    n nVarM = m(j11, nVar);
                    if (nVarM != null) {
                        nVar = nVarM;
                    }
                }
                n nVar2 = nVar;
                if (C(nVar2, i, j9, null) != AbstractC0558h.f9254o || j9 < q()) {
                    nVar2.a();
                }
                nVar = nVar2;
            }
        }
    }

    /* JADX WARN: Code restructure failed: missing block: B:102:0x018e, code lost:
    
        r(r15);
     */
    /* JADX WARN: Code restructure failed: missing block: B:103:0x0191, code lost:
    
        return;
     */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void j() {
        Object objB;
        if (w()) {
            return;
        }
        AtomicReferenceFieldUpdater atomicReferenceFieldUpdater = f9236x;
        n nVar = (n) atomicReferenceFieldUpdater.get(this);
        loop0: while (true) {
            long andIncrement = f9232t.getAndIncrement(this);
            long j8 = andIncrement / ((long) AbstractC0558h.f9242b);
            if (q() <= andIncrement) {
                if (nVar.f12574s < j8 && nVar.c() != null) {
                    x(j8, nVar);
                }
                r(this);
                return;
            }
            if (nVar.f12574s != j8) {
                C0557g c0557g = C0557g.f9240y;
                while (true) {
                    objB = AbstractC0892a.b(nVar, j8, c0557g);
                    if (!AbstractC0892a.e(objB)) {
                        e7.r rVarC = AbstractC0892a.c(objB);
                        while (true) {
                            e7.r rVar = (e7.r) atomicReferenceFieldUpdater.get(this);
                            if (rVar.f12574s >= rVarC.f12574s) {
                                break;
                            }
                            if (!rVarC.j()) {
                                break;
                            }
                            while (!atomicReferenceFieldUpdater.compareAndSet(this, rVar, rVarC)) {
                                if (atomicReferenceFieldUpdater.get(this) != rVar) {
                                    if (rVarC.f()) {
                                        rVarC.e();
                                    }
                                }
                            }
                            if (rVar.f()) {
                                rVar.e();
                            }
                        }
                    } else {
                        break;
                    }
                }
                n nVar2 = null;
                if (AbstractC0892a.e(objB)) {
                    u();
                    x(j8, nVar);
                    r(this);
                } else {
                    n nVar3 = (n) AbstractC0892a.c(objB);
                    long j9 = nVar3.f12574s;
                    if (j9 > j8) {
                        long j10 = j9 * ((long) AbstractC0558h.f9242b);
                        if (f9232t.compareAndSet(this, 1 + andIncrement, j10)) {
                            AtomicLongFieldUpdater atomicLongFieldUpdater = f9233u;
                            if ((atomicLongFieldUpdater.addAndGet(this, j10 - andIncrement) & 4611686018427387904L) != 0) {
                                while ((atomicLongFieldUpdater.get(this) & 4611686018427387904L) != 0) {
                                }
                            }
                        } else {
                            r(this);
                        }
                    } else {
                        nVar2 = nVar3;
                    }
                }
                if (nVar2 == null) {
                    continue;
                } else {
                    nVar = nVar2;
                }
            }
            int i = (int) (andIncrement % ((long) AbstractC0558h.f9242b));
            Object objL = nVar.l(i);
            boolean z8 = objL instanceof B0;
            AtomicLongFieldUpdater atomicLongFieldUpdater2 = f9231s;
            if (!z8 || andIncrement < atomicLongFieldUpdater2.get(this) || !nVar.k(objL, i, AbstractC0558h.f9247g)) {
                while (true) {
                    Object objL2 = nVar.l(i);
                    if (!(objL2 instanceof B0)) {
                        if (objL2 != AbstractC0558h.f9249j) {
                            if (objL2 != null) {
                                if (objL2 == AbstractC0558h.f9244d || objL2 == AbstractC0558h.f9248h || objL2 == AbstractC0558h.i || objL2 == AbstractC0558h.f9250k || objL2 == AbstractC0558h.f9251l) {
                                    break loop0;
                                }
                                if (objL2 != AbstractC0558h.f9246f) {
                                    throw new IllegalStateException(("Unexpected cell state: " + objL2).toString());
                                }
                            } else if (nVar.k(objL2, i, AbstractC0558h.f9245e)) {
                                break loop0;
                            }
                        } else {
                            break;
                        }
                    } else if (andIncrement < atomicLongFieldUpdater2.get(this)) {
                        if (nVar.k(objL2, i, new x((B0) objL2))) {
                            break loop0;
                        }
                    } else if (nVar.k(objL2, i, AbstractC0558h.f9247g)) {
                        if (B(objL2, nVar, i)) {
                            nVar.o(i, AbstractC0558h.f9244d);
                            break;
                        } else {
                            nVar.o(i, AbstractC0558h.f9249j);
                            nVar.i();
                        }
                    }
                }
            } else if (B(objL, nVar, i)) {
                nVar.o(i, AbstractC0558h.f9244d);
                break;
            } else {
                nVar.o(i, AbstractC0558h.f9249j);
                nVar.i();
                r(this);
            }
        }
    }

    /* JADX WARN: Code restructure failed: missing block: B:104:0x0178, code lost:
    
        return r10;
     */
    /* JADX WARN: Code restructure failed: missing block: B:46:0x00c2, code lost:
    
        c(r1, r4, r7);
     */
    /* JADX WARN: Removed duplicated region for block: B:94:0x0161  */
    /* JADX WARN: Removed duplicated region for block: B:96:0x0164 A[RETURN] */
    @Override // b7.w
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public Object k(E6.d dVar, Object obj) throws Throwable {
        int iD;
        Object objU;
        Object obj2;
        C0556f c0556f;
        n nVar;
        int i;
        C0556f c0556f2 = this;
        AtomicReferenceFieldUpdater atomicReferenceFieldUpdater = f9234v;
        n nVar2 = (n) atomicReferenceFieldUpdater.get(c0556f2);
        while (true) {
            AtomicLongFieldUpdater atomicLongFieldUpdater = f9230r;
            long andIncrement = atomicLongFieldUpdater.getAndIncrement(c0556f2);
            long j8 = andIncrement & 1152921504606846975L;
            boolean zS = c0556f2.s(andIncrement, false);
            int i5 = AbstractC0558h.f9242b;
            long j9 = i5;
            long j10 = j8 / j9;
            int i8 = (int) (j8 % j9);
            long j11 = nVar2.f12574s;
            A6.n nVar3 = A6.n.f457a;
            F6.a aVar = F6.a.f2580q;
            if (j11 != j10) {
                n nVarA = a(c0556f2, j10, nVar2);
                if (nVarA != null) {
                    nVar2 = nVarA;
                } else if (zS) {
                    Object objY = y(dVar, obj);
                    if (objY == aVar) {
                        return objY;
                    }
                }
            }
            int iD2 = d(c0556f2, nVar2, i8, obj, j8, null, zS);
            if (iD2 == 0) {
                nVar2.a();
                return nVar3;
            }
            if (iD2 == 1) {
                break;
            }
            if (iD2 != 2) {
                AtomicLongFieldUpdater atomicLongFieldUpdater2 = f9231s;
                if (iD2 == 3) {
                    C0369i c0369iO = AbstractC0385z.o(C1.A(dVar));
                    Object obj3 = obj;
                    try {
                        iD = d(c0556f2, nVar2, i8, obj3, j8, c0369iO, false);
                        try {
                        } catch (Throwable th) {
                            th = th;
                        }
                    } catch (Throwable th2) {
                        th = th2;
                    }
                    if (iD != 0) {
                        if (iD == 1) {
                            c0369iO.i(nVar3);
                        } else if (iD != 2) {
                            if (iD != 4) {
                                String str = "unexpected";
                                if (iD != 5) {
                                    throw new IllegalStateException("unexpected");
                                }
                                nVar2.a();
                                n nVar4 = (n) atomicReferenceFieldUpdater.get(c0556f2);
                                while (true) {
                                    long andIncrement2 = atomicLongFieldUpdater.getAndIncrement(c0556f2);
                                    long j12 = andIncrement2 & 1152921504606846975L;
                                    boolean zS2 = c0556f2.s(andIncrement2, false);
                                    int i9 = AbstractC0558h.f9242b;
                                    long j13 = i9;
                                    String str2 = str;
                                    long j14 = j12 / j13;
                                    int i10 = (int) (j12 % j13);
                                    if (nVar4.f12574s != j14) {
                                        n nVarA2 = a(c0556f2, j14, nVar4);
                                        if (nVarA2 != null) {
                                            i = i9;
                                            nVar = nVarA2;
                                        } else {
                                            if (zS2) {
                                                break;
                                            }
                                            str = str2;
                                        }
                                    } else {
                                        nVar = nVar4;
                                        i = i9;
                                    }
                                    int iD3 = d(c0556f2, nVar, i10, obj3, j12, c0369iO, zS2);
                                    Object obj4 = obj3;
                                    c0556f = c0556f2;
                                    n nVar5 = nVar;
                                    obj2 = obj4;
                                    if (iD3 == 0) {
                                        nVar5.a();
                                        break;
                                    }
                                    if (iD3 == 1) {
                                        break;
                                    }
                                    if (iD3 != 2) {
                                        if (iD3 == 3) {
                                            throw new IllegalStateException(str2);
                                        }
                                        if (iD3 != 4) {
                                            if (iD3 == 5) {
                                                nVar5.a();
                                            }
                                            nVar4 = nVar5;
                                            c0556f2 = c0556f;
                                            str = str2;
                                            obj3 = obj2;
                                        } else if (j12 < atomicLongFieldUpdater2.get(c0556f)) {
                                            nVar5.a();
                                        }
                                    } else if (zS2) {
                                        nVar5.i();
                                    } else {
                                        c0369iO.a(nVar5, i10 + i);
                                    }
                                }
                                c0369iO.C();
                                throw th;
                            }
                            obj2 = obj3;
                            c0556f = c0556f2;
                            if (j8 < atomicLongFieldUpdater2.get(c0556f)) {
                                nVar2.a();
                            }
                            c(c0556f, obj2, c0369iO);
                        } else {
                            c0369iO.a(nVar2, i8 + i5);
                        }
                        objU = c0369iO.u();
                        if (objU != aVar) {
                            objU = nVar3;
                        }
                        if (objU != aVar) {
                            return objU;
                        }
                    } else {
                        nVar2.a();
                    }
                    c0369iO.i(nVar3);
                    objU = c0369iO.u();
                    if (objU != aVar) {
                    }
                    if (objU != aVar) {
                    }
                } else if (iD2 == 4) {
                    if (j8 < atomicLongFieldUpdater2.get(c0556f2)) {
                        nVar2.a();
                    }
                    Object objY2 = y(dVar, obj);
                    if (objY2 == aVar) {
                        return objY2;
                    }
                } else if (iD2 == 5) {
                    nVar2.a();
                }
            } else if (zS) {
                nVar2.i();
                Object objY3 = y(dVar, obj);
                if (objY3 == aVar) {
                    return objY3;
                }
            }
        }
    }

    @Override // b7.v
    public final V0 l() {
        P6.p.b(3, C0554d.f9228y);
        P6.p.b(3, C0555e.f9229y);
        return new V0(this, (AbstractC0552b) null);
    }

    public final n m(long j8, n nVar) {
        Object objB;
        AtomicLongFieldUpdater atomicLongFieldUpdater;
        long j9;
        n nVar2 = AbstractC0558h.f9241a;
        C0557g c0557g = C0557g.f9240y;
        loop0: while (true) {
            objB = AbstractC0892a.b(nVar, j8, c0557g);
            if (!AbstractC0892a.e(objB)) {
                e7.r rVarC = AbstractC0892a.c(objB);
                while (true) {
                    AtomicReferenceFieldUpdater atomicReferenceFieldUpdater = f9235w;
                    e7.r rVar = (e7.r) atomicReferenceFieldUpdater.get(this);
                    if (rVar.f12574s >= rVarC.f12574s) {
                        break loop0;
                    }
                    if (!rVarC.j()) {
                        break;
                    }
                    while (!atomicReferenceFieldUpdater.compareAndSet(this, rVar, rVarC)) {
                        if (atomicReferenceFieldUpdater.get(this) != rVar) {
                            if (rVarC.f()) {
                                rVarC.e();
                            }
                        }
                    }
                    if (rVar.f()) {
                        rVar.e();
                    }
                }
            } else {
                break;
            }
        }
        if (AbstractC0892a.e(objB)) {
            u();
            if (nVar.f12574s * ((long) AbstractC0558h.f9242b) < q()) {
                nVar.a();
                return null;
            }
        } else {
            n nVar3 = (n) AbstractC0892a.c(objB);
            boolean zW = w();
            long j10 = nVar3.f12574s;
            if (!zW && j8 <= f9232t.get(this) / ((long) AbstractC0558h.f9242b)) {
                while (true) {
                    AtomicReferenceFieldUpdater atomicReferenceFieldUpdater2 = f9236x;
                    e7.r rVar2 = (e7.r) atomicReferenceFieldUpdater2.get(this);
                    if (rVar2.f12574s >= j10 || !nVar3.j()) {
                        break;
                    }
                    while (!atomicReferenceFieldUpdater2.compareAndSet(this, rVar2, nVar3)) {
                        if (atomicReferenceFieldUpdater2.get(this) != rVar2) {
                            if (nVar3.f()) {
                                nVar3.e();
                            }
                        }
                    }
                    if (rVar2.f()) {
                        rVar2.e();
                    }
                }
            }
            if (j10 <= j8) {
                return nVar3;
            }
            long j11 = j10 * ((long) AbstractC0558h.f9242b);
            do {
                atomicLongFieldUpdater = f9231s;
                j9 = atomicLongFieldUpdater.get(this);
                if (j9 >= j11) {
                    break;
                }
            } while (!atomicLongFieldUpdater.compareAndSet(this, j9, j11));
            if (j10 * ((long) AbstractC0558h.f9242b) < q()) {
                nVar3.a();
            }
        }
        return null;
    }

    public final Throwable n() {
        return (Throwable) f9237y.get(this);
    }

    public final Throwable o() {
        Throwable thN = n();
        return thN == null ? new o("Channel was closed") : thN;
    }

    public final Throwable p() {
        Throwable thN = n();
        return thN == null ? new p("Channel was closed") : thN;
    }

    public final long q() {
        return f9230r.get(this) & 1152921504606846975L;
    }

    /* JADX WARN: Code restructure failed: missing block: B:53:0x00a2, code lost:
    
        r0 = (b7.n) ((e7.b) e7.b.f12541r.get(r0));
     */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final boolean s(long j8, boolean z8) throws IllegalAccessException, F, InvocationTargetException {
        int i = (int) (j8 >> 60);
        if (i != 0 && i != 1) {
            AtomicLongFieldUpdater atomicLongFieldUpdater = f9231s;
            if (i == 2) {
                h(1152921504606846975L & j8);
                if (z8) {
                    while (true) {
                        AtomicReferenceFieldUpdater atomicReferenceFieldUpdater = f9235w;
                        n nVarM = (n) atomicReferenceFieldUpdater.get(this);
                        long j9 = atomicLongFieldUpdater.get(this);
                        if (q() <= j9) {
                            break;
                        }
                        long j10 = AbstractC0558h.f9242b;
                        long j11 = j9 / j10;
                        if (nVarM.f12574s != j11 && (nVarM = m(j11, nVarM)) == null) {
                            if (((n) atomicReferenceFieldUpdater.get(this)).f12574s < j11) {
                                break;
                            }
                        } else {
                            nVarM.a();
                            int i5 = (int) (j9 % j10);
                            while (true) {
                                Object objL = nVarM.l(i5);
                                if (objL != null && objL != AbstractC0558h.f9245e) {
                                    if (objL == AbstractC0558h.f9244d || (objL != AbstractC0558h.f9249j && objL != AbstractC0558h.f9251l && objL != AbstractC0558h.i && objL != AbstractC0558h.f9248h && (objL == AbstractC0558h.f9247g || (objL != AbstractC0558h.f9246f && j9 == atomicLongFieldUpdater.get(this))))) {
                                        break;
                                    }
                                } else {
                                    if (nVarM.k(objL, i5, AbstractC0558h.f9248h)) {
                                        j();
                                        break;
                                    }
                                }
                            }
                            f9231s.compareAndSet(this, j9, j9 + 1);
                        }
                    }
                }
            } else {
                if (i != 3) {
                    throw new IllegalStateException(AbstractC0844a.j("unexpected close status: ", i).toString());
                }
                n nVarH = h(1152921504606846975L & j8);
                Object objF = null;
                loop0: do {
                    int i8 = AbstractC0558h.f9242b - 1;
                    while (true) {
                        if (-1 >= i8) {
                            break;
                        }
                        long j12 = (nVarH.f12574s * ((long) AbstractC0558h.f9242b)) + ((long) i8);
                        while (true) {
                            Object objL2 = nVarH.l(i8);
                            if (objL2 == AbstractC0558h.i) {
                                break loop0;
                            }
                            if (objL2 != AbstractC0558h.f9244d) {
                                if (objL2 != AbstractC0558h.f9245e && objL2 != null) {
                                    if (!(objL2 instanceof B0) && !(objL2 instanceof x)) {
                                        B3.f fVar = AbstractC0558h.f9247g;
                                        if (objL2 == fVar || objL2 == AbstractC0558h.f9246f) {
                                            break loop0;
                                        }
                                        if (objL2 != fVar) {
                                            break;
                                        }
                                    } else {
                                        if (j12 < atomicLongFieldUpdater.get(this)) {
                                            break loop0;
                                        }
                                        B0 b02 = objL2 instanceof x ? ((x) objL2).f9274a : (B0) objL2;
                                        if (nVarH.k(objL2, i8, AbstractC0558h.f9251l)) {
                                            objF = AbstractC0892a.f(objF, b02);
                                            nVarH.n(i8, null);
                                            nVarH.i();
                                            break;
                                        }
                                    }
                                } else {
                                    if (nVarH.k(objL2, i8, AbstractC0558h.f9251l)) {
                                        nVarH.i();
                                        break;
                                    }
                                }
                            } else {
                                if (j12 < atomicLongFieldUpdater.get(this)) {
                                    break loop0;
                                }
                                if (nVarH.k(objL2, i8, AbstractC0558h.f9251l)) {
                                    nVarH.n(i8, null);
                                    nVarH.i();
                                    break;
                                }
                            }
                        }
                        i8--;
                    }
                } while (nVarH != null);
                if (objF != null) {
                    if (objF instanceof ArrayList) {
                        ArrayList arrayList = (ArrayList) objF;
                        for (int size = arrayList.size() - 1; -1 < size; size--) {
                            z((B0) arrayList.get(size), false);
                        }
                    } else {
                        z((B0) objF, false);
                    }
                }
            }
            return true;
        }
        return false;
    }

    public final boolean t() {
        return s(f9230r.get(this), true);
    }

    /* JADX WARN: Code restructure failed: missing block: B:82:0x01ae, code lost:
    
        r16 = r7;
        r3 = (b7.n) r3.c();
     */
    /* JADX WARN: Code restructure failed: missing block: B:83:0x01b7, code lost:
    
        if (r3 != null) goto L93;
     */
    /* JADX WARN: Multi-variable type inference failed */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final String toString() {
        boolean z8;
        String string;
        StringBuilder sb = new StringBuilder();
        int i = (int) (f9230r.get(this) >> 60);
        if (i == 2) {
            sb.append("closed,");
        } else if (i == 3) {
            sb.append("cancelled,");
        }
        sb.append("capacity=" + this.f9239q + ',');
        sb.append("data=[");
        int i5 = 0;
        boolean z9 = true;
        List listW = B6.l.W(f9235w.get(this), f9234v.get(this), f9236x.get(this));
        ArrayList arrayList = new ArrayList();
        for (Object obj : listW) {
            if (((n) obj) != AbstractC0558h.f9241a) {
                arrayList.add(obj);
            }
        }
        Iterator it = arrayList.iterator();
        if (!it.hasNext()) {
            throw new NoSuchElementException();
        }
        Object next = it.next();
        if (it.hasNext()) {
            long j8 = ((n) next).f12574s;
            do {
                Object next2 = it.next();
                long j9 = ((n) next2).f12574s;
                if (j8 > j9) {
                    next = next2;
                    j8 = j9;
                }
            } while (it.hasNext());
        }
        n nVar = (n) next;
        long j10 = f9231s.get(this);
        long jQ = q();
        loop2: while (true) {
            int i8 = AbstractC0558h.f9242b;
            int i9 = i5;
            while (true) {
                if (i9 >= i8) {
                    break;
                }
                long j11 = (nVar.f12574s * ((long) AbstractC0558h.f9242b)) + ((long) i9);
                if (j11 >= jQ && j11 >= j10) {
                    break loop2;
                }
                Object objL = nVar.l(i9);
                boolean z10 = z9;
                Object obj2 = nVar.f9266v.get(i9 * 2);
                if (objL instanceof InterfaceC0367g) {
                    string = (j11 >= j10 || j11 < jQ) ? (j11 >= jQ || j11 < j10) ? "cont" : "send" : "receive";
                } else if (objL instanceof InterfaceC1041f) {
                    string = (j11 >= j10 || j11 < jQ) ? (j11 >= jQ || j11 < j10) ? "select" : "onSend" : "onReceive";
                } else if (objL instanceof x) {
                    string = "EB(" + objL + ')';
                } else if (P6.g.a(objL, AbstractC0558h.f9246f) || P6.g.a(objL, AbstractC0558h.f9247g)) {
                    string = "resuming_sender";
                } else if (objL == null || objL.equals(AbstractC0558h.f9245e) || objL.equals(AbstractC0558h.i) || objL.equals(AbstractC0558h.f9248h) || objL.equals(AbstractC0558h.f9250k) || objL.equals(AbstractC0558h.f9249j) || objL.equals(AbstractC0558h.f9251l)) {
                    i9++;
                    z9 = z10;
                } else {
                    string = objL.toString();
                }
                if (obj2 != null) {
                    sb.append("(" + string + ',' + obj2 + "),");
                } else {
                    sb.append(string + ',');
                }
                i9++;
                z9 = z10;
            }
            z9 = z8;
            i5 = 0;
        }
        if (sb.length() == 0) {
            throw new NoSuchElementException("Char sequence is empty.");
        }
        if (sb.charAt(X6.e.Q(sb)) == ',') {
            P6.g.d(sb.deleteCharAt(sb.length() - 1), "deleteCharAt(...)");
        }
        sb.append("]");
        return sb.toString();
    }

    public final boolean u() {
        return s(f9230r.get(this), false);
    }

    public boolean v() {
        return false;
    }

    public final boolean w() {
        long j8 = f9232t.get(this);
        return j8 == 0 || j8 == Long.MAX_VALUE;
    }

    /* JADX WARN: Code restructure failed: missing block: B:39:0x0011, code lost:
    
        continue;
     */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void x(long j8, n nVar) {
        n nVar2;
        n nVar3;
        while (nVar.f12574s < j8 && (nVar3 = (n) nVar.c()) != null) {
            nVar = nVar3;
        }
        while (true) {
            if (!nVar.d() || (nVar2 = (n) nVar.c()) == null) {
                while (true) {
                    AtomicReferenceFieldUpdater atomicReferenceFieldUpdater = f9236x;
                    e7.r rVar = (e7.r) atomicReferenceFieldUpdater.get(this);
                    if (rVar.f12574s >= nVar.f12574s) {
                        return;
                    }
                    if (!nVar.j()) {
                        break;
                    }
                    while (!atomicReferenceFieldUpdater.compareAndSet(this, rVar, nVar)) {
                        if (atomicReferenceFieldUpdater.get(this) != rVar) {
                            if (nVar.f()) {
                                nVar.e();
                            }
                        }
                    }
                    if (rVar.f()) {
                        rVar.e();
                        return;
                    }
                    return;
                }
            }
            nVar = nVar2;
        }
    }

    public final Object y(E6.d dVar, Object obj) throws IllegalAccessException, F, InvocationTargetException {
        C0369i c0369i = new C0369i(1, C1.A(dVar));
        c0369i.v();
        c0369i.i(C1.j(p()));
        Object objU = c0369i.u();
        return objU == F6.a.f2580q ? objU : A6.n.f457a;
    }

    public final void z(B0 b02, boolean z8) throws IllegalAccessException, F, InvocationTargetException {
        if (b02 instanceof InterfaceC0367g) {
            ((E6.d) b02).i(C1.j(z8 ? o() : p()));
            return;
        }
        if (!(b02 instanceof C0553c)) {
            if (b02 instanceof InterfaceC1041f) {
                ((C1040e) ((InterfaceC1041f) b02)).g(this, AbstractC0558h.f9251l);
                return;
            } else {
                throw new IllegalStateException(("Unexpected waiter: " + b02).toString());
            }
        }
        C0553c c0553c = (C0553c) b02;
        C0369i c0369i = c0553c.f9226r;
        P6.g.b(c0369i);
        c0553c.f9226r = null;
        c0553c.f9225q = AbstractC0558h.f9251l;
        Throwable thN = c0553c.f9227s.n();
        if (thN == null) {
            c0369i.i(Boolean.FALSE);
        } else {
            c0369i.i(C1.j(thN));
        }
    }
}
