package androidx.datastore.preferences.protobuf;

import java.util.Arrays;

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

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

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

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

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

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

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

    public h0(int i6, int[] iArr, Object[] objArr, boolean z6) {
        this.f11394a = i6;
        this.f11395b = iArr;
        this.f11396c = objArr;
        this.f11398e = z6;
    }

    public final void a(int i6) {
        int[] iArr = this.f11395b;
        if (i6 > iArr.length) {
            int i7 = this.f11394a;
            int i8 = (i7 / 2) + i7;
            if (i8 >= i6) {
                i6 = i8;
            }
            if (i6 < 8) {
                i6 = 8;
            }
            this.f11395b = Arrays.copyOf(iArr, i6);
            this.f11396c = Arrays.copyOf(this.f11396c, i6);
        }
    }

    public final int b() {
        int iS;
        int iU;
        int iO;
        int i6 = this.f11397d;
        if (i6 != -1) {
            return i6;
        }
        int i7 = 0;
        for (int i8 = 0; i8 < this.f11394a; i8++) {
            int i9 = this.f11395b[i8];
            int i10 = i9 >>> 3;
            int i11 = i9 & 7;
            if (i11 != 0) {
                if (i11 == 1) {
                    ((Long) this.f11396c[i8]).getClass();
                    iO = C1021j.o(i10);
                } else if (i11 == 2) {
                    iO = C1021j.l(i10, (C1018g) this.f11396c[i8]);
                } else if (i11 == 3) {
                    iS = C1021j.s(i10) * 2;
                    iU = ((h0) this.f11396c[i8]).b();
                } else {
                    if (i11 != 5) {
                        throw new IllegalStateException(C1034x.b());
                    }
                    ((Integer) this.f11396c[i8]).getClass();
                    iO = C1021j.n(i10);
                }
                i7 = iO + i7;
            } else {
                long jLongValue = ((Long) this.f11396c[i8]).longValue();
                iS = C1021j.s(i10);
                iU = C1021j.u(jLongValue);
            }
            i7 = iU + iS + i7;
        }
        this.f11397d = i7;
        return i7;
    }

    public final void c(int i6, Object obj) {
        if (!this.f11398e) {
            throw new UnsupportedOperationException();
        }
        a(this.f11394a + 1);
        int[] iArr = this.f11395b;
        int i7 = this.f11394a;
        iArr[i7] = i6;
        this.f11396c[i7] = obj;
        this.f11394a = i7 + 1;
    }

    public final void d(F f6) {
        if (this.f11394a == 0) {
            return;
        }
        f6.getClass();
        for (int i6 = 0; i6 < this.f11394a; i6++) {
            int i7 = this.f11395b[i6];
            Object obj = this.f11396c[i6];
            int i8 = i7 >>> 3;
            int i9 = i7 & 7;
            C1021j c1021j = (C1021j) f6.f11310a;
            if (i9 == 0) {
                c1021j.O(i8, ((Long) obj).longValue());
            } else if (i9 == 1) {
                c1021j.E(i8, ((Long) obj).longValue());
            } else if (i9 == 2) {
                f6.a(i8, (C1018g) obj);
            } else if (i9 == 3) {
                c1021j.L(i8, 3);
                ((h0) obj).d(f6);
                c1021j.L(i8, 4);
            } else {
                if (i9 != 5) {
                    throw new RuntimeException(C1034x.b());
                }
                c1021j.C(i8, ((Integer) obj).intValue());
            }
        }
    }

    public final boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null || !(obj instanceof h0)) {
            return false;
        }
        h0 h0Var = (h0) obj;
        int i6 = this.f11394a;
        if (i6 == h0Var.f11394a) {
            int[] iArr = this.f11395b;
            int[] iArr2 = h0Var.f11395b;
            int i7 = 0;
            while (true) {
                if (i7 >= i6) {
                    Object[] objArr = this.f11396c;
                    Object[] objArr2 = h0Var.f11396c;
                    int i8 = this.f11394a;
                    for (int i9 = 0; i9 < i8; i9++) {
                        if (objArr[i9].equals(objArr2[i9])) {
                        }
                    }
                    return true;
                }
                if (iArr[i7] != iArr2[i7]) {
                    break;
                }
                i7++;
            }
        }
        return false;
    }

    public final int hashCode() {
        int i6 = this.f11394a;
        int i7 = (527 + i6) * 31;
        int[] iArr = this.f11395b;
        int iHashCode = 17;
        int i8 = 17;
        for (int i9 = 0; i9 < i6; i9++) {
            i8 = (i8 * 31) + iArr[i9];
        }
        int i10 = (i7 + i8) * 31;
        Object[] objArr = this.f11396c;
        int i11 = this.f11394a;
        for (int i12 = 0; i12 < i11; i12++) {
            iHashCode = (iHashCode * 31) + objArr[i12].hashCode();
        }
        return i10 + iHashCode;
    }
}
