package defpackage;

import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;

/* renamed from: ᵫʞ, reason: contains not printable characters */
/* loaded from: classes3.dex */
public final class C3922 {

    /* renamed from: ˇʼʤˎ, reason: contains not printable characters */
    public final int f14811;

    /* renamed from: ˎˏʜʾ, reason: contains not printable characters */
    public final boolean f14812;

    /* renamed from: ˏˋٴ, reason: contains not printable characters */
    public final int f14813;

    /* renamed from: ˏᵙ, reason: contains not printable characters */
    public final int[] f14814;

    /* renamed from: ᵥᵯˎ, reason: contains not printable characters */
    public final ArrayList f14815;

    /* renamed from: ᵴᵳ, reason: contains not printable characters */
    public final int[] f14816;

    /* renamed from: ᵻᵢﹳᵰ, reason: contains not printable characters */
    public final ˋˌ f14817;

    public C3922(ˋˌ r11, ArrayList arrayList, int[] iArr, int[] iArr2) {
        int i;
        C3307 c3307;
        int i2;
        this.f14815 = arrayList;
        this.f14816 = iArr;
        this.f14814 = iArr2;
        Arrays.fill(iArr, 0);
        Arrays.fill(iArr2, 0);
        this.f14817 = r11;
        int i3 = r11.ˌʾˀ();
        this.f14811 = i3;
        int i4 = r11.ᵳٴᵶ();
        this.f14813 = i4;
        this.f14812 = true;
        C3307 c33072 = arrayList.isEmpty() ? null : (C3307) arrayList.get(0);
        if (c33072 == null || c33072.f12390 != 0 || c33072.f12391 != 0) {
            arrayList.add(0, new C3307(0, 0, 0));
        }
        arrayList.add(new C3307(i3, i4, 0));
        int size = arrayList.size();
        int i5 = 0;
        while (i5 < size) {
            Object obj = arrayList.get(i5);
            i5++;
            C3307 c33073 = (C3307) obj;
            for (int i6 = 0; i6 < c33073.f12389; i6++) {
                int i7 = c33073.f12390 + i6;
                int i8 = c33073.f12391 + i6;
                int i9 = r11.ˏᵙ(i7, i8) ? 1 : 2;
                iArr[i7] = (i8 << 4) | i9;
                iArr2[i8] = (i7 << 4) | i9;
            }
        }
        if (this.f14812) {
            int size2 = arrayList.size();
            int i10 = 0;
            int i11 = 0;
            while (i11 < size2) {
                Object obj2 = arrayList.get(i11);
                i11++;
                C3307 c33074 = (C3307) obj2;
                while (true) {
                    i = c33074.f12390;
                    if (i10 < i) {
                        if (iArr[i10] == 0) {
                            int size3 = arrayList.size();
                            int i12 = 0;
                            int i13 = 0;
                            while (true) {
                                if (i12 < size3) {
                                    c3307 = (C3307) arrayList.get(i12);
                                    while (true) {
                                        i2 = c3307.f12391;
                                        if (i13 < i2) {
                                            if (iArr2[i13] == 0 && r11.ᵻᵢﹳᵰ(i10, i13)) {
                                                int i14 = r11.ˏᵙ(i10, i13) ? 8 : 4;
                                                iArr[i10] = (i13 << 4) | i14;
                                                iArr2[i13] = i14 | (i10 << 4);
                                            } else {
                                                i13++;
                                            }
                                        }
                                    }
                                }
                                i13 = c3307.f12389 + i2;
                                i12++;
                            }
                        }
                        i10++;
                    }
                }
                i10 = c33074.f12389 + i;
            }
        }
    }

    /* renamed from: ᵴᵳ, reason: contains not printable characters */
    public static C5458 m8719(ArrayDeque arrayDeque, int i, boolean z) {
        C5458 c5458;
        Iterator it = arrayDeque.iterator();
        while (true) {
            if (!it.hasNext()) {
                c5458 = null;
                break;
            }
            c5458 = (C5458) it.next();
            if (c5458.f20495 == i && c5458.f20494 == z) {
                it.remove();
                break;
            }
        }
        while (it.hasNext()) {
            C5458 c54582 = (C5458) it.next();
            if (z) {
                c54582.f20496--;
            } else {
                c54582.f20496++;
            }
        }
        return c5458;
    }

    /* renamed from: ᵥᵯˎ, reason: contains not printable characters */
    public final void m8720(ˊᵘʛ r19) {
        int[] iArr;
        ˋˌ r15;
        int i;
        int i2;
        ArrayList arrayList;
        C3922 c3922 = this;
        C4372 c4372 = new C4372(r19);
        ArrayDeque arrayDeque = new ArrayDeque();
        ArrayList arrayList2 = c3922.f14815;
        boolean z = true;
        int size = arrayList2.size() - 1;
        int i3 = c3922.f14811;
        int i4 = c3922.f14813;
        int i5 = i3;
        while (size >= 0) {
            C3307 c3307 = (C3307) arrayList2.get(size);
            int i6 = c3307.f12390;
            int i7 = c3307.f12389;
            int i8 = i6 + i7;
            int i9 = c3307.f12391;
            int i10 = i9 + i7;
            while (true) {
                iArr = c3922.f14816;
                r15 = c3922.f14817;
                boolean z2 = z;
                i = 0;
                if (i5 <= i8) {
                    break;
                }
                i5--;
                int i11 = iArr[i5];
                if ((i11 & 12) != 0) {
                    arrayList = arrayList2;
                    int i12 = i11 >> 4;
                    C5458 c5458M8719 = m8719(arrayDeque, i12, false);
                    if (c5458M8719 != null) {
                        int i13 = (i3 - c5458M8719.f20496) - 1;
                        c4372.mo4403(i5, i13);
                        if ((i11 & 4) != 0) {
                            c4372.mo4404(i13, z2 ? 1 : 0, r15.ˌᵜᵹᵩ(i5, i12));
                        }
                    } else {
                        arrayDeque.add(new C5458(i5, (i3 - i5) - (z2 ? 1 : 0), z2));
                    }
                } else {
                    arrayList = arrayList2;
                    c4372.mo4402(i5, z2 ? 1 : 0);
                    i3--;
                }
                arrayList2 = arrayList;
                z = true;
            }
            ArrayList arrayList3 = arrayList2;
            while (i4 > i10) {
                i4--;
                int i14 = c3922.f14814[i4];
                if ((i14 & 12) != 0) {
                    int i15 = i14 >> 4;
                    C5458 c5458M87192 = m8719(arrayDeque, i15, true);
                    if (c5458M87192 == null) {
                        arrayDeque.add(new C5458(i4, i3 - i5, false));
                        i2 = 0;
                    } else {
                        i2 = 0;
                        c4372.mo4403((i3 - c5458M87192.f20496) - 1, i5);
                        if ((i14 & 4) != 0) {
                            c4372.mo4404(i5, 1, r15.ˌᵜᵹᵩ(i15, i4));
                        }
                    }
                } else {
                    i2 = i;
                    c4372.mo4401(i5, 1);
                    i3++;
                }
                c3922 = this;
                i = i2;
            }
            int i16 = i9;
            int i17 = i6;
            while (i < i7) {
                if ((iArr[i17] & 15) == 2) {
                    c4372.mo4404(i17, 1, r15.ˌᵜᵹᵩ(i17, i16));
                }
                i17++;
                i16++;
                i++;
            }
            size--;
            c3922 = this;
            z = true;
            i4 = i9;
            i5 = i6;
            arrayList2 = arrayList3;
        }
        c4372.m9357();
    }
}
