package androidx.leanback.widget;

import V.C0629x;
import n.C2580g;

/* JADX INFO: loaded from: classes.dex */
public final class S extends AbstractC1078j {

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    public C0629x f11877j;

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    public int f11878k;
    public Object l;

    /* JADX INFO: renamed from: m, reason: collision with root package name */
    public int f11879m;

    @Override // androidx.leanback.widget.AbstractC1078j
    public final boolean b(int i6, boolean z6) {
        Object[] objArr = this.f11982a;
        if (this.f11983b.i() == 0 || (!z6 && c(i6))) {
            return false;
        }
        try {
            if (!o(i6, z6)) {
                return q(i6, z6);
            }
            objArr[0] = null;
            this.l = null;
            return true;
        } finally {
            objArr[0] = null;
            this.l = null;
        }
    }

    @Override // androidx.leanback.widget.AbstractC1078j
    public final int g(int[] iArr, int i6, boolean z6) {
        int i7;
        int iL = this.f11983b.l(i6);
        Q qK = k(i6);
        int i8 = qK.f11981a;
        if (this.f11984c) {
            i7 = i8;
            int i9 = i7;
            int i10 = 1;
            int i11 = iL;
            for (int i12 = i6 + 1; i10 < this.f11986e && i12 <= this.f11988g; i12++) {
                Q qK2 = k(i12);
                i11 += qK2.f11866b;
                int i13 = qK2.f11981a;
                if (i13 != i9) {
                    i10++;
                    if (!z6 ? i11 >= iL : i11 <= iL) {
                        i9 = i13;
                    } else {
                        iL = i11;
                        i6 = i12;
                        i7 = i13;
                        i9 = i7;
                    }
                }
            }
        } else {
            int i14 = 1;
            int i15 = i8;
            Q qK3 = qK;
            int i16 = iL;
            iL = this.f11983b.n(i6) + iL;
            i7 = i15;
            for (int i17 = i6 - 1; i14 < this.f11986e && i17 >= this.f11987f; i17--) {
                i16 -= qK3.f11866b;
                qK3 = k(i17);
                int i18 = qK3.f11981a;
                if (i18 != i15) {
                    i14++;
                    int iN = this.f11983b.n(i17) + i16;
                    if (!z6 ? iN >= iL : iN <= iL) {
                        i15 = i18;
                    } else {
                        iL = iN;
                        i6 = i17;
                        i7 = i18;
                        i15 = i7;
                    }
                }
            }
        }
        if (iArr != null) {
            iArr[0] = i7;
            iArr[1] = i6;
        }
        return iL;
    }

    @Override // androidx.leanback.widget.AbstractC1078j
    public final int i(int[] iArr, int i6, boolean z6) {
        int iN;
        int iL = this.f11983b.l(i6);
        Q qK = k(i6);
        int i7 = qK.f11981a;
        if (this.f11984c) {
            int i8 = 1;
            iN = iL - this.f11983b.n(i6);
            int i9 = i7;
            for (int i10 = i6 - 1; i8 < this.f11986e && i10 >= this.f11987f; i10--) {
                iL -= qK.f11866b;
                qK = k(i10);
                int i11 = qK.f11981a;
                if (i11 != i9) {
                    i8++;
                    int iN2 = iL - this.f11983b.n(i10);
                    if (!z6 ? iN2 >= iN : iN2 <= iN) {
                        i9 = i11;
                    } else {
                        iN = iN2;
                        i6 = i10;
                        i7 = i11;
                        i9 = i7;
                    }
                }
            }
        } else {
            int i12 = i7;
            int i13 = i12;
            int i14 = 1;
            int i15 = iL;
            for (int i16 = i6 + 1; i14 < this.f11986e && i16 <= this.f11988g; i16++) {
                Q qK2 = k(i16);
                i15 += qK2.f11866b;
                int i17 = qK2.f11981a;
                if (i17 != i13) {
                    i14++;
                    if (!z6 ? i15 >= iL : i15 <= iL) {
                        i13 = i17;
                    } else {
                        iL = i15;
                        i6 = i16;
                        i12 = i17;
                        i13 = i12;
                    }
                }
            }
            iN = iL;
            i7 = i12;
        }
        if (iArr != null) {
            iArr[0] = i7;
            iArr[1] = i6;
        }
        return iN;
    }

