package androidx.collection;

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

/* loaded from: classes.dex */
public final class a0 extends p {

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

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

    private final void f() {
        if (this.f1364d <= 8 || Long.compareUnsigned(rm.h0.e(rm.h0.e(this.f1365e) * 32), rm.h0.e(rm.h0.e(this.f1364d) * 25)) > 0) {
            n(q0.e(this.f1364d));
        } else {
            h();
        }
    }

    private final void h() {
        int Y;
        long[] jArr;
        int i10;
        int i11;
        int Y2;
        long[] jArr2 = this.f1361a;
        int i12 = this.f1364d;
        long[] jArr3 = this.f1362b;
        Object[] objArr = this.f1363c;
        q0.a(jArr2, i12);
        char c10 = 0;
        int i13 = 0;
        int i14 = -1;
        while (i13 != i12) {
            int i15 = i13 >> 3;
            int i16 = (i13 & 7) << 3;
            long j10 = (jArr2[i15] >> i16) & 255;
            if (j10 == 128) {
                i14 = i13;
                i13++;
            } else {
                if (j10 == 254) {
                    int hashCode = Long.hashCode(jArr3[i13]) * (-862048943);
                    int i17 = hashCode ^ (hashCode << 16);
                    int i18 = i17 >>> 7;
                    int j11 = j(i18);
                    int i19 = i18 & i12;
                    if (((j11 - i19) & i12) / 8 == ((i13 - i19) & i12) / 8) {
                        jArr2[i15] = ((i17 & ModuleDescriptor.MODULE_VERSION) << i16) | ((~(255 << i16)) & jArr2[i15]);
                        Y = sm.p.Y(jArr2);
                        jArr2[Y] = (jArr2[c10] & 72057594037927935L) | Long.MIN_VALUE;
                    } else {
                        int i20 = j11 >> 3;
                        long j12 = jArr2[i20];
                        int i21 = (j11 & 7) << 3;
                        if (((j12 >> i21) & 255) == 128) {
                            int i22 = i13;
                            jArr = jArr3;
                            jArr2[i20] = (j12 & (~(255 << i21))) | ((i17 & ModuleDescriptor.MODULE_VERSION) << i21);
                            jArr2[i15] = (jArr2[i15] & (~(255 << i16))) | (128 << i16);
                            jArr[j11] = jArr[i22];
                            jArr[i22] = 0;
                            objArr[j11] = objArr[i22];
                            objArr[i22] = null;
                            i11 = i22;
                            i14 = i11;
                            i10 = i12;
                        } else {
                            int i23 = i12;
                            jArr = jArr3;
                            int i24 = i13;
                            jArr2[i20] = ((i17 & ModuleDescriptor.MODULE_VERSION) << i21) | (j12 & (~(255 << i21)));
                            if (i14 == -1) {
                                i10 = i23;
                                i14 = q0.b(jArr2, i24 + 1, i10);
                            } else {
                                i10 = i23;
                            }
                            jArr[i14] = jArr[j11];
                            jArr[j11] = jArr[i24];
                            jArr[i24] = jArr[i14];
                            objArr[i14] = objArr[j11];
                            objArr[j11] = objArr[i24];
                            objArr[i24] = objArr[i14];
                            i11 = i24 - 1;
                        }
                        Y2 = sm.p.Y(jArr2);
                        c10 = 0;
                        jArr2[Y2] = (jArr2[0] & 72057594037927935L) | Long.MIN_VALUE;
                        i13 = i11 + 1;
                        i12 = i10;
                        jArr3 = jArr;
                    }
                }
                i13++;
            }
        }
        k();
    }

