package A;

import b0.AbstractC0399d;
import java.util.Arrays;

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

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    private final int f138a;

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

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

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

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

    public l(int i2, int i3) {
        this.f138a = i2;
        byte[] bArr = new byte[i3 + 3];
        this.f141d = bArr;
        bArr[2] = 1;
    }

    public void a(byte[] bArr, int i2, int i3) {
        if (this.f139b) {
            int i4 = i3 - i2;
            byte[] bArr2 = this.f141d;
            int length = bArr2.length;
            int i5 = this.f142e;
            if (length < i5 + i4) {
                this.f141d = Arrays.copyOf(bArr2, (i5 + i4) * 2);
            }
            System.arraycopy(bArr, i2, this.f141d, this.f142e, i4);
            this.f142e += i4;
        }
    }

    public boolean b(int i2) {
        if (!this.f139b) {
            return false;
        }
        this.f142e -= i2;
        this.f139b = false;
        this.f140c = true;
        return true;
    }

    public boolean c() {
        return this.f140c;
    }

    public void d() {
        this.f139b = false;
        this.f140c = false;
    }

    public void e(int i2) {
        AbstractC0399d.e(!this.f139b);
        boolean z2 = i2 == this.f138a;
        this.f139b = z2;
        if (z2) {
            this.f142e = 3;
            this.f140c = false;
        }
    }
}
