package kotlin.random; import kotlin.jvm.internal.Intrinsics; import kotlin.ranges.IntRange; /* loaded from: classes5.dex */ public abstract class RandomKt { public static final int takeUpperBits(int i, int i2) { return (i >>> (32 - i2)) & ((-i2) >> 31); } public static final int nextInt(Random random, IntRange range) { Intrinsics.checkNotNullParameter(random, ""); Intrinsics.checkNotNullParameter(range, "range"); if (!range.isEmpty()) { return range.getLast() < Integer.MAX_VALUE ? random.nextInt(range.getFirst(), range.getLast() + 1) : range.getFirst() > Integer.MIN_VALUE ? random.nextInt(range.getFirst() - 1, range.getLast()) + 1 : random.nextInt(); } throw new IllegalArgumentException("Cannot get random in empty range: " + range); } public static final int fastLog2(int i) { return 31 - Integer.numberOfLeadingZeros(i); } public static final void checkRangeBounds(int i, int i2) { if (i2 <= i) { throw new IllegalArgumentException(boundsErrorMessage(Integer.valueOf(i), Integer.valueOf(i2)).toString()); } } public static final void checkRangeBounds(long j, long j2) { if (j2 <= j) { throw new IllegalArgumentException(boundsErrorMessage(Long.valueOf(j), Long.valueOf(j2)).toString()); } } public static final String boundsErrorMessage(Object from, Object until) { Intrinsics.checkNotNullParameter(from, "from"); Intrinsics.checkNotNullParameter(until, "until"); return "Random range is empty: [" + from + ", " + until + ")."; } }