package com.google.android.recaptcha.internal;

import java.util.Arrays;

/* JADX INFO: loaded from: classes3.dex */
final class zzlf extends zzli {
    private final byte[] zze;
    private int zzf;
    private int zzg;
    private int zzh;
    private int zzi;
    private int zzj;

    public /* synthetic */ zzlf(byte[] bArr, int i6, int i7, boolean z6, zzlh zzlhVar) {
        super(null);
        this.zzj = Integer.MAX_VALUE;
        this.zze = bArr;
        this.zzf = 0;
        this.zzh = 0;
    }

    private final void zzJ() {
        int i6 = this.zzf + this.zzg;
        this.zzf = i6;
        int i7 = this.zzj;
        if (i6 <= i7) {
            this.zzg = 0;
            return;
        }
        int i8 = i6 - i7;
        this.zzg = i8;
        this.zzf = i6 - i8;
    }

    @Override // com.google.android.recaptcha.internal.zzli
    public final void zzA(int i6) {
        this.zzj = i6;
        zzJ();
    }

    public final void zzB(int i6) throws zznn {
        if (i6 >= 0) {
            int i7 = this.zzf;
            int i8 = this.zzh;
            if (i6 <= i7 - i8) {
                this.zzh = i8 + i6;
                return;
            }
        }
        if (i6 >= 0) {
            throw new zznn("While parsing a protocol message, the input ended unexpectedly in the middle of a field.  This could mean either that the input has been truncated or that an embedded message misreported its own length.");
        }
        throw new zznn("CodedInputStream encountered an embedded string or message which claimed to have negative size.");
    }

    @Override // com.google.android.recaptcha.internal.zzli
    public final boolean zzC() {
        return this.zzh == this.zzf;
    }

    @Override // com.google.android.recaptcha.internal.zzli
    public final boolean zzD() {
        return zzr() != 0;
    }

    @Override // com.google.android.recaptcha.internal.zzli
    public final boolean zzE(int i6) throws zznn {
        int i7 = i6 & 7;
        int i8 = 0;
        if (i7 == 0) {
            if (this.zzf - this.zzh < 10) {
                while (i8 < 10) {
                    if (zza() < 0) {
                        i8++;
                    }
                }
                throw new zznn("CodedInputStream encountered a malformed varint.");
            }
            while (i8 < 10) {
                byte[] bArr = this.zze;
                int i9 = this.zzh;
                this.zzh = i9 + 1;
                if (bArr[i9] < 0) {
                    i8++;
                }
            }
            throw new zznn("CodedInputStream encountered a malformed varint.");
            return true;
        }
        if (i7 == 1) {
            zzB(8);
            return true;
        }
        if (i7 == 2) {
            zzB(zzj());
            return true;
        }
        if (i7 == 3) {
            zzI();
            zzz(((i6 >>> 3) << 3) | 4);
            return true;
        }
        if (i7 == 4) {
            return false;
        }
        if (i7 != 5) {
            throw new zznm("Protocol message tag had invalid wire type.");
        }
        zzB(4);
        return true;
    }

    public final byte zza() throws zznn {
        int i6 = this.zzh;
        if (i6 == this.zzf) {
            throw new zznn("While parsing a protocol message, the input ended unexpectedly in the middle of a field.  This could mean either that the input has been truncated or that an embedded message misreported its own length.");
        }
        byte[] bArr = this.zze;
        this.zzh = i6 + 1;
        return bArr[i6];
    }

    @Override // com.google.android.recaptcha.internal.zzli
    public final double zzb() {
        return Double.longBitsToDouble(zzq());
    }

    @Override // com.google.android.recaptcha.internal.zzli
    public final float zzc() {
        return Float.intBitsToFloat(zzi());
    }

    @Override // com.google.android.recaptcha.internal.zzli
    public final int zzd() {
        return this.zzh;
    }

    @Override // com.google.android.recaptcha.internal.zzli
    public final int zze(int i6) {
        if (i6 < 0) {
            throw new zznn("CodedInputStream encountered an embedded string or message which claimed to have negative size.");
        }
        int i7 = i6 + this.zzh;
        if (i7 < 0) {
            throw new zznn("Failed to parse the message.");
        }
        int i8 = this.zzj;
        if (i7 > i8) {
            throw new zznn("While parsing a protocol message, the input ended unexpectedly in the middle of a field.  This could mean either that the input has been truncated or that an embedded message misreported its own length.");
        }
        this.zzj = i7;
        zzJ();
        return i8;
    }

    @Override // com.google.android.recaptcha.internal.zzli
    public final int zzf() {
        return zzj();
    }

    @Override // com.google.android.recaptcha.internal.zzli
    public final int zzg() {
        return zzi();
    }

    @Override // com.google.android.recaptcha.internal.zzli
    public final int zzh() {
        return zzj();
    }

