package p037.p091.p095;

import p037.p091.p095.AbstractC2183;
import p037.p091.p095.C2127;

/* JADX INFO: renamed from: މ.މ.ލ.ޟ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes.dex */
public final class C2185 extends AbstractC2183 {
    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final int m4246(boolean z) {
        boolean z2 = false;
        if (z) {
            for (int i = this.f6893; i >= this.f6892; i--) {
                int i2 = mo4101(i).f6896;
                if (i2 == 0) {
                    z2 = true;
                } else if (z2 && i2 == this.f6891 - 1) {
                    return i;
                }
            }
            return -1;
        }
        for (int i3 = this.f6892; i3 <= this.f6893; i3++) {
            int i4 = mo4101(i3).f6896;
            if (i4 == this.f6891 - 1) {
                z2 = true;
            } else if (z2 && i4 == 0) {
                return i3;
            }
        }
        return -1;
    }

    @Override // p037.p091.p095.AbstractC2124
    /* JADX INFO: renamed from: ֏ */
    public int mo4089(boolean z, int i, int[] iArr) {
        int i2;
        int iM4160 = ((C2127.C2129) this.f6888).m4160(i);
        AbstractC2183.C2184 c2184Mo4101 = mo4101(i);
        int i3 = c2184Mo4101.f6896;
        if (this.f6889) {
            i2 = i3;
            int i4 = i2;
            int i5 = 1;
            int i6 = iM4160;
            for (int i7 = i + 1; i5 < this.f6891 && i7 <= this.f6893; i7++) {
                AbstractC2183.C2184 c2184Mo41012 = mo4101(i7);
                i6 += c2184Mo41012.f7096;
                int i8 = c2184Mo41012.f6896;
                if (i8 != i4) {
                    i5++;
                    if (!z ? i6 >= iM4160 : i6 <= iM4160) {
                        i4 = i8;
                    } else {
                        iM4160 = i6;
                        i = i7;
                        i2 = i8;
                        i4 = i2;
                    }
                }
            }
        } else {
            int i9 = 1;
            int i10 = i3;
            AbstractC2183.C2184 c2184Mo41013 = c2184Mo4101;
            int i11 = iM4160;
            iM4160 = ((C2127.C2129) this.f6888).m4163(i) + iM4160;
            i2 = i10;
            for (int i12 = i - 1; i9 < this.f6891 && i12 >= this.f6892; i12--) {
                i11 -= c2184Mo41013.f7096;
                c2184Mo41013 = mo4101(i12);
                int i13 = c2184Mo41013.f6896;
                if (i13 != i10) {
                    i9++;
                    int iM4163 = ((C2127.C2129) this.f6888).m4163(i12) + i11;
                    if (!z ? iM4163 >= iM4160 : iM4163 <= iM4160) {
                        i10 = i13;
                    } else {
                        iM4160 = iM4163;
                        i = i12;
                        i2 = i13;
                        i10 = i2;
                    }
                }
            }
        }
        if (iArr != null) {
            iArr[0] = i2;
            iArr[1] = i;
        }
        return iM4160;
    }

    @Override // p037.p091.p095.AbstractC2124
    /* JADX INFO: renamed from: ؠ */
    public int mo4096(boolean z, int i, int[] iArr) {
        int iM4163;
        int iM4160 = ((C2127.C2129) this.f6888).m4160(i);
        AbstractC2183.C2184 c2184Mo4101 = mo4101(i);
        int i2 = c2184Mo4101.f6896;
        if (this.f6889) {
            int i3 = 1;
            iM4163 = iM4160 - ((C2127.C2129) this.f6888).m4163(i);
            int i4 = i2;
            for (int i5 = i - 1; i3 < this.f6891 && i5 >= this.f6892; i5--) {
                iM4160 -= c2184Mo4101.f7096;
                c2184Mo4101 = mo4101(i5);
                int i6 = c2184Mo4101.f6896;
                if (i6 != i4) {
                    i3++;
                    int iM41632 = iM4160 - ((C2127.C2129) this.f6888).m4163(i5);
                    if (!z ? iM41632 >= iM4163 : iM41632 <= iM4163) {
                        i4 = i6;
                    } else {
                        iM4163 = iM41632;
                        i = i5;
                        i2 = i6;
                        i4 = i2;
                    }
                }
            }
        } else {
            int i7 = i2;
            int i8 = i7;
            int i9 = 1;
            int i10 = iM4160;
            for (int i11 = i + 1; i9 < this.f6891 && i11 <= this.f6893; i11++) {
                AbstractC2183.C2184 c2184Mo41012 = mo4101(i11);
                i10 += c2184Mo41012.f7096;
                int i12 = c2184Mo41012.f6896;
                if (i12 != i8) {
                    i9++;
                    if (!z ? i10 >= iM4160 : i10 <= iM4160) {
                        i8 = i12;
                    } else {
                        iM4160 = i10;
                        i = i11;
                        i7 = i12;
                        i8 = i7;
                    }
                }
            }
            iM4163 = iM4160;
            i2 = i7;
        }
        if (iArr != null) {
            iArr[0] = i2;
            iArr[1] = i;
        }
        return iM4163;
    }

