package p025.p026.p027;

import java.util.concurrent.atomic.AtomicLongFieldUpdater;
import java.util.concurrent.atomic.AtomicReferenceArray;
import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
import kotlin.jvm.internal.DefaultConstructorMarker;
import p402.InterfaceC6540;

/* JADX INFO: renamed from: އ.֏.֏.ވ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes.dex */
@InterfaceC6540
public final class C1288<E> {
    public volatile Object _next = null;
    public volatile long _state = 0;

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final int f4423;

    /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
    public AtomicReferenceArray f4424;

    /* JADX INFO: renamed from: ހ, reason: contains not printable characters */
    public final int f4425;

    /* JADX INFO: renamed from: ށ, reason: contains not printable characters */
    public final boolean f4426;

    /* JADX INFO: renamed from: ޅ, reason: contains not printable characters */
    public static final C1289 f4422 = new C1289(null);

    /* JADX INFO: renamed from: ބ, reason: contains not printable characters */
    public static final C1296 f4421 = new C1296("REMOVE_FROZEN");

    /* JADX INFO: renamed from: ނ, reason: contains not printable characters */
    public static final AtomicReferenceFieldUpdater f4419 = AtomicReferenceFieldUpdater.newUpdater(C1288.class, Object.class, "_next");

    /* JADX INFO: renamed from: ރ, reason: contains not printable characters */
    public static final AtomicLongFieldUpdater f4420 = AtomicLongFieldUpdater.newUpdater(C1288.class, "_state");

    /* JADX INFO: renamed from: އ.֏.֏.ވ$֏, reason: contains not printable characters */
    public static final class C1289 {
        public C1289() {
        }

        public /* synthetic */ C1289(DefaultConstructorMarker defaultConstructorMarker) {
        }
    }

    /* JADX INFO: renamed from: އ.֏.֏.ވ$ؠ, reason: contains not printable characters */
    public static final class C1290 {

        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        public final int f4427;

        public C1290(int i) {
            this.f4427 = i;
        }
    }

    public C1288(int i, boolean z) {
        this.f4425 = i;
        this.f4426 = z;
        this.f4423 = i - 1;
        this.f4424 = new AtomicReferenceArray(this.f4425);
        if (!(this.f4423 <= 1073741823)) {
            throw new IllegalStateException("Check failed.".toString());
        }
        if (!((this.f4425 & this.f4423) == 0)) {
            throw new IllegalStateException("Check failed.".toString());
        }
    }

