package defpackage;

import com.google.crypto.tink.shaded.protobuf.CodedOutputStream$OutOfSpaceException;
import java.util.Locale;
import java.util.logging.Logger;

/* renamed from: ʾᵱˇ, reason: contains not printable characters */
/* loaded from: classes3.dex */
public final class C0321 {

    /* renamed from: ˇʼʤˎ, reason: contains not printable characters */
    public static final Logger f1981 = Logger.getLogger(C0321.class.getName());

    /* renamed from: ˏˋٴ, reason: contains not printable characters */
    public static final boolean f1982 = AbstractC4467.f16671;

    /* renamed from: ˏᵙ, reason: contains not printable characters */
    public final int f1983;

    /* renamed from: ᵥᵯˎ, reason: contains not printable characters */
    public C2931 f1984;

    /* renamed from: ᵴᵳ, reason: contains not printable characters */
    public final byte[] f1985;

    /* renamed from: ᵻᵢﹳᵰ, reason: contains not printable characters */
    public int f1986;

    public C0321(int i, byte[] bArr) {
        if (((bArr.length - i) | i) < 0) {
            Locale locale = Locale.US;
            ᵹˉᵞ.ˌᵜᵹᵩ(AbstractC1327.m4091(bArr.length, i, "Array range is invalid. Buffer.length=", ", offset=0, length="));
            throw null;
        }
        this.f1985 = bArr;
        this.f1986 = 0;
        this.f1983 = i;
    }

    /* renamed from: ˇʼʤˎ, reason: contains not printable characters */
    public static int m1704(int i) {
        return m1706(i << 3);
    }

    /* renamed from: ˎˏʜʾ, reason: contains not printable characters */
    public static int m1705(long j) {
        return (640 - (Long.numberOfLeadingZeros(j) * 9)) >>> 6;
    }

    /* renamed from: ˏˋٴ, reason: contains not printable characters */
    public static int m1706(int i) {
        return (352 - (Integer.numberOfLeadingZeros(i) * 9)) >>> 6;
    }

    /* renamed from: ˏᵙ, reason: contains not printable characters */
    public static int m1707(long j) {
        return m1705((j >> 63) ^ (j << 1));
    }

    /* renamed from: ᵥᵯˎ, reason: contains not printable characters */
    public static int m1708(int i, AbstractC2202 abstractC2202) {
        int iM1704 = m1704(i);
        int size = abstractC2202.size();
        return m1706(size) + size + iM1704;
    }

    /* renamed from: ᵴᵳ, reason: contains not printable characters */
    public static int m1709(int i) {
        return m1706((i >> 31) ^ (i << 1));
    }

    /* renamed from: ᵻᵢﹳᵰ, reason: contains not printable characters */
    public static int m1710(String str) {
        int length;
        try {
            length = AbstractC3026.m7371(str);
        } catch (C4586 unused) {
            length = str.getBytes(AbstractC3306.f12387).length;
        }
        return m1706(length) + length;
    }

    /* renamed from: ˌʾˀ, reason: contains not printable characters */
    public final void m1711(int i, int i2) {
        m1721((i << 3) | i2);
    }

    /* renamed from: ˌᵜᵹᵩ, reason: contains not printable characters */
    public final void m1712(long j, int i) {
        m1711(i, 1);
        m1718(j);
    }

    /* renamed from: ᵝᵵᵺ, reason: contains not printable characters */
    public final void m1713(byte[] bArr, int i, int i2) {
        try {
            System.arraycopy(bArr, i, this.f1985, this.f1986, i2);
            this.f1986 += i2;
        } catch (IndexOutOfBoundsException e) {
            throw new CodedOutputStream$OutOfSpaceException(this.f1986, this.f1983, i2, e);
        }
    }

    /* renamed from: ᵞʡ, reason: contains not printable characters */
    public final void m1714(long j, int i) {
        m1711(i, 0);
        m1716(j);
    }

    /* renamed from: ᵡʠ, reason: contains not printable characters */
    public final void m1715(int i, int i2) {
        m1711(i, 0);
        m1721(i2);
    }

