package X6FRs_4.X6FRs_4.KQgRr5e_0;

import X6FRs_4.X6FRs_4.KQgRr5e_0.Xgtqvk_8;
import com.wang.avi.BuildConfig;
import java.util.Arrays;
/* compiled from: ArrayLinkedVariables.java */
/* loaded from: classes.dex */
public class KQgRr5e_0 {

    /* renamed from: KQgRr5e_0  reason: collision with other field name */
    public final PGPF6hQ_2 f1107KQgRr5e_0;

    /* renamed from: KQgRr5e_0  reason: collision with other field name */
    public final QxJ9d_1 f1108KQgRr5e_0;
    public int KQgRr5e_0 = 0;
    public int QxJ9d_1 = 8;

    /* renamed from: KQgRr5e_0  reason: collision with other field name */
    public Xgtqvk_8 f1109KQgRr5e_0 = null;

    /* renamed from: KQgRr5e_0  reason: collision with other field name */
    public int[] f1112KQgRr5e_0 = new int[8];

    /* renamed from: QxJ9d_1  reason: collision with other field name */
    public int[] f1113QxJ9d_1 = new int[8];

    /* renamed from: KQgRr5e_0  reason: collision with other field name */
    public float[] f1111KQgRr5e_0 = new float[8];
    public int PGPF6hQ_2 = -1;

    /* renamed from: Mqv2r_3  reason: collision with root package name */
    public int f3257Mqv2r_3 = -1;

    /* renamed from: KQgRr5e_0  reason: collision with other field name */
    public boolean f1110KQgRr5e_0 = false;

    public KQgRr5e_0(QxJ9d_1 qxJ9d_1, PGPF6hQ_2 pGPF6hQ_2) {
        this.f1108KQgRr5e_0 = qxJ9d_1;
        this.f1107KQgRr5e_0 = pGPF6hQ_2;
    }

    public final void KQgRr5e_0(Xgtqvk_8 xgtqvk_8, float f) {
        if (f == 0.0f) {
            KQgRr5e_0(xgtqvk_8, true);
            return;
        }
        int i = this.PGPF6hQ_2;
        if (i == -1) {
            this.PGPF6hQ_2 = 0;
            this.f1111KQgRr5e_0[0] = f;
            this.f1112KQgRr5e_0[0] = xgtqvk_8.f1127KQgRr5e_0;
            this.f1113QxJ9d_1[0] = -1;
            xgtqvk_8.f3265X6FRs_4++;
            xgtqvk_8.KQgRr5e_0(this.f1108KQgRr5e_0);
            this.KQgRr5e_0++;
            if (this.f1110KQgRr5e_0) {
                return;
            }
            int i2 = this.f3257Mqv2r_3 + 1;
            this.f3257Mqv2r_3 = i2;
            int[] iArr = this.f1112KQgRr5e_0;
            if (i2 >= iArr.length) {
                this.f1110KQgRr5e_0 = true;
                this.f3257Mqv2r_3 = iArr.length - 1;
                return;
            }
            return;
        }
        int i3 = -1;
        for (int i4 = 0; i != -1 && i4 < this.KQgRr5e_0; i4++) {
            int[] iArr2 = this.f1112KQgRr5e_0;
            int i5 = iArr2[i];
            int i6 = xgtqvk_8.f1127KQgRr5e_0;
            if (i5 == i6) {
                this.f1111KQgRr5e_0[i] = f;
                return;
            }
            if (iArr2[i] < i6) {
                i3 = i;
            }
            i = this.f1113QxJ9d_1[i];
        }
        int i7 = this.f3257Mqv2r_3;
        int i8 = i7 + 1;
        if (this.f1110KQgRr5e_0) {
            int[] iArr3 = this.f1112KQgRr5e_0;
            if (iArr3[i7] != -1) {
                i7 = iArr3.length;
            }
        } else {
            i7 = i8;
        }
        int[] iArr4 = this.f1112KQgRr5e_0;
        if (i7 >= iArr4.length && this.KQgRr5e_0 < iArr4.length) {
            int i9 = 0;
            while (true) {
                int[] iArr5 = this.f1112KQgRr5e_0;
                if (i9 >= iArr5.length) {
                    break;
                } else if (iArr5[i9] == -1) {
                    i7 = i9;
                    break;
                } else {
                    i9++;
                }
            }
        }
        int[] iArr6 = this.f1112KQgRr5e_0;
        if (i7 >= iArr6.length) {
            i7 = iArr6.length;
            int i10 = this.QxJ9d_1 * 2;
            this.QxJ9d_1 = i10;
            this.f1110KQgRr5e_0 = false;
            this.f3257Mqv2r_3 = i7 - 1;
            this.f1111KQgRr5e_0 = Arrays.copyOf(this.f1111KQgRr5e_0, i10);
            this.f1112KQgRr5e_0 = Arrays.copyOf(this.f1112KQgRr5e_0, this.QxJ9d_1);
            this.f1113QxJ9d_1 = Arrays.copyOf(this.f1113QxJ9d_1, this.QxJ9d_1);
        }
        this.f1112KQgRr5e_0[i7] = xgtqvk_8.f1127KQgRr5e_0;
        this.f1111KQgRr5e_0[i7] = f;
        if (i3 != -1) {
            int[] iArr7 = this.f1113QxJ9d_1;
            iArr7[i7] = iArr7[i3];
            iArr7[i3] = i7;
        } else {
            this.f1113QxJ9d_1[i7] = this.PGPF6hQ_2;
            this.PGPF6hQ_2 = i7;
        }
        xgtqvk_8.f3265X6FRs_4++;
        xgtqvk_8.KQgRr5e_0(this.f1108KQgRr5e_0);
        this.KQgRr5e_0++;
        if (!this.f1110KQgRr5e_0) {
            this.f3257Mqv2r_3++;
        }
        if (this.KQgRr5e_0 >= this.f1112KQgRr5e_0.length) {
            this.f1110KQgRr5e_0 = true;
        }
        int i11 = this.f3257Mqv2r_3;
        int[] iArr8 = this.f1112KQgRr5e_0;
        if (i11 >= iArr8.length) {
            this.f1110KQgRr5e_0 = true;
            this.f3257Mqv2r_3 = iArr8.length - 1;
        }
    }

