package defpackage;

import java.util.concurrent.atomic.AtomicLongFieldUpdater;
import java.util.concurrent.atomic.AtomicReferenceArray;
import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
import sun.misc.Unsafe;

/* JADX INFO: renamed from: ᵤˈ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes3.dex */
public final class C3410 {
    private volatile /* synthetic */ Object _next$volatile;
    private volatile /* synthetic */ long _state$volatile;

    /* JADX INFO: renamed from: ʽˈˋ, reason: contains not printable characters */
    public final boolean f13137;

    /* JADX INFO: renamed from: ːˏᵟᵯ, reason: contains not printable characters */
    public final int f13138;

    /* JADX INFO: renamed from: ᵲᵶᵳˈ, reason: contains not printable characters */
    public final int f13139;

    /* JADX INFO: renamed from: ᵷᵺʾᵖ, reason: contains not printable characters */
    public final /* synthetic */ AtomicReferenceArray f13140;

    /* JADX INFO: renamed from: ᵨᵣ, reason: contains not printable characters */
    public static final /* synthetic */ AtomicReferenceFieldUpdater f13134 = AtomicReferenceFieldUpdater.newUpdater(C3410.class, Object.class, "_next$volatile");

    /* JADX INFO: renamed from: ˊᵫᵗ, reason: contains not printable characters */
    public static final /* synthetic */ long f13133 = AbstractC1929.f7689.objectFieldOffset(C3410.class.getDeclaredField("_next$volatile"));

    /* JADX INFO: renamed from: ᵻˈᵦʼ, reason: contains not printable characters */
    public static final /* synthetic */ AtomicLongFieldUpdater f13136 = AtomicLongFieldUpdater.newUpdater(C3410.class, "_state$volatile");

    /* JADX INFO: renamed from: ᵵᵽ, reason: contains not printable characters */
    public static final C1735 f13135 = new C1735(6, "REMOVE_FROZEN");

    public C3410(int i, boolean z) {
        this.f13139 = i;
        this.f13137 = z;
        int i2 = i - 1;
        this.f13138 = i2;
        this.f13140 = new AtomicReferenceArray(i);
        if (i2 > 1073741823) {
            ᵕᵩʽᵲ.ᵪᵹᵥᵻ("Check failed.");
            throw null;
        }
        if ((i & i2) == 0) {
            return;
        }
        ᵕᵩʽᵲ.ᵪᵹᵥᵻ("Check failed.");
        throw null;
    }

    /* JADX INFO: renamed from: ʽˈˋ, reason: contains not printable characters */
    public final C3410 m7809(long j) {
        C3410 c3410;
        while (true) {
            f13134.getClass();
            Unsafe unsafe = AbstractC1929.f7689;
            long j2 = f13133;
            C3410 c34102 = (C3410) unsafe.getObjectVolatile(this, j2);
            if (c34102 != null) {
                return c34102;
            }
            C3410 c34103 = new C3410(this.f13139 * 2, this.f13137);
            int i = (int) (1073741823 & j);
            int i2 = (int) ((1152921503533105152L & j) >> 30);
            while (true) {
                int i3 = this.f13138;
                int i4 = i & i3;
                if (i4 == (i3 & i2)) {
                    break;
                }
                Object c2819 = this.f13140.get(i4);
                if (c2819 == null) {
                    c2819 = new C2819(i);
                }
                c34103.f13140.set(c34103.f13138 & i, c2819);
                i++;
            }
            f13136.set(c34103, (-1152921504606846977L) & j);
            while (true) {
                Unsafe unsafe2 = AbstractC1929.f7689;
                c3410 = this;
                if (!unsafe2.compareAndSwapObject(c3410, f13133, (Object) null, c34103) && unsafe2.getObjectVolatile(c3410, j2) == null) {
                    this = c3410;
                }
            }
            this = c3410;
        }
    }

    /* JADX INFO: renamed from: ːˏᵟᵯ, reason: contains not printable characters */
    public final boolean m7810() {
        while (true) {
            AtomicLongFieldUpdater atomicLongFieldUpdater = f13136;
            long j = atomicLongFieldUpdater.get(this);
            if ((j & 2305843009213693952L) != 0) {
                return true;
            }
            if ((1152921504606846976L & j) != 0) {
                return false;
            }
            C3410 c3410 = this;
            if (atomicLongFieldUpdater.compareAndSet(c3410, j, 2305843009213693952L | j)) {
                return true;
            }
            this = c3410;
        }
    }