    /* JADX WARN: Removed duplicated region for block: B:20:0x0051  */
    @Override // androidx.leanback.widget.AbstractC1078j
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final C2580g[] j(int i6, int i7) {
        for (int i8 = 0; i8 < this.f11986e; i8++) {
            C2580g c2580g = this.f11989h[i8];
            c2580g.f21438c = c2580g.f21437b;
        }
        if (i6 >= 0) {
            while (i6 <= i7) {
                C2580g c2580g2 = this.f11989h[k(i6).f11981a];
                if (c2580g2.c() <= 0) {
                    c2580g2.a(i6);
                    c2580g2.a(i6);
                } else {
                    int i9 = c2580g2.f21437b;
                    int i10 = c2580g2.f21438c;
                    if (i9 == i10) {
                        throw new ArrayIndexOutOfBoundsException();
                    }
                    int[] iArr = c2580g2.f21436a;
                    int i11 = c2580g2.f21439d;
                    if (iArr[(i10 - 1) & i11] == i6 - 1) {
                        if (i9 == i10) {
                            throw new ArrayIndexOutOfBoundsException();
                        }
                        int i12 = (i10 - 1) & i11;
                        int i13 = iArr[i12];
                        c2580g2.f21438c = i12;
                        c2580g2.a(i6);
                    }
                }
                i6++;
            }
        }
        return this.f11989h;
    }

    @Override // androidx.leanback.widget.AbstractC1078j
    public final void l(int i6) {
        super.l(i6);
        int iS = (s() - i6) + 1;
        C0629x c0629x = this.f11877j;
        c0629x.H(iS);
        if (c0629x.L() == 0) {
            this.f11878k = -1;
        }
    }

    @Override // androidx.leanback.widget.AbstractC1078j
    public final boolean m(int i6, boolean z6) {
        Object[] objArr = this.f11982a;
        if (this.f11983b.i() == 0 || (!z6 && d(i6))) {
            return false;
        }
        try {
            if (!w(i6, z6)) {
                return y(i6, z6);
            }
            objArr[0] = null;
            this.l = null;
            return true;
        } finally {
            objArr[0] = null;
            this.l = null;
        }
    }

    public final boolean o(int i6, boolean z6) {
        int i7;
        int iL;
        int i8;
        C0629x c0629x = this.f11877j;
        if (c0629x.L() != 0) {
            int i9 = this.f11983b.i();
            int i10 = this.f11988g;
            if (i10 >= 0) {
                i7 = i10 + 1;
                iL = this.f11983b.l(i10);
            } else {
                int i11 = this.f11990i;
                i7 = i11 != -1 ? i11 : 0;
                if (i7 > s() + 1 || i7 < this.f11878k) {
                    c0629x.I(c0629x.L());
                    return false;
                }
                if (i7 <= s()) {
                    iL = Integer.MAX_VALUE;
                }
            }
            int iS = s();
            int i12 = i7;
            while (i12 < i9 && i12 <= iS) {
                Q qK = k(i12);
                if (iL != Integer.MAX_VALUE) {
                    iL += qK.f11866b;
                }
                int i13 = iL;
                int i14 = qK.f11981a;
                C0.B b5 = this.f11983b;
                Object[] objArr = this.f11982a;
                int iG = b5.g(i12, true, objArr, false);
                if (iG != qK.f11867c) {
                    qK.f11867c = iG;
                    c0629x.H(iS - i12);
                    i8 = i12;
                } else {
                    i8 = iS;
                }
                this.f11988g = i12;
                if (this.f11987f < 0) {
                    this.f11987f = i12;
                }
                this.f11983b.d(objArr[0], i12, iG, i14, i13);
                if (z6 || !c(i6)) {
                    iL = i13 == Integer.MAX_VALUE ? this.f11983b.l(i12) : i13;
                    if (i14 != this.f11986e - 1 || !z6) {
                        i12++;
                        iS = i8;
                    }
                }
                return true;
            }
        }
        return false;
    }

