package w;

import androidx.constraintlayout.core.widgets.ConstraintWidget$DimensionBehaviour;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;

/* JADX INFO: loaded from: classes.dex */
public final class g extends m {

    /* JADX INFO: renamed from: f1, reason: collision with root package name */
    public d[] f34100f1;
    public int I0 = -1;
    public int J0 = -1;
    public int K0 = -1;
    public int L0 = -1;
    public int M0 = -1;
    public int N0 = -1;
    public float O0 = 0.5f;
    public float P0 = 0.5f;
    public float Q0 = 0.5f;
    public float R0 = 0.5f;
    public float S0 = 0.5f;
    public float T0 = 0.5f;
    public int U0 = 0;
    public int V0 = 0;
    public int W0 = 2;
    public int X0 = 2;
    public int Y0 = 0;
    public int Z0 = -1;
    public int a1 = 0;

    /* JADX INFO: renamed from: b1, reason: collision with root package name */
    public final ArrayList f34096b1 = new ArrayList();

    /* JADX INFO: renamed from: c1, reason: collision with root package name */
    public d[] f34097c1 = null;

    /* JADX INFO: renamed from: d1, reason: collision with root package name */
    public d[] f34098d1 = null;

    /* JADX INFO: renamed from: e1, reason: collision with root package name */
    public int[] f34099e1 = null;