    /* JADX WARN: Code restructure failed: missing block: B:104:0x0137, code lost:
    
        return true;
     */
    /* JADX WARN: Code restructure failed: missing block: B:105:0x0138, code lost:
    
        r6 = r10;
     */
    /* JADX WARN: Code restructure failed: missing block: B:112:0x014f, code lost:
    
        return r9;
     */
    /* JADX WARN: Removed duplicated region for block: B:106:0x013a  */
    /* JADX WARN: Removed duplicated region for block: B:87:0x0108 A[LOOP:2: B:87:0x0108->B:103:0x012c, LOOP_START, PHI: r6 r9 r10
      0x0108: PHI (r6v13 int) = (r6v6 int), (r6v18 int) binds: [B:86:0x0106, B:103:0x012c] A[DONT_GENERATE, DONT_INLINE]
      0x0108: PHI (r9v20 int) = (r9v18 int), (r9v21 int) binds: [B:86:0x0106, B:103:0x012c] A[DONT_GENERATE, DONT_INLINE]
      0x0108: PHI (r10v6 int) = (r10v5 int), (r10v8 int) binds: [B:86:0x0106, B:103:0x012c] A[DONT_GENERATE, DONT_INLINE]] */
    @Override // p037.p091.p095.AbstractC2183
    /* JADX INFO: renamed from: ށ */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public boolean mo4243(int i, boolean z) {
        int i2;
        int i3;
        boolean z2;
        int iM4248;
        int i4;
        int i5;
        int iM4159 = ((C2127.C2129) this.f6888).m4159();
        int i6 = this.f6893;
        if (i6 < 0) {
            int i7 = this.f6895;
            i2 = i7 != -1 ? i7 : 0;
            i3 = (this.f7092.m3350() > 0 ? mo4101(m4241()).f6896 + 1 : i2) % this.f6891;
            z2 = false;
            iM4248 = 0;
        } else {
            if (i6 < m4241()) {
                return false;
            }
            int i8 = this.f6893;
            i2 = i8 + 1;
            i3 = mo4101(i8).f6896;
            int iM4246 = m4246(true);
            if (iM4246 < 0) {
                iM4248 = Integer.MIN_VALUE;
                for (int i9 = 0; i9 < this.f6891; i9++) {
                    iM4248 = this.f6889 ? m4248(i9) : m4247(i9);
                    if (iM4248 != Integer.MIN_VALUE) {
                        break;
                    }
                }
            } else {
                iM4248 = this.f6889 ? mo4096(false, iM4246, (int[]) null) : mo4089(true, iM4246, (int[]) null);
            }
            if (!this.f6889 ? m4247(i3) >= iM4248 : m4248(i3) <= iM4248) {
                i3++;
                if (i3 == this.f6891) {
                    iM4248 = this.f6889 ? m4097(false, (int[]) null) : m4090(true, (int[]) null);
                    i3 = 0;
                }
            }
            z2 = true;
        }
        boolean z3 = false;
        loop1: while (true) {
            if (i3 < this.f6891) {
                if (i2 == iM4159 || (!z && m4093(i))) {
                    break;
                }
                int iM42482 = this.f6889 ? m4248(i3) : m4247(i3);
                if (iM42482 == Integer.MAX_VALUE || iM42482 == Integer.MIN_VALUE) {
                    if (i3 == 0) {
                        iM42482 = this.f6889 ? m4248(this.f6891 - 1) : m4247(this.f6891 - 1);
                        if (iM42482 != Integer.MAX_VALUE && iM42482 != Integer.MIN_VALUE) {
                            if (this.f6889) {
                                i5 = this.f6890;
                                i4 = -i5;
                                iM42482 += i4;
                            } else {
                                i4 = this.f6890;
                                iM42482 += i4;
                            }
                        }
                    } else {
                        iM42482 = this.f6889 ? m4247(i3 - 1) : m4248(i3 - 1);
                    }
                    int i10 = i2 + 1;
                    int iM4239 = m4239(i2, i3, iM42482);
                    if (z2) {
                        while (true) {
                            if (!this.f6889) {
                                if (iM42482 + iM4239 >= iM4248) {
                                    break;
                                }
                                if (i10 == iM4159) {
                                    break loop1;
                                }
                                break loop1;
                                break loop1;
                            }
                            if (iM42482 - iM4239 <= iM4248) {
                                break;
                            }
                            if (i10 == iM4159 || (!z && m4093(i))) {
                                break loop1;
                            }
                            iM42482 += this.f6889 ? (-iM4239) - this.f6890 : iM4239 + this.f6890;
                            int i11 = i10 + 1;
                            int iM42392 = m4239(i10, i3, iM42482);
                            i10 = i11;
                            iM4239 = iM42392;
                        }
                    } else {
                        iM4248 = this.f6889 ? m4248(i3) : m4247(i3);
                        i2 = i10;
                        z2 = true;
                    }
                    i3++;
                    z3 = true;
                } else if (this.f6889) {
                    i5 = this.f6890;
                    i4 = -i5;
                    iM42482 += i4;
                    int i102 = i2 + 1;
                    int iM42393 = m4239(i2, i3, iM42482);
                    if (z2) {
                    }
                    i3++;
                    z3 = true;
                } else {
                    i4 = this.f6890;
                    iM42482 += i4;
                    int i1022 = i2 + 1;
                    int iM423932 = m4239(i2, i3, iM42482);
                    if (z2) {
                    }
                    i3++;
                    z3 = true;
                }
            } else {
                if (z) {
                    return z3;
                }
                iM4248 = this.f6889 ? m4097(false, (int[]) null) : m4090(true, (int[]) null);
                i3 = 0;
            }
        }
    }

