package com.google.android.gms.internal.measurement;

import java.util.Arrays;

/* JADX INFO: loaded from: classes.dex */
public final class C2 {

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public static final C2 f9570f = new C2(0, new int[0], new Object[0], false);

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public int f9571a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public int[] f9572b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public Object[] f9573c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public int f9574d = -1;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public boolean f9575e;

    public C2(int i, int[] iArr, Object[] objArr, boolean z8) {
        this.f9571a = i;
        this.f9572b = iArr;
        this.f9573c = objArr;
        this.f9575e = z8;
    }

    public static C2 b() {
        return new C2(0, new int[8], new Object[8], true);
    }

    public final int a() {
        int iS;
        int iC;
        int iS2;
        int i = this.f9574d;
        if (i != -1) {
            return i;
        }
        int i5 = 0;
        for (int i8 = 0; i8 < this.f9571a; i8++) {
            int i9 = this.f9572b[i8];
            int i10 = i9 >>> 3;
            int i11 = i9 & 7;
            if (i11 != 0) {
                if (i11 == 1) {
                    ((Long) this.f9573c[i8]).getClass();
                    iS2 = T1.S(i10 << 3) + 8;
                } else if (i11 == 2) {
                    int i12 = i10 << 3;
                    S1 s12 = (S1) this.f9573c[i8];
                    int iS3 = T1.S(i12);
                    int iC2 = s12.c();
                    i5 = I1.a.i(iC2, iC2, iS3, i5);
                } else if (i11 == 3) {
                    int iS4 = T1.S(i10 << 3);
                    iS = iS4 + iS4;
                    iC = ((C2) this.f9573c[i8]).a();
                } else {
                    if (i11 != 5) {
                        throw new IllegalStateException(new C0649i2());
                    }
                    ((Integer) this.f9573c[i8]).getClass();
                    iS2 = T1.S(i10 << 3) + 4;
                }
                i5 = iS2 + i5;
            } else {
                int i13 = i10 << 3;
                long jLongValue = ((Long) this.f9573c[i8]).longValue();
                iS = T1.S(i13);
                iC = T1.C(jLongValue);
            }
            i5 = iC + iS + i5;
        }
        this.f9574d = i5;
        return i5;
    }

    public final void c(int i, Object obj) {
        if (!this.f9575e) {
            throw new UnsupportedOperationException();
        }
        e(this.f9571a + 1);
        int[] iArr = this.f9572b;
        int i5 = this.f9571a;
        iArr[i5] = i;
        this.f9573c[i5] = obj;
        this.f9571a = i5 + 1;
    }

    public final void d(C0674n2 c0674n2) {
        if (this.f9571a != 0) {
            for (int i = 0; i < this.f9571a; i++) {
                int i5 = this.f9572b[i];
                Object obj = this.f9573c[i];
                int i8 = i5 & 7;
                int i9 = i5 >>> 3;
                if (i8 == 0) {
                    ((T1) c0674n2.f9927a).P(((Long) obj).longValue(), i9);
                } else if (i8 == 1) {
                    ((T1) c0674n2.f9927a).H(((Long) obj).longValue(), i9);
                } else if (i8 == 2) {
                    ((T1) c0674n2.f9927a).E(i9, (S1) obj);
                } else if (i8 == 3) {
                    ((T1) c0674n2.f9927a).M(i9, 3);
                    ((C2) obj).d(c0674n2);
                    ((T1) c0674n2.f9927a).M(i9, 4);
                } else {
                    if (i8 != 5) {
                        throw new RuntimeException(new C0649i2());
                    }
                    ((T1) c0674n2.f9927a).F(i9, ((Integer) obj).intValue());
                }
            }
        }
    }

    public final void e(int i) {
        int[] iArr = this.f9572b;
        if (i > iArr.length) {
            int i5 = this.f9571a;
            int i8 = (i5 / 2) + i5;
            if (i8 >= i) {
                i = i8;
            }
            if (i < 8) {
                i = 8;
            }
            this.f9572b = Arrays.copyOf(iArr, i);
            this.f9573c = Arrays.copyOf(this.f9573c, i);
        }
    }

    public final boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null || !(obj instanceof C2)) {
            return false;
        }
        C2 c22 = (C2) obj;
        int i = this.f9571a;
        if (i == c22.f9571a) {
            int[] iArr = this.f9572b;
            int[] iArr2 = c22.f9572b;
            int i5 = 0;
            while (true) {
                if (i5 >= i) {
                    Object[] objArr = this.f9573c;
                    Object[] objArr2 = c22.f9573c;
                    int i8 = this.f9571a;
                    for (int i9 = 0; i9 < i8; i9++) {
                        if (objArr[i9].equals(objArr2[i9])) {
                        }
                    }
                    return true;
                }
                if (iArr[i5] != iArr2[i5]) {
                    break;
                }
                i5++;
            }
        }
        return false;
    }

    public final int hashCode() {
        int i = this.f9571a;
        int i5 = i + 527;
        int[] iArr = this.f9572b;
        int iHashCode = 17;
        int i8 = 17;
        for (int i9 = 0; i9 < i; i9++) {
            i8 = (i8 * 31) + iArr[i9];
        }
        int i10 = ((i5 * 31) + i8) * 31;
        Object[] objArr = this.f9573c;
        int i11 = this.f9571a;
        for (int i12 = 0; i12 < i11; i12++) {
            iHashCode = (iHashCode * 31) + objArr[i12].hashCode();
        }
        return i10 + iHashCode;
    }
}