    /* JADX INFO: renamed from: g1, reason: collision with root package name */
    public int f34101g1 = 0;

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Removed duplicated region for block: B:397:0x0758  */
    /* JADX WARN: Removed duplicated region for block: B:399:0x075e  */
    /* JADX WARN: Removed duplicated region for block: B:406:0x0771  */
    /* JADX WARN: Removed duplicated region for block: B:407:0x0774  */
    /* JADX WARN: Removed duplicated region for block: B:414:0x0790  */
    /* JADX WARN: Removed duplicated region for block: B:415:0x0792  */
    /* JADX WARN: Removed duplicated region for block: B:74:0x0112  */
    @Override // w.m
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void V(int i10, int i11, int i12, int i13) {
        int i14;
        int i15;
        int i16;
        int i17;
        int[] iArr;
        int i18;
        f fVar;
        int i19;
        char c6;
        int i20;
        char c10;
        int i21;
        int i22;
        ConstraintWidget$DimensionBehaviour constraintWidget$DimensionBehaviour;
        int i23;
        int i24;
        int i25;
        ConstraintWidget$DimensionBehaviour constraintWidget$DimensionBehaviour2;
        d dVar;
        int i26;
        int i27;
        int iCeil;
        int iCeil2;
        Object obj;
        d dVar2;
        int i28;
        ConstraintWidget$DimensionBehaviour constraintWidget$DimensionBehaviour3;
        int i29;
        ConstraintWidget$DimensionBehaviour constraintWidget$DimensionBehaviour4;
        int i30;
        int i31;
        ConstraintWidget$DimensionBehaviour constraintWidget$DimensionBehaviour5;
        d dVar3;
        int i32;
        int i33;
        int i34 = this.f34107w0;
        ConstraintWidget$DimensionBehaviour constraintWidget$DimensionBehaviour6 = ConstraintWidget$DimensionBehaviour.f1013b;
        ConstraintWidget$DimensionBehaviour constraintWidget$DimensionBehaviour7 = ConstraintWidget$DimensionBehaviour.f1014c;
        if (i34 > 0) {
            d dVar4 = this.V;
            androidx.constraintlayout.widget.d dVar5 = dVar4 != null ? ((e) dVar4).z0 : null;
            if (dVar5 == null) {
                this.E0 = 0;
                this.F0 = 0;
                this.D0 = false;
                return;
            }
            for (int i35 = 0; i35 < this.f34107w0; i35++) {
                d dVar6 = this.f34106v0[i35];
                if (dVar6 != null && !(dVar6 instanceof h)) {
                    ConstraintWidget$DimensionBehaviour constraintWidget$DimensionBehaviourL = dVar6.l(0);
                    ConstraintWidget$DimensionBehaviour constraintWidget$DimensionBehaviourL2 = dVar6.l(1);
                    if (constraintWidget$DimensionBehaviourL != constraintWidget$DimensionBehaviour7 || dVar6.f34062r == 1 || constraintWidget$DimensionBehaviourL2 != constraintWidget$DimensionBehaviour7 || dVar6.f34064s == 1) {
                        if (constraintWidget$DimensionBehaviourL == constraintWidget$DimensionBehaviour7) {
                            constraintWidget$DimensionBehaviourL = constraintWidget$DimensionBehaviour6;
                        }
                        if (constraintWidget$DimensionBehaviourL2 == constraintWidget$DimensionBehaviour7) {
                            constraintWidget$DimensionBehaviourL2 = constraintWidget$DimensionBehaviour6;
                        }
                        x.b bVar = this.G0;
                        bVar.f34284a = constraintWidget$DimensionBehaviourL;
                        bVar.f34285b = constraintWidget$DimensionBehaviourL2;
                        bVar.f34286c = dVar6.s();
                        bVar.f34287d = dVar6.m();
                        dVar5.b(dVar6, bVar);
                        dVar6.Q(bVar.f34288e);
                        dVar6.N(bVar.f34289f);
                        dVar6.K(bVar.f34290g);
                    }
                }
            }
        }
        int i36 = this.B0;
        int i37 = this.C0;
        int i38 = this.f34109x0;
        int i39 = this.f34110y0;
        int[] iArr2 = new int[2];
        int i40 = (i11 - i36) - i37;
        int i41 = this.a1;
        if (i41 == 1) {
            i40 = (i13 - i38) - i39;
        }
        int i42 = i40;
        if (i41 == 0) {
            if (this.I0 == -1) {
                this.I0 = 0;
            }
            if (this.J0 == -1) {
                this.J0 = 0;
            }
        } else {
            if (this.I0 == -1) {
                this.I0 = 0;
            }
            if (this.J0 == -1) {
                this.J0 = 0;
            }
        }
        d[] dVarArr = this.f34106v0;
        int i43 = 0;
        int i44 = 0;
        while (true) {
            i14 = this.f34107w0;
            if (i43 >= i14) {
                break;
            }
            if (this.f34106v0[i43].f34045i0 == 8) {
                i44++;
            }
            i43++;
        }
        if (i44 > 0) {
            dVarArr = new d[i14 - i44];
            int i45 = 0;
            i14 = 0;
            while (i45 < this.f34107w0) {
                d dVar7 = this.f34106v0[i45];
                int[] iArr3 = iArr2;
                int i46 = i39;
                if (dVar7.f34045i0 != 8) {
                    dVarArr[i14] = dVar7;
                    i14++;
                }
                i45++;
                iArr2 = iArr3;
                i39 = i46;
            }
        }
        int[] iArr4 = iArr2;
        int i47 = i39;
        int i48 = i14;
        d[] dVarArr2 = dVarArr;
        this.f34100f1 = dVarArr2;
        this.f34101g1 = i48;
        int i49 = this.Y0;
        ArrayList arrayList = this.f34096b1;
        if (i49 == 0) {
            i15 = i38;
            i16 = i37;
            i17 = i36;
            iArr = iArr4;
            i18 = i47;
            int i50 = this.a1;
            if (i48 != 0) {
                if (arrayList.size() == 0) {
                    fVar = new f(this, i50, this.J, this.K, this.L, this.M, i42);
                    arrayList.add(fVar);
                } else {
                    fVar = (f) arrayList.get(0);
                    fVar.f34080c = 0;
                    fVar.f34079b = null;
                    fVar.f34089l = 0;
                    fVar.f34090m = 0;
                    fVar.f34091n = 0;
                    fVar.f34092o = 0;
                    fVar.f34093p = 0;
                    fVar.f(i50, this.J, this.K, this.L, this.M, this.B0, this.f34109x0, this.C0, this.f34110y0, i42);
                }
                for (int i51 = 0; i51 < i48; i51++) {
                    fVar.a(dVarArr2[i51]);
                }
                i19 = 0;
                iArr[0] = fVar.d();
                c6 = 1;
                iArr[1] = fVar.c();
            }
            int iMin = iArr[i19] + i17 + i16;
            i20 = iArr[c6] + i15 + i18;
            if (i10 == 1073741824) {
            }
            i21 = i12;
            if (i21 != 1073741824) {
            }
            this.E0 = iMin;
            this.F0 = iMin;
            Q(iMin);
            N(iMin);
            this.D0 = this.f34107w0 <= 0 ? c10 : i19;
        }
        c cVar = this.K;
        c cVar2 = this.J;
        c cVar3 = this.L;
        c cVar4 = this.M;
        if (i49 == 1) {
            c cVar5 = cVar2;
            i15 = i38;
            i16 = i37;
            i17 = i36;
            ConstraintWidget$DimensionBehaviour constraintWidget$DimensionBehaviour8 = constraintWidget$DimensionBehaviour6;
            ConstraintWidget$DimensionBehaviour constraintWidget$DimensionBehaviour9 = constraintWidget$DimensionBehaviour7;
            iArr = iArr4;
            i18 = i47;
            int i52 = this.a1;
            if (i48 != 0) {
                arrayList.clear();
                f fVar2 = new f(this, i52, this.J, this.K, this.L, this.M, i42);
                arrayList.add(fVar2);
                if (i52 == 0) {
                    i23 = 0;
                    int i53 = 0;
                    int i54 = 0;
                    while (i54 < i48) {
                        d dVar8 = dVarArr2[i54];
                        int iY = Y(i42, dVar8);
                        ConstraintWidget$DimensionBehaviour constraintWidget$DimensionBehaviour10 = constraintWidget$DimensionBehaviour9;
                        if (dVar8.U[0] == constraintWidget$DimensionBehaviour10) {
                            i23++;
                        }
                        int i55 = i23;
                        boolean z10 = (i53 == i42 || (this.U0 + i53) + iY > i42) && fVar2.f34079b != null;
                        if ((z10 || i54 <= 0 || (i27 = this.Z0) <= 0 || i54 % i27 != 0) && !z10) {
                            constraintWidget$DimensionBehaviour9 = constraintWidget$DimensionBehaviour10;
                            i25 = i52;
                            constraintWidget$DimensionBehaviour2 = constraintWidget$DimensionBehaviour8;
                            dVar = dVar8;
                            i26 = i54;
                            if (i26 > 0) {
                                i53 = this.U0 + iY + i53;
                            }
                            fVar2.a(dVar);
                            i54 = i26 + 1;
                            i23 = i55;
                            constraintWidget$DimensionBehaviour8 = constraintWidget$DimensionBehaviour2;
                            i52 = i25;
                        } else {
                            int i56 = i52;
                            constraintWidget$DimensionBehaviour2 = constraintWidget$DimensionBehaviour8;
                            i25 = i52;
                            dVar = dVar8;
                            constraintWidget$DimensionBehaviour9 = constraintWidget$DimensionBehaviour10;
                            i26 = i54;
                            fVar2 = new f(this, i56, this.J, this.K, this.L, this.M, i42);
                            fVar2.f34091n = i26;
                            arrayList.add(fVar2);
                        }
                        i53 = iY;
                        fVar2.a(dVar);
                        i54 = i26 + 1;
                        i23 = i55;
                        constraintWidget$DimensionBehaviour8 = constraintWidget$DimensionBehaviour2;
                        i52 = i25;
                    }
                    i22 = i52;
                    constraintWidget$DimensionBehaviour = constraintWidget$DimensionBehaviour8;
                } else {
                    i22 = i52;
                    constraintWidget$DimensionBehaviour = constraintWidget$DimensionBehaviour8;
                    i23 = 0;
                    int i57 = 0;
                    int i58 = 0;
                    while (i58 < i48) {
                        d dVar9 = dVarArr2[i58];
                        int iX = X(i42, dVar9);
                        ConstraintWidget$DimensionBehaviour constraintWidget$DimensionBehaviour11 = constraintWidget$DimensionBehaviour9;
                        if (dVar9.U[1] == constraintWidget$DimensionBehaviour11) {
                            i23++;
                        }
                        int i59 = i23;
                        boolean z11 = (i57 == i42 || (this.V0 + i57) + iX > i42) && fVar2.f34079b != null;
                        if ((z11 || i58 <= 0 || (i24 = this.Z0) <= 0 || i58 % i24 != 0) && !z11) {
                            constraintWidget$DimensionBehaviour9 = constraintWidget$DimensionBehaviour11;
                            if (i58 > 0) {
                                i57 = this.V0 + iX + i57;
                            }
                            fVar2.a(dVar9);
                            i58++;
                            i23 = i59;
                        } else {
                            constraintWidget$DimensionBehaviour9 = constraintWidget$DimensionBehaviour11;
                            fVar2 = new f(this, i22, this.J, this.K, this.L, this.M, i42);
                            fVar2.f34091n = i58;
                            arrayList.add(fVar2);
                        }
                        i57 = iX;
                        fVar2.a(dVar9);
                        i58++;
                        i23 = i59;
                    }
                }
                int size = arrayList.size();
                int i60 = this.B0;
                int i61 = this.f34109x0;
                int i62 = this.C0;
                int i63 = this.f34110y0;
                ConstraintWidget$DimensionBehaviour[] constraintWidget$DimensionBehaviourArr = this.U;
                ConstraintWidget$DimensionBehaviour constraintWidget$DimensionBehaviour12 = constraintWidget$DimensionBehaviour;
                boolean z12 = constraintWidget$DimensionBehaviourArr[0] == constraintWidget$DimensionBehaviour12 || constraintWidget$DimensionBehaviourArr[1] == constraintWidget$DimensionBehaviour12;
                if (i23 > 0 && z12) {
                    for (int i64 = 0; i64 < size; i64++) {
                        f fVar3 = (f) arrayList.get(i64);
                        if (i22 == 0) {
                            fVar3.e(i42 - fVar3.d());
                        } else {
                            fVar3.e(i42 - fVar3.c());
                        }
                    }
                }
                c cVar6 = cVar;
                c cVar7 = cVar3;
                c cVar8 = cVar4;
                int i65 = 0;
                int i66 = 0;
                for (int i67 = 0; i67 < size; i67++) {
                    f fVar4 = (f) arrayList.get(i67);
                    if (i22 == 0) {
                        if (i67 < size - 1) {
                            cVar8 = ((f) arrayList.get(i67 + 1)).f34079b.K;
                            i63 = 0;
                        } else {
                            i63 = this.f34110y0;
                            cVar8 = cVar4;
                        }
                        c cVar9 = fVar4.f34079b.M;
                        fVar4.f(i22, cVar5, cVar6, cVar7, cVar8, i60, i61, i62, i63, i42);
                        int iMax = Math.max(i65, fVar4.d());
                        int iC = fVar4.c() + i66;
                        if (i67 > 0) {
                            iC += this.V0;
                        }
                        i65 = iMax;
                        i66 = iC;
                        cVar6 = cVar9;
                        i61 = 0;
                    } else {
                        if (i67 < size - 1) {
                            cVar7 = ((f) arrayList.get(i67 + 1)).f34079b.J;
                            i62 = 0;
                        } else {
                            i62 = this.C0;
                            cVar7 = cVar3;
                        }
                        c cVar10 = fVar4.f34079b.L;
                        fVar4.f(i22, cVar5, cVar6, cVar7, cVar8, i60, i61, i62, i63, i42);
                        int iD = fVar4.d() + i65;
                        int iMax2 = Math.max(i66, fVar4.c());
                        if (i67 > 0) {
                            iD += this.U0;
                        }
                        i66 = iMax2;
                        cVar5 = cVar10;
                        i65 = iD;
                        i60 = 0;
                    }
                }
                iArr[0] = i65;
                iArr[1] = i66;
            }
        } else {
            if (i49 != 2) {
                if (i49 != 3) {
                    i15 = i38;
                    i16 = i37;
                    i17 = i36;
                    iArr = iArr4;
                    i18 = i47;
                } else {
                    int i68 = this.a1;
                    if (i48 != 0) {
                        arrayList.clear();
                        c cVar11 = cVar2;
                        iArr = iArr4;
                        i18 = i47;
                        i15 = i38;
                        i16 = i37;
                        i17 = i36;
                        f fVar5 = new f(this, i68, this.J, this.K, this.L, this.M, i42);
                        arrayList.add(fVar5);
                        if (i68 == 0) {
                            int i69 = 0;
                            i29 = 0;
                            int i70 = 0;
                            int i71 = 0;
                            while (i71 < i48) {
                                i69++;
                                d dVar10 = dVarArr2[i71];
                                int i72 = i42;
                                int iY2 = Y(i72, dVar10);
                                if (dVar10.U[0] == constraintWidget$DimensionBehaviour7) {
                                    i29++;
                                }
                                int i73 = i29;
                                boolean z13 = (i70 == i72 || (this.U0 + i70) + iY2 > i72) && fVar5.f34079b != null;
                                if ((z13 || i71 <= 0 || (i33 = this.Z0) <= 0 || i69 <= i33) && !z13) {
                                    i42 = i72;
                                    i31 = i68;
                                    constraintWidget$DimensionBehaviour5 = constraintWidget$DimensionBehaviour6;
                                    dVar3 = dVar10;
                                    i32 = i71;
                                    i70 = i32 > 0 ? this.U0 + iY2 + i70 : iY2;
                                } else {
                                    int i74 = i68;
                                    i42 = i72;
                                    constraintWidget$DimensionBehaviour5 = constraintWidget$DimensionBehaviour6;
                                    dVar3 = dVar10;
                                    i31 = i68;
                                    i32 = i71;
                                    f fVar6 = new f(this, i74, this.J, this.K, this.L, this.M, i42);
                                    fVar6.f34091n = i32;
                                    arrayList.add(fVar6);
                                    fVar5 = fVar6;
                                    i70 = iY2;
                                    i69 = 1;
                                }
                                fVar5.a(dVar3);
                                i71 = i32 + 1;
                                i29 = i73;
                                constraintWidget$DimensionBehaviour6 = constraintWidget$DimensionBehaviour5;
                                i68 = i31;
                            }
                            i28 = i68;
                            constraintWidget$DimensionBehaviour3 = constraintWidget$DimensionBehaviour6;
                        } else {
                            i28 = i68;
                            constraintWidget$DimensionBehaviour3 = constraintWidget$DimensionBehaviour6;
                            int i75 = 0;
                            i29 = 0;
                            int i76 = 0;
                            int i77 = 0;
                            while (i77 < i48) {
                                int i78 = i75 + 1;
                                d dVar11 = dVarArr2[i77];
                                int i79 = i42;
                                int iX2 = X(i79, dVar11);
                                if (dVar11.U[1] == constraintWidget$DimensionBehaviour7) {
                                    i29++;
                                }
                                int i80 = i29;
                                boolean z14 = (i76 == i79 || (this.V0 + i76) + iX2 > i79) && fVar5.f34079b != null;
                                if ((z14 || i77 <= 0 || (i30 = this.Z0) <= 0 || i78 <= i30) && !z14) {
                                    constraintWidget$DimensionBehaviour4 = constraintWidget$DimensionBehaviour7;
                                    if (i77 > 0) {
                                        i76 = this.V0 + iX2 + i76;
                                        i75 = i78;
                                    } else {
                                        i75 = i78;
                                        i76 = iX2;
                                    }
                                } else {
                                    constraintWidget$DimensionBehaviour4 = constraintWidget$DimensionBehaviour7;
                                    f fVar7 = new f(this, i28, this.J, this.K, this.L, this.M, i79);
                                    fVar7.f34091n = i77;
                                    arrayList.add(fVar7);
                                    fVar5 = fVar7;
                                    i76 = iX2;
                                    i75 = 1;
                                }
                                fVar5.a(dVar11);
                                i77++;
                                i42 = i79;
                                i29 = i80;
                                constraintWidget$DimensionBehaviour7 = constraintWidget$DimensionBehaviour4;
                            }
                        }
                        int i81 = i42;
                        int size2 = arrayList.size();
                        int i82 = this.B0;
                        int i83 = this.f34109x0;
                        int i84 = this.C0;
                        int i85 = this.f34110y0;
                        ConstraintWidget$DimensionBehaviour[] constraintWidget$DimensionBehaviourArr2 = this.U;
                        ConstraintWidget$DimensionBehaviour constraintWidget$DimensionBehaviour13 = constraintWidget$DimensionBehaviour3;
                        boolean z15 = constraintWidget$DimensionBehaviourArr2[0] == constraintWidget$DimensionBehaviour13 || constraintWidget$DimensionBehaviourArr2[1] == constraintWidget$DimensionBehaviour13;
                        if (i29 > 0 && z15) {
                            for (int i86 = 0; i86 < size2; i86++) {
                                f fVar8 = (f) arrayList.get(i86);
                                if (i28 == 0) {
                                    fVar8.e(i81 - fVar8.d());
                                } else {
                                    fVar8.e(i81 - fVar8.c());
                                }
                            }
                        }
                        int i87 = i82;
                        c cVar12 = cVar;
                        c cVar13 = cVar3;
                        c cVar14 = cVar4;
                        int i88 = 0;
                        int i89 = 0;
                        for (int i90 = 0; i90 < size2; i90++) {
                            f fVar9 = (f) arrayList.get(i90);
                            if (i28 == 0) {
                                if (i90 < size2 - 1) {
                                    cVar14 = ((f) arrayList.get(i90 + 1)).f34079b.K;
                                    i85 = 0;
                                } else {
                                    i85 = this.f34110y0;
                                    cVar14 = cVar4;
                                }
                                c cVar15 = fVar9.f34079b.M;
                                fVar9.f(i28, cVar11, cVar12, cVar13, cVar14, i87, i83, i84, i85, i81);
                                int iMax3 = Math.max(i88, fVar9.d());
                                int iC2 = fVar9.c() + i89;
                                if (i90 > 0) {
                                    iC2 += this.V0;
                                }
                                i88 = iMax3;
                                i89 = iC2;
                                cVar12 = cVar15;
                                i83 = 0;
                            } else {
                                if (i90 < size2 - 1) {
                                    cVar13 = ((f) arrayList.get(i90 + 1)).f34079b.J;
                                    i84 = 0;
                                } else {
                                    i84 = this.C0;
                                    cVar13 = cVar3;
                                }
                                c cVar16 = fVar9.f34079b.L;
                                fVar9.f(i28, cVar11, cVar12, cVar13, cVar14, i87, i83, i84, i85, i81);
                                int iD2 = fVar9.d() + i88;
                                int iMax4 = Math.max(i89, fVar9.c());
                                if (i90 > 0) {
                                    iD2 += this.U0;
                                }
                                i89 = iMax4;
                                cVar11 = cVar16;
                                i88 = iD2;
                                i87 = 0;
                            }
                        }
                        iArr[0] = i88;
                        iArr[1] = i89;
                    }
                }
                int iMin2 = iArr[i19] + i17 + i16;
                i20 = iArr[c6] + i15 + i18;
                if (i10 == 1073741824) {
                    iMin2 = i11;
                    c10 = c6;
                } else {
                    if (i10 != Integer.MIN_VALUE) {
                        c10 = c6;
                        i21 = i12;
                        if (i10 != 0) {
                            iMin2 = i19;
                        }
                        int iMin3 = i21 != 1073741824 ? i13 : i21 == Integer.MIN_VALUE ? Math.min(i20, i13) : i21 == 0 ? i20 : i19;
                        this.E0 = iMin2;
                        this.F0 = iMin3;
                        Q(iMin2);
                        N(iMin3);
                        this.D0 = this.f34107w0 <= 0 ? c10 : i19;
                    }
                    c10 = c6;
                    iMin2 = Math.min(iMin2, i11);
                }
                i21 = i12;
                if (i21 != 1073741824) {
                }
                this.E0 = iMin2;
                this.F0 = iMin3;
                Q(iMin2);
                N(iMin3);
                this.D0 = this.f34107w0 <= 0 ? c10 : i19;
            }
            i15 = i38;
            i16 = i37;
            i17 = i36;
            iArr = iArr4;
            i18 = i47;
            int i91 = this.a1;
            if (i91 == 0) {
                int i92 = this.Z0;
                if (i92 <= 0) {
                    int i93 = 0;
                    iCeil2 = 0;
                    for (int i94 = 0; i94 < i48; i94++) {
                        if (i94 > 0) {
                            i93 += this.U0;
                        }
                        d dVar12 = dVarArr2[i94];
                        if (dVar12 != null) {
                            int iY3 = Y(i42, dVar12) + i93;
                            if (iY3 > i42) {
                                break;
                            }
                            iCeil2++;
                            i93 = iY3;
                        }
                    }
                } else {
                    iCeil2 = i92;
                }
                iCeil = 0;
            } else {
                iCeil = this.Z0;
                if (iCeil <= 0) {
                    int i95 = 0;
                    int i96 = 0;
                    for (int i97 = 0; i97 < i48; i97++) {
                        if (i97 > 0) {
                            i95 += this.V0;
                        }
                        d dVar13 = dVarArr2[i97];
                        if (dVar13 != null) {
                            int iX3 = X(i42, dVar13) + i95;
                            if (iX3 > i42) {
                                break;
                            }
                            i96++;
                            i95 = iX3;
                        }
                    }
                    iCeil = i96;
                }
                iCeil2 = 0;
            }
            if (this.f34099e1 == null) {
                this.f34099e1 = new int[2];
            }
            boolean z16 = (iCeil == 0 && i91 == 1) || (iCeil2 == 0 && i91 == 0);
            while (!z16) {
                if (i91 == 0) {
                    iCeil = (int) Math.ceil(i48 / iCeil2);
                } else {
                    iCeil2 = (int) Math.ceil(i48 / iCeil);
                }
                d[] dVarArr3 = this.f34098d1;
                if (dVarArr3 == null || dVarArr3.length < iCeil2) {
                    obj = null;
                    this.f34098d1 = new d[iCeil2];
                } else {
                    obj = null;
                    Arrays.fill(dVarArr3, (Object) null);
                }
                d[] dVarArr4 = this.f34097c1;
                if (dVarArr4 == null || dVarArr4.length < iCeil) {
                    this.f34097c1 = new d[iCeil];
                } else {
                    Arrays.fill(dVarArr4, obj);
                }
                for (int i98 = 0; i98 < iCeil2; i98++) {
                    for (int i99 = 0; i99 < iCeil; i99++) {
                        int i100 = (i99 * iCeil2) + i98;
                        if (i91 == 1) {
                            i100 = (i98 * iCeil) + i99;
                        }
                        if (i100 < dVarArr2.length && (dVar2 = dVarArr2[i100]) != null) {
                            int iY4 = Y(i42, dVar2);
                            d dVar14 = this.f34098d1[i98];
                            if (dVar14 == null || dVar14.s() < iY4) {
                                this.f34098d1[i98] = dVar2;
                            }
                            int iX4 = X(i42, dVar2);
                            d dVar15 = this.f34097c1[i99];
                            if (dVar15 == null || dVar15.m() < iX4) {
                                this.f34097c1[i99] = dVar2;
                            }
                        }
                    }
                }
                int iY5 = 0;
                for (int i101 = 0; i101 < iCeil2; i101++) {
                    d dVar16 = this.f34098d1[i101];
                    if (dVar16 != null) {
                        if (i101 > 0) {
                            iY5 += this.U0;
                        }
                        iY5 = Y(i42, dVar16) + iY5;
                    }
                }
                int iX5 = 0;
                for (int i102 = 0; i102 < iCeil; i102++) {
                    d dVar17 = this.f34097c1[i102];
                    if (dVar17 != null) {
                        if (i102 > 0) {
                            iX5 += this.V0;
                        }
                        iX5 = X(i42, dVar17) + iX5;
                    }
                }
                iArr[0] = iY5;
                iArr[1] = iX5;
                if (i91 == 0) {
                    if (iY5 <= i42 || iCeil2 <= 1) {
                        z16 = true;
                    } else {
                        iCeil2--;
                    }
                } else if (iX5 <= i42 || iCeil <= 1) {
                    z16 = true;
                } else {
                    iCeil--;
                }
            }
            int[] iArr5 = this.f34099e1;
            iArr5[0] = iCeil2;
            iArr5[1] = iCeil;
        }
        i19 = 0;
        c6 = 1;
        int iMin22 = iArr[i19] + i17 + i16;
        i20 = iArr[c6] + i15 + i18;
        if (i10 == 1073741824) {
        }
        i21 = i12;
        if (i21 != 1073741824) {
        }
        this.E0 = iMin22;
        this.F0 = iMin3;
        Q(iMin22);
        N(iMin3);
        this.D0 = this.f34107w0 <= 0 ? c10 : i19;
    }

