package o; import java.util.concurrent.atomic.AtomicLong; /* loaded from: classes6.dex */ public final class fYK { public static long c(AtomicLong atomicLong, long j) { long j2; long j3; do { j2 = atomicLong.get(); if (j2 == Long.MAX_VALUE) { return Long.MAX_VALUE; } j3 = j2 + j; } while (!atomicLong.compareAndSet(j2, j3 >= 0 ? j3 : Long.MAX_VALUE)); return j2; } public static long b(AtomicLong atomicLong, long j) { long j2; long j3; do { j2 = atomicLong.get(); if (j2 == Long.MAX_VALUE) { return Long.MAX_VALUE; } j3 = j2 - j; if (j3 < 0) { C13418fZu.c(new IllegalStateException("More produced than requested: ".concat(String.valueOf(j3)))); j3 = 0; } } while (!atomicLong.compareAndSet(j2, j3)); return j3; } }