package b0;

import java.nio.charset.Charset;

/* JADX INFO: loaded from: classes.dex */
public final class t {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public byte[] f3092a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    private int f3093b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    private int f3094c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    private Charset f3095d;

    public t() {
    }

    public void A(int i2) {
        AbstractC0399d.a(i2 >= 0 && i2 <= this.f3092a.length);
        this.f3094c = i2;
    }

    public void B(int i2) {
        AbstractC0399d.a(i2 >= 0 && i2 <= this.f3094c);
        this.f3093b = i2;
    }

    public void C(int i2) {
        B(this.f3093b + i2);
    }

    public int a() {
        return this.f3094c - this.f3093b;
    }

    public int b() {
        byte[] bArr = this.f3092a;
        if (bArr == null) {
            return 0;
        }
        return bArr.length;
    }

    public int c() {
        return this.f3093b;
    }

    public int d() {
        return this.f3094c;
    }

    public int e(byte[] bArr, int i2, int i3) {
        System.arraycopy(this.f3092a, this.f3093b, bArr, i2, i3);
        this.f3093b += i3;
        return i2;
    }

    public void f(s sVar, int i2) {
        e(sVar.f3088a, 0, i2);
        sVar.k(0);
    }

    public double g() {
        return Double.longBitsToDouble(l());
    }

    public int h() {
        byte[] bArr = this.f3092a;
        int i2 = this.f3093b;
        int i3 = i2 + 1;
        this.f3093b = i3;
        int i4 = (bArr[i2] & 255) << 24;
        int i5 = i2 + 2;
        this.f3093b = i5;
        int i6 = ((bArr[i3] & 255) << 16) | i4;
        int i7 = i2 + 3;
        this.f3093b = i7;
        int i8 = i6 | ((bArr[i5] & 255) << 8);
        this.f3093b = i2 + 4;
        return (bArr[i7] & 255) | i8;
    }

    public String i() {
        String str;
        byte b2;
        if (a() == 0) {
            return null;
        }
        int i2 = this.f3093b;
        while (i2 < this.f3094c && (b2 = this.f3092a[i2]) != 10 && b2 != 13) {
            i2++;
        }
        int i3 = this.f3093b;
        if (i2 - i3 >= 3) {
            byte[] bArr = this.f3092a;
            if (bArr[i3] == -17 && bArr[i3 + 1] == -69 && bArr[i3 + 2] == -65) {
                this.f3093b = i3 + 3;
            }
        }
        Charset charset = this.f3095d;
        if (charset != null) {
            byte[] bArr2 = this.f3092a;
            int i4 = this.f3093b;
            str = new String(bArr2, i4, i2 - i4, charset);
        } else {
            byte[] bArr3 = this.f3092a;
            int i5 = this.f3093b;
            str = new String(bArr3, i5, i2 - i5);
        }
        this.f3093b = i2;
        int i6 = this.f3094c;
        if (i2 == i6) {
            return str;
        }
        byte[] bArr4 = this.f3092a;
        if (bArr4[i2] == 13) {
            int i7 = i2 + 1;
            this.f3093b = i7;
            if (i7 == i6) {
                return str;
            }
        }
        int i8 = this.f3093b;
        if (bArr4[i8] == 10) {
            this.f3093b = i8 + 1;
        }
        return str;
    }

    public long j() {
        byte[] bArr = this.f3092a;
        int i2 = this.f3093b;
        int i3 = i2 + 1;
        this.f3093b = i3;
        long j2 = ((long) bArr[i2]) & 255;
        int i4 = i2 + 2;
        this.f3093b = i4;
        long j3 = j2 | ((((long) bArr[i3]) & 255) << 8);
        int i5 = i2 + 3;
        this.f3093b = i5;
        long j4 = j3 | ((((long) bArr[i4]) & 255) << 16);
        this.f3093b = i2 + 4;
        return ((((long) bArr[i5]) & 255) << 24) | j4;
    }

    public int k() {
        byte[] bArr = this.f3092a;
        int i2 = this.f3093b;
        int i3 = i2 + 1;
        this.f3093b = i3;
        int i4 = bArr[i2] & 255;
        this.f3093b = i2 + 2;
        return ((bArr[i3] & 255) << 8) | i4;
    }