    public final int p(int i6, int i7, int i8) {
        int iL;
        int i9 = this.f11988g;
        if (i9 >= 0 && (i9 != s() || this.f11988g != i6 - 1)) {
            throw new IllegalStateException();
        }
        int i10 = this.f11988g;
        C0629x c0629x = this.f11877j;
        if (i10 >= 0) {
            iL = i8 - this.f11983b.l(i10);
        } else if (c0629x.L() <= 0 || i6 != s() + 1) {
            iL = 0;
        } else {
            int iS = s();
            while (true) {
                if (iS < this.f11878k) {
                    iS = s();
                    break;
                }
                if (k(iS).f11981a == i7) {
                    break;
                }
                iS--;
            }
            iL = this.f11984c ? (-k(iS).f11867c) - this.f11985d : k(iS).f11867c + this.f11985d;
            for (int i11 = iS + 1; i11 <= s(); i11++) {
                iL -= k(i11).f11866b;
            }
        }
        Q q6 = new Q(i7, iL);
        Object[] objArr = (Object[]) c0629x.f7180e;
        int i12 = c0629x.f7178c;
        objArr[i12] = q6;
        int i13 = c0629x.f7179d & (i12 + 1);
        c0629x.f7178c = i13;
        if (i13 == c0629x.f7177b) {
            c0629x.d();
        }
        Object obj = this.l;
        if (obj != null) {
            q6.f11867c = this.f11879m;
            this.l = null;
        } else {
            C0.B b5 = this.f11983b;
            Object[] objArr2 = this.f11982a;
            q6.f11867c = b5.g(i6, true, objArr2, false);
            obj = objArr2[0];
        }
        Object obj2 = obj;
        if (c0629x.L() == 1) {
            this.f11988g = i6;
            this.f11987f = i6;
            this.f11878k = i6;
        } else {
            int i14 = this.f11988g;
            if (i14 < 0) {
                this.f11988g = i6;
                this.f11987f = i6;
            } else {
                this.f11988g = i14 + 1;
            }
        }
        this.f11983b.d(obj2, i6, q6.f11867c, i7, i8);
        return q6.f11867c;
    }

