package com.google.protobuf;

/* JADX INFO: renamed from: com.google.protobuf.t, reason: case insensitive filesystem */
/* JADX INFO: loaded from: classes3.dex */
public final class C1331t extends AbstractC1335v {

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public final byte[] f14354f;

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public final int f14355g;

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public int f14356h;

    public C1331t(byte[] bArr, int i6, int i7) {
        if (bArr == null) {
            throw new NullPointerException("buffer");
        }
        int i8 = i6 + i7;
        if ((i6 | i7 | (bArr.length - i8)) < 0) {
            throw new IllegalArgumentException(String.format("Array range is invalid. Buffer.length=%d, offset=%d, length=%d", Integer.valueOf(bArr.length), Integer.valueOf(i6), Integer.valueOf(i7)));
        }
        this.f14354f = bArr;
        this.f14356h = i6;
        this.f14355g = i8;
    }

    @Override // com.google.protobuf.AbstractC1335v
    public final void H(byte b5) throws H4.c {
        try {
            byte[] bArr = this.f14354f;
            int i6 = this.f14356h;
            this.f14356h = i6 + 1;
            bArr[i6] = b5;
        } catch (IndexOutOfBoundsException e6) {
            throw new H4.c(String.format("Pos: %d, limit: %d, len: %d", Integer.valueOf(this.f14356h), Integer.valueOf(this.f14355g), 1), e6, 3);
        }
    }

    @Override // com.google.protobuf.AbstractC1335v
    public final void I(int i6, boolean z6) throws H4.c {
        W(i6, 0);
        H(z6 ? (byte) 1 : (byte) 0);
    }

    @Override // com.google.protobuf.AbstractC1335v
    public final void J(byte[] bArr, int i6) throws H4.c {
        Y(i6);
        c0(bArr, 0, i6);
    }

    @Override // com.google.protobuf.AbstractC1335v
    public final void K(int i6, AbstractC1320n abstractC1320n) throws H4.c {
        W(i6, 2);
        L(abstractC1320n);
    }

    @Override // com.google.protobuf.AbstractC1335v
    public final void L(AbstractC1320n abstractC1320n) throws H4.c {
        Y(abstractC1320n.size());
        abstractC1320n.A(this);
    }

    @Override // com.google.protobuf.AbstractC1335v
    public final void M(int i6, int i7) throws H4.c {
        W(i6, 5);
        N(i7);
    }

    @Override // com.google.protobuf.AbstractC1335v
    public final void N(int i6) throws H4.c {
        try {
            byte[] bArr = this.f14354f;
            int i7 = this.f14356h;
            int i8 = i7 + 1;
            this.f14356h = i8;
            bArr[i7] = (byte) (i6 & 255);
            int i9 = i7 + 2;
            this.f14356h = i9;
            bArr[i8] = (byte) ((i6 >> 8) & 255);
            int i10 = i7 + 3;
            this.f14356h = i10;
            bArr[i9] = (byte) ((i6 >> 16) & 255);
            this.f14356h = i7 + 4;
            bArr[i10] = (byte) ((i6 >> 24) & 255);
        } catch (IndexOutOfBoundsException e6) {
            throw new H4.c(String.format("Pos: %d, limit: %d, len: %d", Integer.valueOf(this.f14356h), Integer.valueOf(this.f14355g), 1), e6, 3);
        }
    }

    @Override // com.google.protobuf.AbstractC1335v
    public final void O(int i6, long j4) throws H4.c {
        W(i6, 1);
        P(j4);
    }

    @Override // com.google.protobuf.AbstractC1335v
    public final void P(long j4) throws H4.c {
        try {
            byte[] bArr = this.f14354f;
            int i6 = this.f14356h;
            int i7 = i6 + 1;
            this.f14356h = i7;
            bArr[i6] = (byte) (((int) j4) & 255);
            int i8 = i6 + 2;
            this.f14356h = i8;
            bArr[i7] = (byte) (((int) (j4 >> 8)) & 255);
            int i9 = i6 + 3;
            this.f14356h = i9;
            bArr[i8] = (byte) (((int) (j4 >> 16)) & 255);
            int i10 = i6 + 4;
            this.f14356h = i10;
            bArr[i9] = (byte) (((int) (j4 >> 24)) & 255);
            int i11 = i6 + 5;
            this.f14356h = i11;
            bArr[i10] = (byte) (((int) (j4 >> 32)) & 255);
            int i12 = i6 + 6;
            this.f14356h = i12;
            bArr[i11] = (byte) (((int) (j4 >> 40)) & 255);
            int i13 = i6 + 7;
            this.f14356h = i13;
            bArr[i12] = (byte) (((int) (j4 >> 48)) & 255);
            this.f14356h = i6 + 8;
            bArr[i13] = (byte) (((int) (j4 >> 56)) & 255);
        } catch (IndexOutOfBoundsException e6) {
            throw new H4.c(String.format("Pos: %d, limit: %d, len: %d", Integer.valueOf(this.f14356h), Integer.valueOf(this.f14355g), 1), e6, 3);
        }
    }

    @Override // com.google.protobuf.AbstractC1335v
    public final void Q(int i6, int i7) throws H4.c {
        W(i6, 0);
        R(i7);
    }

