package p138.p176.p177.p190.p198.p205;

import java.io.EOFException;
import java.io.IOException;
import p000.p001.p002.p003.p004.C0567;
import p138.p176.p177.p190.p198.C3558;
import p138.p176.p177.p190.p198.C3574;
import p138.p176.p177.p190.p198.InterfaceC3571;
import p138.p176.p177.p190.p239.C4150;

/* JADX INFO: renamed from: ދ.ހ.֏.ؠ.ೲ.ޛ.֏, reason: contains not printable characters */
/* JADX INFO: loaded from: classes.dex */
public final class C3634 implements InterfaceC3642 {

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final C3641 f10993 = new C3641();

    /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
    public final long f10994;

    /* JADX INFO: renamed from: ހ, reason: contains not printable characters */
    public final long f10995;

    /* JADX INFO: renamed from: ށ, reason: contains not printable characters */
    public final AbstractC3644 f10996;

    /* JADX INFO: renamed from: ނ, reason: contains not printable characters */
    public int f10997;

    /* JADX INFO: renamed from: ރ, reason: contains not printable characters */
    public long f10998;

    /* JADX INFO: renamed from: ބ, reason: contains not printable characters */
    public long f10999;

    /* JADX INFO: renamed from: ޅ, reason: contains not printable characters */
    public long f11000;

    /* JADX INFO: renamed from: ކ, reason: contains not printable characters */
    public long f11001;

    /* JADX INFO: renamed from: އ, reason: contains not printable characters */
    public long f11002;

    /* JADX INFO: renamed from: ވ, reason: contains not printable characters */
    public long f11003;

    /* JADX INFO: renamed from: މ, reason: contains not printable characters */
    public long f11004;

    /* JADX INFO: renamed from: ދ.ހ.֏.ؠ.ೲ.ޛ.֏$ؠ, reason: contains not printable characters */
    public final class C3636 implements InterfaceC3571 {
        public /* synthetic */ C3636(C3635 c3635) {
        }

        @Override // p138.p176.p177.p190.p198.InterfaceC3571
        /* JADX INFO: renamed from: ؠ */
        public InterfaceC3571.C3572 mo5857(long j) {
            C3634 c3634 = C3634.this;
            long j2 = (((long) c3634.f10996.f11037) * j) / 1000000;
            long j3 = c3634.f10994;
            long j4 = c3634.f10995;
            return new InterfaceC3571.C3572(new C3574(j, C4150.m6789(((((j4 - j3) * j2) / c3634.f10998) + j3) - 30000, j3, j4 - 1)));
        }

        @Override // p138.p176.p177.p190.p198.InterfaceC3571
        /* JADX INFO: renamed from: ހ */
        public boolean mo5858() {
            return true;
        }

        @Override // p138.p176.p177.p190.p198.InterfaceC3571
        /* JADX INFO: renamed from: ށ */
        public long mo5859() {
            C3634 c3634 = C3634.this;
            return (c3634.f10998 * 1000000) / ((long) c3634.f10996.f11037);
        }
    }

