package com.google.crypto.tink.shaded.protobuf;

import com.google.android.gms.common.api.Api;
import java.util.Arrays;

/* loaded from: classes3.dex */
public abstract class i {

    /* renamed from: a, reason: collision with root package name */
    int f14357a;

    /* renamed from: b, reason: collision with root package name */
    int f14358b;

    /* renamed from: c, reason: collision with root package name */
    int f14359c;

    /* renamed from: d, reason: collision with root package name */
    j f14360d;

    /* renamed from: e, reason: collision with root package name */
    private boolean f14361e;

    /* JADX INFO: Access modifiers changed from: private */
    /* loaded from: classes3.dex */
    public static final class b extends i {

        /* renamed from: f, reason: collision with root package name */
        private final byte[] f14362f;

        /* renamed from: g, reason: collision with root package name */
        private final boolean f14363g;

        /* renamed from: h, reason: collision with root package name */
        private int f14364h;

        /* renamed from: i, reason: collision with root package name */
        private int f14365i;

        /* renamed from: j, reason: collision with root package name */
        private int f14366j;

        /* renamed from: k, reason: collision with root package name */
        private int f14367k;

        /* renamed from: l, reason: collision with root package name */
        private int f14368l;

        /* renamed from: m, reason: collision with root package name */
        private boolean f14369m;

        /* renamed from: n, reason: collision with root package name */
        private int f14370n;

        private void K() {
            int i10 = this.f14364h + this.f14365i;
            this.f14364h = i10;
            int i11 = i10 - this.f14367k;
            int i12 = this.f14370n;
            if (i11 <= i12) {
                this.f14365i = 0;
                return;
            }
            int i13 = i11 - i12;
            this.f14365i = i13;
            this.f14364h = i10 - i13;
        }

        private void N() {
            if (this.f14364h - this.f14366j >= 10) {
                O();
            } else {
                P();
            }
        }

        private void O() {
            for (int i10 = 0; i10 < 10; i10++) {
                byte[] bArr = this.f14362f;
                int i11 = this.f14366j;
                this.f14366j = i11 + 1;
                if (bArr[i11] >= 0) {
                    return;
                }
            }
            throw a0.e();
        }

        private void P() {
            for (int i10 = 0; i10 < 10; i10++) {
                if (D() >= 0) {
                    return;
                }
            }
            throw a0.e();
        }

        @Override // com.google.crypto.tink.shaded.protobuf.i
        public int A() {
            return H();
        }

        @Override // com.google.crypto.tink.shaded.protobuf.i
        public long B() {
            return I();
        }

        @Override // com.google.crypto.tink.shaded.protobuf.i
        public boolean C(int i10) {
            int b10 = p1.b(i10);
            if (b10 == 0) {
                N();
                return true;
            }
            if (b10 == 1) {
                M(8);
                return true;
            }
            if (b10 == 2) {
                M(H());
                return true;
            }
            if (b10 == 3) {
                L();
                a(p1.c(p1.a(i10), 4));
                return true;
            }
            if (b10 == 4) {
                return false;
            }
            if (b10 != 5) {
                throw a0.d();
            }
            M(4);
            return true;
        }

        public byte D() {
            int i10 = this.f14366j;
            if (i10 == this.f14364h) {
                throw a0.j();
            }
            byte[] bArr = this.f14362f;
            this.f14366j = i10 + 1;
            return bArr[i10];
        }

        public byte[] E(int i10) {
            if (i10 > 0) {
                int i11 = this.f14364h;
                int i12 = this.f14366j;
                if (i10 <= i11 - i12) {
                    int i13 = i10 + i12;
                    this.f14366j = i13;
                    return Arrays.copyOfRange(this.f14362f, i12, i13);
                }
            }
            if (i10 > 0) {
                throw a0.j();
            }
            if (i10 == 0) {
                return z.f14476c;
            }
            throw a0.f();
        }

