package o;

import com.google.android.gms.common.api.Api;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* renamed from: o.si, reason: case insensitive filesystem */
/* loaded from: classes.dex */
public final class C2452si extends AbstractC2071oh {
    public final byte[] n;

    /* renamed from: o, reason: collision with root package name */
    public int f719o;
    public int p;
    public int q;
    public final int r;
    public int s;
    public int t = Api.BaseClientBuilder.API_PRIORITY_OTHER;

    public C2452si(byte[] bArr, int i, int i2, boolean z) {
        this.n = bArr;
        this.f719o = i2 + i;
        this.q = i;
        this.r = i;
    }

    @Override // o.AbstractC2071oh
    public final int A() {
        return G();
    }

    @Override // o.AbstractC2071oh
    public final long B() {
        return H();
    }

    @Override // o.AbstractC2071oh
    public final boolean C(int i) throws EI {
        int i2 = i & 7;
        int i3 = 0;
        if (i2 != 0) {
            if (i2 == 1) {
                K(8);
                return true;
            }
            if (i2 == 2) {
                K(G());
                return true;
            }
            if (i2 == 3) {
                D();
                a(((i >>> 3) << 3) | 4);
                return true;
            }
            if (i2 == 4) {
                return false;
            }
            if (i2 != 5) {
                throw EI.b();
            }
            K(4);
            return true;
        }
        int i4 = this.f719o - this.q;
        byte[] bArr = this.n;
        if (i4 >= 10) {
            while (i3 < 10) {
                int i5 = this.q;
                this.q = i5 + 1;
                if (bArr[i5] < 0) {
                    i3++;
                }
            }
            throw EI.c();
        }
        while (i3 < 10) {
            int i6 = this.q;
            if (i6 == this.f719o) {
                throw EI.e();
            }
            this.q = i6 + 1;
            if (bArr[i6] < 0) {
                i3++;
            }
        }
        throw EI.c();
        return true;
    }

    public final int E() throws EI {
        int i = this.q;
        if (this.f719o - i < 4) {
            throw EI.e();
        }
        this.q = i + 4;
        byte[] bArr = this.n;
        return ((bArr[i + 3] & 255) << 24) | (bArr[i] & 255) | ((bArr[i + 1] & 255) << 8) | ((bArr[i + 2] & 255) << 16);
    }

    public final long F() throws EI {
        int i = this.q;
        if (this.f719o - i < 8) {
            throw EI.e();
        }
        this.q = i + 8;
        byte[] bArr = this.n;
        return ((bArr[i + 7] & 255) << 56) | (bArr[i] & 255) | ((bArr[i + 1] & 255) << 8) | ((bArr[i + 2] & 255) << 16) | ((bArr[i + 3] & 255) << 24) | ((bArr[i + 4] & 255) << 32) | ((bArr[i + 5] & 255) << 40) | ((bArr[i + 6] & 255) << 48);
    }

