package com.applovin.impl; import com.applovin.impl.wd; import com.mbridge.msdk.playercommon.exoplayer2.C; /* loaded from: classes.dex */ public final class k3 implements wd, wd.a { public final wd a; private wd.a b; private a[] c = new a[0]; private long d; long f; long g; public void a(long j, long j2) { this.f = j; this.g = j2; } public boolean c() { return this.d != C.TIME_UNSET; } public k3(wd wdVar, boolean z, long j, long j2) { this.a = wdVar; this.d = z ? j : C.TIME_UNSET; this.f = j; this.g = j2; } @Override // com.applovin.impl.wd public void f() { this.a.f(); } @Override // com.applovin.impl.wd public void a(long j, boolean z) { this.a.a(j, z); } @Override // com.applovin.impl.wd public long h() { if (c()) { long j = this.d; this.d = C.TIME_UNSET; long h = h(); return h != C.TIME_UNSET ? h : j; } long h2 = this.a.h(); if (h2 == C.TIME_UNSET) { return C.TIME_UNSET; } b1.b(h2 >= this.f); long j2 = this.g; b1.b(j2 == Long.MIN_VALUE || h2 <= j2); return h2; } @Override // com.applovin.impl.wd public long e() { long e = this.a.e(); if (e != Long.MIN_VALUE) { long j = this.g; if (j == Long.MIN_VALUE || e < j) { return e; } } return Long.MIN_VALUE; } @Override // com.applovin.impl.wd public long g() { long g = this.a.g(); if (g != Long.MIN_VALUE) { long j = this.g; if (j == Long.MIN_VALUE || g < j) { return g; } } return Long.MIN_VALUE; } private jj b(long j, jj jjVar) { long b = xp.b(jjVar.a, 0L, j - this.f); long j2 = jjVar.b; long j3 = this.g; long b2 = xp.b(j2, 0L, j3 == Long.MIN_VALUE ? Long.MAX_VALUE : j3 - j); return (b == jjVar.a && b2 == jjVar.b) ? jjVar : new jj(b, b2); } public final class a implements cj { public final cj a; private boolean b; public void b() { this.b = false; } public a(cj cjVar) { this.a = cjVar; } @Override // com.applovin.impl.cj public boolean d() { return !k3.this.c() && this.a.d(); } @Override // com.applovin.impl.cj public void a() { this.a.a(); } @Override // com.applovin.impl.cj public int a(g9 g9Var, p5 p5Var, int i) { if (k3.this.c()) { return -3; } if (this.b) { p5Var.e(4); return -4; } int a = this.a.a(g9Var, p5Var, i); if (a == -5) { f9 f9Var = (f9) b1.a(g9Var.b); int i2 = f9Var.C; if (i2 != 0 || f9Var.D != 0) { k3 k3Var = k3.this; if (k3Var.f != 0) { i2 = 0; } g9Var.b = f9Var.a().e(i2).f(k3Var.g == Long.MIN_VALUE ? f9Var.D : 0).a(); } return -5; } k3 k3Var2 = k3.this; long j = k3Var2.g; if (j == Long.MIN_VALUE || ((a != -4 || p5Var.f < j) && !(a == -3 && k3Var2.e() == Long.MIN_VALUE && !p5Var.d))) { return a; } p5Var.b(); p5Var.e(4); this.b = true; return -4; } @Override // com.applovin.impl.cj public int a(long j) { if (k3.this.c()) { return -3; } return this.a.a(j); } } @Override // com.applovin.impl.wd public long a(long j, jj jjVar) { long j2 = this.f; if (j == j2) { return j2; } return this.a.a(j, b(j, jjVar)); } @Override // com.applovin.impl.wd public void c(long j) { this.a.c(j); } @Override // com.applovin.impl.wd public boolean b(long j) { return this.a.b(j); } @Override // com.applovin.impl.wd public boolean a() { return this.a.a(); } @Override // com.applovin.impl.wd public po b() { return this.a.b(); } @Override // com.applovin.impl.pj.a /* renamed from: b, reason: merged with bridge method [inline-methods] */ public void a(wd wdVar) { ((wd.a) b1.a(this.b)).a((pj) this); } @Override // com.applovin.impl.wd.a public void a(wd wdVar) { ((wd.a) b1.a(this.b)).a((wd) this); } @Override // com.applovin.impl.wd public void a(wd.a aVar, long j) { this.b = aVar; this.a.a(this, j); } /* JADX WARN: Code restructure failed: missing block: B:17:0x0032, code lost: if (r0 > r6) goto L17; */ @Override // com.applovin.impl.wd /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct add '--show-bad-code' argument */ public long a(long r6) { /* r5 = this; r0 = -9223372036854775807(0x8000000000000001, double:-4.9E-324) r5.d = r0 com.applovin.impl.k3$a[] r0 = r5.c int r1 = r0.length r2 = 0 r3 = r2 Lc: if (r3 >= r1) goto L18 r4 = r0[r3] if (r4 == 0) goto L15 r4.b() L15: int r3 = r3 + 1 goto Lc L18: com.applovin.impl.wd r0 = r5.a long r0 = r0.a(r6) int r6 = (r0 > r6 ? 1 : (r0 == r6 ? 0 : -1)) if (r6 == 0) goto L34 long r6 = r5.f int r6 = (r0 > r6 ? 1 : (r0 == r6 ? 0 : -1)) if (r6 < 0) goto L35 long r6 = r5.g r3 = -9223372036854775808 int r3 = (r6 > r3 ? 1 : (r6 == r3 ? 0 : -1)) if (r3 == 0) goto L34 int r6 = (r0 > r6 ? 1 : (r0 == r6 ? 0 : -1)) if (r6 > 0) goto L35 L34: r2 = 1 L35: com.applovin.impl.b1.b(r2) return r0 */ throw new UnsupportedOperationException("Method not decompiled: com.applovin.impl.k3.a(long):long"); } /* JADX WARN: Code restructure failed: missing block: B:25:0x005e, code lost: if (r2 > r4) goto L26; */ /* JADX WARN: Removed duplicated region for block: B:20:0x004e */ /* JADX WARN: Removed duplicated region for block: B:30:0x006a */ @Override // com.applovin.impl.wd /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct add '--show-bad-code' argument */ public long a(com.applovin.impl.h8[] r13, boolean[] r14, com.applovin.impl.cj[] r15, boolean[] r16, long r17) { /* r12 = this; r0 = r12 r1 = r15 int r2 = r1.length com.applovin.impl.k3$a[] r2 = new com.applovin.impl.k3.a[r2] r0.c = r2 int r2 = r1.length com.applovin.impl.cj[] r9 = new com.applovin.impl.cj[r2] r10 = 0 r2 = r10 Lc: int r3 = r1.length r11 = 0 if (r2 >= r3) goto L21 com.applovin.impl.k3$a[] r3 = r0.c r4 = r1[r2] com.applovin.impl.k3$a r4 = (com.applovin.impl.k3.a) r4 r3[r2] = r4 if (r4 == 0) goto L1c com.applovin.impl.cj r11 = r4.a L1c: r9[r2] = r11 int r2 = r2 + 1 goto Lc L21: com.applovin.impl.wd r2 = r0.a r3 = r13 r4 = r14 r5 = r9 r6 = r16 r7 = r17 long r2 = r2.a(r3, r4, r5, r6, r7) boolean r4 = r12.c() if (r4 == 0) goto L43 long r4 = r0.f int r6 = (r17 > r4 ? 1 : (r17 == r4 ? 0 : -1)) if (r6 != 0) goto L43 r6 = r13 boolean r4 = a(r4, r13) if (r4 == 0) goto L43 r4 = r2 goto L48 L43: r4 = -9223372036854775807(0x8000000000000001, double:-4.9E-324) L48: r0.d = r4 int r4 = (r2 > r17 ? 1 : (r2 == r17 ? 0 : -1)) if (r4 == 0) goto L63 long r4 = r0.f int r4 = (r2 > r4 ? 1 : (r2 == r4 ? 0 : -1)) if (r4 < 0) goto L61 long r4 = r0.g r6 = -9223372036854775808 int r6 = (r4 > r6 ? 1 : (r4 == r6 ? 0 : -1)) if (r6 == 0) goto L63 int r4 = (r2 > r4 ? 1 : (r2 == r4 ? 0 : -1)) if (r4 > 0) goto L61 goto L63 L61: r4 = r10 goto L64 L63: r4 = 1 L64: com.applovin.impl.b1.b(r4) L67: int r4 = r1.length if (r10 >= r4) goto L8d r4 = r9[r10] if (r4 != 0) goto L73 com.applovin.impl.k3$a[] r4 = r0.c r4[r10] = r11 goto L84 L73: com.applovin.impl.k3$a[] r5 = r0.c r6 = r5[r10] if (r6 == 0) goto L7d com.applovin.impl.cj r6 = r6.a if (r6 == r4) goto L84 L7d: com.applovin.impl.k3$a r6 = new com.applovin.impl.k3$a r6.(r4) r5[r10] = r6 L84: com.applovin.impl.k3$a[] r4 = r0.c r4 = r4[r10] r1[r10] = r4 int r10 = r10 + 1 goto L67 L8d: return r2 */ throw new UnsupportedOperationException("Method not decompiled: com.applovin.impl.k3.a(com.applovin.impl.h8[], boolean[], com.applovin.impl.cj[], boolean[], long):long"); } private static boolean a(long j, h8[] h8VarArr) { if (j != 0) { for (h8 h8Var : h8VarArr) { if (h8Var != null) { f9 g = h8Var.g(); if (!Cif.a(g.m, g.j)) { return true; } } } } return false; } }