package com.google.android.gms.internal.ads; import androidx.work.WorkInfo; import com.applovin.exoplayer2.common.base.Ascii; import java.io.IOException; import java.util.Arrays; import kotlin.jvm.internal.ByteCompanionObject; /* loaded from: classes3.dex */ final class zzgwk extends zzgwp { private final byte[] zze; private int zzf; private int zzg; private int zzh; private final int zzi; private int zzj; private int zzk; public /* synthetic */ zzgwk(byte[] bArr, int i, int i2, boolean z, zzgwo zzgwoVar) { super(null); this.zzk = Integer.MAX_VALUE; this.zze = bArr; this.zzf = i2 + i; this.zzh = i; this.zzi = i; } private final void zzC() { int i = this.zzf + this.zzg; this.zzf = i; int i2 = i - this.zzi; int i3 = this.zzk; if (i2 <= i3) { this.zzg = 0; return; } int i4 = i2 - i3; this.zzg = i4; this.zzf = i - i4; } @Override // com.google.android.gms.internal.ads.zzgwp public final boolean zzA() throws IOException { return this.zzh == this.zzf; } @Override // com.google.android.gms.internal.ads.zzgwp public final boolean zzB() throws IOException { return zzq() != 0; } @Override // com.google.android.gms.internal.ads.zzgwp public final double zza() throws IOException { return Double.longBitsToDouble(zzp()); } @Override // com.google.android.gms.internal.ads.zzgwp public final float zzb() throws IOException { return Float.intBitsToFloat(zzh()); } @Override // com.google.android.gms.internal.ads.zzgwp public final int zzc() { return this.zzh - this.zzi; } @Override // com.google.android.gms.internal.ads.zzgwp public final int zze() throws IOException { return zzi(); } @Override // com.google.android.gms.internal.ads.zzgwp public final int zzf() throws IOException { return zzh(); } @Override // com.google.android.gms.internal.ads.zzgwp public final int zzg() throws IOException { return zzi(); } public final int zzi() throws IOException { int i; int i2 = this.zzh; int i3 = this.zzf; if (i3 != i2) { byte[] bArr = this.zze; int i4 = i2 + 1; byte b = bArr[i2]; if (b >= 0) { this.zzh = i4; return b; } if (i3 - i4 >= 9) { int i5 = i2 + 2; int i6 = (bArr[i4] << 7) ^ b; if (i6 < 0) { i = i6 ^ WorkInfo.STOP_REASON_FOREGROUND_SERVICE_TIMEOUT; } else { int i7 = i2 + 3; int i8 = (bArr[i5] << Ascii.SO) ^ i6; if (i8 >= 0) { i = i8 ^ 16256; } else { int i9 = i2 + 4; int i10 = i8 ^ (bArr[i7] << Ascii.NAK); if (i10 < 0) { i = (-2080896) ^ i10; } else { i7 = i2 + 5; byte b2 = bArr[i9]; int i11 = (i10 ^ (b2 << Ascii.FS)) ^ 266354560; if (b2 < 0) { i9 = i2 + 6; if (bArr[i7] < 0) { i7 = i2 + 7; if (bArr[i9] < 0) { i9 = i2 + 8; if (bArr[i7] < 0) { i7 = i2 + 9; if (bArr[i9] < 0) { int i12 = i2 + 10; if (bArr[i7] >= 0) { i5 = i12; i = i11; } } } } } i = i11; } i = i11; } i5 = i9; } i5 = i7; } this.zzh = i5; return i; } } return (int) zzr(); } @Override // com.google.android.gms.internal.ads.zzgwp public final int zzj() throws IOException { return zzh(); } @Override // com.google.android.gms.internal.ads.zzgwp public final int zzk() throws IOException { return zzgwp.zzD(zzi()); } @Override // com.google.android.gms.internal.ads.zzgwp public final int zzl() throws IOException { if (zzA()) { this.zzj = 0; return 0; } int zzi = zzi(); this.zzj = zzi; if ((zzi >>> 3) != 0) { return zzi; } throw new zzgyg("Protocol message contained an invalid tag (zero)."); } @Override // com.google.android.gms.internal.ads.zzgwp public final int zzm() throws IOException { return zzi(); } @Override // com.google.android.gms.internal.ads.zzgwp public final long zzn() throws IOException { return zzp(); } @Override // com.google.android.gms.internal.ads.zzgwp public final long zzo() throws IOException { return zzq(); } public final long zzq() throws IOException { long j; long j2; int i = this.zzh; int i2 = this.zzf; if (i2 != i) { byte[] bArr = this.zze; int i3 = i + 1; byte b = bArr[i]; if (b >= 0) { this.zzh = i3; return b; } if (i2 - i3 >= 9) { int i4 = i + 2; int i5 = (bArr[i3] << 7) ^ b; if (i5 < 0) { j = i5 ^ WorkInfo.STOP_REASON_FOREGROUND_SERVICE_TIMEOUT; } else { int i6 = i + 3; int i7 = (bArr[i4] << Ascii.SO) ^ i5; if (i7 >= 0) { j = i7 ^ 16256; } else { int i8 = i + 4; int i9 = i7 ^ (bArr[i6] << Ascii.NAK); if (i9 < 0) { long j3 = (-2080896) ^ i9; i4 = i8; j = j3; } else { i6 = i + 5; long j4 = (bArr[i8] << 28) ^ i9; if (j4 >= 0) { j = j4 ^ 266354560; } else { i4 = i + 6; long j5 = (bArr[i6] << 35) ^ j4; if (j5 < 0) { j2 = -34093383808L; } else { int i10 = i + 7; long j6 = j5 ^ (bArr[i4] << 42); if (j6 >= 0) { j = j6 ^ 4363953127296L; } else { i4 = i + 8; j5 = j6 ^ (bArr[i10] << 49); if (j5 < 0) { j2 = -558586000294016L; } else { i10 = i + 9; long j7 = (j5 ^ (bArr[i4] << 56)) ^ 71499008037633920L; if (j7 < 0) { i4 = i + 10; if (bArr[i10] >= 0) { j = j7; } } else { j = j7; } } } i4 = i10; } j = j5 ^ j2; } } } i4 = i6; } this.zzh = i4; return j; } } return zzr(); } public final long zzr() throws IOException { long j = 0; for (int i = 0; i < 64; i += 7) { int i2 = this.zzh; if (i2 == this.zzf) { throw new zzgyg("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 = i2 + 1; j |= (r3 & Byte.MAX_VALUE) << i; if ((bArr[i2] & ByteCompanionObject.MIN_VALUE) == 0) { return j; } } throw new zzgyg("CodedInputStream encountered a malformed varint."); } @Override // com.google.android.gms.internal.ads.zzgwp public final long zzs() throws IOException { return zzp(); } @Override // com.google.android.gms.internal.ads.zzgwp public final long zzt() throws IOException { return zzgwp.zzF(zzq()); } @Override // com.google.android.gms.internal.ads.zzgwp public final long zzu() throws IOException { return zzq(); } @Override // com.google.android.gms.internal.ads.zzgwp public final zzgwj zzv() throws IOException { int zzi = zzi(); if (zzi > 0) { int i = this.zzf; int i2 = this.zzh; if (zzi <= i - i2) { zzgwj zzv = zzgwj.zzv(this.zze, i2, zzi); this.zzh += zzi; return zzv; } } if (zzi == 0) { return zzgwj.zzb; } if (zzi > 0) { int i3 = this.zzf; int i4 = this.zzh; if (zzi <= i3 - i4) { int i5 = zzi + i4; this.zzh = i5; return new zzgwg(Arrays.copyOfRange(this.zze, i4, i5)); } } if (zzi <= 0) { throw new zzgyg("CodedInputStream encountered an embedded string or message which claimed to have negative size."); } throw new zzgyg("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.gms.internal.ads.zzgwp public final String zzw() throws IOException { int zzi = zzi(); if (zzi > 0) { int i = this.zzf; int i2 = this.zzh; if (zzi <= i - i2) { String str = new String(this.zze, i2, zzi, zzgye.zza); this.zzh += zzi; return str; } } if (zzi == 0) { return ""; } if (zzi < 0) { throw new zzgyg("CodedInputStream encountered an embedded string or message which claimed to have negative size."); } throw new zzgyg("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.gms.internal.ads.zzgwp public final String zzx() throws IOException { int zzi = zzi(); if (zzi > 0) { int i = this.zzf; int i2 = this.zzh; if (zzi <= i - i2) { String zzh = zzhat.zzh(this.zze, i2, zzi); this.zzh += zzi; return zzh; } } if (zzi == 0) { return ""; } if (zzi <= 0) { throw new zzgyg("CodedInputStream encountered an embedded string or message which claimed to have negative size."); } throw new zzgyg("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.gms.internal.ads.zzgwp public final void zzy(int i) throws zzgyg { if (this.zzj != i) { throw new zzgyg("Protocol message end-group tag did not match expected tag."); } } @Override // com.google.android.gms.internal.ads.zzgwp public final void zzz(int i) { this.zzk = i; zzC(); } public final int zzh() throws IOException { int i = this.zzh; if (this.zzf - i < 4) { throw new zzgyg("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 = i + 4; int i2 = bArr[i] & 255; int i3 = bArr[i + 1] & 255; int i4 = bArr[i + 2] & 255; return ((bArr[i + 3] & 255) << 24) | (i3 << 8) | i2 | (i4 << 16); } public final long zzp() throws IOException { int i = this.zzh; if (this.zzf - i < 8) { throw new zzgyg("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 = i + 8; long j = bArr[i]; long j2 = bArr[i + 2]; long j3 = bArr[i + 3]; return ((bArr[i + 7] & 255) << 56) | (j & 255) | ((bArr[i + 1] & 255) << 8) | ((j2 & 255) << 16) | ((j3 & 255) << 24) | ((bArr[i + 4] & 255) << 32) | ((bArr[i + 5] & 255) << 40) | ((bArr[i + 6] & 255) << 48); } @Override // com.google.android.gms.internal.ads.zzgwp public final int zzd(int i) throws zzgyg { if (i < 0) { throw new zzgyg("CodedInputStream encountered an embedded string or message which claimed to have negative size."); } int i2 = i + (this.zzh - this.zzi); if (i2 < 0) { throw new zzgyg("Failed to parse the message."); } int i3 = this.zzk; if (i2 > i3) { throw new zzgyg("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.zzk = i2; zzC(); return i3; } }