    public C3634(AbstractC3644 abstractC3644, long j, long j2, long j3, long j4, boolean z) {
        C0567.m1896(j >= 0 && j2 > j);
        this.f10996 = abstractC3644;
        this.f10994 = j;
        this.f10995 = j2;
        if (j3 != j2 - j && !z) {
            this.f10997 = 0;
        } else {
            this.f10998 = j4;
            this.f10997 = 4;
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:14:0x0026  */
    /* JADX WARN: Removed duplicated region for block: B:41:0x00b8 A[RETURN] */
    /* JADX WARN: Removed duplicated region for block: B:42:0x00b9  */
    @Override // p138.p176.p177.p190.p198.p205.InterfaceC3642
    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public long mo5982(C3558 c3558) throws InterruptedException, IOException {
        long jM6789;
        int i = this.f10997;
        if (i == 0) {
            long j = c3558.f10563;
            this.f10999 = j;
            this.f10997 = 1;
            long j2 = this.f10995 - 65307;
            if (j2 > j) {
                return j2;
            }
        } else if (i != 1) {
            if (i == 2) {
                long j3 = this.f11001;
                long j4 = this.f11002;
                if (j3 == j4) {
                    jM6789 = -1;
                    if (jM6789 == -1) {
                        return jM6789;
                    }
                    this.f10997 = 3;
                } else {
                    long j5 = c3558.f10563;
                    if (m5985(c3558, j4)) {
                        this.f10993.m5993(c3558, false);
                        c3558.f10565 = 0;
                        long j6 = this.f11000;
                        C3641 c3641 = this.f10993;
                        long j7 = j6 - c3641.f11021;
                        int i2 = c3641.f11023 + c3641.f11024;
                        if (0 > j7 || j7 >= 72000) {
                            if (j7 < 0) {
                                this.f11002 = j5;
                                this.f11004 = this.f10993.f11021;
                            } else {
                                this.f11001 = c3558.f10563 + ((long) i2);
                                this.f11003 = this.f10993.f11021;
                            }
                            long j8 = this.f11002;
                            long j9 = this.f11001;
                            if (j8 - j9 < 100000) {
                                this.f11002 = j9;
                                jM6789 = j9;
                            } else {
                                long j10 = c3558.f10563 - (((long) i2) * (j7 <= 0 ? 2L : 1L));
                                long j11 = this.f11002;
                                long j12 = this.f11001;
                                jM6789 = C4150.m6789((((j11 - j12) * j7) / (this.f11004 - this.f11003)) + j10, j12, j11 - 1);
                            }
                        }
                    } else {
                        jM6789 = this.f11001;
                        if (jM6789 == j5) {
                            throw new IOException("No ogg page can be found.");
                        }
                    }
                    if (jM6789 == -1) {
                    }
                }
            } else if (i != 3) {
                if (i == 4) {
                    return -1L;
                }
                throw new IllegalStateException();
            }
            this.f10993.m5993(c3558, false);
            while (true) {
                C3641 c36412 = this.f10993;
                if (c36412.f11021 > this.f11000) {
                    c3558.f10565 = 0;
                    this.f10997 = 4;
                    return -(this.f11003 + 2);
                }
                c3558.m5878(c36412.f11023 + c36412.f11024);
                this.f11001 = c3558.f10563;
                C3641 c36413 = this.f10993;
                this.f11003 = c36413.f11021;
                c36413.m5993(c3558, false);
            }
        }
        if (!m5985(c3558, this.f10995)) {
            throw new EOFException();
        }
        this.f10993.m5992();
        while (true) {
            C3641 c36414 = this.f10993;
            if ((c36414.f11020 & 4) == 4 || c3558.f10563 >= this.f10995) {
                break;
            }
            c36414.m5993(c3558, false);
            C3641 c36415 = this.f10993;
            c3558.m5878(c36415.f11023 + c36415.f11024);
        }
        this.f10998 = this.f10993.f11021;
        this.f10997 = 4;
        return this.f10999;
    }

    @Override // p138.p176.p177.p190.p198.p205.InterfaceC3642
    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public InterfaceC3571 mo5983() {
        C3635 c3635 = null;
        if (this.f10998 != 0) {
            return new C3636(c3635);
        }
        return null;
    }

    @Override // p138.p176.p177.p190.p198.p205.InterfaceC3642
    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public void mo5984(long j) {
        this.f11000 = C4150.m6789(j, 0L, this.f10998 - 1);
        this.f10997 = 2;
        this.f11001 = this.f10994;
        this.f11002 = this.f10995;
        this.f11003 = 0L;
        this.f11004 = this.f10998;
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final boolean m5985(C3558 c3558, long j) throws InterruptedException, EOFException {
        int i;
        long jMin = Math.min(j + 3, this.f10995);
        int i2 = 2048;
        byte[] bArr = new byte[2048];
        while (true) {
            long j2 = c3558.f10563;
            int i3 = 0;
            if (((long) i2) + j2 > jMin && (i2 = (int) (jMin - j2)) < 4) {
                return false;
            }
            c3558.m5875(bArr, 0, i2, false);
            while (true) {
                i = i2 - 3;
                if (i3 < i) {
                    if (bArr[i3] == 79 && bArr[i3 + 1] == 103 && bArr[i3 + 2] == 103 && bArr[i3 + 3] == 83) {
                        c3558.m5878(i3);
                        return true;
                    }
                    i3++;
                }
            }
            c3558.m5878(i);
        }
    }
}