    public long l() {
        byte[] bArr = this.f3092a;
        int i2 = this.f3093b;
        int i3 = i2 + 1;
        this.f3093b = i3;
        long j2 = (((long) bArr[i2]) & 255) << 56;
        int i4 = i2 + 2;
        this.f3093b = i4;
        long j3 = j2 | ((((long) bArr[i3]) & 255) << 48);
        int i5 = i2 + 3;
        this.f3093b = i5;
        long j4 = j3 | ((((long) bArr[i4]) & 255) << 40);
        int i6 = i2 + 4;
        this.f3093b = i6;
        long j5 = j4 | ((((long) bArr[i5]) & 255) << 32);
        int i7 = i2 + 5;
        this.f3093b = i7;
        long j6 = j5 | ((((long) bArr[i6]) & 255) << 24);
        int i8 = i2 + 6;
        this.f3093b = i8;
        long j7 = j6 | ((((long) bArr[i7]) & 255) << 16);
        int i9 = i2 + 7;
        this.f3093b = i9;
        long j8 = j7 | ((((long) bArr[i8]) & 255) << 8);
        this.f3093b = i2 + 8;
        return (((long) bArr[i9]) & 255) | j8;
    }

    public short m() {
        byte[] bArr = this.f3092a;
        int i2 = this.f3093b;
        int i3 = i2 + 1;
        this.f3093b = i3;
        int i4 = (bArr[i2] & 255) << 8;
        this.f3093b = i2 + 2;
        return (short) ((bArr[i3] & 255) | i4);
    }

    public String n(int i2) {
        return o(i2, Charset.defaultCharset());
    }

    public String o(int i2, Charset charset) {
        String str = new String(this.f3092a, this.f3093b, i2, charset);
        this.f3093b += i2;
        return str;
    }

    public int p() {
        return (q() << 21) | (q() << 14) | (q() << 7) | q();
    }

    public int q() {
        byte[] bArr = this.f3092a;
        int i2 = this.f3093b;
        this.f3093b = i2 + 1;
        return bArr[i2] & 255;
    }

    public int r() {
        byte[] bArr = this.f3092a;
        int i2 = this.f3093b;
        int i3 = i2 + 1;
        this.f3093b = i3;
        int i4 = (bArr[i2] & 255) << 8;
        this.f3093b = i2 + 2;
        int i5 = (bArr[i3] & 255) | i4;
        this.f3093b = i2 + 4;
        return i5;
    }

    public long s() {
        byte[] bArr = this.f3092a;
        int i2 = this.f3093b;
        int i3 = i2 + 1;
        this.f3093b = i3;
        long j2 = (((long) bArr[i2]) & 255) << 24;
        int i4 = i2 + 2;
        this.f3093b = i4;
        long j3 = j2 | ((((long) bArr[i3]) & 255) << 16);
        int i5 = i2 + 3;
        this.f3093b = i5;
        long j4 = j3 | ((((long) bArr[i4]) & 255) << 8);
        this.f3093b = i2 + 4;
        return (((long) bArr[i5]) & 255) | j4;
    }

    public int t() {
        byte[] bArr = this.f3092a;
        int i2 = this.f3093b;
        int i3 = i2 + 1;
        this.f3093b = i3;
        int i4 = (bArr[i2] & 255) << 16;
        int i5 = i2 + 2;
        this.f3093b = i5;
        int i6 = ((bArr[i3] & 255) << 8) | i4;
        this.f3093b = i2 + 3;
        return (bArr[i5] & 255) | i6;
    }

    public int u() {
        int iH = h();
        if (iH >= 0) {
            return iH;
        }
        throw new IllegalStateException("Top bit not zero: " + iH);
    }

    public long v() {
        long jL = l();
        if (jL >= 0) {
            return jL;
        }
        throw new IllegalStateException("Top bit not zero: " + jL);
    }

    public int w() {
        byte[] bArr = this.f3092a;
        int i2 = this.f3093b;
        int i3 = i2 + 1;
        this.f3093b = i3;
        int i4 = (bArr[i2] & 255) << 8;
        this.f3093b = i2 + 2;
        return (bArr[i3] & 255) | i4;
    }

    public void x() {
        this.f3093b = 0;
        this.f3094c = 0;
    }

    public void y(int i2) {
        z(b() < i2 ? new byte[i2] : this.f3092a, i2);
    }

    public void z(byte[] bArr, int i2) {
        this.f3092a = bArr;
        this.f3094c = i2;
        this.f3093b = 0;
    }

    public t(int i2) {
        byte[] bArr = new byte[i2];
        this.f3092a = bArr;
        this.f3094c = bArr.length;
    }

    public t(byte[] bArr) {
        this.f3092a = bArr;
        this.f3094c = bArr.length;
    }

    public t(byte[] bArr, int i2) {
        this.f3092a = bArr;
        this.f3094c = i2;
    }
}