    /* JADX WARN: Code restructure failed: missing block: B:103:0x012a, code lost:
    
        return true;
     */
    /* JADX WARN: Code restructure failed: missing block: B:104:0x012b, code lost:
    
        r5 = r9;
     */
    /* JADX WARN: Code restructure failed: missing block: B:111:0x0142, code lost:
    
        return r8;
     */
    /* 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 (r5v13 int) = (r5v6 int), (r5v19 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 (r9v7 int) = (r9v6 int), (r9v9 int) binds: [B:85:0x00f9, B:102:0x011f] A[DONT_GENERATE, DONT_INLINE]] */
    @Override // p037.p091.p095.AbstractC2183
    /* JADX INFO: renamed from: ރ */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public boolean mo4245(int i, boolean z) {
        int i2;
        int i3;
        boolean z2;
        int iM4247;
        int i4;
        int i5;
        int i6 = this.f6892;
        if (i6 < 0) {
            int i7 = this.f6895;
            i2 = i7 != -1 ? i7 : 0;
            i3 = (this.f7092.m3350() > 0 ? (mo4101(this.f7093).f6896 + this.f6891) - 1 : i2) % this.f6891;
            z2 = false;
            iM4247 = 0;
        } else {
            if (i6 > this.f7093) {
                return false;
            }
            i2 = i6 - 1;
            i3 = mo4101(i6).f6896;
            int iM4246 = m4246(false);
            if (iM4246 < 0) {
                i3--;
                iM4247 = Integer.MAX_VALUE;
                for (int i8 = this.f6891 - 1; i8 >= 0; i8--) {
                    iM4247 = this.f6889 ? m4247(i8) : m4248(i8);
                    if (iM4247 != Integer.MAX_VALUE) {
                        break;
                    }
                }
            } else {
                iM4247 = this.f6889 ? mo4089(true, iM4246, (int[]) null) : mo4096(false, iM4246, (int[]) null);
            }
            if (!this.f6889 ? m4248(i3) <= iM4247 : m4247(i3) >= iM4247) {
                i3--;
                if (i3 < 0) {
                    i3 = this.f6891 - 1;
                    iM4247 = this.f6889 ? m4090(true, (int[]) null) : m4097(false, (int[]) null);
                }
            }
            z2 = true;
        }
        boolean z3 = false;
        loop1: while (true) {
            if (i3 >= 0) {
                if (i2 < 0 || (!z && m4099(i))) {
                    break;
                }
                int iM42472 = this.f6889 ? m4247(i3) : m4248(i3);
                if (iM42472 == Integer.MAX_VALUE || iM42472 == Integer.MIN_VALUE) {
                    if (i3 == this.f6891 - 1) {
                        iM42472 = this.f6889 ? m4247(0) : m4248(0);
                        if (iM42472 != Integer.MAX_VALUE && iM42472 != Integer.MIN_VALUE) {
                            if (this.f6889) {
                                i5 = this.f6890;
                                iM42472 += i5;
                            } else {
                                i4 = this.f6890;
                                i5 = -i4;
                                iM42472 += i5;
                            }
                        }
                    } else {
                        iM42472 = this.f6889 ? m4248(i3 + 1) : m4247(i3 + 1);
                    }
                    int i9 = i2 - 1;
                    int iM4240 = m4240(i2, i3, iM42472);
                    if (z2) {
                        while (true) {
                            if (!this.f6889) {
                                if (iM42472 - iM4240 <= iM4247) {
                                    break;
                                }
                                if (i9 < 0) {
                                    break loop1;
                                }
                                break loop1;
                                break loop1;
                            }
                            if (iM42472 + iM4240 >= iM4247) {
                                break;
                            }
                            if (i9 < 0 || (!z && m4099(i))) {
                                break loop1;
                            }
                            iM42472 += this.f6889 ? iM4240 + this.f6890 : (-iM4240) - this.f6890;
                            int i10 = i9 - 1;
                            int iM42402 = m4240(i9, i3, iM42472);
                            i9 = i10;
                            iM4240 = iM42402;
                        }
                    } else {
                        iM4247 = this.f6889 ? m4247(i3) : m4248(i3);
                        i2 = i9;
                        z2 = true;
                    }
                    i3--;
                    z3 = true;
                } else if (this.f6889) {
                    i5 = this.f6890;
                    iM42472 += i5;
                    int i92 = i2 - 1;
                    int iM42403 = m4240(i2, i3, iM42472);
                    if (z2) {
                    }
                    i3--;
                    z3 = true;
                } else {
                    i4 = this.f6890;
                    i5 = -i4;
                    iM42472 += i5;
                    int i922 = i2 - 1;
                    int iM424032 = m4240(i2, i3, iM42472);
                    if (z2) {
                    }
                    i3--;
                    z3 = true;
                }
            } else {
                if (z) {
                    return z3;
                }
                iM4247 = this.f6889 ? m4090(true, (int[]) null) : m4097(false, (int[]) null);
                i3 = this.f6891 - 1;
            }
        }
    }