    /* JADX WARN: Code restructure failed: missing block: B:105:0x0136, code lost:
    
        return true;
     */
    /* JADX WARN: Removed duplicated region for block: B:107:0x0139  */
    /* JADX WARN: Removed duplicated region for block: B:88:0x0107 A[LOOP:2: B:88:0x0107->B:104:0x012b, LOOP_START, PHI: r6 r9 r10
      0x0107: PHI (r6v12 int) = (r6v6 int), (r6v16 int) binds: [B:87:0x0105, B:104:0x012b] A[DONT_GENERATE, DONT_INLINE]
      0x0107: PHI (r9v20 int) = (r9v18 int), (r9v21 int) binds: [B:87:0x0105, B:104:0x012b] A[DONT_GENERATE, DONT_INLINE]
      0x0107: PHI (r10v7 int) = (r10v5 int), (r10v9 int) binds: [B:87:0x0105, B:104:0x012b] A[DONT_GENERATE, DONT_INLINE]] */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final boolean q(int i6, boolean z6) {
        int i7;
        int i8;
        boolean z7;
        int iV;
        int i9;
        int i10;
        int i11 = this.f11983b.i();
        int i12 = this.f11988g;
        if (i12 < 0) {
            int i13 = this.f11990i;
            i7 = i13 != -1 ? i13 : 0;
            i8 = (this.f11877j.L() > 0 ? k(s()).f11981a + 1 : i7) % this.f11986e;
            z7 = false;
            iV = 0;
        } else {
            if (i12 < s()) {
                return false;
            }
            int i14 = this.f11988g;
            i7 = i14 + 1;
            i8 = k(i14).f11981a;
            int iR = r(true);
            if (iR < 0) {
                iV = Integer.MIN_VALUE;
                for (int i15 = 0; i15 < this.f11986e; i15++) {
                    iV = this.f11984c ? v(i15) : u(i15);
                    if (iV != Integer.MIN_VALUE) {
                        break;
                    }
                }
            } else {
                iV = this.f11984c ? i(null, iR, false) : g(null, iR, true);
            }
            if (!this.f11984c ? u(i8) >= iV : v(i8) <= iV) {
                i8++;
                if (i8 == this.f11986e) {
                    iV = this.f11984c ? h(false, null) : f(true, null);
                    i8 = 0;
                }
            }
            z7 = true;
        }
        boolean z8 = false;
        loop1: while (true) {
            if (i8 < this.f11986e) {
                if (i7 == i11 || (!z6 && c(i6))) {
                    break;
                }
                int iV2 = this.f11984c ? v(i8) : u(i8);
                if (iV2 == Integer.MAX_VALUE || iV2 == Integer.MIN_VALUE) {
                    if (i8 == 0) {
                        iV2 = this.f11984c ? v(this.f11986e - 1) : u(this.f11986e - 1);
                        if (iV2 != Integer.MAX_VALUE && iV2 != Integer.MIN_VALUE) {
                            if (this.f11984c) {
                                i10 = this.f11985d;
                                i9 = -i10;
                                iV2 += i9;
                            } else {
                                i9 = this.f11985d;
                                iV2 += i9;
                            }
                        }
                    } else {
                        iV2 = this.f11984c ? u(i8 - 1) : v(i8 - 1);
                    }
                    int i16 = i7 + 1;
                    int iP = p(i7, i8, iV2);
                    if (z7) {
                        while (true) {
                            if (!this.f11984c) {
                                if (iV2 + iP >= iV) {
                                    break;
                                }
                                if (i16 == i11) {
                                    break loop1;
                                }
                                break loop1;
                                break loop1;
                            }
                            if (iV2 - iP <= iV) {
                                break;
                            }
                            if (i16 == i11 || (!z6 && c(i6))) {
                                break loop1;
                            }
                            iV2 += this.f11984c ? (-iP) - this.f11985d : iP + this.f11985d;
                            int i17 = i16 + 1;
                            int iP2 = p(i16, i8, iV2);
                            i16 = i17;
                            iP = iP2;
                        }
                    } else {
                        z7 = true;
                        iV = this.f11984c ? v(i8) : u(i8);
                    }
                    i7 = i16;
                    i8++;
                    z8 = true;
                } else if (this.f11984c) {
                    i10 = this.f11985d;
                    i9 = -i10;
                    iV2 += i9;
                    int i162 = i7 + 1;
                    int iP3 = p(i7, i8, iV2);
                    if (z7) {
                    }
                    i7 = i162;
                    i8++;
                    z8 = true;
                } else {
                    i9 = this.f11985d;
                    iV2 += i9;
                    int i1622 = i7 + 1;
                    int iP32 = p(i7, i8, iV2);
                    if (z7) {
                    }
                    i7 = i1622;
                    i8++;
                    z8 = true;
                }
            } else {
                if (z6) {
                    break;
                }
                iV = this.f11984c ? h(false, null) : f(true, null);
                i8 = 0;
            }
        }
        return z8;
    }

