package h;

import com.cvte.vman.instance.InvokeCmd;
import javax.annotation.Nullable;

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

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

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

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

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public boolean f6577d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public boolean f6578e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public t f6579f;

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public t f6580g;

    public t() {
        this.f6574a = new byte[InvokeCmd.CMD_TOUCH_CTRL_START];
        this.f6578e = true;
        this.f6577d = false;
    }

    public t(byte[] bArr, int i2, int i3, boolean z, boolean z2) {
        this.f6574a = bArr;
        this.f6575b = i2;
        this.f6576c = i3;
        this.f6577d = z;
        this.f6578e = z2;
    }

    @Nullable
    public final t a() {
        t tVar = this.f6579f;
        t tVar2 = tVar != this ? tVar : null;
        t tVar3 = this.f6580g;
        tVar3.f6579f = tVar;
        this.f6579f.f6580g = tVar3;
        this.f6579f = null;
        this.f6580g = null;
        return tVar2;
    }

    public final t b(t tVar) {
        tVar.f6580g = this;
        tVar.f6579f = this.f6579f;
        this.f6579f.f6580g = tVar;
        this.f6579f = tVar;
        return tVar;
    }

    public final t c() {
        this.f6577d = true;
        return new t(this.f6574a, this.f6575b, this.f6576c, true, false);
    }

    public final void d(t tVar, int i2) {
        if (!tVar.f6578e) {
            throw new IllegalArgumentException();
        }
        int i3 = tVar.f6576c;
        if (i3 + i2 > 8192) {
            if (tVar.f6577d) {
                throw new IllegalArgumentException();
            }
            int i4 = tVar.f6575b;
            if ((i3 + i2) - i4 > 8192) {
                throw new IllegalArgumentException();
            }
            byte[] bArr = tVar.f6574a;
            System.arraycopy(bArr, i4, bArr, 0, i3 - i4);
            tVar.f6576c -= tVar.f6575b;
            tVar.f6575b = 0;
        }
        System.arraycopy(this.f6574a, this.f6575b, tVar.f6574a, tVar.f6576c, i2);
        tVar.f6576c += i2;
        this.f6575b += i2;
    }
}
