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

import java.util.Arrays;

/* JADX INFO: loaded from: classes3.dex */
public final class zzamy {
    private static final zzamy zza = new zzamy(0, new int[0], new Object[0], false);
    private int zzb;
    private int[] zzc;
    private Object[] zzd;
    private int zze;
    private boolean zzf;

    private zzamy() {
        this(0, new int[8], new Object[8], true);
    }

    public static zzamy zzc() {
        return zza;
    }

    public static zzamy zzd() {
        return new zzamy();
    }

    private final void zzf() {
        if (!this.zzf) {
            throw new UnsupportedOperationException();
        }
    }

    public final boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null || !(obj instanceof zzamy)) {
            return false;
        }
        zzamy zzamyVar = (zzamy) obj;
        int i6 = this.zzb;
        if (i6 == zzamyVar.zzb) {
            int[] iArr = this.zzc;
            int[] iArr2 = zzamyVar.zzc;
            int i7 = 0;
            while (true) {
                if (i7 >= i6) {
                    Object[] objArr = this.zzd;
                    Object[] objArr2 = zzamyVar.zzd;
                    int i8 = this.zzb;
                    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.zzb;
        int i7 = (i6 + 527) * 31;
        int[] iArr = this.zzc;
        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.zzd;
        int i11 = this.zzb;
        for (int i12 = 0; i12 < i11; i12++) {
            iHashCode = (iHashCode * 31) + objArr[i12].hashCode();
        }
        return i10 + iHashCode;
    }

    public final int zza() {
        int iZze;
        int i6 = this.zze;
        if (i6 != -1) {
            return i6;
        }
        int iZza = 0;
        for (int i7 = 0; i7 < this.zzb; i7++) {
            int i8 = this.zzc[i7];
            int i9 = i8 >>> 3;
            int i10 = i8 & 7;
            if (i10 == 0) {
                iZze = zzajo.zze(i9, ((Long) this.zzd[i7]).longValue());
            } else if (i10 == 1) {
                iZze = zzajo.zza(i9, ((Long) this.zzd[i7]).longValue());
            } else if (i10 == 2) {
                iZze = zzajo.zza(i9, (zzaiw) this.zzd[i7]);
            } else if (i10 == 3) {
                iZza = ((zzamy) this.zzd[i7]).zza() + (zzajo.zzg(i9) << 1) + iZza;
            } else {
                if (i10 != 5) {
                    throw new IllegalStateException(zzakm.zza());
                }
                iZze = zzajo.zzb(i9, ((Integer) this.zzd[i7]).intValue());
            }
            iZza = iZze + iZza;
        }
        this.zze = iZza;
        return iZza;
    }

    public final int zzb() {
        int i6 = this.zze;
        if (i6 != -1) {
            return i6;
        }
        int iZzb = 0;
        for (int i7 = 0; i7 < this.zzb; i7++) {
            iZzb += zzajo.zzb(this.zzc[i7] >>> 3, (zzaiw) this.zzd[i7]);
        }
        this.zze = iZzb;
        return iZzb;
    }

    public final void zze() {
        if (this.zzf) {
            this.zzf = false;
        }
    }

    private zzamy(int i6, int[] iArr, Object[] objArr, boolean z6) {
        this.zze = -1;
        this.zzb = i6;
        this.zzc = iArr;
        this.zzd = objArr;
        this.zzf = z6;
    }

    public final void zzb(zzanm zzanmVar) {
        if (this.zzb == 0) {
            return;
        }
        if (zzanmVar.zza() == 1) {
            for (int i6 = 0; i6 < this.zzb; i6++) {
                zza(this.zzc[i6], this.zzd[i6], zzanmVar);
            }
            return;
        }
        for (int i7 = this.zzb - 1; i7 >= 0; i7--) {
            zza(this.zzc[i7], this.zzd[i7], zzanmVar);
        }
    }

    public final zzamy zza(zzamy zzamyVar) {
        if (zzamyVar.equals(zza)) {
            return this;
        }
        zzf();
        int i6 = this.zzb + zzamyVar.zzb;
        zza(i6);
        System.arraycopy(zzamyVar.zzc, 0, this.zzc, this.zzb, zzamyVar.zzb);
        System.arraycopy(zzamyVar.zzd, 0, this.zzd, this.zzb, zzamyVar.zzb);
        this.zzb = i6;
        return this;
    }

    public static zzamy zza(zzamy zzamyVar, zzamy zzamyVar2) {
        int i6 = zzamyVar.zzb + zzamyVar2.zzb;
        int[] iArrCopyOf = Arrays.copyOf(zzamyVar.zzc, i6);
        System.arraycopy(zzamyVar2.zzc, 0, iArrCopyOf, zzamyVar.zzb, zzamyVar2.zzb);
        Object[] objArrCopyOf = Arrays.copyOf(zzamyVar.zzd, i6);
        System.arraycopy(zzamyVar2.zzd, 0, objArrCopyOf, zzamyVar.zzb, zzamyVar2.zzb);
        return new zzamy(i6, iArrCopyOf, objArrCopyOf, true);
    }

    private final void zza(int i6) {
        int[] iArr = this.zzc;
        if (i6 > iArr.length) {
            int i7 = this.zzb;
            int i8 = (i7 / 2) + i7;
            if (i8 >= i6) {
                i6 = i8;
            }
            if (i6 < 8) {
                i6 = 8;
            }
            this.zzc = Arrays.copyOf(iArr, i6);
            this.zzd = Arrays.copyOf(this.zzd, i6);
        }
    }

    public final void zza(StringBuilder sb, int i6) {
        for (int i7 = 0; i7 < this.zzb; i7++) {
            zzalo.zza(sb, i6, String.valueOf(this.zzc[i7] >>> 3), this.zzd[i7]);
        }
    }

    public final void zza(int i6, Object obj) {
        zzf();
        zza(this.zzb + 1);
        int[] iArr = this.zzc;
        int i7 = this.zzb;
        iArr[i7] = i6;
        this.zzd[i7] = obj;
        this.zzb = i7 + 1;
    }

    public final void zza(zzanm zzanmVar) {
        if (zzanmVar.zza() == 2) {
            for (int i6 = this.zzb - 1; i6 >= 0; i6--) {
                zzanmVar.zza(this.zzc[i6] >>> 3, this.zzd[i6]);
            }
            return;
        }
        for (int i7 = 0; i7 < this.zzb; i7++) {
            zzanmVar.zza(this.zzc[i7] >>> 3, this.zzd[i7]);
        }
    }

    private static void zza(int i6, Object obj, zzanm zzanmVar) {
        int i7 = i6 >>> 3;
        int i8 = i6 & 7;
        if (i8 == 0) {
            zzanmVar.zzb(i7, ((Long) obj).longValue());
            return;
        }
        if (i8 == 1) {
            zzanmVar.zza(i7, ((Long) obj).longValue());
            return;
        }
        if (i8 == 2) {
            zzanmVar.zza(i7, (zzaiw) obj);
            return;
        }
        if (i8 != 3) {
            if (i8 == 5) {
                zzanmVar.zzb(i7, ((Integer) obj).intValue());
                return;
            }
            throw new RuntimeException(zzakm.zza());
        }
        if (zzanmVar.zza() == 1) {
            zzanmVar.zzb(i7);
            ((zzamy) obj).zzb(zzanmVar);
            zzanmVar.zza(i7);
        } else {
            zzanmVar.zza(i7);
            ((zzamy) obj).zzb(zzanmVar);
            zzanmVar.zzb(i7);
        }
    }
}