    public final int r(boolean z6) {
        boolean z7 = false;
        if (z6) {
            for (int i6 = this.f11988g; i6 >= this.f11987f; i6--) {
                int i7 = k(i6).f11981a;
                if (i7 == 0) {
                    z7 = true;
                } else if (z7 && i7 == this.f11986e - 1) {
                    return i6;
                }
            }
            return -1;
        }
        for (int i8 = this.f11987f; i8 <= this.f11988g; i8++) {
            int i9 = k(i8).f11981a;
            if (i9 == this.f11986e - 1) {
                z7 = true;
            } else if (z7 && i9 == 0) {
                return i8;
            }
        }
        return -1;
    }

    public final int s() {
        return (this.f11877j.L() + this.f11878k) - 1;
    }

    @Override // androidx.leanback.widget.AbstractC1078j
    /* JADX INFO: renamed from: t, reason: merged with bridge method [inline-methods] */
    public final Q k(int i6) {
        int i7 = i6 - this.f11878k;
        if (i7 < 0) {
            return null;
        }
        C0629x c0629x = this.f11877j;
        if (i7 >= c0629x.L()) {
            return null;
        }
        if (i7 < 0) {
            c0629x.getClass();
        } else if (i7 < c0629x.L()) {
            Object obj = ((Object[]) c0629x.f7180e)[c0629x.f7179d & (c0629x.f7177b + i7)];
            kotlin.jvm.internal.o.e(obj);
            return (Q) obj;
        }
        throw new ArrayIndexOutOfBoundsException();
    }

    public final int u(int i6) {
        int i7;
        Q qK;
        int i8 = this.f11987f;
        if (i8 < 0) {
            return Integer.MIN_VALUE;
        }
        if (this.f11984c) {
            int iL = this.f11983b.l(i8);
            if (k(this.f11987f).f11981a == i6) {
                return iL;
            }
            int i9 = this.f11987f;
            do {
                i9++;
                if (i9 <= s()) {
                    qK = k(i9);
                    iL += qK.f11866b;
                }
            } while (qK.f11981a != i6);
            return iL;
        }
        int iL2 = this.f11983b.l(this.f11988g);
        Q qK2 = k(this.f11988g);
        if (qK2.f11981a == i6) {
            i7 = qK2.f11867c;
        } else {
            int i10 = this.f11988g;
            do {
                i10--;
                if (i10 >= this.f11878k) {
                    iL2 -= qK2.f11866b;
                    qK2 = k(i10);
                }
            } while (qK2.f11981a != i6);
            i7 = qK2.f11867c;
        }
        return iL2 + i7;
        return Integer.MIN_VALUE;
    }

    public final int v(int i6) {
        Q qK;
        int i7;
        int i8 = this.f11987f;
        if (i8 < 0) {
            return Integer.MAX_VALUE;
        }
        if (!this.f11984c) {
            int iL = this.f11983b.l(i8);
            if (k(this.f11987f).f11981a == i6) {
                return iL;
            }
            int i9 = this.f11987f;
            do {
                i9++;
                if (i9 <= s()) {
                    qK = k(i9);
                    iL += qK.f11866b;
                }
            } while (qK.f11981a != i6);
            return iL;
        }
        int iL2 = this.f11983b.l(this.f11988g);
        Q qK2 = k(this.f11988g);
        if (qK2.f11981a == i6) {
            i7 = qK2.f11867c;
        } else {
            int i10 = this.f11988g;
            do {
                i10--;
                if (i10 >= this.f11878k) {
                    iL2 -= qK2.f11866b;
                    qK2 = k(i10);
                }
            } while (qK2.f11981a != i6);
            i7 = qK2.f11867c;
        }
        return iL2 - i7;
        return Integer.MAX_VALUE;
    }

