package j2;

import java.util.Comparator;

/* loaded from: classes.dex */
public final class h1 {

    /* renamed from: c, reason: collision with root package name */
    public static final a f23663c = new a(null);

    /* renamed from: d, reason: collision with root package name */
    public static final int f23664d = 8;

    /* renamed from: a, reason: collision with root package name */
    private final a1.b f23665a = new a1.b(new g0[16], 0);

    /* renamed from: b, reason: collision with root package name */
    private g0[] f23666b;

    /* loaded from: classes.dex */
    public static final class a {

        /* renamed from: j2.h1$a$a, reason: collision with other inner class name */
        /* loaded from: classes.dex */
        private static final class C0503a implements Comparator {

            /* renamed from: p, reason: collision with root package name */
            public static final C0503a f23667p = new C0503a();

            private C0503a() {
            }

            @Override // java.util.Comparator
            /* renamed from: a, reason: merged with bridge method [inline-methods] */
            public int compare(g0 g0Var, g0 g0Var2) {
                int i10 = kotlin.jvm.internal.t.i(g0Var2.L(), g0Var.L());
                return i10 != 0 ? i10 : kotlin.jvm.internal.t.i(g0Var.hashCode(), g0Var2.hashCode());
            }
        }

        private a() {
        }

        public /* synthetic */ a(kotlin.jvm.internal.k kVar) {
            this();
        }
    }

    private final void b(g0 g0Var) {
        g0Var.A();
        int i10 = 0;
        g0Var.F1(false);
        a1.b w02 = g0Var.w0();
        int q10 = w02.q();
        if (q10 > 0) {
            Object[] p10 = w02.p();
            do {
                b((g0) p10[i10]);
                i10++;
            } while (i10 < q10);
        }
    }

    /* JADX WARN: Code restructure failed: missing block: B:4:0x0012, code lost:
    
        if (r2 < r0) goto L6;
     */
    /* JADX WARN: Multi-variable type inference failed */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void a() {
        g0[] g0VarArr;
        this.f23665a.F(a.C0503a.f23667p);
        int q10 = this.f23665a.q();
        g0[] g0VarArr2 = this.f23666b;
        if (g0VarArr2 != null) {
            int length = g0VarArr2.length;
            g0VarArr = g0VarArr2;
        }
        g0VarArr = new g0[Math.max(16, this.f23665a.q())];
        this.f23666b = null;
        for (int i10 = 0; i10 < q10; i10++) {
            g0VarArr[i10] = this.f23665a.p()[i10];
        }
        this.f23665a.k();
        while (true) {
            q10--;
            if (-1 >= q10) {
                this.f23666b = g0VarArr;
                return;
            }
            g0 g0Var = g0VarArr[q10];
            kotlin.jvm.internal.t.d(g0Var);
            if (g0Var.j0()) {
                b(g0Var);
            }
        }
    }

    public final boolean c() {
        return this.f23665a.t();
    }

    public final void d(g0 g0Var) {
        this.f23665a.c(g0Var);
        g0Var.F1(true);
    }

    public final void e(g0 g0Var) {
        this.f23665a.k();
        this.f23665a.c(g0Var);
        g0Var.F1(true);
    }

    public final void f(g0 g0Var) {
        this.f23665a.x(g0Var);
    }
}