    /* JADX WARN: Code restructure failed: missing block: B:23:0x0058, code lost:
    
        return 1;
     */
    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final int m2585(E e) {
        while (true) {
            long j = this._state;
            if ((3458764513820540928L & j) != 0) {
                if (f4422 != null) {
                    return (2305843009213693952L & j) != 0 ? 2 : 1;
                }
                throw null;
            }
            int i = (int) ((1073741823 & j) >> 0);
            int i2 = (int) ((1152921503533105152L & j) >> 30);
            int i3 = this.f4423;
            if (((i2 + 2) & i3) == (i & i3)) {
                return 1;
            }
            if (this.f4426 || this.f4424.get(i2 & i3) == null) {
                int i4 = (i2 + 1) & 1073741823;
                AtomicLongFieldUpdater atomicLongFieldUpdater = f4420;
                if (f4422 == null) {
                    throw null;
                }
                if (atomicLongFieldUpdater.compareAndSet(this, j, ((-1152921503533105153L) & j) | (((long) i4) << 30))) {
                    this.f4424.set(i2 & i3, e);
                    C1288<E> c1288M2588 = this;
                    while ((c1288M2588._state & 1152921504606846976L) != 0) {
                        c1288M2588 = c1288M2588.m2588();
                        Object obj = c1288M2588.f4424.get(c1288M2588.f4423 & i2);
                        if ((obj instanceof C1290) && ((C1290) obj).f4427 == i2) {
                            c1288M2588.f4424.set(c1288M2588.f4423 & i2, e);
                        } else {
                            c1288M2588 = null;
                        }
                        if (c1288M2588 == null) {
                            break;
                        }
                    }
                    return 0;
                }
            } else {
                int i5 = this.f4425;
                if (i5 < 1024 || ((i2 - i) & 1073741823) > (i5 >> 1)) {
                    break;
                }
            }
        }
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final boolean m2586() {
        long j;
        do {
            j = this._state;
            if ((j & 2305843009213693952L) != 0) {
                return true;
            }
            if ((1152921504606846976L & j) != 0) {
                return false;
            }
        } while (!f4420.compareAndSet(this, j, j | 2305843009213693952L));
        return true;
    }

    /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
    public final boolean m2587() {
        long j = this._state;
        return ((int) ((1073741823 & j) >> 0)) == ((int) ((j & 1152921503533105152L) >> 30));
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX INFO: renamed from: ހ, reason: contains not printable characters */
    public final C1288<E> m2588() {
        long j;
        while (true) {
            j = this._state;
            if ((j & 1152921504606846976L) != 0) {
                break;
            }
            long j2 = j | 1152921504606846976L;
            if (f4420.compareAndSet(this, j, j2)) {
                j = j2;
                break;
            }
        }
        while (true) {
            C1288<E> c1288 = (C1288) this._next;
            if (c1288 != null) {
                return c1288;
            }
            AtomicReferenceFieldUpdater atomicReferenceFieldUpdater = f4419;
            C1288 c12882 = new C1288(this.f4425 * 2, this.f4426);
            int i = (int) ((1073741823 & j) >> 0);
            int i2 = (int) ((1152921503533105152L & j) >> 30);
            while (true) {
                int i3 = this.f4423;
                int i4 = i & i3;
                if (i4 == (i3 & i2)) {
                    break;
                }
                Object c1290 = this.f4424.get(i4);
                if (c1290 == null) {
                    c1290 = new C1290(i);
                }
                c12882.f4424.set(c12882.f4423 & i, c1290);
                i++;
            }
            if (f4422 == null) {
                throw null;
            }
            c12882._state = (-1152921504606846977L) & j;
            atomicReferenceFieldUpdater.compareAndSet(this, null, c12882);
        }
    }

    /* JADX INFO: renamed from: ށ, reason: contains not printable characters */
    public final Object m2589() {
        while (true) {
            long j = this._state;
            if ((j & 1152921504606846976L) != 0) {
                return f4421;
            }
            int i = (int) ((j & 1073741823) >> 0);
            int i2 = this.f4423;
            int i3 = ((int) ((1152921503533105152L & j) >> 30)) & i2;
            int i4 = i2 & i;
            if (i3 == i4) {
                return null;
            }
            Object obj = this.f4424.get(i4);
            if (obj == null) {
                if (this.f4426) {
                    return null;
                }
            } else {
                if (obj instanceof C1290) {
                    return null;
                }
                int i5 = (i + 1) & 1073741823;
                AtomicLongFieldUpdater atomicLongFieldUpdater = f4420;
                if (f4422 == null) {
                    throw null;
                }
                long j2 = ((long) i5) << 0;
                if (atomicLongFieldUpdater.compareAndSet(this, j, (j & (-1073741824)) | j2)) {
                    this.f4424.set(this.f4423 & i, null);
                    return obj;
                }
                if (this.f4426) {
                    C1288<E> c1288M2588 = this;
                    while (true) {
                        long j3 = c1288M2588._state;
                        C1289 c1289 = f4422;
                        int i6 = (int) ((j3 & 1073741823) >> 0);
                        if ((j3 & 1152921504606846976L) != 0) {
                            c1288M2588 = c1288M2588.m2588();
                        } else {
                            AtomicLongFieldUpdater atomicLongFieldUpdater2 = f4420;
                            if (c1289 == null) {
                                throw null;
                            }
                            if (atomicLongFieldUpdater2.compareAndSet(c1288M2588, j3, j2 | (j3 & (-1073741824)))) {
                                c1288M2588.f4424.set(c1288M2588.f4423 & i6, null);
                                c1288M2588 = null;
                            } else {
                                continue;
                            }
                        }
                        if (c1288M2588 == null) {
                            return obj;
                        }
                    }
                }
            }
        }
    }
}