    /* JADX INFO: renamed from: ބ, reason: contains not printable characters */
    public int m4247(int i) {
        int i2;
        AbstractC2183.C2184 c2184Mo4101;
        int i3 = this.f6892;
        if (i3 < 0) {
            return Integer.MIN_VALUE;
        }
        if (this.f6889) {
            int iM4160 = ((C2127.C2129) this.f6888).m4160(i3);
            if (mo4101(this.f6892).f6896 == i) {
                return iM4160;
            }
            int i4 = this.f6892;
            do {
                i4++;
                if (i4 <= m4241()) {
                    c2184Mo4101 = mo4101(i4);
                    iM4160 += c2184Mo4101.f7096;
                }
            } while (c2184Mo4101.f6896 != i);
            return iM4160;
        }
        int iM41602 = ((C2127.C2129) this.f6888).m4160(this.f6893);
        AbstractC2183.C2184 c2184Mo41012 = mo4101(this.f6893);
        if (c2184Mo41012.f6896 == i) {
            i2 = c2184Mo41012.f7097;
        } else {
            int i5 = this.f6893;
            do {
                i5--;
                if (i5 >= this.f7093) {
                    iM41602 -= c2184Mo41012.f7096;
                    c2184Mo41012 = mo4101(i5);
                }
            } while (c2184Mo41012.f6896 != i);
            i2 = c2184Mo41012.f7097;
        }
        return iM41602 + i2;
        return Integer.MIN_VALUE;
    }

    /* JADX INFO: renamed from: ޅ, reason: contains not printable characters */
    public int m4248(int i) {
        AbstractC2183.C2184 c2184Mo4101;
        int i2;
        int i3 = this.f6892;
        if (i3 < 0) {
            return Integer.MAX_VALUE;
        }
        if (!this.f6889) {
            int iM4160 = ((C2127.C2129) this.f6888).m4160(i3);
            if (mo4101(this.f6892).f6896 == i) {
                return iM4160;
            }
            int i4 = this.f6892;
            do {
                i4++;
                if (i4 <= m4241()) {
                    c2184Mo4101 = mo4101(i4);
                    iM4160 += c2184Mo4101.f7096;
                }
            } while (c2184Mo4101.f6896 != i);
            return iM4160;
        }
        int iM41602 = ((C2127.C2129) this.f6888).m4160(this.f6893);
        AbstractC2183.C2184 c2184Mo41012 = mo4101(this.f6893);
        if (c2184Mo41012.f6896 == i) {
            i2 = c2184Mo41012.f7097;
        } else {
            int i5 = this.f6893;
            do {
                i5--;
                if (i5 >= this.f7093) {
                    iM41602 -= c2184Mo41012.f7096;
                    c2184Mo41012 = mo4101(i5);
                }
            } while (c2184Mo41012.f6896 != i);
            i2 = c2184Mo41012.f7097;
        }
        return iM41602 - i2;
        return Integer.MAX_VALUE;
    }
}