    public void QxJ9d_1() {
        int i = this.PGPF6hQ_2;
        for (int i2 = 0; i != -1 && i2 < this.KQgRr5e_0; i2++) {
            float[] fArr = this.f1111KQgRr5e_0;
            fArr[i] = fArr[i] * (-1.0f);
            i = this.f1113QxJ9d_1[i];
        }
    }

    public String toString() {
        int i = this.PGPF6hQ_2;
        String str = BuildConfig.FLAVOR;
        for (int i2 = 0; i != -1 && i2 < this.KQgRr5e_0; i2++) {
            str = ((str + " -> ") + this.f1111KQgRr5e_0[i] + " : ") + this.f1107KQgRr5e_0.f1114KQgRr5e_0[this.f1112KQgRr5e_0[i]];
            i = this.f1113QxJ9d_1[i];
        }
        return str;
    }

    public final void KQgRr5e_0(Xgtqvk_8 xgtqvk_8, float f, boolean z) {
        if (f == 0.0f) {
            return;
        }
        int i = this.PGPF6hQ_2;
        if (i == -1) {
            this.PGPF6hQ_2 = 0;
            this.f1111KQgRr5e_0[0] = f;
            this.f1112KQgRr5e_0[0] = xgtqvk_8.f1127KQgRr5e_0;
            this.f1113QxJ9d_1[0] = -1;
            xgtqvk_8.f3265X6FRs_4++;
            xgtqvk_8.KQgRr5e_0(this.f1108KQgRr5e_0);
            this.KQgRr5e_0++;
            if (this.f1110KQgRr5e_0) {
                return;
            }
            int i2 = this.f3257Mqv2r_3 + 1;
            this.f3257Mqv2r_3 = i2;
            int[] iArr = this.f1112KQgRr5e_0;
            if (i2 >= iArr.length) {
                this.f1110KQgRr5e_0 = true;
                this.f3257Mqv2r_3 = iArr.length - 1;
                return;
            }
            return;
        }
        int i3 = -1;
        for (int i4 = 0; i != -1 && i4 < this.KQgRr5e_0; i4++) {
            int[] iArr2 = this.f1112KQgRr5e_0;
            int i5 = iArr2[i];
            int i6 = xgtqvk_8.f1127KQgRr5e_0;
            if (i5 == i6) {
                float[] fArr = this.f1111KQgRr5e_0;
                fArr[i] = fArr[i] + f;
                if (fArr[i] == 0.0f) {
                    if (i == this.PGPF6hQ_2) {
                        this.PGPF6hQ_2 = this.f1113QxJ9d_1[i];
                    } else {
                        int[] iArr3 = this.f1113QxJ9d_1;
                        iArr3[i3] = iArr3[i];
                    }
                    if (z) {
                        xgtqvk_8.QxJ9d_1(this.f1108KQgRr5e_0);
                    }
                    if (this.f1110KQgRr5e_0) {
                        this.f3257Mqv2r_3 = i;
                    }
                    xgtqvk_8.f3265X6FRs_4--;
                    this.KQgRr5e_0--;
                    return;
                }
                return;
            }
            if (iArr2[i] < i6) {
                i3 = i;
            }
            i = this.f1113QxJ9d_1[i];
        }
        int i7 = this.f3257Mqv2r_3;
        int i8 = i7 + 1;
        if (this.f1110KQgRr5e_0) {
            int[] iArr4 = this.f1112KQgRr5e_0;
            if (iArr4[i7] != -1) {
                i7 = iArr4.length;
            }
        } else {
            i7 = i8;
        }
        int[] iArr5 = this.f1112KQgRr5e_0;
        if (i7 >= iArr5.length && this.KQgRr5e_0 < iArr5.length) {
            int i9 = 0;
            while (true) {
                int[] iArr6 = this.f1112KQgRr5e_0;
                if (i9 >= iArr6.length) {
                    break;
                } else if (iArr6[i9] == -1) {
                    i7 = i9;
                    break;
                } else {
                    i9++;
                }
            }
        }
        int[] iArr7 = this.f1112KQgRr5e_0;
        if (i7 >= iArr7.length) {
            i7 = iArr7.length;
            int i10 = this.QxJ9d_1 * 2;
            this.QxJ9d_1 = i10;
            this.f1110KQgRr5e_0 = false;
            this.f3257Mqv2r_3 = i7 - 1;
            this.f1111KQgRr5e_0 = Arrays.copyOf(this.f1111KQgRr5e_0, i10);
            this.f1112KQgRr5e_0 = Arrays.copyOf(this.f1112KQgRr5e_0, this.QxJ9d_1);
            this.f1113QxJ9d_1 = Arrays.copyOf(this.f1113QxJ9d_1, this.QxJ9d_1);
        }
        this.f1112KQgRr5e_0[i7] = xgtqvk_8.f1127KQgRr5e_0;
        this.f1111KQgRr5e_0[i7] = f;
        if (i3 != -1) {
            int[] iArr8 = this.f1113QxJ9d_1;
            iArr8[i7] = iArr8[i3];
            iArr8[i3] = i7;
        } else {
            this.f1113QxJ9d_1[i7] = this.PGPF6hQ_2;
            this.PGPF6hQ_2 = i7;
        }
        xgtqvk_8.f3265X6FRs_4++;
        xgtqvk_8.KQgRr5e_0(this.f1108KQgRr5e_0);
        this.KQgRr5e_0++;
        if (!this.f1110KQgRr5e_0) {
            this.f3257Mqv2r_3++;
        }
        int i11 = this.f3257Mqv2r_3;
        int[] iArr9 = this.f1112KQgRr5e_0;
        if (i11 >= iArr9.length) {
            this.f1110KQgRr5e_0 = true;
            this.f3257Mqv2r_3 = iArr9.length - 1;
        }
    }

