package k1;

import l1.AbstractC0621d;

/* JADX INFO: renamed from: k1.b, reason: case insensitive filesystem */
/* JADX INFO: loaded from: classes.dex */
abstract class AbstractC0584b extends AbstractC0600r {

    /* JADX INFO: renamed from: q0, reason: collision with root package name */
    private byte f4768q0;

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

    /* JADX INFO: renamed from: s0, reason: collision with root package name */
    AbstractC0600r f4770s0;

    AbstractC0584b() {
        this.f4768q0 = (byte) -1;
        this.f4769r0 = 0;
        this.f4770s0 = null;
    }

    int E(byte b2) {
        return 0;
    }

    int F(byte[] bArr, int i2) {
        byte b2;
        int i3 = i2 + 1;
        byte b3 = bArr[i2];
        this.f5009c0 = b3;
        if (b3 != 0) {
            this.f4768q0 = bArr[i3];
            int iJ = AbstractC0600r.j(bArr, i2 + 3);
            this.f4769r0 = iJ;
            if (iJ == 0) {
                this.f4768q0 = (byte) -1;
            }
            if (this.f5009c0 > 2) {
                m(bArr, i2 + 5);
                if (this.f5021r == -94 && ((C0608z) this).f5070G0) {
                    this.f5009c0 += 8;
                }
            }
            i3 += this.f5009c0 * 2;
        }
        int iJ2 = AbstractC0600r.j(bArr, i3);
        this.f5010d0 = iJ2;
        int iF = i3 + 2;
        if (iJ2 != 0) {
            h(bArr, iF);
            iF += this.f5010d0;
        }
        int i4 = this.f5003L;
        if (i4 != 0 || (b2 = this.f4768q0) == -1) {
            this.f4768q0 = (byte) -1;
            this.f4770s0 = null;
        } else {
            AbstractC0600r abstractC0600r = this.f4770s0;
            if (abstractC0600r == null) {
                this.f4768q0 = (byte) -1;
                throw new RuntimeException("no andx command supplied with response");
            }
            int i5 = this.f5023y;
            int i6 = this.f4769r0 + i5;
            abstractC0600r.f5023y = i5;
            abstractC0600r.f5021r = b2;
            abstractC0600r.f5003L = i4;
            abstractC0600r.f5022x = this.f5022x;
            abstractC0600r.f5004M = this.f5004M;
            abstractC0600r.f5005Q = this.f5005Q;
            abstractC0600r.f5006Z = this.f5006Z;
            abstractC0600r.f5007a0 = this.f5007a0;
            abstractC0600r.f5008b0 = this.f5008b0;
            abstractC0600r.f5011e0 = this.f5011e0;
            if (abstractC0600r instanceof AbstractC0584b) {
                iF = i6 + ((AbstractC0584b) abstractC0600r).F(bArr, i6);
            } else {
                int iM = i6 + 1;
                int i7 = abstractC0600r.f5009c0;
                bArr[i6] = (byte) (i7 & 255);
                if (i7 != 0 && i7 > 2) {
                    iM += abstractC0600r.m(bArr, iM);
                }
                this.f4770s0.f5010d0 = AbstractC0600r.j(bArr, iM);
                int i8 = iM + 2;
                AbstractC0600r abstractC0600r2 = this.f4770s0;
                if (abstractC0600r2.f5010d0 != 0) {
                    abstractC0600r2.h(bArr, i8);
                    i8 += this.f4770s0.f5010d0;
                }
                iF = i8;
            }
            this.f4770s0.f5012f0 = true;
        }
        return iF - i2;
    }

    int G(byte[] bArr, int i2) {
        int iG;
        int i3 = i2 + 3;
        int iA = A(bArr, i2 + 5);
        int i4 = iA + 4;
        int i5 = iA + 5 + i2;
        int i6 = i4 / 2;
        this.f5009c0 = i6;
        bArr[i2] = (byte) (i6 & 255);
        int iV = v(bArr, i5 + 2);
        this.f5010d0 = iV;
        bArr[i5] = (byte) (iV & 255);
        bArr[i5 + 1] = (byte) ((iV >> 8) & 255);
        int i7 = i5 + 2 + iV;
        AbstractC0600r abstractC0600r = this.f4770s0;
        if (abstractC0600r == null || !U.f4690B || this.f5002I >= E(abstractC0600r.f5021r)) {
            this.f4768q0 = (byte) -1;
            this.f4770s0 = null;
            bArr[i2 + 1] = -1;
            bArr[i2 + 2] = 0;
            bArr[i3] = -34;
            bArr[i2 + 4] = -34;
            return i7 - i2;
        }
        this.f4770s0.f5002I = this.f5002I + 1;
        bArr[i2 + 1] = this.f4768q0;
        bArr[i2 + 2] = 0;
        int i8 = i7 - this.f5023y;
        this.f4769r0 = i8;
        AbstractC0600r.x(i8, bArr, i3);
        AbstractC0600r abstractC0600r2 = this.f4770s0;
        abstractC0600r2.f5011e0 = this.f5011e0;
        if (abstractC0600r2 instanceof AbstractC0584b) {
            abstractC0600r2.f5007a0 = this.f5007a0;
            iG = i7 + ((AbstractC0584b) abstractC0600r2).G(bArr, i7);
        } else {
            abstractC0600r2.f5009c0 = abstractC0600r2.A(bArr, i7);
            AbstractC0600r abstractC0600r3 = this.f4770s0;
            int i9 = abstractC0600r3.f5009c0;
            int i10 = i9 + 1 + i7;
            int i11 = i9 / 2;
            abstractC0600r3.f5009c0 = i11;
            bArr[i7] = (byte) (i11 & 255);
            abstractC0600r3.f5010d0 = abstractC0600r3.v(bArr, i10 + 2);
            int i12 = this.f4770s0.f5010d0;
            bArr[i10] = (byte) (i12 & 255);
            bArr[i10 + 1] = (byte) ((i12 >> 8) & 255);
            iG = i12 + i10 + 2;
        }
        return iG - i2;
    }

    @Override // k1.AbstractC0600r
    int e(byte[] bArr, int i2) {
        this.f5023y = i2;
        int i3 = i(bArr, i2) + i2;
        int iF = (i3 + F(bArr, i3)) - i2;
        this.f5001H = iF;
        return iF;
    }

    @Override // k1.AbstractC0600r
    int f(byte[] bArr, int i2) {
        this.f5023y = i2;
        int iW = w(bArr, i2) + i2;
        int iG = (iW + G(bArr, iW)) - i2;
        this.f5001H = iG;
        C0601s c0601s = this.f5019m0;
        if (c0601s != null) {
            c0601s.b(bArr, this.f5023y, iG, this, this.f5020n0);
        }
        return this.f5001H;
    }

    @Override // k1.AbstractC0600r
    public String toString() {
        return new String(super.toString() + ",andxCommand=0x" + AbstractC0621d.c(this.f4768q0, 2) + ",andxOffset=" + this.f4769r0);
    }

    AbstractC0584b(AbstractC0600r abstractC0600r) {
        this.f4768q0 = (byte) -1;
        this.f4769r0 = 0;
        this.f4770s0 = null;
        if (abstractC0600r != null) {
            this.f4770s0 = abstractC0600r;
            this.f4768q0 = abstractC0600r.f5021r;
        }
    }
}