    public final int zzi() throws zznn {
        int i6 = this.zzh;
        if (this.zzf - i6 < 4) {
            throw new zznn("While parsing a protocol message, the input ended unexpectedly in the middle of a field.  This could mean either that the input has been truncated or that an embedded message misreported its own length.");
        }
        byte[] bArr = this.zze;
        this.zzh = i6 + 4;
        int i7 = bArr[i6] & 255;
        int i8 = bArr[i6 + 1] & 255;
        int i9 = bArr[i6 + 2] & 255;
        return ((bArr[i6 + 3] & 255) << 24) | (i8 << 8) | i7 | (i9 << 16);
    }

    public final int zzj() {
        int i6;
        int i7 = this.zzh;
        int i8 = this.zzf;
        if (i8 != i7) {
            byte[] bArr = this.zze;
            int i9 = i7 + 1;
            byte b5 = bArr[i7];
            if (b5 >= 0) {
                this.zzh = i9;
                return b5;
            }
            if (i8 - i9 >= 9) {
                int i10 = i7 + 2;
                int i11 = (bArr[i9] << 7) ^ b5;
                if (i11 < 0) {
                    i6 = i11 ^ (-128);
                } else {
                    int i12 = i7 + 3;
                    int i13 = (bArr[i10] << 14) ^ i11;
                    if (i13 >= 0) {
                        i6 = i13 ^ 16256;
                    } else {
                        int i14 = i7 + 4;
                        int i15 = i13 ^ (bArr[i12] << 21);
                        if (i15 < 0) {
                            i6 = (-2080896) ^ i15;
                        } else {
                            i12 = i7 + 5;
                            byte b6 = bArr[i14];
                            int i16 = (i15 ^ (b6 << 28)) ^ 266354560;
                            if (b6 < 0) {
                                i14 = i7 + 6;
                                if (bArr[i12] < 0) {
                                    i12 = i7 + 7;
                                    if (bArr[i14] < 0) {
                                        i14 = i7 + 8;
                                        if (bArr[i12] < 0) {
                                            i12 = i7 + 9;
                                            if (bArr[i14] < 0) {
                                                int i17 = i7 + 10;
                                                if (bArr[i12] >= 0) {
                                                    i10 = i17;
                                                    i6 = i16;
                                                }
                                            }
                                        }
                                    }
                                }
                                i6 = i16;
                            }
                            i6 = i16;
                        }
                        i10 = i14;
                    }
                    i10 = i12;
                }
                this.zzh = i10;
                return i6;
            }
        }
        return (int) zzs();
    }

    @Override // com.google.android.recaptcha.internal.zzli
    public final int zzk() {
        return zzi();
    }

    @Override // com.google.android.recaptcha.internal.zzli
    public final int zzl() {
        return zzli.zzF(zzj());
    }

    @Override // com.google.android.recaptcha.internal.zzli
    public final int zzm() throws zznn {
        if (zzC()) {
            this.zzi = 0;
            return 0;
        }
        int iZzj = zzj();
        this.zzi = iZzj;
        if ((iZzj >>> 3) != 0) {
            return iZzj;
        }
        throw new zznn("Protocol message contained an invalid tag (zero).");
    }

    @Override // com.google.android.recaptcha.internal.zzli
    public final int zzn() {
        return zzj();
    }

    @Override // com.google.android.recaptcha.internal.zzli
    public final long zzo() {
        return zzq();
    }

    @Override // com.google.android.recaptcha.internal.zzli
    public final long zzp() {
        return zzr();
    }

    public final long zzq() throws zznn {
        int i6 = this.zzh;
        if (this.zzf - i6 < 8) {
            throw new zznn("While parsing a protocol message, the input ended unexpectedly in the middle of a field.  This could mean either that the input has been truncated or that an embedded message misreported its own length.");
        }
        byte[] bArr = this.zze;
        this.zzh = i6 + 8;
        long j4 = bArr[i6];
        long j6 = (((long) bArr[i6 + 1]) & 255) << 8;
        long j7 = bArr[i6 + 2];
        long j8 = bArr[i6 + 3];
        return ((((long) bArr[i6 + 6]) & 255) << 48) | (j4 & 255) | j6 | ((j7 & 255) << 16) | ((j8 & 255) << 24) | ((bArr[i6 + 4] & 255) << 32) | ((bArr[i6 + 5] & 255) << 40) | ((((long) bArr[i6 + 7]) & 255) << 56);
    }