    public final float KQgRr5e_0(Xgtqvk_8 xgtqvk_8, boolean z) {
        if (this.f1109KQgRr5e_0 == xgtqvk_8) {
            this.f1109KQgRr5e_0 = null;
        }
        int i = this.PGPF6hQ_2;
        if (i == -1) {
            return 0.0f;
        }
        int i2 = 0;
        int i3 = -1;
        while (i != -1 && i2 < this.KQgRr5e_0) {
            if (this.f1112KQgRr5e_0[i] == xgtqvk_8.f1127KQgRr5e_0) {
                if (i == this.PGPF6hQ_2) {
                    this.PGPF6hQ_2 = this.f1113QxJ9d_1[i];
                } else {
                    int[] iArr = this.f1113QxJ9d_1;
                    iArr[i3] = iArr[i];
                }
                if (z) {
                    xgtqvk_8.QxJ9d_1(this.f1108KQgRr5e_0);
                }
                xgtqvk_8.f3265X6FRs_4--;
                this.KQgRr5e_0--;
                this.f1112KQgRr5e_0[i] = -1;
                if (this.f1110KQgRr5e_0) {
                    this.f3257Mqv2r_3 = i;
                }
                return this.f1111KQgRr5e_0[i];
            }
            i2++;
            i3 = i;
            i = this.f1113QxJ9d_1[i];
        }
        return 0.0f;
    }

