package o;

import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* renamed from: o.sR, reason: case insensitive filesystem */
/* loaded from: classes.dex */
public final class C2427sR extends C1071e60 implements InterfaceC2238qR {
    public static final /* synthetic */ AtomicReferenceFieldUpdater h = AtomicReferenceFieldUpdater.newUpdater(C2427sR.class, Object.class, "owner$volatile");
    private volatile /* synthetic */ Object owner$volatile;

    public C2427sR(boolean z) {
        super(1, z ? 1 : 0);
        this.owner$volatile = z ? null : C1884mi0.f;
    }

    public final boolean c() {
        return Math.max(C1071e60.g.get(this), 0) == 0;
    }

    /* JADX WARN: Code restructure failed: missing block: B:10:0x0022, code lost:
    
        r2 = r0.m;
        o.C2427sR.h.set(r2, null);
        r3 = r0.l;
        r3.C(r1, r3.n, new o.C2353rg(0, new o.S1(11, r2, r0)));
     */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public final java.lang.Object d(o.AbstractC0298Lm r7) {
        /*
            r6 = this;
            boolean r0 = r6.e()
            o.Oh0 r1 = o.Oh0.a
            if (r0 == 0) goto L9
            goto L52
        L9:
            o.Im r7 = o.AbstractC2539te.G(r7)
            o.sg r7 = o.AbstractC0752ap.P(r7)
            o.rR r0 = new o.rR     // Catch: java.lang.Throwable -> L53
            r0.<init>(r6, r7)     // Catch: java.lang.Throwable -> L53
        L16:
            java.util.concurrent.atomic.AtomicIntegerFieldUpdater r2 = o.C1071e60.g     // Catch: java.lang.Throwable -> L53
            int r2 = r2.getAndDecrement(r6)     // Catch: java.lang.Throwable -> L53
            int r3 = r6.a     // Catch: java.lang.Throwable -> L53
            if (r2 > r3) goto L16
            if (r2 <= 0) goto L3f
            o.sR r2 = r0.m     // Catch: java.lang.Throwable -> L53
            java.util.concurrent.atomic.AtomicReferenceFieldUpdater r3 = o.C2427sR.h     // Catch: java.lang.Throwable -> L53
            r4 = 0
            r3.set(r2, r4)     // Catch: java.lang.Throwable -> L53
            o.sg r3 = r0.l     // Catch: java.lang.Throwable -> L53
            o.S1 r4 = new o.S1     // Catch: java.lang.Throwable -> L53
            r5 = 11
            r4.<init>(r5, r2, r0)     // Catch: java.lang.Throwable -> L53
            int r0 = r3.n     // Catch: java.lang.Throwable -> L53
            o.rg r2 = new o.rg     // Catch: java.lang.Throwable -> L53
            r5 = 0
            r2.<init>(r5, r4)     // Catch: java.lang.Throwable -> L53
            r3.C(r1, r0, r2)     // Catch: java.lang.Throwable -> L53
            goto L45
        L3f:
            boolean r2 = r6.a(r0)     // Catch: java.lang.Throwable -> L53
            if (r2 == 0) goto L16
        L45:
            java.lang.Object r7 = r7.q()
            o.Dn r0 = o.EnumC0091Dn.l
            if (r7 != r0) goto L4e
            goto L4f
        L4e:
            r7 = r1
        L4f:
            if (r7 != r0) goto L52
            return r7
        L52:
            return r1
        L53:
            r0 = move-exception
            r7.B()
            throw r0
        */
        throw new UnsupportedOperationException("Method not decompiled: o.C2427sR.d(o.Lm):java.lang.Object");
    }

    public final boolean e() {
        int i;
        while (true) {
            AtomicIntegerFieldUpdater atomicIntegerFieldUpdater = C1071e60.g;
            int i2 = atomicIntegerFieldUpdater.get(this);
            int i3 = this.a;
            if (i2 > i3) {
                do {
                    i = atomicIntegerFieldUpdater.get(this);
                    if (i > i3) {
                    }
                } while (!atomicIntegerFieldUpdater.compareAndSet(this, i, i3));
            } else {
                if (i2 <= 0) {
                    return false;
                }
                if (atomicIntegerFieldUpdater.compareAndSet(this, i2, i2 - 1)) {
                    h.set(this, null);
                    return true;
                }
            }
        }
    }

    public final void f(Object obj) {
        while (c()) {
            AtomicReferenceFieldUpdater atomicReferenceFieldUpdater = h;
            Object obj2 = atomicReferenceFieldUpdater.get(this);
            C2943xq c2943xq = C1884mi0.f;
            if (obj2 != c2943xq) {
                if (obj2 == obj || obj == null) {
                    while (!atomicReferenceFieldUpdater.compareAndSet(this, obj2, c2943xq)) {
                        if (atomicReferenceFieldUpdater.get(this) != obj2) {
                            break;
                        }
                    }
                    b();
                    return;
                }
                throw new IllegalStateException(("This mutex is locked by " + obj2 + ", but " + obj + " is expected").toString());
            }
        }
        throw new IllegalStateException("This mutex is not locked");
    }

    public final String toString() {
        return "Mutex@" + AbstractC0249Jp.K(this) + "[isLocked=" + c() + ",owner=" + h.get(this) + ']';
    }
}
