package a1;

import androidx.collection.g0;
import androidx.collection.h0;
import androidx.collection.q0;
import kotlin.jvm.internal.t;

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

    /* renamed from: a, reason: collision with root package name */
    private final g0 f131a = q0.d();

    public final void a(Object obj, Object obj2) {
        g0 g0Var = this.f131a;
        int k10 = g0Var.k(obj);
        boolean z10 = k10 < 0;
        Object obj3 = z10 ? null : g0Var.f1368c[k10];
        if (obj3 != null) {
            if (obj3 instanceof h0) {
                t.e(obj3, "null cannot be cast to non-null type androidx.collection.MutableScatterSet<Scope of androidx.compose.runtime.collection.ScopeMap.add$lambda$0>");
                ((h0) obj3).h(obj2);
            } else if (obj3 != obj2) {
                h0 h0Var = new h0(0, 1, null);
                t.e(obj3, "null cannot be cast to non-null type Scope of androidx.compose.runtime.collection.ScopeMap.add$lambda$0");
                h0Var.h(obj3);
                h0Var.h(obj2);
                obj2 = h0Var;
            }
            obj2 = obj3;
        }
        if (!z10) {
            g0Var.f1368c[k10] = obj2;
            return;
        }
        int i10 = ~k10;
        g0Var.f1367b[i10] = obj;
        g0Var.f1368c[i10] = obj2;
    }

    public final void b() {
        this.f131a.h();
    }

    public final boolean c(Object obj) {
        return this.f131a.a(obj);
    }

    public final g0 d() {
        return this.f131a;
    }

    public final int e() {
        return this.f131a.d();
    }

    public final boolean f(Object obj, Object obj2) {
        Object b10 = this.f131a.b(obj);
        if (b10 == null) {
            return false;
        }
        if (!(b10 instanceof h0)) {
            if (!t.b(b10, obj2)) {
                return false;
            }
            this.f131a.o(obj);
            return true;
        }
        h0 h0Var = (h0) b10;
        boolean x10 = h0Var.x(obj2);
        if (x10 && h0Var.d()) {
            this.f131a.o(obj);
        }
        return x10;
    }

    public final void g(Object obj) {
        g0 g0Var = this.f131a;
        long[] jArr = g0Var.f1366a;
        int length = jArr.length - 2;
        if (length < 0) {
            return;
        }
        int i10 = 0;
        while (true) {
            long j10 = jArr[i10];
            if ((((~j10) << 7) & j10 & (-9187201950435737472L)) != -9187201950435737472L) {
                int i11 = 8 - ((~(i10 - length)) >>> 31);
                for (int i12 = 0; i12 < i11; i12++) {
                    boolean z10 = true;
                    if ((255 & j10) < 128) {
                        int i13 = (i10 << 3) + i12;
                        Object obj2 = g0Var.f1367b[i13];
                        Object obj3 = g0Var.f1368c[i13];
                        if (obj3 instanceof h0) {
                            t.e(obj3, "null cannot be cast to non-null type androidx.collection.MutableScatterSet<Scope of androidx.compose.runtime.collection.ScopeMap.removeScope$lambda$3>");
                            h0 h0Var = (h0) obj3;
                            h0Var.x(obj);
                            z10 = h0Var.d();
                        } else if (obj3 != obj) {
                            z10 = false;
                        }
                        if (z10) {
                            g0Var.p(i13);
                        }
                    }
                    j10 >>= 8;
                }
                if (i11 != 8) {
                    return;
                }
            }
            if (i10 == length) {
                return;
            } else {
                i10++;
            }
        }
    }

    public final void h(Object obj, Object obj2) {
        this.f131a.r(obj, obj2);
    }
}
