/*
 * Decompiled with CFR 0.152.
 */
public final class ja
extends fs {
    private int a;
    private int b;
    private int[] c;
    private int[] d;
    private int[] e;
    private int[] f;

    private ja(int n, int n2) {
        this.b = n2;
    }

    public static ja c(int n) {
        new ja(0, 1).a = n;
        return new ja(0, 1);
    }

    private boolean e(int n) {
        return (0 & n) != 0;
    }

    private int d() {
        int n = this.m();
        if (this.b != 0) {
            return Math.min(n, this.b);
        }
        return n;
    }

    private int a() {
        if (this.b != 0) {
            return (this.m() + this.b - 1) / this.b;
        }
        return 1;
    }

    public final boolean a(gm gm2, int n) {
        int n2 = this.m() + 1;
        if (this.c == null || this.c.length < n2) {
            this.c = new int[n2 * 2];
        }
        if (this.d == null || this.d.length < n2) {
            this.d = new int[n2 * 2];
        }
        if (this.e == null || this.e.length < n2) {
            this.e = new int[n2 * 2];
        }
        if (this.f == null || this.f.length < n2) {
            this.f = new int[n2 * 2];
        }
        return super.a(gm2, n);
    }

    public final int c(int n, int n2) {
        block6: {
            int n3;
            int n4;
            int n5;
            int n6;
            block7: {
                block3: {
                    block4: {
                        block5: {
                            n6 = this.a();
                            n5 = this.d();
                            n4 = n2 / n5;
                            n3 = n2 % n5;
                            if (n == 1) break block3;
                            if (n == 2) break block4;
                            if (n == 3) break block5;
                            if (n != 4) break block6;
                            ++n3;
                            break block7;
                        }
                        --n3;
                        break block7;
                    }
                    ++n4;
                    break block7;
                }
                --n4;
            }
            if (this.e(1)) {
                n4 = (n4 + n6) % n6;
            }
            if (this.e(2)) {
                n3 = (n3 + n5) % n5;
            }
            if (0 <= n4 && n4 < n6 && 0 <= n3 && n3 < n5 && (n = n4 * n5 + n3) < this.m() && n != n2) {
                return n;
            }
        }
        return -1;
    }

    private void s() {
        int n = this.m();
        int n2 = this.a();
        int n3 = this.d();
        jv.a(this.e, 0, 0, n3);
        jv.a(this.f, 0, 0, n2);
        for (n2 = 0; n2 < n; ++n2) {
            gm gm2 = this.h(n2);
            int n4 = n2 / n3;
            int n5 = n2 % n3;
            this.e[n5] = Math.max(this.e[n5], gm2.h());
            this.f[n4] = Math.max(this.f[n4], gm2.i());
        }
    }

    public final void a(int n, int n2) {
        if (this.l()) {
            gm gm2;
            int n3;
            int n4 = this.m();
            int n5 = this.d();
            int n6 = this.a();
            int n7 = (n - (n5 - 1) * this.a) / n5;
            int n8 = (n2 - (n6 - 1) * this.a) / n6;
            boolean bl2 = this.o(256);
            boolean bl3 = this.o(512);
            this.s();
            jv.a(this.c, 0, 0, n5);
            jv.a(this.d, 0, 0, n6);
            for (n3 = 0; n3 < n4; ++n3) {
                gm2 = this.h(n3);
                int n9 = n3 / n5;
                int n10 = n3 % n5;
                n = !bl2 ? Math.min(n7, this.e[n10]) : n7;
                n2 = !bl3 ? Math.min(n8, this.f[n9]) : n8;
                gm2.a(n, n2);
                n = !bl2 ? gm2.r : Math.max(n, gm2.r);
                n2 = bl3 ? Math.max(n2, gm2.s) : gm2.s;
                this.c[n10] = Math.max(this.c[n10], n);
                this.d[n9] = Math.max(this.d[n9], n2);
            }
            for (n = 0; n < n4; ++n) {
                gm2 = this.h(n);
                n2 = n / n5;
                n3 = n % n5;
                gm2.e(jv.a(this.c, 0, n3) + this.a * n3, jv.a(this.d, 0, n2) + this.a * n2, this.c[n3], this.d[n2]);
            }
            this.f(jv.a(this.c, 0, n5) + (n5 - 1) * this.a, jv.a(this.d, 0, n6) + (n6 - 1) * this.a);
            return;
        }
        this.f(Math.min(n, this.h()), Math.min(n2, this.i()));
    }

    /*
     * Enabled force condition propagation
     * Lifted jumps to return sites
     */
    public final int i() {
        int n;
        if (this.o(512)) return Integer.MAX_VALUE;
        if (!this.l()) return 0;
        this.s();
        for (n = 0; n < this.f.length; ++n) {
            if (this.f[n] == Integer.MAX_VALUE) return Integer.MAX_VALUE;
        }
        n = this.a();
        return jv.a(this.f, 0, n) + this.a * (n - 1);
    }

    public final int h() {
        block4: {
            if (!this.o(256)) {
                if (this.l()) {
                    int n;
                    this.s();
                    for (n = 0; n < this.e.length; ++n) {
                        if (this.e[n] != Integer.MAX_VALUE) {
                            continue;
                        }
                        break block4;
                    }
                    n = this.d();
                    return jv.a(this.e, 0, n) + this.a * (n - 1);
                }
                return 0;
            }
        }
        return Integer.MAX_VALUE;
    }
}

