package androidx.collection;

import com.google.android.gms.dynamite.descriptors.com.google.android.gms.measurement.dynamite.ModuleDescriptor;

/* loaded from: classes.dex */
public final class w extends i {

    /* renamed from: f, reason: collision with root package name */
    private int f1400f;

    public /* synthetic */ w(int i10, int i11, kotlin.jvm.internal.k kVar) {
        this((i11 & 1) != 0 ? 6 : i10);
    }

    private final void h() {
        if (this.f1322d <= 8 || Long.compareUnsigned(rm.h0.e(rm.h0.e(this.f1323e) * 32), rm.h0.e(rm.h0.e(this.f1322d) * 25)) > 0) {
            p(q0.e(this.f1322d));
        } else {
            j();
        }
    }

    private final void j() {
        int Y;
        int[] iArr;
        int i10;
        int i11;
        int Y2;
        long[] jArr = this.f1319a;
        int i12 = this.f1322d;
        int[] iArr2 = this.f1320b;
        int[] iArr3 = this.f1321c;
        q0.a(jArr, i12);
        char c10 = 0;
        int i13 = 0;
        int i14 = -1;
        while (i13 != i12) {
            int i15 = i13 >> 3;
            int i16 = (i13 & 7) << 3;
            long j10 = (jArr[i15] >> i16) & 255;
            if (j10 == 128) {
                i14 = i13;
                i13++;
            } else {
                if (j10 == 254) {
                    int hashCode = Integer.hashCode(iArr2[i13]) * (-862048943);
                    int i17 = hashCode ^ (hashCode << 16);
                    int i18 = i17 >>> 7;
                    int k10 = k(i18);
                    int i19 = i18 & i12;
                    if (((k10 - i19) & i12) / 8 == ((i13 - i19) & i12) / 8) {
                        jArr[i15] = ((i17 & ModuleDescriptor.MODULE_VERSION) << i16) | ((~(255 << i16)) & jArr[i15]);
                        Y = sm.p.Y(jArr);
                        jArr[Y] = (jArr[c10] & 72057594037927935L) | Long.MIN_VALUE;
                    } else {
                        int i20 = k10 >> 3;
                        long j11 = jArr[i20];
                        int i21 = (k10 & 7) << 3;
                        if (((j11 >> i21) & 255) == 128) {
                            int i22 = i13;
                            iArr = iArr2;
                            jArr[i20] = (j11 & (~(255 << i21))) | ((i17 & ModuleDescriptor.MODULE_VERSION) << i21);
                            jArr[i15] = (jArr[i15] & (~(255 << i16))) | (128 << i16);
                            iArr[k10] = iArr[i22];
                            iArr[i22] = 0;
                            iArr3[k10] = iArr3[i22];
                            iArr3[i22] = 0;
                            i11 = i22;
                            i14 = i11;
                            i10 = i12;
                        } else {
                            int i23 = i12;
                            iArr = iArr2;
                            int i24 = i13;
                            jArr[i20] = ((i17 & ModuleDescriptor.MODULE_VERSION) << i21) | (j11 & (~(255 << i21)));
                            if (i14 == -1) {
                                i10 = i23;
                                i14 = q0.b(jArr, i24 + 1, i10);
                            } else {
                                i10 = i23;
                            }
                            iArr[i14] = iArr[k10];
                            iArr[k10] = iArr[i24];
                            iArr[i24] = iArr[i14];
                            iArr3[i14] = iArr3[k10];
                            iArr3[k10] = iArr3[i24];
                            iArr3[i24] = iArr3[i14];
                            i11 = i24 - 1;
                        }
                        Y2 = sm.p.Y(jArr);
                        c10 = 0;
                        jArr[Y2] = (jArr[0] & 72057594037927935L) | Long.MIN_VALUE;
                        i13 = i11 + 1;
                        i12 = i10;
                        iArr2 = iArr;
                    }
                }
                i13++;
            }
        }
        m();
    }