    public final int G() {
        int i;
        int i2 = this.q;
        int i3 = this.f719o;
        if (i3 != i2) {
            int i4 = i2 + 1;
            byte[] bArr = this.n;
            byte b = bArr[i2];
            if (b >= 0) {
                this.q = i4;
                return b;
            }
            if (i3 - i4 >= 9) {
                int i5 = i2 + 2;
                int i6 = (bArr[i4] << 7) ^ b;
                if (i6 < 0) {
                    i = i6 ^ (-128);
                } else {
                    int i7 = i2 + 3;
                    int i8 = (bArr[i5] << 14) ^ i6;
                    if (i8 >= 0) {
                        i = i8 ^ 16256;
                    } else {
                        int i9 = i2 + 4;
                        int i10 = i8 ^ (bArr[i7] << 21);
                        if (i10 < 0) {
                            i = (-2080896) ^ i10;
                        } else {
                            i7 = i2 + 5;
                            byte b2 = bArr[i9];
                            int i11 = (i10 ^ (b2 << 28)) ^ 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.q = i5;
                return i;
            }
        }
        return (int) I();
    }

    public final long H() {
        long j;
        long j2;
        long j3;
        long j4;
        int i = this.q;
        int i2 = this.f719o;
        if (i2 != i) {
            int i3 = i + 1;
            byte[] bArr = this.n;
            byte b = bArr[i];
            if (b >= 0) {
                this.q = i3;
                return b;
            }
            if (i2 - i3 >= 9) {
                int i4 = i + 2;
                int i5 = (bArr[i3] << 7) ^ b;
                if (i5 < 0) {
                    j = i5 ^ (-128);
                } else {
                    int i6 = i + 3;
                    int i7 = (bArr[i4] << 14) ^ i5;
                    if (i7 >= 0) {
                        j = i7 ^ 16256;
                        i4 = i6;
                    } else {
                        int i8 = i + 4;
                        int i9 = i7 ^ (bArr[i6] << 21);
                        if (i9 < 0) {
                            j4 = (-2080896) ^ i9;
                        } else {
                            long j5 = i9;
                            i4 = i + 5;
                            long j6 = j5 ^ (bArr[i8] << 28);
                            if (j6 >= 0) {
                                j3 = 266354560;
                            } else {
                                i8 = i + 6;
                                long j7 = j6 ^ (bArr[i4] << 35);
                                if (j7 < 0) {
                                    j2 = -34093383808L;
                                } else {
                                    i4 = i + 7;
                                    j6 = j7 ^ (bArr[i8] << 42);
                                    if (j6 >= 0) {
                                        j3 = 4363953127296L;
                                    } else {
                                        i8 = i + 8;
                                        j7 = j6 ^ (bArr[i4] << 49);
                                        if (j7 < 0) {
                                            j2 = -558586000294016L;
                                        } else {
                                            i4 = i + 9;
                                            long j8 = (j7 ^ (bArr[i8] << 56)) ^ 71499008037633920L;
                                            if (j8 < 0) {
                                                int i10 = i + 10;
                                                if (bArr[i4] >= 0) {
                                                    i4 = i10;
                                                }
                                            }
                                            j = j8;
                                        }
                                    }
                                }
                                j4 = j2 ^ j7;
                            }
                            j = j3 ^ j6;
                        }
                        i4 = i8;
                        j = j4;
                    }
                }
                this.q = i4;
                return j;
            }
        }
        return I();
    }

    public final long I() throws EI {
        long j = 0;
        for (int i = 0; i < 64; i += 7) {
            int i2 = this.q;
            if (i2 == this.f719o) {
                throw EI.e();
            }
            this.q = i2 + 1;
            j |= (r3 & Byte.MAX_VALUE) << i;
            if ((this.n[i2] & 128) == 0) {
                return j;
            }
        }
        throw EI.c();
    }

    public final void J() {
        int i = this.f719o + this.p;
        this.f719o = i;
        int i2 = i - this.r;
        int i3 = this.t;
        if (i2 <= i3) {
            this.p = 0;
            return;
        }
        int i4 = i2 - i3;
        this.p = i4;
        this.f719o = i - i4;
    }

    public final void K(int i) throws EI {
        if (i >= 0) {
            int i2 = this.f719o;
            int i3 = this.q;
            if (i <= i2 - i3) {
                this.q = i3 + i;
                return;
            }
        }
        if (i >= 0) {
            throw EI.e();
        }
        throw EI.d();
    }

    @Override // o.AbstractC2071oh
    public final void a(int i) throws EI {
        if (this.s != i) {
            throw new EI("Protocol message end-group tag did not match expected tag.");
        }
    }

    @Override // o.AbstractC2071oh
    public final int b() {
        return this.q - this.r;
    }

    @Override // o.AbstractC2071oh
    public final boolean c() {
        return this.q == this.f719o;
    }

    @Override // o.AbstractC2071oh
    public final void h(int i) {
        this.t = i;
        J();
    }

    @Override // o.AbstractC2071oh
    public final int j(int i) throws EI {
        if (i < 0) {
            throw EI.d();
        }
        int iB = b() + i;
        if (iB < 0) {
            throw new EI("Failed to parse the message.");
        }
        int i2 = this.t;
        if (iB > i2) {
            throw EI.e();
        }
        this.t = iB;
        J();
        return i2;
    }

    @Override // o.AbstractC2071oh
    public final boolean k() {
        return H() != 0;
    }

    /* JADX WARN: Removed duplicated region for block: B:15:0x002f  */
    @Override // o.AbstractC2071oh
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public final o.C0109Ef l() throws o.EI {
        /*
            r4 = this;
            int r0 = r4.G()
            byte[] r1 = r4.n
            if (r0 <= 0) goto L19
            int r2 = r4.f719o
            int r3 = r4.q
            int r2 = r2 - r3
            if (r0 > r2) goto L19
            o.Ef r1 = o.AbstractC0161Gf.c(r1, r3, r0)
            int r2 = r4.q
            int r2 = r2 + r0
            r4.q = r2
            return r1
        L19:
            if (r0 != 0) goto L1e
            o.Ef r0 = o.AbstractC0161Gf.m
            return r0
        L1e:
            if (r0 <= 0) goto L2f
            int r2 = r4.f719o
            int r3 = r4.q
            int r2 = r2 - r3
            if (r0 > r2) goto L2f
            int r0 = r0 + r3
            r4.q = r0
            byte[] r0 = java.util.Arrays.copyOfRange(r1, r3, r0)
            goto L35
        L2f:
            if (r0 > 0) goto L42
            if (r0 != 0) goto L3d
            byte[] r0 = o.AbstractC2418sI.b
        L35:
            o.Ef r1 = o.AbstractC0161Gf.m
            o.Ef r1 = new o.Ef
            r1.<init>(r0)
            return r1
        L3d:
            o.EI r0 = o.EI.d()
            throw r0
        L42:
            o.EI r0 = o.EI.e()
            throw r0
        */
        throw new UnsupportedOperationException("Method not decompiled: o.C2452si.l():o.Ef");
    }

    @Override // o.AbstractC2071oh
    public final double m() {
        return Double.longBitsToDouble(F());
    }

    @Override // o.AbstractC2071oh
    public final int n() {
        return G();
    }

    @Override // o.AbstractC2071oh
    public final int o() {
        return E();
    }

    @Override // o.AbstractC2071oh
    public final long p() {
        return F();
    }

    @Override // o.AbstractC2071oh
    public final float q() {
        return Float.intBitsToFloat(E());
    }

    @Override // o.AbstractC2071oh
    public final int r() {
        return G();
    }

    @Override // o.AbstractC2071oh
    public final long s() {
        return H();
    }

    @Override // o.AbstractC2071oh
    public final int t() {
        return E();
    }

    @Override // o.AbstractC2071oh
    public final long u() {
        return F();
    }

    @Override // o.AbstractC2071oh
    public final int v() {
        int iG = G();
        return (-(iG & 1)) ^ (iG >>> 1);
    }

    @Override // o.AbstractC2071oh
    public final long w() {
        long jH = H();
        return (-(jH & 1)) ^ (jH >>> 1);
    }

    @Override // o.AbstractC2071oh
    public final String x() throws EI {
        int iG = G();
        if (iG > 0) {
            int i = this.f719o;
            int i2 = this.q;
            if (iG <= i - i2) {
                String str = new String(this.n, i2, iG, AbstractC2418sI.a);
                this.q += iG;
                return str;
            }
        }
        if (iG == 0) {
            return "";
        }
        if (iG < 0) {
            throw EI.d();
        }
        throw EI.e();
    }

    @Override // o.AbstractC2071oh
    public final String y() throws EI {
        int iG = G();
        if (iG > 0) {
            int i = this.f719o;
            int i2 = this.q;
            if (iG <= i - i2) {
                String strU = AbstractC2074oi0.a.u(this.n, i2, iG);
                this.q += iG;
                return strU;
            }
        }
        if (iG == 0) {
            return "";
        }
        if (iG <= 0) {
            throw EI.d();
        }
        throw EI.e();
    }

    @Override // o.AbstractC2071oh
    public final int z() throws EI {
        if (c()) {
            this.s = 0;
            return 0;
        }
        int iG = G();
        this.s = iG;
        if ((iG >>> 3) != 0) {
            return iG;
        }
        throw new EI("Protocol message contained an invalid tag (zero).");
    }
}
