package kotlin.random; import java.io.Serializable; import kotlin.internal.PlatformImplementationsKt; import kotlin.jvm.internal.DefaultConstructorMarker; /* loaded from: classes5.dex */ public abstract class Random { public static final Default Default = new Default(null); public static final Random defaultRandom = PlatformImplementationsKt.IMPLEMENTATIONS.defaultPlatformRandom(); public abstract int nextBits(int i); public abstract int nextInt(); public abstract int nextInt(int i); public abstract long nextLong(); public int nextInt(int i, int i2) { int nextInt; int i3; int i4; RandomKt.checkRangeBounds(i, i2); int i5 = i2 - i; if (i5 > 0 || i5 == Integer.MIN_VALUE) { if (((-i5) & i5) == i5) { i4 = nextBits(RandomKt.fastLog2(i5)); } else { do { nextInt = nextInt() >>> 1; i3 = nextInt % i5; } while ((nextInt - i3) + (i5 - 1) < 0); i4 = i3; } return i + i4; } while (true) { int nextInt2 = nextInt(); if (i <= nextInt2 && nextInt2 < i2) { return nextInt2; } } } public long nextLong(long j, long j2) { long nextLong; long j3; long j4; int nextInt; RandomKt.checkRangeBounds(j, j2); long j5 = j2 - j; if (j5 > 0) { if (((-j5) & j5) == j5) { int i = (int) j5; int i2 = (int) (j5 >>> 32); if (i != 0) { nextInt = nextBits(RandomKt.fastLog2(i)); } else if (i2 == 1) { nextInt = nextInt(); } else { j4 = (nextBits(RandomKt.fastLog2(i2)) << 32) + (nextInt() & 4294967295L); } j4 = nextInt & 4294967295L; } else { do { nextLong = nextLong() >>> 1; j3 = nextLong % j5; } while ((nextLong - j3) + (j5 - 1) < 0); j4 = j3; } return j + j4; } while (true) { long nextLong2 = nextLong(); if (j <= nextLong2 && nextLong2 < j2) { return nextLong2; } } } public static final class Default extends Random implements Serializable { public /* synthetic */ Default(DefaultConstructorMarker defaultConstructorMarker) { this(); } public Default() { } public static final class Serialized implements Serializable { public static final Serialized INSTANCE = new Serialized(); private static final long serialVersionUID = 0; private final Object readResolve() { return Random.Default; } } private final Object writeReplace() { return Serialized.INSTANCE; } @Override // kotlin.random.Random public int nextBits(int i) { return Random.defaultRandom.nextBits(i); } @Override // kotlin.random.Random public int nextInt() { return Random.defaultRandom.nextInt(); } @Override // kotlin.random.Random public int nextInt(int i) { return Random.defaultRandom.nextInt(i); } @Override // kotlin.random.Random public int nextInt(int i, int i2) { return Random.defaultRandom.nextInt(i, i2); } @Override // kotlin.random.Random public long nextLong() { return Random.defaultRandom.nextLong(); } @Override // kotlin.random.Random public long nextLong(long j, long j2) { return Random.defaultRandom.nextLong(j, j2); } } }