package d2;

import java.util.List;
import l1.i;

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

    /* renamed from: a, reason: collision with root package name */
    private final h2.s f15792a;

    /* renamed from: b, reason: collision with root package name */
    private final k f15793b = new k();

    /* renamed from: c, reason: collision with root package name */
    private final androidx.collection.a0 f15794c = new androidx.collection.a0(10);

    public f(h2.s sVar) {
        this.f15792a = sVar;
    }

    private final void f(long j10, androidx.collection.e0 e0Var) {
        this.f15793b.i(j10, e0Var);
    }

    public final void a(long j10, List list, boolean z10) {
        Object obj;
        k kVar = this.f15793b;
        this.f15794c.g();
        int size = list.size();
        boolean z11 = true;
        for (int i10 = 0; i10 < size; i10++) {
            i.c cVar = (i.c) list.get(i10);
            if (z11) {
                a1.b g10 = kVar.g();
                int q10 = g10.q();
                if (q10 > 0) {
                    Object[] p10 = g10.p();
                    int i11 = 0;
                    do {
                        obj = p10[i11];
                        if (kotlin.jvm.internal.t.b(((j) obj).k(), cVar)) {
                            break;
                        } else {
                            i11++;
                        }
                    } while (i11 < q10);
                }
                obj = null;
                j jVar = (j) obj;
                if (jVar != null) {
                    jVar.n();
                    jVar.l().b(j10);
                    androidx.collection.a0 a0Var = this.f15794c;
                    Object b10 = a0Var.b(j10);
                    if (b10 == null) {
                        b10 = new androidx.collection.e0(0, 1, null);
                        a0Var.o(j10, b10);
                    }
                    ((androidx.collection.e0) b10).e(jVar);
                    kVar = jVar;
                } else {
                    z11 = false;
                }
            }
            j jVar2 = new j(cVar);
            jVar2.l().b(j10);
            androidx.collection.a0 a0Var2 = this.f15794c;
            Object b11 = a0Var2.b(j10);
            if (b11 == null) {
                b11 = new androidx.collection.e0(0, 1, null);
                a0Var2.o(j10, b11);
            }
            ((androidx.collection.e0) b11).e(jVar2);
            kVar.g().c(jVar2);
            kVar = jVar2;
        }
        if (!z10) {
            return;
        }
        androidx.collection.a0 a0Var3 = this.f15794c;
        long[] jArr = a0Var3.f1362b;
        Object[] objArr = a0Var3.f1363c;
        long[] jArr2 = a0Var3.f1361a;
        int length = jArr2.length - 2;
        if (length < 0) {
            return;
        }
        int i12 = 0;
        while (true) {
            long j11 = jArr2[i12];
            if ((((~j11) << 7) & j11 & (-9187201950435737472L)) != -9187201950435737472L) {
                int i13 = 8 - ((~(i12 - length)) >>> 31);
                for (int i14 = 0; i14 < i13; i14++) {
                    if ((255 & j11) < 128) {
                        int i15 = (i12 << 3) + i14;
                        f(jArr[i15], (androidx.collection.e0) objArr[i15]);
                    }
                    j11 >>= 8;
                }
                if (i13 != 8) {
                    return;
                }
            }
            if (i12 == length) {
                return;
            } else {
                i12++;
            }
        }
    }

    public final void b() {
        this.f15793b.c();
    }

    public final boolean c(g gVar, boolean z10) {
        if (this.f15793b.a(gVar.b(), this.f15792a, gVar, z10)) {
            return this.f15793b.e(gVar) || this.f15793b.f(gVar.b(), this.f15792a, gVar, z10);
        }
        return false;
    }

    public final void d() {
        this.f15793b.d();
        b();
    }

    public final void e() {
        this.f15793b.h();
    }
}