    public final void KQgRr5e_0() {
        int i = this.PGPF6hQ_2;
        for (int i2 = 0; i != -1 && i2 < this.KQgRr5e_0; i2++) {
            Xgtqvk_8 xgtqvk_8 = this.f1107KQgRr5e_0.f1114KQgRr5e_0[this.f1112KQgRr5e_0[i]];
            if (xgtqvk_8 != null) {
                xgtqvk_8.QxJ9d_1(this.f1108KQgRr5e_0);
            }
            i = this.f1113QxJ9d_1[i];
        }
        this.PGPF6hQ_2 = -1;
        this.f3257Mqv2r_3 = -1;
        this.f1110KQgRr5e_0 = false;
        this.KQgRr5e_0 = 0;
    }

    /* renamed from: KQgRr5e_0  reason: collision with other method in class */
    public final boolean m534KQgRr5e_0(Xgtqvk_8 xgtqvk_8) {
        int i = this.PGPF6hQ_2;
        if (i == -1) {
            return false;
        }
        for (int i2 = 0; i != -1 && i2 < this.KQgRr5e_0; i2++) {
            if (this.f1112KQgRr5e_0[i] == xgtqvk_8.f1127KQgRr5e_0) {
                return true;
            }
            i = this.f1113QxJ9d_1[i];
        }
        return false;
    }

    public void KQgRr5e_0(float f) {
        int i = this.PGPF6hQ_2;
        for (int i2 = 0; i != -1 && i2 < this.KQgRr5e_0; i2++) {
            float[] fArr = this.f1111KQgRr5e_0;
            fArr[i] = fArr[i] / f;
            i = this.f1113QxJ9d_1[i];
        }
    }

    public final boolean KQgRr5e_0(Xgtqvk_8 xgtqvk_8, X6FRs_4 x6FRs_4) {
        return xgtqvk_8.f3265X6FRs_4 <= 1;
    }