    /* JADX WARN: Code restructure failed: missing block: B:16:0x0041, code lost:
    
        return null;
     */
    /* JADX INFO: renamed from: ᵨᵣ, reason: contains not printable characters */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object m7811() {
        C3410 c3410M7813 = this;
        while (true) {
            AtomicLongFieldUpdater atomicLongFieldUpdater = f13136;
            long j = atomicLongFieldUpdater.get(c3410M7813);
            if ((j & 1152921504606846976L) != 0) {
                return f13135;
            }
            int i = (int) (j & 1073741823);
            int i2 = c3410M7813.f13138;
            int i3 = i & i2;
            if ((((int) ((1152921503533105152L & j) >> 30)) & i2) == i3) {
                break;
            }
            AtomicReferenceArray atomicReferenceArray = c3410M7813.f13140;
            Object obj = atomicReferenceArray.get(i3);
            boolean z = c3410M7813.f13137;
            if (obj == null) {
                if (z) {
                    break;
                }
            } else {
                if (obj instanceof C2819) {
                    break;
                }
                long j2 = (i + 1) & 1073741823;
                if (f13136.compareAndSet(c3410M7813, j, (j & (-1073741824)) | j2)) {
                    atomicReferenceArray.set(i3, null);
                    return obj;
                }
                c3410M7813 = this;
                if (z) {
                    while (true) {
                        long j3 = atomicLongFieldUpdater.get(c3410M7813);
                        int i4 = (int) (j3 & 1073741823);
                        if ((j3 & 1152921504606846976L) != 0) {
                            c3410M7813 = c3410M7813.m7813();
                        } else {
                            C3410 c3410 = c3410M7813;
                            if (f13136.compareAndSet(c3410, j3, (j3 & (-1073741824)) | j2)) {
                                c3410.f13140.set(i4 & c3410.f13138, null);
                                c3410M7813 = null;
                            } else {
                                c3410M7813 = c3410;
                            }
                        }
                        if (c3410M7813 == null) {
                            return obj;
                        }
                    }
                }
            }
        }
    }

    /* JADX INFO: renamed from: ᵲᵶᵳˈ, reason: contains not printable characters */
    public final int m7812(Object obj) {
        while (true) {
            AtomicLongFieldUpdater atomicLongFieldUpdater = f13136;
            long j = atomicLongFieldUpdater.get(this);
            if ((3458764513820540928L & j) != 0) {
                return (2305843009213693952L & j) != 0 ? 2 : 1;
            }
            int i = (int) (1073741823 & j);
            int i2 = (int) ((1152921503533105152L & j) >> 30);
            int i3 = this.f13138;
            if (((i2 + 2) & i3) == (i & i3)) {
                return 1;
            }
            boolean z = this.f13137;
            AtomicReferenceArray atomicReferenceArray = this.f13140;
            if (z || atomicReferenceArray.get(i2 & i3) == null) {
                C3410 c3410 = this;
                if (f13136.compareAndSet(c3410, j, ((-1152921503533105153L) & j) | (((long) ((i2 + 1) & 1073741823)) << 30))) {
                    atomicReferenceArray.set(i2 & i3, obj);
                    C3410 c3410M7813 = c3410;
                    while ((atomicLongFieldUpdater.get(c3410M7813) & 1152921504606846976L) != 0) {
                        c3410M7813 = c3410M7813.m7813();
                        AtomicReferenceArray atomicReferenceArray2 = c3410M7813.f13140;
                        int i4 = c3410M7813.f13138 & i2;
                        Object obj2 = atomicReferenceArray2.get(i4);
                        if ((obj2 instanceof C2819) && ((C2819) obj2).f10825 == i2) {
                            atomicReferenceArray2.set(i4, obj);
                        } else {
                            c3410M7813 = null;
                        }
                        if (c3410M7813 == null) {
                            return 0;
                        }
                    }
                    return 0;
                }
                this = c3410;
            } else {
                int i5 = this.f13139;
                if (i5 < 1024 || ((i2 - i) & 1073741823) > (i5 >> 1)) {
                    return 1;
                }
            }
        }
    }

    /* JADX INFO: renamed from: ᵷᵺʾᵖ, reason: contains not printable characters */
    public final C3410 m7813() {
        long j;
        C3410 c3410;
        while (true) {
            AtomicLongFieldUpdater atomicLongFieldUpdater = f13136;
            j = atomicLongFieldUpdater.get(this);
            if ((j & 1152921504606846976L) != 0) {
                c3410 = this;
                break;
            }
            long j2 = 1152921504606846976L | j;
            c3410 = this;
            if (atomicLongFieldUpdater.compareAndSet(c3410, j, j2)) {
                j = j2;
                break;
            }
            this = c3410;
        }
        return c3410.m7809(j);
    }
}
