package kotlinx.coroutines.internal;

import d2.m1;
import kotlinx.coroutines.ThreadContextElement;

/* JADX INFO: compiled from: ThreadContext.kt */
/* JADX INFO: loaded from: classes.dex */
final class i0 {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final n1.f f5205a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    private final Object[] f5206b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    private final ThreadContextElement<Object>[] f5207c;

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

    public i0(n1.f fVar, int i3) {
        this.f5205a = fVar;
        this.f5206b = new Object[i3];
        this.f5207c = new m1[i3];
    }

    /* JADX WARN: Multi-variable type inference failed */
    public final void a(m1<?> m1Var, Object obj) {
        Object[] objArr = this.f5206b;
        int i3 = this.f5208d;
        objArr[i3] = obj;
        ThreadContextElement<Object>[] threadContextElementArr = this.f5207c;
        this.f5208d = i3 + 1;
        threadContextElementArr[i3] = m1Var;
    }

    public final void b(n1.f fVar) {
        int length = this.f5207c.length - 1;
        if (length < 0) {
            return;
        }
        while (true) {
            int i3 = length - 1;
            m1 m1Var = this.f5207c[length];
            w1.g.b(m1Var);
            m1Var.o(fVar, this.f5206b[length]);
            if (i3 < 0) {
                return;
            } else {
                length = i3;
            }
        }
    }
}