    /* JADX WARN: Removed duplicated region for block: B:18:0x0047  */
    /* JADX WARN: Removed duplicated region for block: B:50:0x0090 A[SYNTHETIC] */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public Xgtqvk_8 KQgRr5e_0(X6FRs_4 x6FRs_4) {
        boolean KQgRr5e_0;
        boolean KQgRr5e_02;
        int i = this.PGPF6hQ_2;
        Xgtqvk_8 xgtqvk_8 = null;
        Xgtqvk_8 xgtqvk_82 = null;
        boolean z = false;
        boolean z2 = false;
        float f = 0.0f;
        float f2 = 0.0f;
        for (int i2 = 0; i != -1 && i2 < this.KQgRr5e_0; i2++) {
            float[] fArr = this.f1111KQgRr5e_0;
            float f3 = fArr[i];
            Xgtqvk_8 xgtqvk_83 = this.f1107KQgRr5e_0.f1114KQgRr5e_0[this.f1112KQgRr5e_0[i]];
            if (f3 < 0.0f) {
                if (f3 > -0.001f) {
                    fArr[i] = 0.0f;
                    xgtqvk_83.QxJ9d_1(this.f1108KQgRr5e_0);
                    f3 = 0.0f;
                }
                if (f3 != 0.0f) {
                    if (xgtqvk_83.f1128KQgRr5e_0 == Xgtqvk_8.KQgRr5e_0.UNRESTRICTED) {
                        if (xgtqvk_82 == null) {
                            KQgRr5e_02 = KQgRr5e_0(xgtqvk_83, x6FRs_4);
                        } else if (f > f3) {
                            KQgRr5e_02 = KQgRr5e_0(xgtqvk_83, x6FRs_4);
                        } else if (!z && KQgRr5e_0(xgtqvk_83, x6FRs_4)) {
                            f = f3;
                            xgtqvk_82 = xgtqvk_83;
                            z = true;
                        }
                        z = KQgRr5e_02;
                        f = f3;
                        xgtqvk_82 = xgtqvk_83;
                    } else if (xgtqvk_82 == null && f3 < 0.0f) {
                        if (xgtqvk_8 == null) {
                            KQgRr5e_0 = KQgRr5e_0(xgtqvk_83, x6FRs_4);
                        } else if (f2 > f3) {
                            KQgRr5e_0 = KQgRr5e_0(xgtqvk_83, x6FRs_4);
                        } else if (!z2 && KQgRr5e_0(xgtqvk_83, x6FRs_4)) {
                            f2 = f3;
                            xgtqvk_8 = xgtqvk_83;
                            z2 = true;
                        }
                        z2 = KQgRr5e_0;
                        f2 = f3;
                        xgtqvk_8 = xgtqvk_83;
                    }
                }
                i = this.f1113QxJ9d_1[i];
            } else {
                if (f3 < 0.001f) {
                    fArr[i] = 0.0f;
                    xgtqvk_83.QxJ9d_1(this.f1108KQgRr5e_0);
                    f3 = 0.0f;
                }
                if (f3 != 0.0f) {
                }
                i = this.f1113QxJ9d_1[i];
            }
        }
        return xgtqvk_82 != null ? xgtqvk_82 : xgtqvk_8;
    }

    public final void KQgRr5e_0(QxJ9d_1 qxJ9d_1, QxJ9d_1 qxJ9d_12, boolean z) {
        int i = this.PGPF6hQ_2;
        while (true) {
            for (int i2 = 0; i != -1 && i2 < this.KQgRr5e_0; i2++) {
                int i3 = this.f1112KQgRr5e_0[i];
                Xgtqvk_8 xgtqvk_8 = qxJ9d_12.f1116KQgRr5e_0;
                if (i3 == xgtqvk_8.f1127KQgRr5e_0) {
                    float f = this.f1111KQgRr5e_0[i];
                    KQgRr5e_0(xgtqvk_8, z);
                    KQgRr5e_0 kQgRr5e_0 = qxJ9d_12.f1115KQgRr5e_0;
                    int i4 = kQgRr5e_0.PGPF6hQ_2;
                    for (int i5 = 0; i4 != -1 && i5 < kQgRr5e_0.KQgRr5e_0; i5++) {
                        KQgRr5e_0(this.f1107KQgRr5e_0.f1114KQgRr5e_0[kQgRr5e_0.f1112KQgRr5e_0[i4]], kQgRr5e_0.f1111KQgRr5e_0[i4] * f, z);
                        i4 = kQgRr5e_0.f1113QxJ9d_1[i4];
                    }
                    qxJ9d_1.KQgRr5e_0 += qxJ9d_12.KQgRr5e_0 * f;
                    if (z) {
                        qxJ9d_12.f1116KQgRr5e_0.QxJ9d_1(qxJ9d_1);
                    }
                    i = this.PGPF6hQ_2;
                } else {
                    i = this.f1113QxJ9d_1[i];
                }
            }
            return;
        }
    }

