package androidx.datastore.preferences.protobuf;

import java.util.Arrays;

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

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

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

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

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

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

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

    public b0(int i, int[] iArr, Object[] objArr, boolean z8) {
        this.f8054a = i;
        this.f8055b = iArr;
        this.f8056c = objArr;
        this.f8058e = z8;
    }

    public final void a(int i) {
        int[] iArr = this.f8055b;
        if (i > iArr.length) {
            int i5 = this.f8054a;
            int i8 = (i5 / 2) + i5;
            if (i8 >= i) {
                i = i8;
            }
            if (i < 8) {
                i = 8;
            }
            this.f8055b = Arrays.copyOf(iArr, i);
            this.f8056c = Arrays.copyOf(this.f8056c, i);
        }
    }

    public final int b() {
        int iR;
        int iT;
        int iR2;
        int i = this.f8057d;
        if (i != -1) {
            return i;
        }
        int i5 = 0;
        for (int i8 = 0; i8 < this.f8054a; i8++) {
            int i9 = this.f8055b[i8];
            int i10 = i9 >>> 3;
            int i11 = i9 & 7;
            if (i11 != 0) {
                if (i11 == 1) {
                    ((Long) this.f8056c[i8]).getClass();
                    iR2 = C0433k.R(i10) + 8;
                } else if (i11 == 2) {
                    iR2 = C0433k.P(i10, (C0429g) this.f8056c[i8]);
                } else if (i11 == 3) {
                    iR = C0433k.R(i10) * 2;
                    iT = ((b0) this.f8056c[i8]).b();
                } else {
                    if (i11 != 5) {
                        throw new IllegalStateException(C0446y.b());
                    }
                    ((Integer) this.f8056c[i8]).getClass();
                    iR2 = C0433k.R(i10) + 4;
                }
                i5 = iR2 + i5;
            } else {
                long jLongValue = ((Long) this.f8056c[i8]).longValue();
                iR = C0433k.R(i10);
                iT = C0433k.T(jLongValue);
            }
            i5 = iT + iR + i5;
        }
        this.f8057d = i5;
        return i5;
    }

    public final void c(int i, Object obj) {
        if (!this.f8058e) {
            throw new UnsupportedOperationException();
        }
        a(this.f8054a + 1);
        int[] iArr = this.f8055b;
        int i5 = this.f8054a;
        iArr[i5] = i;
        this.f8056c[i5] = obj;
        this.f8054a = i5 + 1;
    }

    public final void d(D d8) {
        if (this.f8054a == 0) {
            return;
        }
        d8.getClass();
        for (int i = 0; i < this.f8054a; i++) {
            int i5 = this.f8055b[i];
            Object obj = this.f8056c[i];
            int i8 = i5 >>> 3;
            int i9 = i5 & 7;
            C0433k c0433k = (C0433k) d8.f7995a;
            if (i9 == 0) {
                c0433k.n0(((Long) obj).longValue(), i8);
            } else if (i9 == 1) {
                c0433k.d0(((Long) obj).longValue(), i8);
            } else if (i9 == 2) {
                c0433k.Z(i8, (C0429g) obj);
            } else if (i9 == 3) {
                c0433k.k0(i8, 3);
                ((b0) obj).d(d8);
                c0433k.k0(i8, 4);
            } else {
                if (i9 != 5) {
                    throw new RuntimeException(C0446y.b());
                }
                c0433k.b0(i8, ((Integer) obj).intValue());
            }
        }
    }

    public final boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null || !(obj instanceof b0)) {
            return false;
        }
        b0 b0Var = (b0) obj;
        int i = this.f8054a;
        if (i == b0Var.f8054a) {
            int[] iArr = this.f8055b;
            int[] iArr2 = b0Var.f8055b;
            int i5 = 0;
            while (true) {
                if (i5 >= i) {
                    Object[] objArr = this.f8056c;
                    Object[] objArr2 = b0Var.f8056c;
                    int i8 = this.f8054a;
                    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.f8054a;
        int i5 = (527 + i) * 31;
        int[] iArr = this.f8055b;
        int iHashCode = 17;
        int i8 = 17;
        for (int i9 = 0; i9 < i; i9++) {
            i8 = (i8 * 31) + iArr[i9];
        }
        int i10 = (i5 + i8) * 31;
        Object[] objArr = this.f8056c;
        int i11 = this.f8054a;
        for (int i12 = 0; i12 < i11; i12++) {
            iHashCode = (iHashCode * 31) + objArr[i12].hashCode();
        }
        return i10 + iHashCode;
    }
}