    @Override // com.google.protobuf.AbstractC1335v
    public final void R(int i6) throws H4.c {
        if (i6 >= 0) {
            Y(i6);
        } else {
            a0(i6);
        }
    }

    @Override // com.google.protobuf.AbstractC1335v
    public final void S(int i6, InterfaceC1332t0 interfaceC1332t0, J0 j02) throws H4.c {
        W(i6, 2);
        Y(((AbstractC1298c) interfaceC1332t0).getSerializedSize(j02));
        j02.e(interfaceC1332t0, this.f14363c);
    }

    @Override // com.google.protobuf.AbstractC1335v
    public final void T(InterfaceC1332t0 interfaceC1332t0) throws H4.c {
        Y(interfaceC1332t0.getSerializedSize());
        interfaceC1332t0.writeTo(this);
    }

    @Override // com.google.protobuf.AbstractC1335v
    public final void U(int i6, String str) throws H4.c {
        W(i6, 2);
        V(str);
    }

    @Override // com.google.protobuf.AbstractC1335v
    public final void V(String str) throws H4.c {
        int i6 = this.f14356h;
        try {
            int iE = AbstractC1335v.E(str.length() * 3);
            int iE2 = AbstractC1335v.E(str.length());
            byte[] bArr = this.f14354f;
            if (iE2 != iE) {
                Y(f1.c(str));
                this.f14356h = f1.f14272a.q(str, bArr, this.f14356h, b0());
                return;
            }
            int i7 = i6 + iE2;
            this.f14356h = i7;
            int iQ = f1.f14272a.q(str, bArr, i7, b0());
            this.f14356h = i6;
            Y((iQ - i6) - iE2);
            this.f14356h = iQ;
        } catch (e1 e6) {
            this.f14356h = i6;
            G(str, e6);
        } catch (IndexOutOfBoundsException e7) {
            throw new H4.c(e7);
        }
    }

    @Override // com.google.protobuf.AbstractC1335v
    public final void W(int i6, int i7) throws H4.c {
        Y((i6 << 3) | i7);
    }

    @Override // com.google.protobuf.AbstractC1335v
    public final void X(int i6, int i7) throws H4.c {
        W(i6, 0);
        Y(i7);
    }

    @Override // com.google.protobuf.AbstractC1335v
    public final void Y(int i6) throws H4.c {
        while (true) {
            int i7 = i6 & (-128);
            byte[] bArr = this.f14354f;
            if (i7 == 0) {
                int i8 = this.f14356h;
                this.f14356h = i8 + 1;
                bArr[i8] = (byte) i6;
                return;
            } else {
                try {
                    int i9 = this.f14356h;
                    this.f14356h = i9 + 1;
                    bArr[i9] = (byte) ((i6 & 127) | 128);
                    i6 >>>= 7;
                } catch (IndexOutOfBoundsException e6) {
                    throw new H4.c(String.format("Pos: %d, limit: %d, len: %d", Integer.valueOf(this.f14356h), Integer.valueOf(this.f14355g), 1), e6, 3);
                }
            }
            throw new H4.c(String.format("Pos: %d, limit: %d, len: %d", Integer.valueOf(this.f14356h), Integer.valueOf(this.f14355g), 1), e6, 3);
        }
    }

    @Override // com.google.protobuf.AbstractC1335v
    public final void Z(int i6, long j4) throws H4.c {
        W(i6, 0);
        a0(j4);
    }

    @Override // com.google.protobuf.AbstractC1335v
    public final void a0(long j4) throws H4.c {
        boolean z6 = AbstractC1335v.f14362e;
        byte[] bArr = this.f14354f;
        if (z6 && b0() >= 10) {
            while ((j4 & (-128)) != 0) {
                int i6 = this.f14356h;
                this.f14356h = i6 + 1;
                c1.k(bArr, i6, (byte) ((((int) j4) & 127) | 128));
                j4 >>>= 7;
            }
            int i7 = this.f14356h;
            this.f14356h = i7 + 1;
            c1.k(bArr, i7, (byte) j4);
            return;
        }
        while ((j4 & (-128)) != 0) {
            try {
                int i8 = this.f14356h;
                this.f14356h = i8 + 1;
                bArr[i8] = (byte) ((((int) j4) & 127) | 128);
                j4 >>>= 7;
            } catch (IndexOutOfBoundsException e6) {
                throw new H4.c(String.format("Pos: %d, limit: %d, len: %d", Integer.valueOf(this.f14356h), Integer.valueOf(this.f14355g), 1), e6, 3);
            }
        }
        int i9 = this.f14356h;
        this.f14356h = i9 + 1;
        bArr[i9] = (byte) j4;
    }

    public final int b0() {
        return this.f14355g - this.f14356h;
    }

    public final void c0(byte[] bArr, int i6, int i7) throws H4.c {
        try {
            System.arraycopy(bArr, i6, this.f14354f, this.f14356h, i7);
            this.f14356h += i7;
        } catch (IndexOutOfBoundsException e6) {
            throw new H4.c(String.format("Pos: %d, limit: %d, len: %d", Integer.valueOf(this.f14356h), Integer.valueOf(this.f14355g), Integer.valueOf(i7)), e6, 3);
        }
    }

    @Override // com.google.protobuf.O0
    public final void y(byte[] bArr, int i6, int i7) throws H4.c {
        c0(bArr, i6, i7);
    }
}