    /* renamed from: ᵨᵳʝ, reason: contains not printable characters */
    public final void m1716(long j) throws CodedOutputStream$OutOfSpaceException {
        int i;
        int i2 = this.f1986;
        boolean z = f1982;
        int i3 = this.f1983;
        byte[] bArr = this.f1985;
        if (!z || i3 - i2 < 10) {
            while ((j & (-128)) != 0) {
                i = i2 + 1;
                try {
                    bArr[i2] = (byte) (((int) j) | 128);
                    j >>>= 7;
                    i2 = i;
                } catch (IndexOutOfBoundsException e) {
                    throw new CodedOutputStream$OutOfSpaceException(i, i3, 1, e);
                }
            }
            i = i2 + 1;
            bArr[i2] = (byte) j;
        } else {
            while ((j & (-128)) != 0) {
                AbstractC4467.m9508(bArr, i2, (byte) (((int) j) | 128));
                j >>>= 7;
                i2++;
            }
            i = i2 + 1;
            AbstractC4467.m9508(bArr, i2, (byte) j);
        }
        this.f1986 = i;
    }

    /* renamed from: ᵪʩ, reason: contains not printable characters */
    public final void m1717(int i, int i2) throws CodedOutputStream$OutOfSpaceException {
        m1711(i, 0);
        m1719(i2);
    }

    /* renamed from: ᵯٴᵦ, reason: contains not printable characters */
    public final void m1718(long j) throws CodedOutputStream$OutOfSpaceException {
        int i = this.f1986;
        try {
            byte[] bArr = this.f1985;
            bArr[i] = (byte) j;
            bArr[i + 1] = (byte) (j >> 8);
            bArr[i + 2] = (byte) (j >> 16);
            bArr[i + 3] = (byte) (j >> 24);
            bArr[i + 4] = (byte) (j >> 32);
            bArr[i + 5] = (byte) (j >> 40);
            bArr[i + 6] = (byte) (j >> 48);
            bArr[i + 7] = (byte) (j >> 56);
            this.f1986 = i + 8;
        } catch (IndexOutOfBoundsException e) {
            throw new CodedOutputStream$OutOfSpaceException(i, this.f1983, 8, e);
        }
    }

    /* renamed from: ᵳٴᵶ, reason: contains not printable characters */
    public final void m1719(int i) throws CodedOutputStream$OutOfSpaceException {
        if (i >= 0) {
            m1721(i);
        } else {
            m1716(i);
        }
    }

    /* renamed from: ᵶᵷᵕ, reason: contains not printable characters */
    public final void m1720(int i, int i2) {
        m1711(i, 5);
        m1722(i2);
    }

    /* renamed from: ᵸʓᵠ, reason: contains not printable characters */
    public final void m1721(int i) {
        int i2;
        int i3 = this.f1986;
        while (true) {
            int i4 = i & (-128);
            byte[] bArr = this.f1985;
            if (i4 == 0) {
                i2 = i3 + 1;
                bArr[i3] = (byte) i;
                this.f1986 = i2;
                return;
            } else {
                i2 = i3 + 1;
                try {
                    bArr[i3] = (byte) (i | 128);
                    i >>>= 7;
                    i3 = i2;
                } catch (IndexOutOfBoundsException e) {
                    throw new CodedOutputStream$OutOfSpaceException(i2, this.f1983, 1, e);
                }
            }
            throw new CodedOutputStream$OutOfSpaceException(i2, this.f1983, 1, e);
        }
    }

    /* renamed from: ᵸˑ, reason: contains not printable characters */
    public final void m1722(int i) throws CodedOutputStream$OutOfSpaceException {
        int i2 = this.f1986;
        try {
            byte[] bArr = this.f1985;
            bArr[i2] = (byte) i;
            bArr[i2 + 1] = (byte) (i >> 8);
            bArr[i2 + 2] = (byte) (i >> 16);
            bArr[i2 + 3] = (byte) (i >> 24);
            this.f1986 = i2 + 4;
        } catch (IndexOutOfBoundsException e) {
            throw new CodedOutputStream$OutOfSpaceException(i2, this.f1983, 4, e);
        }
    }

    /* renamed from: ᵹᵝᵶ, reason: contains not printable characters */
    public final void m1723(byte b) throws CodedOutputStream$OutOfSpaceException {
        int i = this.f1986;
        try {
            int i2 = i + 1;
            try {
                this.f1985[i] = b;
                this.f1986 = i2;
            } catch (IndexOutOfBoundsException e) {
                e = e;
                i = i2;
                throw new CodedOutputStream$OutOfSpaceException(i, this.f1983, 1, e);
            }
        } catch (IndexOutOfBoundsException e2) {
            e = e2;
        }
    }
}
