package o;

import java.util.Arrays;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* loaded from: classes.dex */
public final class IY extends C2029o9 {
    public R90[] f;
    public R90[] g;
    public int h;
    public C3031ym0 i;

    @Override // o.C2029o9
    public final R90 d(boolean[] zArr) {
        int i = -1;
        for (int i2 = 0; i2 < this.h; i2++) {
            R90[] r90Arr = this.f;
            R90 r90 = r90Arr[i2];
            if (!zArr[r90.m]) {
                C3031ym0 c3031ym0 = this.i;
                c3031ym0.m = r90;
                int i3 = 8;
                if (i == -1) {
                    while (i3 >= 0) {
                        float f = ((R90) c3031ym0.m).s[i3];
                        if (f <= 0.0f) {
                            if (f < 0.0f) {
                                i = i2;
                                break;
                            }
                            i3--;
                        }
                    }
                } else {
                    R90 r902 = r90Arr[i];
                    while (true) {
                        if (i3 >= 0) {
                            float f2 = r902.s[i3];
                            float f3 = ((R90) c3031ym0.m).s[i3];
                            if (f3 == f2) {
                                i3--;
                            } else if (f3 < f2) {
                            }
                        }
                    }
                }
            }
        }
        if (i == -1) {
            return null;
        }
        return this.f[i];
    }

    @Override // o.C2029o9
    public final boolean e() {
        return this.h == 0;
    }

    @Override // o.C2029o9
    public final void i(C2991yL c2991yL, C2029o9 c2029o9, boolean z) {
        R90 r90 = c2029o9.a;
        if (r90 == null) {
            return;
        }
        float[] fArr = r90.s;
        C1268g9 c1268g9 = c2029o9.d;
        int iD = c1268g9.d();
        for (int i = 0; i < iD; i++) {
            R90 r90E = c1268g9.e(i);
            float f = c1268g9.f(i);
            C3031ym0 c3031ym0 = this.i;
            c3031ym0.m = r90E;
            if (r90E.l) {
                boolean z2 = true;
                for (int i2 = 0; i2 < 9; i2++) {
                    float[] fArr2 = ((R90) c3031ym0.m).s;
                    float f2 = (fArr[i2] * f) + fArr2[i2];
                    fArr2[i2] = f2;
                    if (Math.abs(f2) < 1.0E-4f) {
                        ((R90) c3031ym0.m).s[i2] = 0.0f;
                    } else {
                        z2 = false;
                    }
                }
                if (z2) {
                    ((IY) c3031ym0.n).k((R90) c3031ym0.m);
                }
            } else {
                for (int i3 = 0; i3 < 9; i3++) {
                    float f3 = fArr[i3];
                    if (f3 != 0.0f) {
                        float f4 = f3 * f;
                        if (Math.abs(f4) < 1.0E-4f) {
                            f4 = 0.0f;
                        }
                        ((R90) c3031ym0.m).s[i3] = f4;
                    } else {
                        ((R90) c3031ym0.m).s[i3] = 0.0f;
                    }
                }
                j(r90E);
            }
            this.b = (c2029o9.b * f) + this.b;
        }
        k(r90);
    }

    public final void j(R90 r90) {
        int i;
        int i2 = this.h + 1;
        R90[] r90Arr = this.f;
        if (i2 > r90Arr.length) {
            R90[] r90Arr2 = (R90[]) Arrays.copyOf(r90Arr, r90Arr.length * 2);
            this.f = r90Arr2;
            this.g = (R90[]) Arrays.copyOf(r90Arr2, r90Arr2.length * 2);
        }
        R90[] r90Arr3 = this.f;
        int i3 = this.h;
        r90Arr3[i3] = r90;
        int i4 = i3 + 1;
        this.h = i4;
        if (i4 > 1 && r90Arr3[i3].m > r90.m) {
            int i5 = 0;
            while (true) {
                i = this.h;
                if (i5 >= i) {
                    break;
                }
                this.g[i5] = this.f[i5];
                i5++;
            }
            Arrays.sort(this.g, 0, i, new C1746lA(11));
            for (int i6 = 0; i6 < this.h; i6++) {
                this.f[i6] = this.g[i6];
            }
        }
        r90.l = true;
        r90.a(this);
    }

    public final void k(R90 r90) {
        int i = 0;
        while (i < this.h) {
            if (this.f[i] == r90) {
                while (true) {
                    int i2 = this.h;
                    if (i >= i2 - 1) {
                        this.h = i2 - 1;
                        r90.l = false;
                        return;
                    } else {
                        R90[] r90Arr = this.f;
                        int i3 = i + 1;
                        r90Arr[i] = r90Arr[i3];
                        i = i3;
                    }
                }
            } else {
                i++;
            }
        }
    }

    @Override // o.C2029o9
    public final String toString() {
        C3031ym0 c3031ym0 = this.i;
        String str = " goal -> (" + this.b + ") : ";
        for (int i = 0; i < this.h; i++) {
            c3031ym0.m = this.f[i];
            str = str + c3031ym0 + " ";
        }
        return str;
    }
}
