package androidx.compose.runtime;

import androidx.compose.runtime.internal.StabilityInferred;
import java.util.Arrays;

/* JADX INFO: loaded from: classes.dex */
@StabilityInferred(parameters = 0)
public final class IntStack {
    public static final int $stable = 8;
    public int[] slots = new int[10];
    public int tos;

    private final int[] resize() {
        int[] iArr = this.slots;
        int[] iArrCopyOf = Arrays.copyOf(iArr, iArr.length * 2);
        kotlin.jvm.internal.o.g(iArrCopyOf, "copyOf(...)");
        this.slots = iArrCopyOf;
        return iArrCopyOf;
    }

    public final void clear() {
        this.tos = 0;
    }

    public final int getSize() {
        return this.tos;
    }

    public final int indexOf(int i6) {
        int[] iArr = this.slots;
        int iMin = Math.min(iArr.length, this.tos);
        for (int i7 = 0; i7 < iMin; i7++) {
            if (iArr[i7] == i6) {
                return i7;
            }
        }
        return -1;
    }

    public final boolean isEmpty() {
        return this.tos == 0;
    }

    public final boolean isNotEmpty() {
        return this.tos != 0;
    }

    public final int peek() {
        return this.slots[this.tos - 1];
    }

    public final int peek2() {
        return this.slots[this.tos - 2];
    }

    public final int peekOr(int i6) {
        int i7 = this.tos - 1;
        return i7 >= 0 ? this.slots[i7] : i6;
    }

    public final int pop() {
        int[] iArr = this.slots;
        int i6 = this.tos - 1;
        this.tos = i6;
        return iArr[i6];
    }

    public final void push(int i6) {
        int[] iArrResize = this.slots;
        if (this.tos >= iArrResize.length) {
            iArrResize = resize();
        }
        int i7 = this.tos;
        this.tos = i7 + 1;
        iArrResize[i7] = i6;
    }

    public final int peek(int i6) {
        return this.slots[i6];
    }
}