        public int F() {
            int i10 = this.f14366j;
            if (this.f14364h - i10 < 4) {
                throw a0.j();
            }
            byte[] bArr = this.f14362f;
            this.f14366j = i10 + 4;
            return (bArr[i10] & 255) | ((bArr[i10 + 1] & 255) << 8) | ((bArr[i10 + 2] & 255) << 16) | ((bArr[i10 + 3] & 255) << 24);
        }

        public long G() {
            int i10 = this.f14366j;
            if (this.f14364h - i10 < 8) {
                throw a0.j();
            }
            byte[] bArr = this.f14362f;
            this.f14366j = i10 + 8;
            return ((bArr[i10 + 7] & 255) << 56) | (bArr[i10] & 255) | ((bArr[i10 + 1] & 255) << 8) | ((bArr[i10 + 2] & 255) << 16) | ((bArr[i10 + 3] & 255) << 24) | ((bArr[i10 + 4] & 255) << 32) | ((bArr[i10 + 5] & 255) << 40) | ((bArr[i10 + 6] & 255) << 48);
        }

        /* JADX WARN: Code restructure failed: missing block: B:33:0x0068, code lost:
        
            if (r2[r3] < 0) goto L34;
         */
        /*
            Code decompiled incorrectly, please refer to instructions dump.
        */
        public int H() {
            int i10;
            int i11 = this.f14366j;
            int i12 = this.f14364h;
            if (i12 != i11) {
                byte[] bArr = this.f14362f;
                int i13 = i11 + 1;
                byte b10 = bArr[i11];
                if (b10 >= 0) {
                    this.f14366j = i13;
                    return b10;
                }
                if (i12 - i13 >= 9) {
                    int i14 = i13 + 1;
                    int i15 = b10 ^ (bArr[i13] << 7);
                    if (i15 < 0) {
                        i10 = i15 ^ (-128);
                    } else {
                        int i16 = i14 + 1;
                        int i17 = i15 ^ (bArr[i14] << 14);
                        if (i17 >= 0) {
                            i10 = i17 ^ 16256;
                        } else {
                            i14 = i16 + 1;
                            int i18 = i17 ^ (bArr[i16] << 21);
                            if (i18 < 0) {
                                i10 = i18 ^ (-2080896);
                            } else {
                                i16 = i14 + 1;
                                byte b11 = bArr[i14];
                                i10 = (i18 ^ (b11 << 28)) ^ 266354560;
                                if (b11 < 0) {
                                    i14 = i16 + 1;
                                    if (bArr[i16] < 0) {
                                        i16 = i14 + 1;
                                        if (bArr[i14] < 0) {
                                            i14 = i16 + 1;
                                            if (bArr[i16] < 0) {
                                                i16 = i14 + 1;
                                                if (bArr[i14] < 0) {
                                                    i14 = i16 + 1;
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        i14 = i16;
                    }
                    this.f14366j = i14;
                    return i10;
                }
            }
            return (int) J();
        }

        /* JADX WARN: Code restructure failed: missing block: B:39:0x00b4, code lost:
        
            if (r2[r0] < 0) goto L40;
         */
        /*
            Code decompiled incorrectly, please refer to instructions dump.
        */
        public long I() {
            long j10;
            long j11;
            long j12;
            int i10;
            int i11 = this.f14366j;
            int i12 = this.f14364h;
            if (i12 != i11) {
                byte[] bArr = this.f14362f;
                int i13 = i11 + 1;
                byte b10 = bArr[i11];
                if (b10 >= 0) {
                    this.f14366j = i13;
                    return b10;
                }
                if (i12 - i13 >= 9) {
                    int i14 = i13 + 1;
                    int i15 = b10 ^ (bArr[i13] << 7);
                    if (i15 >= 0) {
                        int i16 = i14 + 1;
                        int i17 = i15 ^ (bArr[i14] << 14);
                        if (i17 >= 0) {
                            i14 = i16;
                            j10 = i17 ^ 16256;
                        } else {
                            i14 = i16 + 1;
                            int i18 = i17 ^ (bArr[i16] << 21);
                            if (i18 < 0) {
                                i10 = i18 ^ (-2080896);
                            } else {
                                long j13 = i18;
                                int i19 = i14 + 1;
                                long j14 = j13 ^ (bArr[i14] << 28);
                                if (j14 >= 0) {
                                    j12 = 266354560;
                                } else {
                                    i14 = i19 + 1;
                                    long j15 = j14 ^ (bArr[i19] << 35);
                                    if (j15 < 0) {
                                        j11 = -34093383808L;
                                    } else {
                                        i19 = i14 + 1;
                                        j14 = j15 ^ (bArr[i14] << 42);
                                        if (j14 >= 0) {
                                            j12 = 4363953127296L;
                                        } else {
                                            i14 = i19 + 1;
                                            j15 = j14 ^ (bArr[i19] << 49);
                                            if (j15 < 0) {
                                                j11 = -558586000294016L;
                                            } else {
                                                int i20 = i14 + 1;
                                                long j16 = (j15 ^ (bArr[i14] << 56)) ^ 71499008037633920L;
                                                i14 = j16 < 0 ? i20 + 1 : i20;
                                                j10 = j16;
                                            }
                                        }
                                    }
                                    j10 = j15 ^ j11;
                                }
                                j10 = j14 ^ j12;
                                i14 = i19;
                            }
                        }
                        this.f14366j = i14;
                        return j10;
                    }
                    i10 = i15 ^ (-128);
                    j10 = i10;
                    this.f14366j = i14;
                    return j10;
                }
            }
            return J();
        }

        long J() {
            long j10 = 0;
            for (int i10 = 0; i10 < 64; i10 += 7) {
                j10 |= (r3 & Byte.MAX_VALUE) << i10;
                if ((D() & 128) == 0) {
                    return j10;
                }
            }
            throw a0.e();
        }

        public void L() {
            int z10;
            do {
                z10 = z();
                if (z10 == 0) {
                    return;
                }
            } while (C(z10));
        }

        public void M(int i10) {
            if (i10 >= 0) {
                int i11 = this.f14364h;
                int i12 = this.f14366j;
                if (i10 <= i11 - i12) {
                    this.f14366j = i12 + i10;
                    return;
                }
            }
            if (i10 >= 0) {
                throw a0.j();
            }
            throw a0.f();
        }

        @Override // com.google.crypto.tink.shaded.protobuf.i
        public void a(int i10) {
            if (this.f14368l != i10) {
                throw a0.a();
            }
        }

        @Override // com.google.crypto.tink.shaded.protobuf.i
        public int d() {
            return this.f14366j - this.f14367k;
        }

        @Override // com.google.crypto.tink.shaded.protobuf.i
        public boolean e() {
            return this.f14366j == this.f14364h;
        }

        @Override // com.google.crypto.tink.shaded.protobuf.i
        public void i(int i10) {
            this.f14370n = i10;
            K();
        }

        @Override // com.google.crypto.tink.shaded.protobuf.i
        public int j(int i10) {
            if (i10 < 0) {
                throw a0.f();
            }
            int d10 = i10 + d();
            int i11 = this.f14370n;
            if (d10 > i11) {
                throw a0.j();
            }
            this.f14370n = d10;
            K();
            return i11;
        }

        @Override // com.google.crypto.tink.shaded.protobuf.i
        public boolean k() {
            return I() != 0;
        }

        @Override // com.google.crypto.tink.shaded.protobuf.i
        public h l() {
            int H = H();
            if (H > 0) {
                int i10 = this.f14364h;
                int i11 = this.f14366j;
                if (H <= i10 - i11) {
                    h J = (this.f14363g && this.f14369m) ? h.J(this.f14362f, i11, H) : h.m(this.f14362f, i11, H);
                    this.f14366j += H;
                    return J;
                }
            }
            return H == 0 ? h.f14344q : h.I(E(H));
        }

        @Override // com.google.crypto.tink.shaded.protobuf.i
        public double m() {
            return Double.longBitsToDouble(G());
        }

        @Override // com.google.crypto.tink.shaded.protobuf.i
        public int n() {
            return H();
        }

        @Override // com.google.crypto.tink.shaded.protobuf.i
        public int o() {
            return F();
        }

        @Override // com.google.crypto.tink.shaded.protobuf.i
        public long p() {
            return G();
        }

        @Override // com.google.crypto.tink.shaded.protobuf.i
        public float q() {
            return Float.intBitsToFloat(F());
        }

        @Override // com.google.crypto.tink.shaded.protobuf.i
        public int r() {
            return H();
        }

        @Override // com.google.crypto.tink.shaded.protobuf.i
        public long s() {
            return I();
        }

        @Override // com.google.crypto.tink.shaded.protobuf.i
        public int t() {
            return F();
        }

        @Override // com.google.crypto.tink.shaded.protobuf.i
        public long u() {
            return G();
        }

        @Override // com.google.crypto.tink.shaded.protobuf.i
        public int v() {
            return i.b(H());
        }

        @Override // com.google.crypto.tink.shaded.protobuf.i
        public long w() {
            return i.c(I());
        }

        @Override // com.google.crypto.tink.shaded.protobuf.i
        public String x() {
            int H = H();
            if (H > 0) {
                int i10 = this.f14364h;
                int i11 = this.f14366j;
                if (H <= i10 - i11) {
                    String str = new String(this.f14362f, i11, H, z.f14474a);
                    this.f14366j += H;
                    return str;
                }
            }
            if (H == 0) {
                return "";
            }
            if (H < 0) {
                throw a0.f();
            }
            throw a0.j();
        }

        @Override // com.google.crypto.tink.shaded.protobuf.i
        public String y() {
            int H = H();
            if (H > 0) {
                int i10 = this.f14364h;
                int i11 = this.f14366j;
                if (H <= i10 - i11) {
                    String e10 = o1.e(this.f14362f, i11, H);
                    this.f14366j += H;
                    return e10;
                }
            }
            if (H == 0) {
                return "";
            }
            if (H <= 0) {
                throw a0.f();
            }
            throw a0.j();
        }

        @Override // com.google.crypto.tink.shaded.protobuf.i
        public int z() {
            if (e()) {
                this.f14368l = 0;
                return 0;
            }
            int H = H();
            this.f14368l = H;
            if (p1.a(H) != 0) {
                return this.f14368l;
            }
            throw a0.b();
        }

        private b(byte[] bArr, int i10, int i11, boolean z10) {
            super();
            this.f14370n = Api.BaseClientBuilder.API_PRIORITY_OTHER;
            this.f14362f = bArr;
            this.f14364h = i11 + i10;
            this.f14366j = i10;
            this.f14367k = i10;
            this.f14363g = z10;
        }
    }

    public static int b(int i10) {
        return (-(i10 & 1)) ^ (i10 >>> 1);
    }

    public static long c(long j10) {
        return (-(j10 & 1)) ^ (j10 >>> 1);
    }

    public static i f(byte[] bArr) {
        return g(bArr, 0, bArr.length);
    }

    public static i g(byte[] bArr, int i10, int i11) {
        return h(bArr, i10, i11, false);
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public static i h(byte[] bArr, int i10, int i11, boolean z10) {
        b bVar = new b(bArr, i10, i11, z10);
        try {
            bVar.j(i11);
            return bVar;
        } catch (a0 e10) {
            throw new IllegalArgumentException(e10);
        }
    }

    public abstract int A();

    public abstract long B();

    public abstract boolean C(int i10);

    public abstract void a(int i10);

    public abstract int d();

    public abstract boolean e();

    public abstract void i(int i10);

    public abstract int j(int i10);

    public abstract boolean k();

    public abstract h l();

    public abstract double m();

    public abstract int n();

    public abstract int o();

    public abstract long p();

    public abstract float q();

    public abstract int r();

    public abstract long s();

    public abstract int t();

    public abstract long u();

    public abstract int v();

    public abstract long w();

    public abstract String x();

    public abstract String y();

    public abstract int z();

    private i() {
        this.f14358b = 100;
        this.f14359c = Api.BaseClientBuilder.API_PRIORITY_OTHER;
        this.f14361e = false;
    }
}