    /* JADX WARN: Code restructure failed: missing block: B:15:0x0070, code lost:
    
        if (((((~r7) << 6) & r7) & (-9187201950435737472L)) == 0) goto L29;
     */
    /* JADX WARN: Code restructure failed: missing block: B:18:0x0072, code lost:
    
        r1 = j(r2);
     */
    /* JADX WARN: Code restructure failed: missing block: B:19:0x007a, code lost:
    
        if (r21.f1285f != 0) goto L23;
     */
    /* JADX WARN: Code restructure failed: missing block: B:21:0x008c, code lost:
    
        if (((r21.f1361a[r1 >> 3] >> ((r1 & 7) << 3)) & 255) != 254) goto L20;
     */
    /* JADX WARN: Code restructure failed: missing block: B:22:0x008e, code lost:
    
        r3 = true;
     */
    /* JADX WARN: Code restructure failed: missing block: B:23:0x0091, code lost:
    
        if (r3 != false) goto L23;
     */
    /* JADX WARN: Code restructure failed: missing block: B:24:0x0093, code lost:
    
        f();
        r1 = j(r2);
     */
    /* JADX WARN: Code restructure failed: missing block: B:25:0x0090, code lost:
    
        r3 = false;
     */
    /* JADX WARN: Code restructure failed: missing block: B:26:0x009a, code lost:
    
        r21.f1365e++;
        r2 = r21.f1285f;
        r3 = r21.f1361a;
        r6 = r1 >> 3;
        r7 = r3[r6];
        r11 = (r1 & 7) << 3;
     */
    /* JADX WARN: Code restructure failed: missing block: B:27:0x00b2, code lost:
    
        if (((r7 >> r11) & 255) != 128) goto L26;
     */
    /* JADX WARN: Code restructure failed: missing block: B:28:0x00b4, code lost:
    
        r18 = 1;
     */
    /* JADX WARN: Code restructure failed: missing block: B:29:0x00b9, code lost:
    
        r21.f1285f = r2 - r18;
        r0 = r21.f1364d;
        r4 = ((~(255 << r11)) & r7) | (r9 << r11);
        r3[r6] = r4;
        r3[(((r1 - 7) & r0) + (r0 & 7)) >> 3] = r4;
     */
    /* JADX WARN: Code restructure failed: missing block: B:30:0x00d1, code lost:
    
        return r1;
     */
    /* JADX WARN: Code restructure failed: missing block: B:31:0x00b7, code lost:
    
        r18 = 0;
     */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    private final int i(long j10) {
        int hashCode = Long.hashCode(j10) * (-862048943);
        int i10 = hashCode ^ (hashCode << 16);
        int i11 = i10 >>> 7;
        int i12 = i10 & ModuleDescriptor.MODULE_VERSION;
        int i13 = this.f1364d;
        int i14 = i11 & i13;
        int i15 = 0;
        while (true) {
            long[] jArr = this.f1361a;
            int i16 = i14 >> 3;
            int i17 = (i14 & 7) << 3;
            long j11 = ((jArr[i16 + 1] << (64 - i17)) & ((-i17) >> 63)) | (jArr[i16] >>> i17);
            long j12 = i12;
            int i18 = i15;
            long j13 = j11 ^ (j12 * 72340172838076673L);
            long j14 = (~j13) & (j13 - 72340172838076673L) & (-9187201950435737472L);
            while (true) {
                if (!(j14 != 0)) {
                    break;
                }
                int numberOfTrailingZeros = ((Long.numberOfTrailingZeros(j14) >> 3) + i14) & i13;
                if (this.f1362b[numberOfTrailingZeros] == j10) {
                    return numberOfTrailingZeros;
                }
                j14 &= j14 - 1;
            }
            i15 = i18 + 8;
            i14 = (i14 + i15) & i13;
        }
    }

    private final int j(int i10) {
        int i11 = this.f1364d;
        int i12 = i10 & i11;
        int i13 = 0;
        while (true) {
            long[] jArr = this.f1361a;
            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;
        }
    }

    private final void k() {
        this.f1285f = q0.c(c()) - this.f1365e;
    }

    private final void l(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.f1361a = jArr;
        int i11 = i10 >> 3;
        long j10 = 255 << ((i10 & 7) << 3);
        jArr[i11] = (jArr[i11] & (~j10)) | j10;
        k();
    }

    private final void m(int i10) {
        int max = i10 > 0 ? Math.max(7, q0.f(i10)) : 0;
        this.f1364d = max;
        l(max);
        this.f1362b = new long[max];
        this.f1363c = new Object[max];
    }

    private final void n(int i10) {
        long[] jArr;
        a0 a0Var = this;
        long[] jArr2 = a0Var.f1361a;
        long[] jArr3 = a0Var.f1362b;
        Object[] objArr = a0Var.f1363c;
        int i11 = a0Var.f1364d;
        m(i10);
        long[] jArr4 = a0Var.f1361a;
        long[] jArr5 = a0Var.f1362b;
        Object[] objArr2 = a0Var.f1363c;
        int i12 = a0Var.f1364d;
        int i13 = 0;
        while (i13 < i11) {
            if (((jArr2[i13 >> 3] >> ((i13 & 7) << 3)) & 255) < 128) {
                long j10 = jArr3[i13];
                int hashCode = Long.hashCode(j10) * (-862048943);
                int i14 = hashCode ^ (hashCode << 16);
                int j11 = a0Var.j(i14 >>> 7);
                long j12 = i14 & ModuleDescriptor.MODULE_VERSION;
                int i15 = j11 >> 3;
                int i16 = (j11 & 7) << 3;
                jArr = jArr2;
                long j13 = (jArr4[i15] & (~(255 << i16))) | (j12 << i16);
                jArr4[i15] = j13;
                jArr4[(((j11 - 7) & i12) + (i12 & 7)) >> 3] = j13;
                jArr5[j11] = j10;
                objArr2[j11] = objArr[i13];
            } else {
                jArr = jArr2;
            }
            i13++;
            a0Var = this;
            jArr2 = jArr;
        }
    }

    public final void g() {
        this.f1365e = 0;
        long[] jArr = this.f1361a;
        if (jArr != q0.f1375a) {
            sm.o.x(jArr, -9187201950435737472L, 0, 0, 6, null);
            long[] jArr2 = this.f1361a;
            int i10 = this.f1364d;
            int i11 = i10 >> 3;
            long j10 = 255 << ((i10 & 7) << 3);
            jArr2[i11] = (jArr2[i11] & (~j10)) | j10;
        }
        sm.o.v(this.f1363c, null, 0, this.f1364d);
        k();
    }

    public final void o(long j10, Object obj) {
        int i10 = i(j10);
        this.f1362b[i10] = j10;
        this.f1363c[i10] = obj;
    }
}
