package o;

import java.util.Arrays;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* renamed from: o.yL, reason: case insensitive filesystem */
/* loaded from: classes.dex */
public final class C2991yL {
    public static boolean q = false;
    public final IY d;
    public final C3126zm0 m;
    public C2029o9 p;
    public int a = 1000;
    public boolean b = false;
    public int c = 0;
    public int e = 32;
    public int f = 32;
    public boolean h = false;
    public boolean[] i = new boolean[32];
    public int j = 1;
    public int k = 0;
    public int l = 32;
    public R90[] n = new R90[1000];

    /* renamed from: o, reason: collision with root package name */
    public int f804o = 0;
    public C2029o9[] g = new C2029o9[32];

    public C2991yL() {
        s();
        C3126zm0 c3126zm0 = new C3126zm0(8, false);
        c3126zm0.m = new RX();
        c3126zm0.n = new RX();
        c3126zm0.f831o = new R90[32];
        this.m = c3126zm0;
        IY iy = new IY(c3126zm0);
        iy.f = new R90[128];
        iy.g = new R90[128];
        iy.h = 0;
        iy.i = new C3031ym0(iy);
        this.d = iy;
        this.p = new C2029o9(c3126zm0);
    }

    public static int n(Object obj) {
        R90 r90 = ((C3123zl) obj).i;
        if (r90 != null) {
            return (int) (r90.p + 0.5f);
        }
        return 0;
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Type inference failed for: r3v0, types: [java.lang.Object[]] */
    /* JADX WARN: Type inference failed for: r4v0 */
    public final R90 a(int i) {
        RX rx = (RX) this.m.n;
        int i2 = rx.b;
        R90 r90 = null;
        if (i2 > 0) {
            int i3 = i2 - 1;
            ?? r3 = rx.a;
            ?? r4 = r3[i3];
            r3[i3] = 0;
            rx.b = i3;
            r90 = r4;
        }
        R90 r902 = r90;
        if (r902 == null) {
            r902 = new R90(i);
            r902.w = i;
        } else {
            r902.c();
            r902.w = i;
        }
        int i4 = this.f804o;
        int i5 = this.a;
        if (i4 >= i5) {
            int i6 = i5 * 2;
            this.a = i6;
            this.n = (R90[]) Arrays.copyOf(this.n, i6);
        }
        R90[] r90Arr = this.n;
        int i7 = this.f804o;
        this.f804o = i7 + 1;
        r90Arr[i7] = r902;
        return r902;
    }

    public final void b(R90 r90, R90 r902, int i, float f, R90 r903, R90 r904, int i2, int i3) {
        C2029o9 c2029o9L = l();
        if (r902 == r903) {
            c2029o9L.d.g(r90, 1.0f);
            c2029o9L.d.g(r904, 1.0f);
            c2029o9L.d.g(r902, -2.0f);
        } else if (f == 0.5f) {
            c2029o9L.d.g(r90, 1.0f);
            c2029o9L.d.g(r902, -1.0f);
            c2029o9L.d.g(r903, -1.0f);
            c2029o9L.d.g(r904, 1.0f);
            if (i > 0 || i2 > 0) {
                c2029o9L.b = (-i) + i2;
            }
        } else if (f <= 0.0f) {
            c2029o9L.d.g(r90, -1.0f);
            c2029o9L.d.g(r902, 1.0f);
            c2029o9L.b = i;
        } else if (f >= 1.0f) {
            c2029o9L.d.g(r904, -1.0f);
            c2029o9L.d.g(r903, 1.0f);
            c2029o9L.b = -i2;
        } else {
            float f2 = 1.0f - f;
            c2029o9L.d.g(r90, f2 * 1.0f);
            c2029o9L.d.g(r902, f2 * (-1.0f));
            c2029o9L.d.g(r903, (-1.0f) * f);
            c2029o9L.d.g(r904, 1.0f * f);
            if (i > 0 || i2 > 0) {
                c2029o9L.b = (i2 * f) + ((-i) * f2);
            }
        }
        if (i3 != 8) {
            c2029o9L.a(this, i3);
        }
        c(c2029o9L);
    }

    /* JADX WARN: Removed duplicated region for block: B:120:0x01ae  */
    /* JADX WARN: Removed duplicated region for block: B:123:0x01b3  */
    /* JADX WARN: Removed duplicated region for block: B:156:? A[RETURN, SYNTHETIC] */
    /* JADX WARN: Removed duplicated region for block: B:58:0x00d6  */
    /* JADX WARN: Removed duplicated region for block: B:76:0x00f8  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public final void c(o.C2029o9 r18) {
        /*
            Method dump skipped, instructions count: 453
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: o.C2991yL.c(o.o9):void");
    }

    public final void d(R90 r90, int i) {
        int i2 = r90.n;
        if (i2 == -1) {
            r90.d(this, i);
            for (int i3 = 0; i3 < this.c + 1; i3++) {
                R90 r902 = ((R90[]) this.m.f831o)[i3];
            }
            return;
        }
        if (i2 == -1) {
            C2029o9 c2029o9L = l();
            c2029o9L.a = r90;
            float f = i;
            r90.p = f;
            c2029o9L.b = f;
            c2029o9L.e = true;
            c(c2029o9L);
            return;
        }
        C2029o9 c2029o9 = this.g[i2];
        if (c2029o9.e) {
            c2029o9.b = i;
            return;
        }
        if (c2029o9.d.d() == 0) {
            c2029o9.e = true;
            c2029o9.b = i;
            return;
        }
        C2029o9 c2029o9L2 = l();
        if (i < 0) {
            c2029o9L2.b = i * (-1);
            c2029o9L2.d.g(r90, 1.0f);
        } else {
            c2029o9L2.b = i;
            c2029o9L2.d.g(r90, -1.0f);
        }
        c(c2029o9L2);
    }

    public final void e(R90 r90, R90 r902, int i, int i2) {
        if (i2 == 8 && r902.q && r90.n == -1) {
            r90.d(this, r902.p + i);
            return;
        }
        C2029o9 c2029o9L = l();
        boolean z = false;
        if (i != 0) {
            if (i < 0) {
                i *= -1;
                z = true;
            }
            c2029o9L.b = i;
        }
        if (z) {
            c2029o9L.d.g(r90, 1.0f);
            c2029o9L.d.g(r902, -1.0f);
        } else {
            c2029o9L.d.g(r90, -1.0f);
            c2029o9L.d.g(r902, 1.0f);
        }
        if (i2 != 8) {
            c2029o9L.a(this, i2);
        }
        c(c2029o9L);
    }

    public final void f(R90 r90, R90 r902, int i, int i2) {
        C2029o9 c2029o9L = l();
        R90 r90M = m();
        r90M.f310o = 0;
        c2029o9L.b(r90, r902, r90M, i);
        if (i2 != 8) {
            c2029o9L.d.g(j(i2), (int) (c2029o9L.d.c(r90M) * (-1.0f)));
        }
        c(c2029o9L);
    }

    public final void g(R90 r90, R90 r902, int i, int i2) {
        C2029o9 c2029o9L = l();
        R90 r90M = m();
        r90M.f310o = 0;
        c2029o9L.c(r90, r902, r90M, i);
        if (i2 != 8) {
            c2029o9L.d.g(j(i2), (int) (c2029o9L.d.c(r90M) * (-1.0f)));
        }
        c(c2029o9L);
    }

    public final void h(C2029o9 c2029o9) {
        int i;
        if (c2029o9.e) {
            c2029o9.a.d(this, c2029o9.b);
        } else {
            C2029o9[] c2029o9Arr = this.g;
            int i2 = this.k;
            c2029o9Arr[i2] = c2029o9;
            R90 r90 = c2029o9.a;
            r90.n = i2;
            this.k = i2 + 1;
            r90.e(this, c2029o9);
        }
        if (this.b) {
            int i3 = 0;
            while (i3 < this.k) {
                if (this.g[i3] == null) {
                    System.out.println("WTF");
                }
                C2029o9 c2029o92 = this.g[i3];
                if (c2029o92 != null && c2029o92.e) {
                    c2029o92.a.d(this, c2029o92.b);
                    ((RX) this.m.m).b(c2029o92);
                    this.g[i3] = null;
                    int i4 = i3 + 1;
                    int i5 = i4;
                    while (true) {
                        i = this.k;
                        if (i4 >= i) {
                            break;
                        }
                        C2029o9[] c2029o9Arr2 = this.g;
                        int i6 = i4 - 1;
                        C2029o9 c2029o93 = c2029o9Arr2[i4];
                        c2029o9Arr2[i6] = c2029o93;
                        R90 r902 = c2029o93.a;
                        if (r902.n == i4) {
                            r902.n = i6;
                        }
                        i5 = i4;
                        i4++;
                    }
                    if (i5 < i) {
                        this.g[i5] = null;
                    }
                    this.k = i - 1;
                    i3--;
                }
                i3++;
            }
            this.b = false;
        }
    }

    public final void i() {
        for (int i = 0; i < this.k; i++) {
            C2029o9 c2029o9 = this.g[i];
            c2029o9.a.p = c2029o9.b;
        }
    }

    public final R90 j(int i) {
        if (this.j + 1 >= this.f) {
            o();
        }
        R90 r90A = a(4);
        float[] fArr = r90A.s;
        int i2 = this.c + 1;
        this.c = i2;
        this.j++;
        r90A.m = i2;
        r90A.f310o = i;
        ((R90[]) this.m.f831o)[i2] = r90A;
        IY iy = this.d;
        iy.i.m = r90A;
        Arrays.fill(fArr, 0.0f);
        fArr[r90A.f310o] = 1.0f;
        iy.j(r90A);
        return r90A;
    }

    public final R90 k(Object obj) {
        if (obj == null) {
            return null;
        }
        if (this.j + 1 >= this.f) {
            o();
        }
        if (!(obj instanceof C3123zl)) {
            return null;
        }
        C3123zl c3123zl = (C3123zl) obj;
        R90 r90 = c3123zl.i;
        if (r90 == null) {
            c3123zl.k();
            r90 = c3123zl.i;
        }
        int i = r90.m;
        C3126zm0 c3126zm0 = this.m;
        if (i != -1 && i <= this.c && ((R90[]) c3126zm0.f831o)[i] != null) {
            return r90;
        }
        if (i != -1) {
            r90.c();
        }
        int i2 = this.c + 1;
        this.c = i2;
        this.j++;
        r90.m = i2;
        r90.w = 1;
        ((R90[]) c3126zm0.f831o)[i2] = r90;
        return r90;
    }

    public final C2029o9 l() {
        Object obj;
        C3126zm0 c3126zm0 = this.m;
        RX rx = (RX) c3126zm0.m;
        int i = rx.b;
        if (i > 0) {
            int i2 = i - 1;
            Object[] objArr = rx.a;
            obj = objArr[i2];
            objArr[i2] = null;
            rx.b = i2;
        } else {
            obj = null;
        }
        C2029o9 c2029o9 = (C2029o9) obj;
        if (c2029o9 == null) {
            return new C2029o9(c3126zm0);
        }
        c2029o9.a = null;
        c2029o9.d.b();
        c2029o9.b = 0.0f;
        c2029o9.e = false;
        return c2029o9;
    }

    public final R90 m() {
        if (this.j + 1 >= this.f) {
            o();
        }
        R90 r90A = a(3);
        int i = this.c + 1;
        this.c = i;
        this.j++;
        r90A.m = i;
        ((R90[]) this.m.f831o)[i] = r90A;
        return r90A;
    }

    public final void o() {
        int i = this.e * 2;
        this.e = i;
        this.g = (C2029o9[]) Arrays.copyOf(this.g, i);
        C3126zm0 c3126zm0 = this.m;
        c3126zm0.f831o = (R90[]) Arrays.copyOf((R90[]) c3126zm0.f831o, this.e);
        int i2 = this.e;
        this.i = new boolean[i2];
        this.f = i2;
        this.l = i2;
    }

    public final void p() {
        IY iy = this.d;
        if (iy.e()) {
            i();
            return;
        }
        if (!this.h) {
            q(iy);
            return;
        }
        for (int i = 0; i < this.k; i++) {
            if (!this.g[i].e) {
                q(iy);
                return;
            }
        }
        i();
    }

    public final void q(IY iy) {
        int i = 0;
        while (true) {
            if (i >= this.k) {
                break;
            }
            C2029o9 c2029o9 = this.g[i];
            int i2 = 1;
            if (c2029o9.a.w != 1) {
                float f = 0.0f;
                if (c2029o9.b < 0.0f) {
                    boolean z = false;
                    int i3 = 0;
                    while (!z) {
                        i3 += i2;
                        float f2 = Float.MAX_VALUE;
                        int i4 = -1;
                        int i5 = -1;
                        int i6 = 0;
                        int i7 = 0;
                        while (i6 < this.k) {
                            C2029o9 c2029o92 = this.g[i6];
                            if (c2029o92.a.w != i2 && !c2029o92.e && c2029o92.b < f) {
                                int iD = c2029o92.d.d();
                                int i8 = 0;
                                while (i8 < iD) {
                                    R90 r90E = c2029o92.d.e(i8);
                                    float fC = c2029o92.d.c(r90E);
                                    if (fC > f) {
                                        for (int i9 = 0; i9 < 9; i9++) {
                                            float f3 = r90E.r[i9] / fC;
                                            if ((f3 < f2 && i9 == i7) || i9 > i7) {
                                                i7 = i9;
                                                i5 = r90E.m;
                                                i4 = i6;
                                                f2 = f3;
                                            }
                                        }
                                    }
                                    i8++;
                                    f = 0.0f;
                                }
                            }
                            i6++;
                            f = 0.0f;
                            i2 = 1;
                        }
                        if (i4 != -1) {
                            C2029o9 c2029o93 = this.g[i4];
                            c2029o93.a.n = -1;
                            c2029o93.g(((R90[]) this.m.f831o)[i5]);
                            R90 r90 = c2029o93.a;
                            r90.n = i4;
                            r90.e(this, c2029o93);
                        } else {
                            z = true;
                        }
                        if (i3 > this.j / 2) {
                            z = true;
                        }
                        f = 0.0f;
                        i2 = 1;
                    }
                }
            }
            i++;
        }
        r(iy);
        i();
    }

    /* JADX WARN: Removed duplicated region for block: B:43:0x007d  */
    /* JADX WARN: Removed duplicated region for block: B:63:0x0092 A[SYNTHETIC] */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public final void r(o.C2029o9 r17) {
        /*
            Method dump skipped, instructions count: 177
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: o.C2991yL.r(o.o9):void");
    }

    public final void s() {
        for (int i = 0; i < this.k; i++) {
            C2029o9 c2029o9 = this.g[i];
            if (c2029o9 != null) {
                ((RX) this.m.m).b(c2029o9);
            }
            this.g[i] = null;
        }
    }

    public final void t() {
        C3126zm0 c3126zm0;
        int i = 0;
        while (true) {
            c3126zm0 = this.m;
            R90[] r90Arr = (R90[]) c3126zm0.f831o;
            if (i >= r90Arr.length) {
                break;
            }
            R90 r90 = r90Arr[i];
            if (r90 != null) {
                r90.c();
            }
            i++;
        }
        RX rx = (RX) c3126zm0.n;
        R90[] r90Arr2 = this.n;
        int length = this.f804o;
        rx.getClass();
        if (length > r90Arr2.length) {
            length = r90Arr2.length;
        }
        for (int i2 = 0; i2 < length; i2++) {
            R90 r902 = r90Arr2[i2];
            int i3 = rx.b;
            Object[] objArr = rx.a;
            if (i3 < objArr.length) {
                objArr[i3] = r902;
                rx.b = i3 + 1;
            }
        }
        this.f804o = 0;
        Arrays.fill((R90[]) c3126zm0.f831o, (Object) null);
        this.c = 0;
        IY iy = this.d;
        iy.h = 0;
        iy.b = 0.0f;
        this.j = 1;
        for (int i4 = 0; i4 < this.k; i4++) {
            C2029o9 c2029o9 = this.g[i4];
        }
        s();
        this.k = 0;
        this.p = new C2029o9(c3126zm0);
    }
}