    public final int X(int i10, d dVar) {
        if (dVar == null) {
            return 0;
        }
        if (dVar.U[1] == ConstraintWidget$DimensionBehaviour.f1014c) {
            int i11 = dVar.f34064s;
            if (i11 == 0) {
                return 0;
            }
            if (i11 == 2) {
                int i12 = (int) (dVar.f34074z * i10);
                if (i12 != dVar.m()) {
                    dVar.f34040g = true;
                    W(dVar, dVar.U[0], dVar.s(), ConstraintWidget$DimensionBehaviour.f1012a, i12);
                }
                return i12;
            }
            if (i11 == 1) {
                return dVar.m();
            }
            if (i11 == 3) {
                return (int) ((dVar.s() * dVar.Y) + 0.5f);
            }
        }
        return dVar.m();
    }

    public final int Y(int i10, d dVar) {
        if (dVar == null) {
            return 0;
        }
        if (dVar.U[0] == ConstraintWidget$DimensionBehaviour.f1014c) {
            int i11 = dVar.f34062r;
            if (i11 == 0) {
                return 0;
            }
            if (i11 == 2) {
                int i12 = (int) (dVar.f34071w * i10);
                if (i12 != dVar.s()) {
                    dVar.f34040g = true;
                    W(dVar, ConstraintWidget$DimensionBehaviour.f1012a, i12, dVar.U[1], dVar.m());
                }
                return i12;
            }
            if (i11 == 1) {
                return dVar.s();
            }
            if (i11 == 3) {
                return (int) ((dVar.m() * dVar.Y) + 0.5f);
            }
        }
        return dVar.s();
    }