    private final int k(int i10) {
        int i11 = this.f1322d;
        int i12 = i10 & i11;
        int i13 = 0;
        while (true) {
            long[] jArr = this.f1319a;
            int i14 = i12 >> 3;
            int i15 = (i12 & 7) << 3;
            long j10 = ((jArr[i14 + 1] << (64 - i15)) & ((-i15) >> 63)) | (jArr[i14] >>> i15);
            long j11 = j10 & ((~j10) << 7) & (-9187201950435737472L);
            if (j11 != 0) {
                return (i12 + (Long.numberOfTrailingZeros(j11) >> 3)) & i11;
            }
            i13 += 8;
            i12 = (i12 + i13) & i11;
        }
    }

    /* JADX WARN: Code restructure failed: missing block: B:15:0x0073, code lost:
    
        if (((((~r7) << 6) & r7) & (-9187201950435737472L)) == 0) goto L29;
     */
    /* JADX WARN: Code restructure failed: missing block: B:18:0x0075, code lost:
    
        r1 = k(r2);
     */
    /* JADX WARN: Code restructure failed: missing block: B:19:0x007d, code lost:
    
        if (r19.f1400f != 0) goto L23;
     */
    /* JADX WARN: Code restructure failed: missing block: B:21:0x008f, code lost:
    
        if (((r19.f1319a[r1 >> 3] >> ((r1 & 7) << 3)) & 255) != 254) goto L20;
     */
    /* JADX WARN: Code restructure failed: missing block: B:22:0x0091, code lost:
    
        r3 = true;
     */
    /* JADX WARN: Code restructure failed: missing block: B:23:0x0094, code lost:
    
        if (r3 != false) goto L23;
     */
    /* JADX WARN: Code restructure failed: missing block: B:24:0x0096, code lost:
    
        h();
        r1 = k(r2);
     */
    /* JADX WARN: Code restructure failed: missing block: B:25:0x0093, code lost:
    
        r3 = false;
     */
    /* JADX WARN: Code restructure failed: missing block: B:26:0x009d, code lost:
    
        r19.f1323e++;
        r2 = r19.f1400f;
        r6 = r19.f1319a;
        r7 = r1 >> 3;
        r11 = r6[r7];
        r8 = (r1 & 7) << 3;
     */
    /* JADX WARN: Code restructure failed: missing block: B:27:0x00b6, code lost:
    
        if (((r11 >> r8) & 255) != 128) goto L26;
     */
    /* JADX WARN: Code restructure failed: missing block: B:28:0x00b8, code lost:
    
        r18 = 1;
     */
    /* JADX WARN: Code restructure failed: missing block: B:29:0x00bd, code lost:
    
        r19.f1400f = r2 - r18;
        r0 = r19.f1322d;
        r2 = ((~(255 << r8)) & r11) | (r9 << r8);
        r6[r7] = r2;
        r6[(((r1 - 7) & r0) + (r0 & 7)) >> 3] = r2;
     */
    /* JADX WARN: Code restructure failed: missing block: B:30:0x00d7, code lost:
    
        return ~r1;
     */
    /* JADX WARN: Code restructure failed: missing block: B:31:0x00bb, code lost:
    
        r18 = 0;
     */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    private final int l(int i10) {
        int hashCode = Integer.hashCode(i10) * (-862048943);
        int i11 = hashCode ^ (hashCode << 16);
        int i12 = i11 >>> 7;
        int i13 = i11 & ModuleDescriptor.MODULE_VERSION;
        int i14 = this.f1322d;
        int i15 = i12 & i14;
        int i16 = 0;
        while (true) {
            long[] jArr = this.f1319a;
            int i17 = i15 >> 3;
            int i18 = (i15 & 7) << 3;
            boolean z10 = true;
            long j10 = ((jArr[i17 + 1] << (64 - i18)) & ((-i18) >> 63)) | (jArr[i17] >>> i18);
            long j11 = i13;
            int i19 = i16;
            long j12 = j10 ^ (j11 * 72340172838076673L);
            long j13 = (~j12) & (j12 - 72340172838076673L) & (-9187201950435737472L);
            while (true) {
                if (!(j13 != 0 ? z10 : false)) {
                    break;
                }
                int numberOfTrailingZeros = ((Long.numberOfTrailingZeros(j13) >> 3) + i15) & i14;
                if (this.f1320b[numberOfTrailingZeros] == i10) {
                    return numberOfTrailingZeros;
                }
                j13 &= j13 - 1;
                z10 = true;
            }
            i16 = i19 + 8;
            i15 = (i15 + i16) & i14;
        }
    }

