package o;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* renamed from: o.t50, reason: case insensitive filesystem */
/* loaded from: classes.dex */
public final class C2496t50 {
    public final byte[] a;
    public int b;
    public int c;
    public boolean d;
    public final boolean e;
    public C2496t50 f;
    public C2496t50 g;

    public C2496t50() {
        this.a = new byte[8192];
        this.e = true;
        this.d = false;
    }

    public final C2496t50 a() {
        C2496t50 c2496t50 = this.f;
        C2496t50 c2496t502 = c2496t50 != this ? c2496t50 : null;
        C2496t50 c2496t503 = this.g;
        c2496t503.f = c2496t50;
        this.f.g = c2496t503;
        this.f = null;
        this.g = null;
        return c2496t502;
    }

    public final void b(C2496t50 c2496t50) {
        c2496t50.g = this;
        c2496t50.f = this.f;
        this.f.g = c2496t50;
        this.f = c2496t50;
    }

    public final C2496t50 c() {
        this.d = true;
        return new C2496t50(this.a, this.b, this.c, true);
    }

    public final void d(C2496t50 c2496t50, int i) {
        boolean z = c2496t50.e;
        byte[] bArr = c2496t50.a;
        if (!z) {
            throw new IllegalStateException("only owner can write");
        }
        int i2 = c2496t50.c;
        int i3 = i2 + i;
        if (i3 > 8192) {
            if (c2496t50.d) {
                throw new IllegalArgumentException();
            }
            int i4 = c2496t50.b;
            if (i3 - i4 > 8192) {
                throw new IllegalArgumentException();
            }
            AbstractC2219q9.N(bArr, bArr, i4, i2);
            c2496t50.c -= c2496t50.b;
            c2496t50.b = 0;
        }
        int i5 = c2496t50.c;
        int i6 = this.b;
        System.arraycopy(this.a, i6, bArr, i5, (i6 + i) - i6);
        c2496t50.c += i;
        this.b += i;
    }

    public C2496t50(byte[] bArr, int i, int i2, boolean z) {
        this.a = bArr;
        this.b = i;
        this.c = i2;
        this.d = z;
        this.e = false;
    }
}