    @Override // w.d
    public final void c(u.f fVar, boolean z10) {
        d dVar;
        float f10;
        int i10;
        super.c(fVar, z10);
        d dVar2 = this.V;
        boolean z11 = dVar2 != null && ((e) dVar2).A0;
        int i11 = this.Y0;
        ArrayList arrayList = this.f34096b1;
        if (i11 != 0) {
            if (i11 == 1) {
                int size = arrayList.size();
                int i12 = 0;
                while (i12 < size) {
                    ((f) arrayList.get(i12)).b(i12, z11, i12 == size + (-1));
                    i12++;
                }
            } else if (i11 != 2) {
                if (i11 == 3) {
                    int size2 = arrayList.size();
                    int i13 = 0;
                    while (i13 < size2) {
                        ((f) arrayList.get(i13)).b(i13, z11, i13 == size2 + (-1));
                        i13++;
                    }
                }
            } else if (this.f34099e1 != null && this.f34098d1 != null && this.f34097c1 != null) {
                for (int i14 = 0; i14 < this.f34101g1; i14++) {
                    this.f34100f1[i14].F();
                }
                int[] iArr = this.f34099e1;
                int i15 = iArr[0];
                int i16 = iArr[1];
                float f11 = this.O0;
                d dVar3 = null;
                int i17 = 0;
                while (i17 < i15) {
                    if (z11) {
                        i10 = (i15 - i17) - 1;
                        f10 = 1.0f - this.O0;
                    } else {
                        f10 = f11;
                        i10 = i17;
                    }
                    d dVar4 = this.f34098d1[i10];
                    if (dVar4 != null && dVar4.f34045i0 != 8) {
                        c cVar = dVar4.J;
                        if (i17 == 0) {
                            dVar4.g(cVar, this.J, this.B0);
                            dVar4.f34053m0 = this.I0;
                            dVar4.f34039f0 = f10;
                        }
                        if (i17 == i15 - 1) {
                            dVar4.g(dVar4.L, this.L, this.C0);
                        }
                        if (i17 > 0 && dVar3 != null) {
                            int i18 = this.U0;
                            c cVar2 = dVar3.L;
                            dVar4.g(cVar, cVar2, i18);
                            dVar3.g(cVar2, cVar, 0);
                        }
                        dVar3 = dVar4;
                    }
                    i17++;
                    f11 = f10;
                }
                for (int i19 = 0; i19 < i16; i19++) {
                    d dVar5 = this.f34097c1[i19];
                    if (dVar5 != null && dVar5.f34045i0 != 8) {
                        c cVar3 = dVar5.K;
                        if (i19 == 0) {
                            dVar5.g(cVar3, this.K, this.f34109x0);
                            dVar5.f34055n0 = this.J0;
                            dVar5.f34041g0 = this.P0;
                        }
                        if (i19 == i16 - 1) {
                            dVar5.g(dVar5.M, this.M, this.f34110y0);
                        }
                        if (i19 > 0 && dVar3 != null) {
                            int i20 = this.V0;
                            c cVar4 = dVar3.M;
                            dVar5.g(cVar3, cVar4, i20);
                            dVar3.g(cVar4, cVar3, 0);
                        }
                        dVar3 = dVar5;
                    }
                }
                for (int i21 = 0; i21 < i15; i21++) {
                    for (int i22 = 0; i22 < i16; i22++) {
                        int i23 = (i22 * i15) + i21;
                        if (this.a1 == 1) {
                            i23 = (i21 * i16) + i22;
                        }
                        d[] dVarArr = this.f34100f1;
                        if (i23 < dVarArr.length && (dVar = dVarArr[i23]) != null && dVar.f34045i0 != 8) {
                            d dVar6 = this.f34098d1[i21];
                            d dVar7 = this.f34097c1[i22];
                            if (dVar != dVar6) {
                                dVar.g(dVar.J, dVar6.J, 0);
                                dVar.g(dVar.L, dVar6.L, 0);
                            }
                            if (dVar != dVar7) {
                                dVar.g(dVar.K, dVar7.K, 0);
                                dVar.g(dVar.M, dVar7.M, 0);
                            }
                        }
                    }
                }
            }
        } else if (arrayList.size() > 0) {
            ((f) arrayList.get(0)).b(0, z11, true);
        }
        this.D0 = false;
    }

    @Override // w.j, w.d
    public final void h(d dVar, HashMap map) {
        super.h(dVar, map);
        g gVar = (g) dVar;
        this.I0 = gVar.I0;
        this.J0 = gVar.J0;
        this.K0 = gVar.K0;
        this.L0 = gVar.L0;
        this.M0 = gVar.M0;
        this.N0 = gVar.N0;
        this.O0 = gVar.O0;
        this.P0 = gVar.P0;
        this.Q0 = gVar.Q0;
        this.R0 = gVar.R0;
        this.S0 = gVar.S0;
        this.T0 = gVar.T0;
        this.U0 = gVar.U0;
        this.V0 = gVar.V0;
        this.W0 = gVar.W0;
        this.X0 = gVar.X0;
        this.Y0 = gVar.Y0;
        this.Z0 = gVar.Z0;
        this.a1 = gVar.a1;
    }
}