    private final void m() {
        this.f1400f = q0.c(d()) - this.f1323e;
    }

    private final void n(int i10) {
        long[] jArr;
        if (i10 == 0) {
            jArr = q0.f1375a;
        } else {
            jArr = new long[((((i10 + 1) + 7) + 7) & (-8)) >> 3];
            sm.o.x(jArr, -9187201950435737472L, 0, 0, 6, null);
        }
        this.f1319a = jArr;
        int i11 = i10 >> 3;
        long j10 = 255 << ((i10 & 7) << 3);
        jArr[i11] = (jArr[i11] & (~j10)) | j10;
        m();
    }

    private final void o(int i10) {
        int max = i10 > 0 ? Math.max(7, q0.f(i10)) : 0;
        this.f1322d = max;
        n(max);
        this.f1320b = new int[max];
        this.f1321c = new int[max];
    }

    private final void p(int i10) {
        int i11;
        long[] jArr = this.f1319a;
        int[] iArr = this.f1320b;
        int[] iArr2 = this.f1321c;
        int i12 = this.f1322d;
        o(i10);
        long[] jArr2 = this.f1319a;
        int[] iArr3 = this.f1320b;
        int[] iArr4 = this.f1321c;
        int i13 = this.f1322d;
        int i14 = 0;
        while (i14 < i12) {
            if (((jArr[i14 >> 3] >> ((i14 & 7) << 3)) & 255) < 128) {
                int i15 = iArr[i14];
                int hashCode = Integer.hashCode(i15) * (-862048943);
                int i16 = hashCode ^ (hashCode << 16);
                int k10 = k(i16 >>> 7);
                i11 = i14;
                long j10 = i16 & ModuleDescriptor.MODULE_VERSION;
                int i17 = k10 >> 3;
                int i18 = (k10 & 7) << 3;
                long j11 = (j10 << i18) | (jArr2[i17] & (~(255 << i18)));
                jArr2[i17] = j11;
                jArr2[(((k10 - 7) & i13) + (i13 & 7)) >> 3] = j11;
                iArr3[k10] = i15;
                iArr4[k10] = iArr2[i11];
            } else {
                i11 = i14;
            }
            i14 = i11 + 1;
        }
    }

    public final void i() {
        this.f1323e = 0;
        long[] jArr = this.f1319a;
        if (jArr != q0.f1375a) {
            sm.o.x(jArr, -9187201950435737472L, 0, 0, 6, null);
            long[] jArr2 = this.f1319a;
            int i10 = this.f1322d;
            int i11 = i10 >> 3;
            long j10 = 255 << ((i10 & 7) << 3);
            jArr2[i11] = (jArr2[i11] & (~j10)) | j10;
        }
        m();
    }

    public final void q(int i10, int i11) {
        int l10 = l(i10);
        if (l10 < 0) {
            l10 = ~l10;
        }
        this.f1320b[l10] = i10;
        this.f1321c[l10] = i11;
    }

    public w(int i10) {
        super(null);
        if (!(i10 >= 0)) {
            w.d.a("Capacity must be a positive value.");
        }
        o(q0.g(i10));
    }
}
