package q;

/* JADX INFO: loaded from: classes.dex */
public final class Q0 implements L0 {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final int f23226a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final K0 f23227b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final X f23228c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public final long f23229d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public final long f23230e;

    public Q0(int i6, K0 k02, X x6, long j4) {
        this.f23226a = i6;
        this.f23227b = k02;
        this.f23228c = x6;
        if (i6 < 1) {
            throw new IllegalArgumentException("Iterations count can't be less than 1");
        }
        this.f23229d = ((long) (k02.f() + k02.e())) * 1000000;
        this.f23230e = j4 * 1000000;
    }

    @Override // q.I0
    public final long b(AbstractC2798s abstractC2798s, AbstractC2798s abstractC2798s2, AbstractC2798s abstractC2798s3) {
        return (((long) this.f23226a) * this.f23229d) - this.f23230e;
    }

    @Override // q.I0
    public final AbstractC2798s c(long j4, AbstractC2798s abstractC2798s, AbstractC2798s abstractC2798s2, AbstractC2798s abstractC2798s3) {
        return this.f23227b.c(h(j4), abstractC2798s, abstractC2798s2, i(j4, abstractC2798s, abstractC2798s3, abstractC2798s2));
    }

    @Override // q.I0
    public final AbstractC2798s d(long j4, AbstractC2798s abstractC2798s, AbstractC2798s abstractC2798s2, AbstractC2798s abstractC2798s3) {
        return this.f23227b.d(h(j4), abstractC2798s, abstractC2798s2, i(j4, abstractC2798s, abstractC2798s3, abstractC2798s2));
    }

    public final long h(long j4) {
        long j6 = this.f23230e;
        if (j4 + j6 <= 0) {
            return 0L;
        }
        long j7 = j4 + j6;
        long j8 = this.f23229d;
        long jMin = Math.min(j7 / j8, ((long) this.f23226a) - 1);
        return (this.f23228c == X.f23246a || jMin % ((long) 2) == 0) ? j7 - (jMin * j8) : ((jMin + 1) * j8) - j7;
    }

    public final AbstractC2798s i(long j4, AbstractC2798s abstractC2798s, AbstractC2798s abstractC2798s2, AbstractC2798s abstractC2798s3) {
        long j6 = this.f23230e;
        long j7 = j4 + j6;
        long j8 = this.f23229d;
        return j7 > j8 ? d(j8 - j6, abstractC2798s, abstractC2798s2, abstractC2798s3) : abstractC2798s2;
    }
}