    public final long zzr() {
        long j4;
        long j6;
        int i6 = this.zzh;
        int i7 = this.zzf;
        if (i7 != i6) {
            byte[] bArr = this.zze;
            int i8 = i6 + 1;
            byte b5 = bArr[i6];
            if (b5 >= 0) {
                this.zzh = i8;
                return b5;
            }
            if (i7 - i8 >= 9) {
                int i9 = i6 + 2;
                int i10 = (bArr[i8] << 7) ^ b5;
                if (i10 < 0) {
                    j4 = i10 ^ (-128);
                } else {
                    int i11 = i6 + 3;
                    int i12 = (bArr[i9] << 14) ^ i10;
                    if (i12 >= 0) {
                        j4 = i12 ^ 16256;
                    } else {
                        int i13 = i6 + 4;
                        int i14 = i12 ^ (bArr[i11] << 21);
                        if (i14 < 0) {
                            long j7 = (-2080896) ^ i14;
                            i9 = i13;
                            j4 = j7;
                        } else {
                            i11 = i6 + 5;
                            long j8 = (((long) bArr[i13]) << 28) ^ ((long) i14);
                            if (j8 >= 0) {
                                j4 = j8 ^ 266354560;
                            } else {
                                i9 = i6 + 6;
                                long j9 = (((long) bArr[i11]) << 35) ^ j8;
                                if (j9 < 0) {
                                    j6 = -34093383808L;
                                } else {
                                    int i15 = i6 + 7;
                                    long j10 = j9 ^ (((long) bArr[i9]) << 42);
                                    if (j10 >= 0) {
                                        j4 = j10 ^ 4363953127296L;
                                    } else {
                                        i9 = i6 + 8;
                                        j9 = j10 ^ (((long) bArr[i15]) << 49);
                                        if (j9 < 0) {
                                            j6 = -558586000294016L;
                                        } else {
                                            i15 = i6 + 9;
                                            long j11 = (j9 ^ (((long) bArr[i9]) << 56)) ^ 71499008037633920L;
                                            if (j11 < 0) {
                                                i9 = i6 + 10;
                                                if (bArr[i15] >= 0) {
                                                    j4 = j11;
                                                }
                                            } else {
                                                j4 = j11;
                                            }
                                        }
                                    }
                                    i9 = i15;
                                }
                                j4 = j9 ^ j6;
                            }
                        }
                    }
                    i9 = i11;
                }
                this.zzh = i9;
                return j4;
            }
        }
        return zzs();
    }

    public final long zzs() throws zznn {
        long j4 = 0;
        for (int i6 = 0; i6 < 64; i6 += 7) {
            byte bZza = zza();
            j4 |= ((long) (bZza & 127)) << i6;
            if ((bZza & 128) == 0) {
                return j4;
            }
        }
        throw new zznn("CodedInputStream encountered a malformed varint.");
    }

    @Override // com.google.android.recaptcha.internal.zzli
    public final long zzt() {
        return zzq();
    }

    @Override // com.google.android.recaptcha.internal.zzli
    public final long zzu() {
        return zzli.zzG(zzr());
    }

    @Override // com.google.android.recaptcha.internal.zzli
    public final long zzv() {
        return zzr();
    }

    @Override // com.google.android.recaptcha.internal.zzli
    public final zzle zzw() throws zznn {
        int iZzj = zzj();
        if (iZzj > 0) {
            int i6 = this.zzf;
            int i7 = this.zzh;
            if (iZzj <= i6 - i7) {
                zzle zzleVarZzk = zzle.zzk(this.zze, i7, iZzj);
                this.zzh += iZzj;
                return zzleVarZzk;
            }
        }
        if (iZzj == 0) {
            return zzle.zzb;
        }
        if (iZzj > 0) {
            int i8 = this.zzf;
            int i9 = this.zzh;
            if (iZzj <= i8 - i9) {
                int i10 = iZzj + i9;
                this.zzh = i10;
                return new zzlc(Arrays.copyOfRange(this.zze, i9, i10));
            }
        }
        if (iZzj <= 0) {
            throw new zznn("CodedInputStream encountered an embedded string or message which claimed to have negative size.");
        }
        throw new zznn("While parsing a protocol message, the input ended unexpectedly in the middle of a field.  This could mean either that the input has been truncated or that an embedded message misreported its own length.");
    }

    @Override // com.google.android.recaptcha.internal.zzli
    public final String zzx() throws zznn {
        int iZzj = zzj();
        if (iZzj > 0) {
            int i6 = this.zzf;
            int i7 = this.zzh;
            if (iZzj <= i6 - i7) {
                String str = new String(this.zze, i7, iZzj, zznl.zza);
                this.zzh += iZzj;
                return str;
            }
        }
        if (iZzj == 0) {
            return "";
        }
        if (iZzj < 0) {
            throw new zznn("CodedInputStream encountered an embedded string or message which claimed to have negative size.");
        }
        throw new zznn("While parsing a protocol message, the input ended unexpectedly in the middle of a field.  This could mean either that the input has been truncated or that an embedded message misreported its own length.");
    }

    @Override // com.google.android.recaptcha.internal.zzli
    public final String zzy() throws zznn {
        int iZzj = zzj();
        if (iZzj > 0) {
            int i6 = this.zzf;
            int i7 = this.zzh;
            if (iZzj <= i6 - i7) {
                String strZzd = zzpv.zzd(this.zze, i7, iZzj);
                this.zzh += iZzj;
                return strZzd;
            }
        }
        if (iZzj == 0) {
            return "";
        }
        if (iZzj <= 0) {
            throw new zznn("CodedInputStream encountered an embedded string or message which claimed to have negative size.");
        }
        throw new zznn("While parsing a protocol message, the input ended unexpectedly in the middle of a field.  This could mean either that the input has been truncated or that an embedded message misreported its own length.");
    }

    @Override // com.google.android.recaptcha.internal.zzli
    public final void zzz(int i6) throws zznn {
        if (this.zzi != i6) {
            throw new zznn("Protocol message end-group tag did not match expected tag.");
        }
    }
}