    public final boolean w(int i6, boolean z6) {
        int i7;
        int iL;
        int i8;
        C0629x c0629x = this.f11877j;
        if (c0629x.L() != 0) {
            int i9 = this.f11987f;
            if (i9 < 0) {
                int i10 = this.f11990i;
                i7 = i10 != -1 ? i10 : 0;
                if (i7 <= s()) {
                    int i11 = this.f11878k;
                    if (i7 >= i11 - 1) {
                        if (i7 >= i11) {
                            iL = Integer.MAX_VALUE;
                            i8 = 0;
                        }
                    }
                }
                c0629x.I(c0629x.L());
                return false;
            }
            iL = this.f11983b.l(i9);
            i8 = k(this.f11987f).f11866b;
            i7 = this.f11987f - 1;
            int iMax = Math.max(((C1084p) this.f11983b.f506b).f12052u, this.f11878k);
            for (int i12 = i7; i12 >= iMax; i12--) {
                Q qK = k(i12);
                int i13 = qK.f11981a;
                C0.B b5 = this.f11983b;
                Object[] objArr = this.f11982a;
                int iG = b5.g(i12, false, objArr, false);
                if (iG != qK.f11867c) {
                    c0629x.I((i12 + 1) - this.f11878k);
                    this.f11878k = this.f11987f;
                    this.l = objArr[0];
                    this.f11879m = iG;
                    return false;
                }
                this.f11987f = i12;
                if (this.f11988g < 0) {
                    this.f11988g = i12;
                }
                this.f11983b.d(objArr[0], i12, iG, i13, iL - i8);
                if (z6 || !d(i6)) {
                    iL = this.f11983b.l(i12);
                    i8 = qK.f11866b;
                    if (i13 != 0 || !z6) {
                    }
                }
                return true;
            }
        }
        return false;
    }

    public final int x(int i6, int i7, int i8) {
        int i9 = this.f11987f;
        if (i9 >= 0 && (i9 != this.f11878k || i9 != i6 + 1)) {
            throw new IllegalStateException();
        }
        int i10 = this.f11878k;
        Q qK = i10 >= 0 ? k(i10) : null;
        int iL = this.f11983b.l(this.f11878k);
        Q q6 = new Q(i7, 0);
        C0629x c0629x = this.f11877j;
        int i11 = (c0629x.f7177b - 1) & c0629x.f7179d;
        c0629x.f7177b = i11;
        ((Object[]) c0629x.f7180e)[i11] = q6;
        if (i11 == c0629x.f7178c) {
            c0629x.d();
        }
        Object obj = this.l;
        if (obj != null) {
            q6.f11867c = this.f11879m;
            this.l = null;
        } else {
            C0.B b5 = this.f11983b;
            Object[] objArr = this.f11982a;
            q6.f11867c = b5.g(i6, false, objArr, false);
            obj = objArr[0];
        }
        Object obj2 = obj;
        this.f11987f = i6;
        this.f11878k = i6;
        if (this.f11988g < 0) {
            this.f11988g = i6;
        }
        int i12 = !this.f11984c ? i8 - q6.f11867c : i8 + q6.f11867c;
        if (qK != null) {
            qK.f11866b = iL - i12;
        }
        this.f11983b.d(obj2, i6, q6.f11867c, i7, i12);
        return q6.f11867c;
    }

