package n;

import java.util.ArrayList;
import n.e;

/* JADX INFO: compiled from: ChainHead.java */
/* JADX INFO: loaded from: classes.dex */
public class c {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    protected e f5578a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    protected e f5579b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    protected e f5580c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    protected e f5581d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    protected e f5582e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    protected e f5583f;

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    protected e f5584g;

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    protected ArrayList<e> f5585h;

    /* JADX INFO: renamed from: i, reason: collision with root package name */
    protected int f5586i;

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    protected int f5587j;

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    protected float f5588k = 0.0f;

    /* JADX INFO: renamed from: l, reason: collision with root package name */
    int f5589l;

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

    /* JADX INFO: renamed from: n, reason: collision with root package name */
    int f5591n;

    /* JADX INFO: renamed from: o, reason: collision with root package name */
    private int f5592o;

    /* JADX INFO: renamed from: p, reason: collision with root package name */
    private boolean f5593p;

    /* JADX INFO: renamed from: q, reason: collision with root package name */
    protected boolean f5594q;

    /* JADX INFO: renamed from: r, reason: collision with root package name */
    protected boolean f5595r;

    /* JADX INFO: renamed from: s, reason: collision with root package name */
    protected boolean f5596s;

    /* JADX INFO: renamed from: t, reason: collision with root package name */
    private boolean f5597t;

    public c(e eVar, int i3, boolean z2) {
        this.f5593p = false;
        this.f5578a = eVar;
        this.f5592o = i3;
        this.f5593p = z2;
    }

    private void b() {
        int i3 = this.f5592o * 2;
        e eVar = this.f5578a;
        boolean z2 = false;
        e eVar2 = eVar;
        boolean z3 = false;
        while (!z3) {
            this.f5586i++;
            e[] eVarArr = eVar.f5646s0;
            int i4 = this.f5592o;
            e eVar3 = null;
            eVarArr[i4] = null;
            eVar.f5644r0[i4] = null;
            if (eVar.T() != 8) {
                this.f5589l++;
                e.b bVarS = eVar.s(this.f5592o);
                e.b bVar = e.b.MATCH_CONSTRAINT;
                if (bVarS != bVar) {
                    this.f5590m += eVar.C(this.f5592o);
                }
                int iE = this.f5590m + eVar.T[i3].e();
                this.f5590m = iE;
                int i5 = i3 + 1;
                this.f5590m = iE + eVar.T[i5].e();
                int iE2 = this.f5591n + eVar.T[i3].e();
                this.f5591n = iE2;
                this.f5591n = iE2 + eVar.T[i5].e();
                if (this.f5579b == null) {
                    this.f5579b = eVar;
                }
                this.f5581d = eVar;
                e.b[] bVarArr = eVar.W;
                int i6 = this.f5592o;
                if (bVarArr[i6] == bVar) {
                    int[] iArr = eVar.f5651v;
                    if (iArr[i6] == 0 || iArr[i6] == 3 || iArr[i6] == 2) {
                        this.f5587j++;
                        float[] fArr = eVar.f5642q0;
                        float f3 = fArr[i6];
                        if (f3 > 0.0f) {
                            this.f5588k += fArr[i6];
                        }
                        if (c(eVar, i6)) {
                            if (f3 < 0.0f) {
                                this.f5594q = true;
                            } else {
                                this.f5595r = true;
                            }
                            if (this.f5585h == null) {
                                this.f5585h = new ArrayList<>();
                            }
                            this.f5585h.add(eVar);
                        }
                        if (this.f5583f == null) {
                            this.f5583f = eVar;
                        }
                        e eVar4 = this.f5584g;
                        if (eVar4 != null) {
                            eVar4.f5644r0[this.f5592o] = eVar;
                        }
                        this.f5584g = eVar;
                    }
                    if (this.f5592o == 0) {
                        if (eVar.f5647t == 0 && eVar.f5652w == 0) {
                            int i7 = eVar.f5653x;
                        }
                    } else if (eVar.f5649u == 0 && eVar.f5655z == 0) {
                        int i8 = eVar.A;
                    }
                }
            }
            if (eVar2 != eVar) {
                eVar2.f5646s0[this.f5592o] = eVar;
            }
            d dVar = eVar.T[i3 + 1].f5603f;
            if (dVar != null) {
                e eVar5 = dVar.f5601d;
                d[] dVarArr = eVar5.T;
                if (dVarArr[i3].f5603f != null && dVarArr[i3].f5603f.f5601d == eVar) {
                    eVar3 = eVar5;
                }
            }
            if (eVar3 == null) {
                eVar3 = eVar;
                z3 = true;
            }
            eVar2 = eVar;
            eVar = eVar3;
        }
        e eVar6 = this.f5579b;
        if (eVar6 != null) {
            this.f5590m -= eVar6.T[i3].e();
        }
        e eVar7 = this.f5581d;
        if (eVar7 != null) {
            this.f5590m -= eVar7.T[i3 + 1].e();
        }
        this.f5580c = eVar;
        if (this.f5592o == 0 && this.f5593p) {
            this.f5582e = eVar;
        } else {
            this.f5582e = this.f5578a;
        }
        if (this.f5595r && this.f5594q) {
            z2 = true;
        }
        this.f5596s = z2;
    }

    private static boolean c(e eVar, int i3) {
        if (eVar.T() != 8 && eVar.W[i3] == e.b.MATCH_CONSTRAINT) {
            int[] iArr = eVar.f5651v;
            if (iArr[i3] == 0 || iArr[i3] == 3) {
                return true;
            }
        }
        return false;
    }

    public void a() {
        if (!this.f5597t) {
            b();
        }
        this.f5597t = true;
    }
}
