package com.applovin.impl; import com.applovin.impl.bf; import com.applovin.impl.f9; import com.applovin.impl.lj; import com.applovin.impl.tf; import com.applovin.impl.xa; import com.mbridge.msdk.playercommon.exoplayer2.C; import java.io.EOFException; /* loaded from: classes.dex */ public final class of implements k8 { public static final o8 u = new o8() { // from class: com.applovin.impl.of$$ExternalSyntheticLambda0 @Override // com.applovin.impl.o8 public final k8[] a() { k8[] d; d = of.d(); return d; } }; private static final xa.a v = new xa.a() { // from class: com.applovin.impl.of$$ExternalSyntheticLambda1 @Override // com.applovin.impl.xa.a public final boolean a(int i, int i2, int i3, int i4, int i5) { boolean a; a = of.a(i, i2, i3, i4, i5); return a; } }; private final int a; private final long b; private final bh c; private final tf.a d; private final z9 e; private final za f; private final qo g; private m8 h; private qo i; private qo j; private int k; private bf l; private long m; private long n; private long o; private int p; private lj q; private boolean r; private boolean s; private long t; /* JADX INFO: Access modifiers changed from: private */ public static /* synthetic */ boolean a(int i, int i2, int i3, int i4, int i5) { return (i2 == 67 && i3 == 79 && i4 == 77 && (i5 == 77 || i == 2)) || (i2 == 77 && i3 == 76 && i4 == 76 && (i5 == 84 || i == 2)); } private static boolean a(int i, long j) { return ((long) (i & (-128000))) == (j & (-128000)); } @Override // com.applovin.impl.k8 public void a() { } public void c() { this.r = true; } public of() { this(0); } private int e(l8 l8Var) { if (this.k == 0) { try { b(l8Var, false); } catch (EOFException unused) { return -1; } } if (this.q == null) { lj b = b(l8Var); this.q = b; this.h.a(b); this.j.a(new f9.b().f(this.d.b).i(4096).c(this.d.e).n(this.d.d).e(this.e.a).f(this.e.b).a((this.a & 8) != 0 ? null : this.l).a()); this.o = l8Var.f(); } else if (this.o != 0) { long f = l8Var.f(); long j = this.o; if (f < j) { l8Var.a((int) (j - f)); } } return f(l8Var); } private int f(l8 l8Var) { if (this.p == 0) { l8Var.b(); if (d(l8Var)) { return -1; } this.c.f(0); int j = this.c.j(); if (a(j, this.k) && tf.b(j) != -1) { this.d.a(j); if (this.m == C.TIME_UNSET) { this.m = this.q.a(l8Var.f()); if (this.b != C.TIME_UNSET) { this.m += this.b - this.q.a(0L); } } this.p = this.d.c; lj ljVar = this.q; if (ljVar instanceof nb) { nb nbVar = (nb) ljVar; nbVar.a(a(this.n + r0.g), l8Var.f() + this.d.c); if (this.s && nbVar.c(this.t)) { this.s = false; this.j = this.i; } } } else { l8Var.a(1); this.k = 0; return 0; } } int a = this.j.a((g5) l8Var, this.p, true); if (a == -1) { return -1; } int i = this.p - a; this.p = i; if (i > 0) { return 0; } this.j.a(a(this.n), 1, this.d.c, 0, null); this.n += this.d.g; this.p = 0; return 0; } public of(int i) { this(i, C.TIME_UNSET); } private long a(long j) { return this.m + ((j * 1000000) / this.d.d); } private boolean d(l8 l8Var) { lj ljVar = this.q; if (ljVar != null) { long c = ljVar.c(); if (c != -1 && l8Var.d() > c - 4) { return true; } } try { return !l8Var.b(this.c.c(), 0, 4, true); } catch (EOFException unused) { return true; } } /* JADX INFO: Access modifiers changed from: private */ public static /* synthetic */ k8[] d() { return new k8[]{new of()}; } public of(int i, long j) { this.a = (i & 2) != 0 ? i | 1 : i; this.b = j; this.c = new bh(10); this.d = new tf.a(); this.e = new z9(); this.m = C.TIME_UNSET; this.f = new za(); i7 i7Var = new i7(); this.g = i7Var; this.j = i7Var; } private void b() { b1.b(this.i); xp.a(this.h); } private lj c(l8 l8Var) { int i; bh bhVar = new bh(this.d.c); l8Var.c(bhVar.c(), 0, this.d.c); tf.a aVar = this.d; if ((aVar.a & 1) != 0) { if (aVar.e != 1) { i = 36; } i = 21; } else { if (aVar.e == 1) { i = 13; } i = 21; } int i2 = i; int a = a(bhVar, i2); if (a != 1483304551 && a != 1231971951) { if (a == 1447187017) { pq a2 = pq.a(l8Var.a(), l8Var.f(), this.d, bhVar); l8Var.a(this.d.c); return a2; } l8Var.b(); return null; } ds a3 = ds.a(l8Var.a(), l8Var.f(), this.d, bhVar); if (a3 != null && !this.e.a()) { l8Var.b(); l8Var.c(i2 + 141); l8Var.c(this.c.c(), 0, 3); this.c.f(0); this.e.a(this.c.z()); } l8Var.a(this.d.c); return (a3 == null || a3.b() || a != 1231971951) ? a3 : a(l8Var, false); } private lj a(l8 l8Var, boolean z) { l8Var.c(this.c.c(), 0, 4); this.c.f(0); this.d.a(this.c.j()); return new q4(l8Var.a(), l8Var.f(), this.d, z); } private lj b(l8 l8Var) { long a; long j; lj c = c(l8Var); kf a2 = a(this.l, l8Var.f()); if (this.r) { return new lj.a(); } if ((this.a & 4) != 0) { if (a2 != null) { a = a2.d(); j = a2.c(); } else if (c != null) { a = c.d(); j = c.c(); } else { a = a(this.l); j = -1; } c = new nb(a, l8Var.f(), j); } else if (a2 != null) { c = a2; } else if (c == null) { c = null; } if (c == null || !(c.b() || (this.a & 1) == 0)) { return a(l8Var, (this.a & 2) != 0); } return c; } /* JADX WARN: Code restructure failed: missing block: B:48:0x009a, code lost: if (r13 == false) goto L49; */ /* JADX WARN: Code restructure failed: missing block: B:49:0x009c, code lost: r12.a(r1 + r6); */ /* JADX WARN: Code restructure failed: missing block: B:50:0x00a4, code lost: r11.k = r4; */ /* JADX WARN: Code restructure failed: missing block: B:51:0x00a6, code lost: return true; */ /* JADX WARN: Code restructure failed: missing block: B:52:0x00a1, code lost: r12.b(); */ /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct add '--show-bad-code' argument */ private boolean b(com.applovin.impl.l8 r12, boolean r13) { /* r11 = this; if (r13 == 0) goto L6 r0 = 32768(0x8000, float:4.5918E-41) goto L8 L6: r0 = 131072(0x20000, float:1.83671E-40) L8: r12.b() long r1 = r12.f() r3 = 0 int r1 = (r1 > r3 ? 1 : (r1 == r3 ? 0 : -1)) r2 = 0 r3 = 0 if (r1 != 0) goto L3e int r1 = r11.a r1 = r1 & 8 if (r1 != 0) goto L1f r1 = r2 goto L21 L1f: com.applovin.impl.xa$a r1 = com.applovin.impl.of.v L21: com.applovin.impl.za r4 = r11.f com.applovin.impl.bf r1 = r4.a(r12, r1) r11.l = r1 if (r1 == 0) goto L30 com.applovin.impl.z9 r4 = r11.e r4.a(r1) L30: long r4 = r12.d() int r1 = (int) r4 if (r13 != 0) goto L3a r12.a(r1) L3a: r4 = r3 L3b: r5 = r4 r6 = r5 goto L41 L3e: r1 = r3 r4 = r1 goto L3b L41: boolean r7 = r11.d(r12) r8 = 1 if (r7 == 0) goto L51 if (r5 <= 0) goto L4b goto L9a L4b: java.io.EOFException r12 = new java.io.EOFException r12.() throw r12 L51: com.applovin.impl.bh r7 = r11.c r7.f(r3) com.applovin.impl.bh r7 = r11.c int r7 = r7.j() if (r4 == 0) goto L65 long r9 = (long) r4 boolean r9 = a(r7, r9) if (r9 == 0) goto L6c L65: int r9 = com.applovin.impl.tf.b(r7) r10 = -1 if (r9 != r10) goto L8c L6c: int r4 = r6 + 1 if (r6 != r0) goto L7a if (r13 == 0) goto L73 return r3 L73: java.lang.String r12 = "Searched too many bytes." com.applovin.impl.dh r12 = com.applovin.impl.dh.a(r12, r2) throw r12 L7a: if (r13 == 0) goto L85 r12.b() int r5 = r1 + r4 r12.c(r5) goto L88 L85: r12.a(r8) L88: r5 = r3 r6 = r4 r4 = r5 goto L41 L8c: int r5 = r5 + 1 if (r5 != r8) goto L97 com.applovin.impl.tf$a r4 = r11.d r4.a(r7) r4 = r7 goto La7 L97: r7 = 4 if (r5 != r7) goto La7 L9a: if (r13 == 0) goto La1 int r1 = r1 + r6 r12.a(r1) goto La4 La1: r12.b() La4: r11.k = r4 return r8 La7: int r9 = r9 + (-4) r12.c(r9) goto L41 */ throw new UnsupportedOperationException("Method not decompiled: com.applovin.impl.of.b(com.applovin.impl.l8, boolean):boolean"); } private static long a(bf bfVar) { if (bfVar == null) { return C.TIME_UNSET; } int c = bfVar.c(); for (int i = 0; i < c; i++) { bf.b a = bfVar.a(i); if (a instanceof zn) { zn znVar = (zn) a; if (znVar.a.equals("TLEN")) { return t2.a(Long.parseLong(znVar.c)); } } } return C.TIME_UNSET; } private static int a(bh bhVar, int i) { if (bhVar.e() >= i + 4) { bhVar.f(i); int j = bhVar.j(); if (j == 1483304551 || j == 1231971951) { return j; } } if (bhVar.e() < 40) { return 0; } bhVar.f(36); return bhVar.j() == 1447187017 ? 1447187017 : 0; } @Override // com.applovin.impl.k8 public void a(m8 m8Var) { this.h = m8Var; qo a = m8Var.a(0, 1); this.i = a; this.j = a; this.h.c(); } private static kf a(bf bfVar, long j) { if (bfVar == null) { return null; } int c = bfVar.c(); for (int i = 0; i < c; i++) { bf.b a = bfVar.a(i); if (a instanceof jf) { return kf.a(j, (jf) a, a(bfVar)); } } return null; } @Override // com.applovin.impl.k8 public int a(l8 l8Var, th thVar) { b(); int e = e(l8Var); if (e == -1 && (this.q instanceof nb)) { long a = a(this.n); if (this.q.d() != a) { ((nb) this.q).d(a); this.h.a(this.q); } } return e; } @Override // com.applovin.impl.k8 public void a(long j, long j2) { this.k = 0; this.m = C.TIME_UNSET; this.n = 0L; this.p = 0; this.t = j2; lj ljVar = this.q; if (!(ljVar instanceof nb) || ((nb) ljVar).c(j2)) { return; } this.s = true; this.j = this.g; } @Override // com.applovin.impl.k8 public boolean a(l8 l8Var) { return b(l8Var, true); } }