    /* JADX WARN: Code restructure failed: missing block: B:103:0x012a, code lost:
    
        return true;
     */
    /* JADX WARN: Removed duplicated region for block: B:105:0x012d  */
    /* JADX WARN: Removed duplicated region for block: B:86:0x00fb A[LOOP:2: B:86:0x00fb->B:102:0x011f, LOOP_START, PHI: r5 r8 r9
      0x00fb: PHI (r5v12 int) = (r5v6 int), (r5v17 int) binds: [B:85:0x00f9, B:102:0x011f] A[DONT_GENERATE, DONT_INLINE]
      0x00fb: PHI (r8v19 int) = (r8v17 int), (r8v20 int) binds: [B:85:0x00f9, B:102:0x011f] A[DONT_GENERATE, DONT_INLINE]
      0x00fb: PHI (r9v8 int) = (r9v6 int), (r9v10 int) binds: [B:85:0x00f9, B:102:0x011f] A[DONT_GENERATE, DONT_INLINE]] */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final boolean y(int i6, boolean z6) {
        int i7;
        int i8;
        boolean z7;
        int iU;
        int i9;
        int i10;
        int i11 = this.f11987f;
        if (i11 < 0) {
            int i12 = this.f11990i;
            i7 = i12 != -1 ? i12 : 0;
            i8 = (this.f11877j.L() > 0 ? (k(this.f11878k).f11981a + this.f11986e) - 1 : i7) % this.f11986e;
            z7 = false;
            iU = 0;
        } else {
            if (i11 > this.f11878k) {
                return false;
            }
            i7 = i11 - 1;
            i8 = k(i11).f11981a;
            int iR = r(false);
            if (iR < 0) {
                i8--;
                iU = Integer.MAX_VALUE;
                for (int i13 = this.f11986e - 1; i13 >= 0; i13--) {
                    iU = this.f11984c ? u(i13) : v(i13);
                    if (iU != Integer.MAX_VALUE) {
                        break;
                    }
                }
            } else {
                iU = this.f11984c ? g(null, iR, true) : i(null, iR, false);
            }
            if (!this.f11984c ? v(i8) <= iU : u(i8) >= iU) {
                i8--;
                if (i8 < 0) {
                    i8 = this.f11986e - 1;
                    iU = this.f11984c ? f(true, null) : h(false, null);
                }
            }
            z7 = true;
        }
        boolean z8 = false;
        loop1: while (true) {
            if (i8 >= 0) {
                if (i7 < 0 || (!z6 && d(i6))) {
                    break;
                }
                int iU2 = this.f11984c ? u(i8) : v(i8);
                if (iU2 == Integer.MAX_VALUE || iU2 == Integer.MIN_VALUE) {
                    if (i8 == this.f11986e - 1) {
                        iU2 = this.f11984c ? u(0) : v(0);
                        if (iU2 != Integer.MAX_VALUE && iU2 != Integer.MIN_VALUE) {
                            if (this.f11984c) {
                                i10 = this.f11985d;
                                iU2 += i10;
                            } else {
                                i9 = this.f11985d;
                                i10 = -i9;
                                iU2 += i10;
                            }
                        }
                    } else {
                        iU2 = this.f11984c ? v(i8 + 1) : u(i8 + 1);
                    }
                    int i14 = i7 - 1;
                    int iX = x(i7, i8, iU2);
                    if (z7) {
                        while (true) {
                            if (!this.f11984c) {
                                if (iU2 - iX <= iU) {
                                    break;
                                }
                                if (i14 < 0) {
                                    break loop1;
                                }
                                break loop1;
                                break loop1;
                            }
                            if (iU2 + iX >= iU) {
                                break;
                            }
                            if (i14 < 0 || (!z6 && d(i6))) {
                                break loop1;
                            }
                            iU2 += this.f11984c ? iX + this.f11985d : (-iX) - this.f11985d;
                            int i15 = i14 - 1;
                            int iX2 = x(i14, i8, iU2);
                            i14 = i15;
                            iX = iX2;
                        }
                    } else {
                        z7 = true;
                        iU = this.f11984c ? u(i8) : v(i8);
                    }
                    i7 = i14;
                    i8--;
                    z8 = true;
                } else if (this.f11984c) {
                    i10 = this.f11985d;
                    iU2 += i10;
                    int i142 = i7 - 1;
                    int iX3 = x(i7, i8, iU2);
                    if (z7) {
                    }
                    i7 = i142;
                    i8--;
                    z8 = true;
                } else {
                    i9 = this.f11985d;
                    i10 = -i9;
                    iU2 += i10;
                    int i1422 = i7 - 1;
                    int iX32 = x(i7, i8, iU2);
                    if (z7) {
                    }
                    i7 = i1422;
                    i8--;
                    z8 = true;
                }
            } else {
                if (z6) {
                    break;
                }
                iU = this.f11984c ? f(true, null) : h(false, null);
                i8 = this.f11986e - 1;
            }
        }
        return z8;
    }
}