    public void KQgRr5e_0(QxJ9d_1 qxJ9d_1, QxJ9d_1[] qxJ9d_1Arr) {
        int i = this.PGPF6hQ_2;
        while (true) {
            for (int i2 = 0; i != -1 && i2 < this.KQgRr5e_0; i2++) {
                Xgtqvk_8 xgtqvk_8 = this.f1107KQgRr5e_0.f1114KQgRr5e_0[this.f1112KQgRr5e_0[i]];
                if (xgtqvk_8.QxJ9d_1 != -1) {
                    float f = this.f1111KQgRr5e_0[i];
                    KQgRr5e_0(xgtqvk_8, true);
                    QxJ9d_1 qxJ9d_12 = qxJ9d_1Arr[xgtqvk_8.QxJ9d_1];
                    if (!qxJ9d_12.QxJ9d_1) {
                        KQgRr5e_0 kQgRr5e_0 = qxJ9d_12.f1115KQgRr5e_0;
                        int i3 = kQgRr5e_0.PGPF6hQ_2;
                        for (int i4 = 0; i3 != -1 && i4 < kQgRr5e_0.KQgRr5e_0; i4++) {
                            KQgRr5e_0(this.f1107KQgRr5e_0.f1114KQgRr5e_0[kQgRr5e_0.f1112KQgRr5e_0[i3]], kQgRr5e_0.f1111KQgRr5e_0[i3] * f, true);
                            i3 = kQgRr5e_0.f1113QxJ9d_1[i3];
                        }
                    }
                    qxJ9d_1.KQgRr5e_0 += qxJ9d_12.KQgRr5e_0 * f;
                    qxJ9d_12.f1116KQgRr5e_0.QxJ9d_1(qxJ9d_1);
                    i = this.PGPF6hQ_2;
                } else {
                    i = this.f1113QxJ9d_1[i];
                }
            }
            return;
        }
    }

    public Xgtqvk_8 KQgRr5e_0(boolean[] zArr, Xgtqvk_8 xgtqvk_8) {
        Xgtqvk_8.KQgRr5e_0 kQgRr5e_0;
        int i = this.PGPF6hQ_2;
        Xgtqvk_8 xgtqvk_82 = null;
        float f = 0.0f;
        for (int i2 = 0; i != -1 && i2 < this.KQgRr5e_0; i2++) {
            if (this.f1111KQgRr5e_0[i] < 0.0f) {
                Xgtqvk_8 xgtqvk_83 = this.f1107KQgRr5e_0.f1114KQgRr5e_0[this.f1112KQgRr5e_0[i]];
                if ((zArr == null || !zArr[xgtqvk_83.f1127KQgRr5e_0]) && xgtqvk_83 != xgtqvk_8 && ((kQgRr5e_0 = xgtqvk_83.f1128KQgRr5e_0) == Xgtqvk_8.KQgRr5e_0.SLACK || kQgRr5e_0 == Xgtqvk_8.KQgRr5e_0.ERROR)) {
                    float f2 = this.f1111KQgRr5e_0[i];
                    if (f2 < f) {
                        xgtqvk_82 = xgtqvk_83;
                        f = f2;
                    }
                }
            }
            i = this.f1113QxJ9d_1[i];
        }
        return xgtqvk_82;
    }

    /* renamed from: KQgRr5e_0  reason: collision with other method in class */
    public final Xgtqvk_8 m533KQgRr5e_0(int i) {
        int i2 = this.PGPF6hQ_2;
        for (int i3 = 0; i2 != -1 && i3 < this.KQgRr5e_0; i3++) {
            if (i3 == i) {
                return this.f1107KQgRr5e_0.f1114KQgRr5e_0[this.f1112KQgRr5e_0[i2]];
            }
            i2 = this.f1113QxJ9d_1[i2];
        }
        return null;
    }

    public final float KQgRr5e_0(int i) {
        int i2 = this.PGPF6hQ_2;
        for (int i3 = 0; i2 != -1 && i3 < this.KQgRr5e_0; i3++) {
            if (i3 == i) {
                return this.f1111KQgRr5e_0[i2];
            }
            i2 = this.f1113QxJ9d_1[i2];
        }
        return 0.0f;
    }

    public final float KQgRr5e_0(Xgtqvk_8 xgtqvk_8) {
        int i = this.PGPF6hQ_2;
        for (int i2 = 0; i != -1 && i2 < this.KQgRr5e_0; i2++) {
            if (this.f1112KQgRr5e_0[i] == xgtqvk_8.f1127KQgRr5e_0) {
                return this.f1111KQgRr5e_0[i];
            }
            i = this.f1113QxJ9d_1[i];
        }
        return 0.0f;
    }
}
