package defpackage;

import com.google.android.gms.internal.play_billing.zzfm;
import java.util.Locale;

/* renamed from: ᵙᵼˁ, reason: contains not printable characters */
/* loaded from: classes3.dex */
public final class C2629 {

    /* renamed from: ˇʼʤˎ, reason: contains not printable characters */
    public static final boolean f10205 = AbstractC4335.f16245;

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

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

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

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

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

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

    /* renamed from: ᵳٴᵶ, reason: contains not printable characters */
    public static int m6605(long j) {
        return (640 - (Long.numberOfLeadingZeros(j) * 9)) >>> 6;
    }

    /* renamed from: ˇʼʤˎ, reason: contains not printable characters */
    public final void m6606(long j, int i) throws zzfm {
        m6616((i << 3) | 1);
        m6609(j);
    }

    /* renamed from: ˌᵜᵹᵩ, reason: contains not printable characters */
    public final void m6607(long j, int i) throws zzfm {
        m6616(i << 3);
        m6613(j);
    }

    /* renamed from: ˎˏʜʾ, reason: contains not printable characters */
    public final void m6608(int i, int i2) throws zzfm {
        m6616(i << 3);
        m6617(i2);
    }

    /* renamed from: ˏˋٴ, reason: contains not printable characters */
    public final void m6609(long j) throws zzfm {
        int i = this.f10209;
        try {
            byte[] bArr = this.f10208;
            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.f10209 = i + 8;
        } catch (IndexOutOfBoundsException e) {
            throw new zzfm(i, this.f10206, 8, e);
        }
    }

    /* renamed from: ˏᵙ, reason: contains not printable characters */
    public final void m6610(int i, int i2) throws zzfm {
        m6616((i << 3) | 5);
        m6618(i2);
    }

    /* renamed from: ᵝᵵᵺ, reason: contains not printable characters */
    public final void m6611(int i, int i2) {
        m6616((i << 3) | i2);
    }

    /* renamed from: ᵥᵯˎ, reason: contains not printable characters */
    public final void m6612(byte b) throws zzfm {
        int i = this.f10209;
        try {
            int i2 = i + 1;
            try {
                this.f10208[i] = b;
                this.f10209 = i2;
            } catch (IndexOutOfBoundsException e) {
                e = e;
                i = i2;
                throw new zzfm(i, this.f10206, 1, e);
            }
        } catch (IndexOutOfBoundsException e2) {
            e = e2;
        }
    }

    /* renamed from: ᵯٴᵦ, reason: contains not printable characters */
    public final void m6613(long j) throws zzfm {
        int i;
        int i2 = this.f10209;
        boolean z = f10205;
        byte[] bArr = this.f10208;
        int i3 = this.f10206;
        if (!z || i3 - i2 < 10) {
            int i4 = i2;
            long j2 = j;
            while ((j2 & (-128)) != 0) {
                int i5 = i4 + 1;
                try {
                    bArr[i4] = (byte) (((int) j2) | 128);
                    j2 >>>= 7;
                    i4 = i5;
                } catch (IndexOutOfBoundsException e) {
                    e = e;
                    i = i5;
                    throw new zzfm(i, i3, 1, e);
                }
            }
            i = i4 + 1;
            try {
                bArr[i4] = (byte) j2;
            } catch (IndexOutOfBoundsException e2) {
                e = e2;
                throw new zzfm(i, i3, 1, e);
            }
        } else {
            int i6 = i2;
            long j3 = j;
            while ((j3 & (-128)) != 0) {
                AbstractC4335.f16242.mo1467(bArr, AbstractC4335.f16240 + i6, (byte) (((int) j3) | 128));
                j3 >>>= 7;
                i6++;
            }
            i = i6 + 1;
            AbstractC4335.f16242.mo1467(bArr, AbstractC4335.f16240 + i6, (byte) j3);
        }
        this.f10209 = i;
    }

    /* renamed from: ᵴᵳ, reason: contains not printable characters */
    public final void m6614(byte[] bArr, int i, int i2) {
        try {
            System.arraycopy(bArr, i, this.f10208, this.f10209, i2);
            this.f10209 += i2;
        } catch (IndexOutOfBoundsException e) {
            throw new zzfm(this.f10209, this.f10206, i2, e);
        }
    }

    /* renamed from: ᵶᵷᵕ, reason: contains not printable characters */
    public final void m6615(int i, int i2) {
        m6616(i << 3);
        m6616(i2);
    }

    /* renamed from: ᵸˑ, reason: contains not printable characters */
    public final void m6616(int i) {
        int i2;
        int i3 = this.f10209;
        while (true) {
            int i4 = i & (-128);
            byte[] bArr = this.f10208;
            if (i4 == 0) {
                i2 = i3 + 1;
                bArr[i3] = (byte) i;
                this.f10209 = i2;
                return;
            } else {
                i2 = i3 + 1;
                try {
                    bArr[i3] = (byte) (i | 128);
                    i >>>= 7;
                    i3 = i2;
                } catch (IndexOutOfBoundsException e) {
                    throw new zzfm(i2, this.f10206, 1, e);
                }
            }
            throw new zzfm(i2, this.f10206, 1, e);
        }
    }

    /* renamed from: ᵹᵝᵶ, reason: contains not printable characters */
    public final void m6617(int i) throws zzfm {
        if (i >= 0) {
            m6616(i);
        } else {
            m6613(i);
        }
    }

    /* renamed from: ᵻᵢﹳᵰ, reason: contains not printable characters */
    public final void m6618(int i) throws zzfm {
        int i2 = this.f10209;
        try {
            byte[] bArr = this.f10208;
            bArr[i2] = (byte) i;
            bArr[i2 + 1] = (byte) (i >> 8);
            bArr[i2 + 2] = (byte) (i >> 16);
            bArr[i2 + 3] = (byte) (i >> 24);
            this.f10209 = i2 + 4;
        } catch (IndexOutOfBoundsException e) {
            throw new zzfm(i2, this.f10206, 4, e);
        }
    }
}
