package Nm6q_10;

import androidx.recyclerview.widget.RecyclerView;
import com.wang.avi.BuildConfig;
import java.io.EOFException;
import java.io.IOException;
import java.io.InputStream;
import java.nio.ByteBuffer;
import java.nio.channels.ByteChannel;
import java.nio.charset.Charset;
/* compiled from: Buffer.kt */
/* loaded from: classes.dex */
public final class X6FRs_4 implements IMuAHx_6, IFxWkV_5, Cloneable, ByteChannel {
    public static final byte[] KQgRr5e_0;

    /* renamed from: KQgRr5e_0  reason: collision with other field name */
    public long f347KQgRr5e_0;

    /* renamed from: KQgRr5e_0  reason: collision with other field name */
    public BVpCZyH_19 f348KQgRr5e_0;

    /* compiled from: Buffer.kt */
    /* loaded from: classes.dex */
    public static final class KQgRr5e_0 {
        public KQgRr5e_0() {
        }

        public /* synthetic */ KQgRr5e_0(FSaI4_7.Xgtqvk_8.QxJ9d_1.Mqv2r_3 mqv2r_3) {
            this();
        }
    }

    static {
        new KQgRr5e_0(null);
        byte[] bytes = "0123456789abcdef".getBytes(FSaI4_7.KNBe_11.PGPF6hQ_2.KQgRr5e_0);
        FSaI4_7.Xgtqvk_8.QxJ9d_1.IFxWkV_5.KQgRr5e_0((Object) bytes, "(this as java.lang.String).getBytes(charset)");
        KQgRr5e_0 = bytes;
    }

    @Override // Nm6q_10.IMuAHx_6, Nm6q_10.G83uNX_24
    public /* bridge */ /* synthetic */ IFxWkV_5 KQgRr5e_0() {
        Mqv2r_3();
        return this;
    }

    @Override // Nm6q_10.IMuAHx_6, Nm6q_10.G83uNX_24
    public X6FRs_4 KQgRr5e_0() {
        return this;
    }

    public X6FRs_4 Mqv2r_3() {
        return this;
    }

    public X6FRs_4 Mqv2r_3(int i) {
        if (i < 128) {
            KQgRr5e_0(i);
        } else if (i < 2048) {
            BVpCZyH_19 KQgRr5e_02 = KQgRr5e_0(2);
            byte[] bArr = KQgRr5e_02.f320KQgRr5e_0;
            int i2 = KQgRr5e_02.QxJ9d_1;
            bArr[i2] = (byte) ((i >> 6) | 192);
            bArr[i2 + 1] = (byte) ((i & 63) | RecyclerView.WGk6X_27.FLAG_IGNORE);
            KQgRr5e_02.QxJ9d_1 = i2 + 2;
            this.f347KQgRr5e_0 += 2;
        } else if (55296 <= i && 57343 >= i) {
            KQgRr5e_0(63);
        } else if (i < 65536) {
            BVpCZyH_19 KQgRr5e_03 = KQgRr5e_0(3);
            byte[] bArr2 = KQgRr5e_03.f320KQgRr5e_0;
            int i3 = KQgRr5e_03.QxJ9d_1;
            bArr2[i3] = (byte) ((i >> 12) | 224);
            bArr2[i3 + 1] = (byte) (((i >> 6) & 63) | RecyclerView.WGk6X_27.FLAG_IGNORE);
            bArr2[i3 + 2] = (byte) ((i & 63) | RecyclerView.WGk6X_27.FLAG_IGNORE);
            KQgRr5e_03.QxJ9d_1 = i3 + 3;
            this.f347KQgRr5e_0 += 3;
        } else if (i <= 1114111) {
            BVpCZyH_19 KQgRr5e_04 = KQgRr5e_0(4);
            byte[] bArr3 = KQgRr5e_04.f320KQgRr5e_0;
            int i4 = KQgRr5e_04.QxJ9d_1;
            bArr3[i4] = (byte) ((i >> 18) | 240);
            bArr3[i4 + 1] = (byte) (((i >> 12) & 63) | RecyclerView.WGk6X_27.FLAG_IGNORE);
            bArr3[i4 + 2] = (byte) (((i >> 6) & 63) | RecyclerView.WGk6X_27.FLAG_IGNORE);
            bArr3[i4 + 3] = (byte) ((i & 63) | RecyclerView.WGk6X_27.FLAG_IGNORE);
            KQgRr5e_04.QxJ9d_1 = i4 + 4;
            this.f347KQgRr5e_0 += 4;
        } else {
            throw new IllegalArgumentException("Unexpected code point: " + Integer.toHexString(i));
        }
        return this;
    }

    @Override // Nm6q_10.IFxWkV_5
    public /* bridge */ /* synthetic */ IFxWkV_5 PGPF6hQ_2(int i) {
        QxJ9d_1(i);
        return this;
    }

    @Override // Nm6q_10.IFxWkV_5
    public /* bridge */ /* synthetic */ IFxWkV_5 QxJ9d_1(int i) {
        KQgRr5e_0(i);
        return this;
    }

    @Override // Nm6q_10.IFxWkV_5
    public X6FRs_4 QxJ9d_1() {
        return this;
    }

    @Override // Nm6q_10.G83uNX_24, java.io.Closeable, java.lang.AutoCloseable, java.nio.channels.Channel
    public void close() {
    }

    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj instanceof X6FRs_4) {
            long j = this.f347KQgRr5e_0;
            X6FRs_4 x6FRs_4 = (X6FRs_4) obj;
            if (j != x6FRs_4.f347KQgRr5e_0) {
                return false;
            }
            long j2 = 0;
            if (j == 0) {
                return true;
            }
            BVpCZyH_19 bVpCZyH_19 = this.f348KQgRr5e_0;
            if (bVpCZyH_19 != null) {
                BVpCZyH_19 bVpCZyH_192 = x6FRs_4.f348KQgRr5e_0;
                if (bVpCZyH_192 != null) {
                    int i = bVpCZyH_19.KQgRr5e_0;
                    int i2 = bVpCZyH_192.KQgRr5e_0;
                    long j3 = 0;
                    while (j3 < this.f347KQgRr5e_0) {
                        long min = Math.min(bVpCZyH_19.QxJ9d_1 - i, bVpCZyH_192.QxJ9d_1 - i2);
                        long j4 = j2;
                        while (j4 < min) {
                            int i3 = i + 1;
                            int i4 = i2 + 1;
                            if (bVpCZyH_19.f320KQgRr5e_0[i] != bVpCZyH_192.f320KQgRr5e_0[i2]) {
                                return false;
                            }
                            j4++;
                            i = i3;
                            i2 = i4;
                        }
                        if (i == bVpCZyH_19.QxJ9d_1) {
                            bVpCZyH_19 = bVpCZyH_19.f318KQgRr5e_0;
                            if (bVpCZyH_19 != null) {
                                i = bVpCZyH_19.KQgRr5e_0;
                            } else {
                                FSaI4_7.Xgtqvk_8.QxJ9d_1.IFxWkV_5.KQgRr5e_0();
                                throw null;
                            }
                        }
                        if (i2 == bVpCZyH_192.QxJ9d_1) {
                            bVpCZyH_192 = bVpCZyH_192.f318KQgRr5e_0;
                            if (bVpCZyH_192 != null) {
                                i2 = bVpCZyH_192.KQgRr5e_0;
                            } else {
                                FSaI4_7.Xgtqvk_8.QxJ9d_1.IFxWkV_5.KQgRr5e_0();
                                throw null;
                            }
                        }
                        j3 += min;
                        j2 = 0;
                    }
                    return true;
                }
                FSaI4_7.Xgtqvk_8.QxJ9d_1.IFxWkV_5.KQgRr5e_0();
                throw null;
            }
            FSaI4_7.Xgtqvk_8.QxJ9d_1.IFxWkV_5.KQgRr5e_0();
            throw null;
        }
        return false;
    }

    @Override // Nm6q_10.IFxWkV_5, Nm6q_10.H5YG8fq_22, java.io.Flushable
    public void flush() {
    }

    public int hashCode() {
        BVpCZyH_19 bVpCZyH_19 = this.f348KQgRr5e_0;
        if (bVpCZyH_19 != null) {
            int i = 1;
            do {
                int i2 = bVpCZyH_19.QxJ9d_1;
                for (int i3 = bVpCZyH_19.KQgRr5e_0; i3 < i2; i3++) {
                    i = (i * 31) + bVpCZyH_19.f320KQgRr5e_0[i3];
                }
                bVpCZyH_19 = bVpCZyH_19.f318KQgRr5e_0;
                if (bVpCZyH_19 == null) {
                    FSaI4_7.Xgtqvk_8.QxJ9d_1.IFxWkV_5.KQgRr5e_0();
                    throw null;
                }
            } while (bVpCZyH_19 != this.f348KQgRr5e_0);
            return i;
        }
        return 0;
    }

    @Override // java.nio.channels.Channel
    public boolean isOpen() {
        return true;
    }

    @Override // java.nio.channels.ReadableByteChannel
    public int read(ByteBuffer byteBuffer) throws IOException {
        FSaI4_7.Xgtqvk_8.QxJ9d_1.IFxWkV_5.QxJ9d_1(byteBuffer, "sink");
        BVpCZyH_19 bVpCZyH_19 = this.f348KQgRr5e_0;
        if (bVpCZyH_19 != null) {
            int min = Math.min(byteBuffer.remaining(), bVpCZyH_19.QxJ9d_1 - bVpCZyH_19.KQgRr5e_0);
            byteBuffer.put(bVpCZyH_19.f320KQgRr5e_0, bVpCZyH_19.KQgRr5e_0, min);
            int i = bVpCZyH_19.KQgRr5e_0 + min;
            bVpCZyH_19.KQgRr5e_0 = i;
            this.f347KQgRr5e_0 -= min;
            if (i == bVpCZyH_19.QxJ9d_1) {
                this.f348KQgRr5e_0 = bVpCZyH_19.KQgRr5e_0();
                ZzDuCHW_20.KQgRr5e_0(bVpCZyH_19);
            }
            return min;
        }
        return -1;
    }

    @Override // Nm6q_10.IMuAHx_6
    public byte readByte() throws EOFException {
        long j = this.f347KQgRr5e_0;
        if (j != 0) {
            BVpCZyH_19 bVpCZyH_19 = this.f348KQgRr5e_0;
            if (bVpCZyH_19 != null) {
                int i = bVpCZyH_19.KQgRr5e_0;
                int i2 = bVpCZyH_19.QxJ9d_1;
                int i3 = i + 1;
                byte b = bVpCZyH_19.f320KQgRr5e_0[i];
                this.f347KQgRr5e_0 = j - 1;
                if (i3 == i2) {
                    this.f348KQgRr5e_0 = bVpCZyH_19.KQgRr5e_0();
                    ZzDuCHW_20.KQgRr5e_0(bVpCZyH_19);
                } else {
                    bVpCZyH_19.KQgRr5e_0 = i3;
                }
                return b;
            }
            FSaI4_7.Xgtqvk_8.QxJ9d_1.IFxWkV_5.KQgRr5e_0();
            throw null;
        }
        throw new EOFException();
    }

    @Override // Nm6q_10.IMuAHx_6
    public void readFully(byte[] bArr) throws EOFException {
        FSaI4_7.Xgtqvk_8.QxJ9d_1.IFxWkV_5.QxJ9d_1(bArr, "sink");
        int i = 0;
        while (i < bArr.length) {
            int KQgRr5e_02 = KQgRr5e_0(bArr, i, bArr.length - i);
            if (KQgRr5e_02 == -1) {
                throw new EOFException();
            }
            i += KQgRr5e_02;
        }
    }

    @Override // Nm6q_10.IMuAHx_6
    public int readInt() throws EOFException {
        long j = this.f347KQgRr5e_0;
        if (j >= 4) {
            BVpCZyH_19 bVpCZyH_19 = this.f348KQgRr5e_0;
            if (bVpCZyH_19 != null) {
                int i = bVpCZyH_19.KQgRr5e_0;
                int i2 = bVpCZyH_19.QxJ9d_1;
                if (i2 - i < 4) {
                    return ((readByte() & 255) << 24) | ((readByte() & 255) << 16) | ((readByte() & 255) << 8) | (readByte() & 255);
                }
                byte[] bArr = bVpCZyH_19.f320KQgRr5e_0;
                int i3 = i + 1;
                int i4 = i3 + 1;
                int i5 = ((bArr[i] & 255) << 24) | ((bArr[i3] & 255) << 16);
                int i6 = i4 + 1;
                int i7 = i5 | ((bArr[i4] & 255) << 8);
                int i8 = i6 + 1;
                int i9 = i7 | (bArr[i6] & 255);
                this.f347KQgRr5e_0 = j - 4;
                if (i8 == i2) {
                    this.f348KQgRr5e_0 = bVpCZyH_19.KQgRr5e_0();
                    ZzDuCHW_20.KQgRr5e_0(bVpCZyH_19);
                } else {
                    bVpCZyH_19.KQgRr5e_0 = i8;
                }
                return i9;
            }
            FSaI4_7.Xgtqvk_8.QxJ9d_1.IFxWkV_5.KQgRr5e_0();
            throw null;
        }
        throw new EOFException();
    }

    @Override // Nm6q_10.IMuAHx_6
    public short readShort() throws EOFException {
        long j = this.f347KQgRr5e_0;
        if (j >= 2) {
            BVpCZyH_19 bVpCZyH_19 = this.f348KQgRr5e_0;
            if (bVpCZyH_19 != null) {
                int i = bVpCZyH_19.KQgRr5e_0;
                int i2 = bVpCZyH_19.QxJ9d_1;
                if (i2 - i < 2) {
                    return (short) (((readByte() & 255) << 8) | (readByte() & 255));
                }
                byte[] bArr = bVpCZyH_19.f320KQgRr5e_0;
                int i3 = i + 1;
                int i4 = i3 + 1;
                int i5 = ((bArr[i] & 255) << 8) | (bArr[i3] & 255);
                this.f347KQgRr5e_0 = j - 2;
                if (i4 == i2) {
                    this.f348KQgRr5e_0 = bVpCZyH_19.KQgRr5e_0();
                    ZzDuCHW_20.KQgRr5e_0(bVpCZyH_19);
                } else {
                    bVpCZyH_19.KQgRr5e_0 = i4;
                }
                return (short) i5;
            }
            FSaI4_7.Xgtqvk_8.QxJ9d_1.IFxWkV_5.KQgRr5e_0();
            throw null;
        }
        throw new EOFException();
    }

    public String toString() {
        return QxJ9d_1().toString();
    }

    @Override // java.nio.channels.WritableByteChannel
    public int write(ByteBuffer byteBuffer) throws IOException {
        FSaI4_7.Xgtqvk_8.QxJ9d_1.IFxWkV_5.QxJ9d_1(byteBuffer, "source");
        int remaining = byteBuffer.remaining();
        int i = remaining;
        while (i > 0) {
            BVpCZyH_19 KQgRr5e_02 = KQgRr5e_0(1);
            int min = Math.min(i, 8192 - KQgRr5e_02.QxJ9d_1);
            byteBuffer.get(KQgRr5e_02.f320KQgRr5e_0, KQgRr5e_02.QxJ9d_1, min);
            i -= min;
            KQgRr5e_02.QxJ9d_1 += min;
        }
        this.f347KQgRr5e_0 += remaining;
        return remaining;
    }

    /* compiled from: Buffer.kt */
    /* loaded from: classes.dex */
    public static final class QxJ9d_1 extends InputStream {
        public QxJ9d_1() {
        }

        @Override // java.io.InputStream
        public int available() {
            return (int) Math.min(X6FRs_4.this.PGPF6hQ_2(), Integer.MAX_VALUE);
        }

        @Override // java.io.InputStream, java.io.Closeable, java.lang.AutoCloseable
        public void close() {
        }

        @Override // java.io.InputStream
        public int read() {
            if (X6FRs_4.this.PGPF6hQ_2() > 0) {
                return X6FRs_4.this.readByte() & 255;
            }
            return -1;
        }

        public String toString() {
            return X6FRs_4.this + ".inputStream()";
        }

        @Override // java.io.InputStream
        public int read(byte[] bArr, int i, int i2) {
            FSaI4_7.Xgtqvk_8.QxJ9d_1.IFxWkV_5.QxJ9d_1(bArr, "sink");
            return X6FRs_4.this.KQgRr5e_0(bArr, i, i2);
        }
    }

    @Override // Nm6q_10.IFxWkV_5
    public /* bridge */ /* synthetic */ IFxWkV_5 KQgRr5e_0(byte[] bArr) {
        KQgRr5e_0(bArr);
        return this;
    }

    /* renamed from: PGPF6hQ_2  reason: collision with other method in class */
    public final void m182PGPF6hQ_2(long j) {
        this.f347KQgRr5e_0 = j;
    }

    @Override // Nm6q_10.IFxWkV_5
    public final long QxJ9d_1() {
        long j = this.f347KQgRr5e_0;
        if (j == 0) {
            return 0L;
        }
        BVpCZyH_19 bVpCZyH_19 = this.f348KQgRr5e_0;
        if (bVpCZyH_19 == null) {
            FSaI4_7.Xgtqvk_8.QxJ9d_1.IFxWkV_5.KQgRr5e_0();
            throw null;
        }
        BVpCZyH_19 bVpCZyH_192 = bVpCZyH_19.f321QxJ9d_1;
        if (bVpCZyH_192 != null) {
            int i = bVpCZyH_192.QxJ9d_1;
            return (i >= 8192 || !bVpCZyH_192.f322QxJ9d_1) ? j : j - (i - bVpCZyH_192.KQgRr5e_0);
        }
        FSaI4_7.Xgtqvk_8.QxJ9d_1.IFxWkV_5.KQgRr5e_0();
        throw null;
    }

    @Override // Nm6q_10.IFxWkV_5
    public /* bridge */ /* synthetic */ IFxWkV_5 KQgRr5e_0(byte[] bArr, int i, int i2) {
        KQgRr5e_0(bArr, i, i2);
        return this;
    }

    public final long PGPF6hQ_2() {
        return this.f347KQgRr5e_0;
    }

    @Override // Nm6q_10.IMuAHx_6
    public /* bridge */ /* synthetic */ IFxWkV_5 KQgRr5e_0(long j) {
        KQgRr5e_0(j);
        return this;
    }

    public final String PGPF6hQ_2(long j) throws EOFException {
        if (j > 0) {
            long j2 = j - 1;
            if (KQgRr5e_0(j2) == ((byte) 13)) {
                String QxJ9d_12 = QxJ9d_1(j2);
                QxJ9d_1(2L);
                return QxJ9d_12;
            }
        }
        String QxJ9d_13 = QxJ9d_1(j);
        QxJ9d_1(1L);
        return QxJ9d_13;
    }

    @Override // Nm6q_10.IFxWkV_5
    public /* bridge */ /* synthetic */ IFxWkV_5 KQgRr5e_0(int i) {
        PGPF6hQ_2(i);
        return this;
    }

    @Override // Nm6q_10.IFxWkV_5
    public /* bridge */ /* synthetic */ IFxWkV_5 KQgRr5e_0(String str) {
        KQgRr5e_0(str);
        return this;
    }

    @Override // Nm6q_10.IMuAHx_6, Nm6q_10.G83uNX_24
    public boolean KQgRr5e_0() {
        return this.f347KQgRr5e_0 == 0;
    }

    @Override // Nm6q_10.IFxWkV_5
    public String QxJ9d_1() {
        return KQgRr5e_0(this.f347KQgRr5e_0, FSaI4_7.KNBe_11.PGPF6hQ_2.KQgRr5e_0);
    }

    @Override // Nm6q_10.IMuAHx_6
    public void KQgRr5e_0(long j) throws EOFException {
        if (this.f347KQgRr5e_0 < j) {
            throw new EOFException();
        }
    }

    @Override // Nm6q_10.IMuAHx_6
    public String QxJ9d_1(long j) throws EOFException {
        return KQgRr5e_0(j, FSaI4_7.KNBe_11.PGPF6hQ_2.KQgRr5e_0);
    }

    @Override // Nm6q_10.IMuAHx_6, Nm6q_10.G83uNX_24
    public InputStream KQgRr5e_0() {
        return new QxJ9d_1();
    }

    @Override // Nm6q_10.IFxWkV_5
    public X6FRs_4 PGPF6hQ_2(int i) {
        BVpCZyH_19 KQgRr5e_02 = KQgRr5e_0(2);
        byte[] bArr = KQgRr5e_02.f320KQgRr5e_0;
        int i2 = KQgRr5e_02.QxJ9d_1;
        int i3 = i2 + 1;
        bArr[i2] = (byte) ((i >>> 8) & 255);
        bArr[i3] = (byte) (i & 255);
        KQgRr5e_02.QxJ9d_1 = i3 + 1;
        this.f347KQgRr5e_0 += 2;
        return this;
    }

    @Override // Nm6q_10.IMuAHx_6
    public void QxJ9d_1(long j) throws EOFException {
        while (j > 0) {
            BVpCZyH_19 bVpCZyH_19 = this.f348KQgRr5e_0;
            if (bVpCZyH_19 != null) {
                int min = (int) Math.min(j, bVpCZyH_19.QxJ9d_1 - bVpCZyH_19.KQgRr5e_0);
                long j2 = min;
                this.f347KQgRr5e_0 -= j2;
                j -= j2;
                int i = bVpCZyH_19.KQgRr5e_0 + min;
                bVpCZyH_19.KQgRr5e_0 = i;
                if (i == bVpCZyH_19.QxJ9d_1) {
                    this.f348KQgRr5e_0 = bVpCZyH_19.KQgRr5e_0();
                    ZzDuCHW_20.KQgRr5e_0(bVpCZyH_19);
                }
            } else {
                throw new EOFException();
            }
        }
    }

    public final X6FRs_4 KQgRr5e_0(X6FRs_4 x6FRs_4, long j, long j2) {
        FSaI4_7.Xgtqvk_8.QxJ9d_1.IFxWkV_5.QxJ9d_1(x6FRs_4, "out");
        PGPF6hQ_2.KQgRr5e_0(this.f347KQgRr5e_0, j, j2);
        if (j2 == 0) {
            return this;
        }
        x6FRs_4.f347KQgRr5e_0 += j2;
        BVpCZyH_19 bVpCZyH_19 = this.f348KQgRr5e_0;
        while (bVpCZyH_19 != null) {
            int i = bVpCZyH_19.QxJ9d_1;
            int i2 = bVpCZyH_19.KQgRr5e_0;
            if (j < i - i2) {
                while (j2 > 0) {
                    if (bVpCZyH_19 != null) {
                        BVpCZyH_19 QxJ9d_12 = bVpCZyH_19.QxJ9d_1();
                        int i3 = QxJ9d_12.KQgRr5e_0 + ((int) j);
                        QxJ9d_12.KQgRr5e_0 = i3;
                        QxJ9d_12.QxJ9d_1 = Math.min(i3 + ((int) j2), QxJ9d_12.QxJ9d_1);
                        BVpCZyH_19 bVpCZyH_192 = x6FRs_4.f348KQgRr5e_0;
                        if (bVpCZyH_192 == null) {
                            QxJ9d_12.f321QxJ9d_1 = QxJ9d_12;
                            QxJ9d_12.f318KQgRr5e_0 = QxJ9d_12;
                            x6FRs_4.f348KQgRr5e_0 = QxJ9d_12;
                        } else if (bVpCZyH_192 == null) {
                            FSaI4_7.Xgtqvk_8.QxJ9d_1.IFxWkV_5.KQgRr5e_0();
                            throw null;
                        } else {
                            BVpCZyH_19 bVpCZyH_193 = bVpCZyH_192.f321QxJ9d_1;
                            if (bVpCZyH_193 == null) {
                                FSaI4_7.Xgtqvk_8.QxJ9d_1.IFxWkV_5.KQgRr5e_0();
                                throw null;
                            }
                            bVpCZyH_193.KQgRr5e_0(QxJ9d_12);
                        }
                        j2 -= QxJ9d_12.QxJ9d_1 - QxJ9d_12.KQgRr5e_0;
                        bVpCZyH_19 = bVpCZyH_19.f318KQgRr5e_0;
                        j = 0;
                    } else {
                        FSaI4_7.Xgtqvk_8.QxJ9d_1.IFxWkV_5.KQgRr5e_0();
                        throw null;
                    }
                }
                return this;
            }
            j -= i - i2;
            bVpCZyH_19 = bVpCZyH_19.f318KQgRr5e_0;
        }
        FSaI4_7.Xgtqvk_8.QxJ9d_1.IFxWkV_5.KQgRr5e_0();
        throw null;
    }

    /* renamed from: PGPF6hQ_2  reason: collision with other method in class */
    public X6FRs_4 clone() {
        X6FRs_4 x6FRs_4 = new X6FRs_4();
        if (this.f347KQgRr5e_0 == 0) {
            return x6FRs_4;
        }
        BVpCZyH_19 bVpCZyH_19 = this.f348KQgRr5e_0;
        if (bVpCZyH_19 == null) {
            FSaI4_7.Xgtqvk_8.QxJ9d_1.IFxWkV_5.KQgRr5e_0();
            throw null;
        }
        BVpCZyH_19 QxJ9d_12 = bVpCZyH_19.QxJ9d_1();
        x6FRs_4.f348KQgRr5e_0 = QxJ9d_12;
        if (QxJ9d_12 != null) {
            QxJ9d_12.f321QxJ9d_1 = QxJ9d_12;
            if (QxJ9d_12 == null) {
                FSaI4_7.Xgtqvk_8.QxJ9d_1.IFxWkV_5.KQgRr5e_0();
                throw null;
            } else if (QxJ9d_12 != null) {
                QxJ9d_12.f318KQgRr5e_0 = QxJ9d_12;
                BVpCZyH_19 bVpCZyH_192 = this.f348KQgRr5e_0;
                if (bVpCZyH_192 != null) {
                    for (BVpCZyH_19 bVpCZyH_193 = bVpCZyH_192.f318KQgRr5e_0; bVpCZyH_193 != this.f348KQgRr5e_0; bVpCZyH_193 = bVpCZyH_193.f318KQgRr5e_0) {
                        BVpCZyH_19 bVpCZyH_194 = x6FRs_4.f348KQgRr5e_0;
                        if (bVpCZyH_194 == null) {
                            FSaI4_7.Xgtqvk_8.QxJ9d_1.IFxWkV_5.KQgRr5e_0();
                            throw null;
                        }
                        BVpCZyH_19 bVpCZyH_195 = bVpCZyH_194.f321QxJ9d_1;
                        if (bVpCZyH_195 == null) {
                            FSaI4_7.Xgtqvk_8.QxJ9d_1.IFxWkV_5.KQgRr5e_0();
                            throw null;
                        } else if (bVpCZyH_193 != null) {
                            bVpCZyH_195.KQgRr5e_0(bVpCZyH_193.QxJ9d_1());
                        } else {
                            FSaI4_7.Xgtqvk_8.QxJ9d_1.IFxWkV_5.KQgRr5e_0();
                            throw null;
                        }
                    }
                    x6FRs_4.f347KQgRr5e_0 = this.f347KQgRr5e_0;
                    return x6FRs_4;
                }
                FSaI4_7.Xgtqvk_8.QxJ9d_1.IFxWkV_5.KQgRr5e_0();
                throw null;
            } else {
                FSaI4_7.Xgtqvk_8.QxJ9d_1.IFxWkV_5.KQgRr5e_0();
                throw null;
            }
        }
        FSaI4_7.Xgtqvk_8.QxJ9d_1.IFxWkV_5.KQgRr5e_0();
        throw null;
    }

    @Override // Nm6q_10.IFxWkV_5
    public X6FRs_4 QxJ9d_1(int i) {
        BVpCZyH_19 KQgRr5e_02 = KQgRr5e_0(4);
        byte[] bArr = KQgRr5e_02.f320KQgRr5e_0;
        int i2 = KQgRr5e_02.QxJ9d_1;
        int i3 = i2 + 1;
        bArr[i2] = (byte) ((i >>> 24) & 255);
        int i4 = i3 + 1;
        bArr[i3] = (byte) ((i >>> 16) & 255);
        int i5 = i4 + 1;
        bArr[i4] = (byte) ((i >>> 8) & 255);
        bArr[i5] = (byte) (i & 255);
        KQgRr5e_02.QxJ9d_1 = i5 + 1;
        this.f347KQgRr5e_0 += 4;
        return this;
    }

    @Override // Nm6q_10.IFxWkV_5
    public final FSaI4_7 QxJ9d_1() {
        if (this.f347KQgRr5e_0 <= ((long) Integer.MAX_VALUE)) {
            return KQgRr5e_0((int) this.f347KQgRr5e_0);
        }
        throw new IllegalStateException(("size > Integer.MAX_VALUE: " + this.f347KQgRr5e_0).toString());
    }

    @Override // Nm6q_10.IMuAHx_6
    public final byte KQgRr5e_0(long j) {
        PGPF6hQ_2.KQgRr5e_0(this.f347KQgRr5e_0, j, 1L);
        BVpCZyH_19 bVpCZyH_19 = this.f348KQgRr5e_0;
        if (bVpCZyH_19 != null) {
            if (PGPF6hQ_2() - j < j) {
                long PGPF6hQ_2 = PGPF6hQ_2();
                while (PGPF6hQ_2 > j) {
                    bVpCZyH_19 = bVpCZyH_19.f321QxJ9d_1;
                    if (bVpCZyH_19 != null) {
                        PGPF6hQ_2 -= bVpCZyH_19.QxJ9d_1 - bVpCZyH_19.KQgRr5e_0;
                    } else {
                        FSaI4_7.Xgtqvk_8.QxJ9d_1.IFxWkV_5.KQgRr5e_0();
                        throw null;
                    }
                }
                if (bVpCZyH_19 != null) {
                    return bVpCZyH_19.f320KQgRr5e_0[(int) ((bVpCZyH_19.KQgRr5e_0 + j) - PGPF6hQ_2)];
                }
                FSaI4_7.Xgtqvk_8.QxJ9d_1.IFxWkV_5.KQgRr5e_0();
                throw null;
            }
            long j2 = 0;
            while (true) {
                int i = bVpCZyH_19.QxJ9d_1;
                int i2 = bVpCZyH_19.KQgRr5e_0;
                long j3 = (i - i2) + j2;
                if (j3 > j) {
                    if (bVpCZyH_19 != null) {
                        return bVpCZyH_19.f320KQgRr5e_0[(int) ((i2 + j) - j2)];
                    }
                    FSaI4_7.Xgtqvk_8.QxJ9d_1.IFxWkV_5.KQgRr5e_0();
                    throw null;
                }
                bVpCZyH_19 = bVpCZyH_19.f318KQgRr5e_0;
                if (bVpCZyH_19 == null) {
                    FSaI4_7.Xgtqvk_8.QxJ9d_1.IFxWkV_5.KQgRr5e_0();
                    throw null;
                }
                j2 = j3;
            }
        } else {
            FSaI4_7.Xgtqvk_8.QxJ9d_1.IFxWkV_5.KQgRr5e_0();
            throw null;
        }
    }

    @Override // Nm6q_10.IMuAHx_6, Nm6q_10.G83uNX_24
    public short KQgRr5e_0() throws EOFException {
        return PGPF6hQ_2.KQgRr5e_0(readShort());
    }

    @Override // Nm6q_10.IMuAHx_6, Nm6q_10.G83uNX_24
    public int KQgRr5e_0() throws EOFException {
        return PGPF6hQ_2.KQgRr5e_0(readInt());
    }

    /* JADX WARN: Removed duplicated region for block: B:34:0x0097  */
    /* JADX WARN: Removed duplicated region for block: B:35:0x00a1  */
    /* JADX WARN: Removed duplicated region for block: B:37:0x00a5  */
    /* JADX WARN: Removed duplicated region for block: B:48:0x00a9 A[EDGE_INSN: B:48:0x00a9->B:39:0x00a9 ?: BREAK  , SYNTHETIC] */
    @Override // Nm6q_10.IMuAHx_6, Nm6q_10.G83uNX_24
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public long KQgRr5e_0() throws EOFException {
        int i;
        if (this.f347KQgRr5e_0 != 0) {
            int i2 = 0;
            long j = 0;
            boolean z = false;
            do {
                BVpCZyH_19 bVpCZyH_19 = this.f348KQgRr5e_0;
                if (bVpCZyH_19 != null) {
                    byte[] bArr = bVpCZyH_19.f320KQgRr5e_0;
                    int i3 = bVpCZyH_19.KQgRr5e_0;
                    int i4 = bVpCZyH_19.QxJ9d_1;
                    while (i3 < i4) {
                        byte b = bArr[i3];
                        byte b2 = (byte) 48;
                        if (b < b2 || b > ((byte) 57)) {
                            byte b3 = (byte) 97;
                            if ((b >= b3 && b <= ((byte) 102)) || (b >= (b3 = (byte) 65) && b <= ((byte) 70))) {
                                i = (b - b3) + 10;
                            } else if (i2 == 0) {
                                throw new NumberFormatException("Expected leading [0-9a-fA-F] character but was 0x" + Integer.toHexString(b));
                            } else {
                                z = true;
                                if (i3 != i4) {
                                    this.f348KQgRr5e_0 = bVpCZyH_19.KQgRr5e_0();
                                    ZzDuCHW_20.KQgRr5e_0(bVpCZyH_19);
                                } else {
                                    bVpCZyH_19.KQgRr5e_0 = i3;
                                }
                                if (!z) {
                                    break;
                                }
                            }
                        } else {
                            i = b - b2;
                        }
                        if (((-1152921504606846976L) & j) != 0) {
                            X6FRs_4 x6FRs_4 = new X6FRs_4();
                            x6FRs_4.KQgRr5e_0(j);
                            x6FRs_4.KQgRr5e_0((int) b);
                            throw new NumberFormatException("Number too large: " + x6FRs_4.QxJ9d_1());
                        }
                        j = (j << 4) | i;
                        i3++;
                        i2++;
                    }
                    if (i3 != i4) {
                    }
                    if (!z) {
                    }
                } else {
                    FSaI4_7.Xgtqvk_8.QxJ9d_1.IFxWkV_5.KQgRr5e_0();
                    throw null;
                }
            } while (this.f348KQgRr5e_0 != null);
            this.f347KQgRr5e_0 -= i2;
            return j;
        }
        throw new EOFException();
    }

    @Override // Nm6q_10.IMuAHx_6, Nm6q_10.G83uNX_24
    public FSaI4_7 KQgRr5e_0() {
        return new FSaI4_7(KQgRr5e_0());
    }

    @Override // Nm6q_10.IMuAHx_6
    public FSaI4_7 KQgRr5e_0(long j) throws EOFException {
        return new FSaI4_7(KQgRr5e_0(j));
    }

    public String KQgRr5e_0(long j, Charset charset) throws EOFException {
        FSaI4_7.Xgtqvk_8.QxJ9d_1.IFxWkV_5.QxJ9d_1(charset, "charset");
        if (j >= 0 && j <= ((long) Integer.MAX_VALUE)) {
            if (this.f347KQgRr5e_0 >= j) {
                if (j == 0) {
                    return BuildConfig.FLAVOR;
                }
                BVpCZyH_19 bVpCZyH_19 = this.f348KQgRr5e_0;
                if (bVpCZyH_19 != null) {
                    int i = bVpCZyH_19.KQgRr5e_0;
                    if (i + j > bVpCZyH_19.QxJ9d_1) {
                        return new String(KQgRr5e_0(j), charset);
                    }
                    int i2 = (int) j;
                    String str = new String(bVpCZyH_19.f320KQgRr5e_0, i, i2, charset);
                    int i3 = bVpCZyH_19.KQgRr5e_0 + i2;
                    bVpCZyH_19.KQgRr5e_0 = i3;
                    this.f347KQgRr5e_0 -= j;
                    if (i3 == bVpCZyH_19.QxJ9d_1) {
                        this.f348KQgRr5e_0 = bVpCZyH_19.KQgRr5e_0();
                        ZzDuCHW_20.KQgRr5e_0(bVpCZyH_19);
                    }
                    return str;
                }
                FSaI4_7.Xgtqvk_8.QxJ9d_1.IFxWkV_5.KQgRr5e_0();
                throw null;
            }
            throw new EOFException();
        }
        throw new IllegalArgumentException(("byteCount: " + j).toString());
    }

    @Override // Nm6q_10.IMuAHx_6, Nm6q_10.G83uNX_24
    public String KQgRr5e_0() throws EOFException {
        return KQgRr5e_0(RecyclerView.FOREVER_NS);
    }

    @Override // Nm6q_10.IMuAHx_6
    public String KQgRr5e_0(long j) throws EOFException {
        if (j >= 0) {
            long j2 = RecyclerView.FOREVER_NS;
            if (j != RecyclerView.FOREVER_NS) {
                j2 = j + 1;
            }
            byte b = (byte) 10;
            long KQgRr5e_02 = KQgRr5e_0(b, 0L, j2);
            if (KQgRr5e_02 != -1) {
                return PGPF6hQ_2(KQgRr5e_02);
            }
            if (j2 < this.f347KQgRr5e_0 && KQgRr5e_0(j2 - 1) == ((byte) 13) && KQgRr5e_0(j2) == b) {
                return PGPF6hQ_2(j2);
            }
            X6FRs_4 x6FRs_4 = new X6FRs_4();
            KQgRr5e_0(x6FRs_4, 0L, Math.min(32, this.f347KQgRr5e_0));
            throw new EOFException("\\n not found: limit=" + Math.min(this.f347KQgRr5e_0, j) + " content=" + x6FRs_4.KQgRr5e_0().m164PGPF6hQ_2() + (char) 8230);
        }
        throw new IllegalArgumentException(("limit < 0: " + j).toString());
    }

    @Override // Nm6q_10.IMuAHx_6, Nm6q_10.G83uNX_24
    public byte[] KQgRr5e_0() {
        return KQgRr5e_0(this.f347KQgRr5e_0);
    }

    @Override // Nm6q_10.IMuAHx_6
    public byte[] KQgRr5e_0(long j) throws EOFException {
        if (j >= 0 && j <= ((long) Integer.MAX_VALUE)) {
            if (this.f347KQgRr5e_0 >= j) {
                byte[] bArr = new byte[(int) j];
                readFully(bArr);
                return bArr;
            }
            throw new EOFException();
        }
        throw new IllegalArgumentException(("byteCount: " + j).toString());
    }

    @Override // Nm6q_10.IFxWkV_5
    public int KQgRr5e_0(byte[] bArr, int i, int i2) {
        FSaI4_7.Xgtqvk_8.QxJ9d_1.IFxWkV_5.QxJ9d_1(bArr, "sink");
        PGPF6hQ_2.KQgRr5e_0(bArr.length, i, i2);
        BVpCZyH_19 bVpCZyH_19 = this.f348KQgRr5e_0;
        if (bVpCZyH_19 != null) {
            int min = Math.min(i2, bVpCZyH_19.QxJ9d_1 - bVpCZyH_19.KQgRr5e_0);
            System.arraycopy(bVpCZyH_19.f320KQgRr5e_0, bVpCZyH_19.KQgRr5e_0, bArr, i, min);
            int i3 = bVpCZyH_19.KQgRr5e_0 + min;
            bVpCZyH_19.KQgRr5e_0 = i3;
            this.f347KQgRr5e_0 -= min;
            if (i3 == bVpCZyH_19.QxJ9d_1) {
                this.f348KQgRr5e_0 = bVpCZyH_19.KQgRr5e_0();
                ZzDuCHW_20.KQgRr5e_0(bVpCZyH_19);
            }
            return min;
        }
        return -1;
    }

    @Override // Nm6q_10.IMuAHx_6, Nm6q_10.G83uNX_24
    public final void KQgRr5e_0() {
        QxJ9d_1(this.f347KQgRr5e_0);
    }

    public X6FRs_4 KQgRr5e_0(FSaI4_7 fSaI4_7) {
        FSaI4_7.Xgtqvk_8.QxJ9d_1.IFxWkV_5.QxJ9d_1(fSaI4_7, "byteString");
        fSaI4_7.KQgRr5e_0(this);
        return this;
    }

    @Override // Nm6q_10.IFxWkV_5
    public X6FRs_4 KQgRr5e_0(String str) {
        FSaI4_7.Xgtqvk_8.QxJ9d_1.IFxWkV_5.QxJ9d_1(str, "string");
        KQgRr5e_0(str, 0, str.length());
        return this;
    }

    public X6FRs_4 KQgRr5e_0(String str, int i, int i2) {
        FSaI4_7.Xgtqvk_8.QxJ9d_1.IFxWkV_5.QxJ9d_1(str, "string");
        if (!(i >= 0)) {
            throw new IllegalArgumentException(("beginIndex < 0: " + i).toString());
        }
        if (i2 >= i) {
            if (!(i2 <= str.length())) {
                throw new IllegalArgumentException(("endIndex > string.length: " + i2 + " > " + str.length()).toString());
            }
            while (i < i2) {
                char charAt = str.charAt(i);
                if (charAt < 128) {
                    BVpCZyH_19 KQgRr5e_02 = KQgRr5e_0(1);
                    byte[] bArr = KQgRr5e_02.f320KQgRr5e_0;
                    int i3 = KQgRr5e_02.QxJ9d_1 - i;
                    int min = Math.min(i2, 8192 - i3);
                    int i4 = i + 1;
                    bArr[i + i3] = (byte) charAt;
                    while (i4 < min) {
                        char charAt2 = str.charAt(i4);
                        if (charAt2 >= 128) {
                            break;
                        }
                        bArr[i4 + i3] = (byte) charAt2;
                        i4++;
                    }
                    int i5 = KQgRr5e_02.QxJ9d_1;
                    int i6 = (i3 + i4) - i5;
                    KQgRr5e_02.QxJ9d_1 = i5 + i6;
                    this.f347KQgRr5e_0 += i6;
                    i = i4;
                } else {
                    if (charAt < 2048) {
                        BVpCZyH_19 KQgRr5e_03 = KQgRr5e_0(2);
                        byte[] bArr2 = KQgRr5e_03.f320KQgRr5e_0;
                        int i7 = KQgRr5e_03.QxJ9d_1;
                        bArr2[i7] = (byte) ((charAt >> 6) | 192);
                        bArr2[i7 + 1] = (byte) ((charAt & '?') | RecyclerView.WGk6X_27.FLAG_IGNORE);
                        KQgRr5e_03.QxJ9d_1 = i7 + 2;
                        this.f347KQgRr5e_0 += 2;
                    } else if (charAt >= 55296 && charAt <= 57343) {
                        int i8 = i + 1;
                        char charAt3 = i8 < i2 ? str.charAt(i8) : (char) 0;
                        if (charAt <= 56319 && 56320 <= charAt3 && 57343 >= charAt3) {
                            int i9 = (((charAt & 1023) << 10) | (charAt3 & 1023)) + 65536;
                            BVpCZyH_19 KQgRr5e_04 = KQgRr5e_0(4);
                            byte[] bArr3 = KQgRr5e_04.f320KQgRr5e_0;
                            int i10 = KQgRr5e_04.QxJ9d_1;
                            bArr3[i10] = (byte) ((i9 >> 18) | 240);
                            bArr3[i10 + 1] = (byte) (((i9 >> 12) & 63) | RecyclerView.WGk6X_27.FLAG_IGNORE);
                            bArr3[i10 + 2] = (byte) (((i9 >> 6) & 63) | RecyclerView.WGk6X_27.FLAG_IGNORE);
                            bArr3[i10 + 3] = (byte) ((i9 & 63) | RecyclerView.WGk6X_27.FLAG_IGNORE);
                            KQgRr5e_04.QxJ9d_1 = i10 + 4;
                            this.f347KQgRr5e_0 += 4;
                            i += 2;
                        } else {
                            KQgRr5e_0(63);
                            i = i8;
                        }
                    } else {
                        BVpCZyH_19 KQgRr5e_05 = KQgRr5e_0(3);
                        byte[] bArr4 = KQgRr5e_05.f320KQgRr5e_0;
                        int i11 = KQgRr5e_05.QxJ9d_1;
                        bArr4[i11] = (byte) ((charAt >> '\f') | 224);
                        bArr4[i11 + 1] = (byte) ((63 & (charAt >> 6)) | RecyclerView.WGk6X_27.FLAG_IGNORE);
                        bArr4[i11 + 2] = (byte) ((charAt & '?') | RecyclerView.WGk6X_27.FLAG_IGNORE);
                        KQgRr5e_05.QxJ9d_1 = i11 + 3;
                        this.f347KQgRr5e_0 += 3;
                    }
                    i++;
                }
            }
            return this;
        }
        throw new IllegalArgumentException(("endIndex < beginIndex: " + i2 + " < " + i).toString());
    }

    public X6FRs_4 KQgRr5e_0(String str, int i, int i2, Charset charset) {
        FSaI4_7.Xgtqvk_8.QxJ9d_1.IFxWkV_5.QxJ9d_1(str, "string");
        FSaI4_7.Xgtqvk_8.QxJ9d_1.IFxWkV_5.QxJ9d_1(charset, "charset");
        if (!(i >= 0)) {
            throw new IllegalArgumentException(("beginIndex < 0: " + i).toString());
        }
        if (i2 >= i) {
            if (i2 <= str.length()) {
                if (FSaI4_7.Xgtqvk_8.QxJ9d_1.IFxWkV_5.KQgRr5e_0(charset, FSaI4_7.KNBe_11.PGPF6hQ_2.KQgRr5e_0)) {
                    KQgRr5e_0(str, i, i2);
                    return this;
                }
                String substring = str.substring(i, i2);
                FSaI4_7.Xgtqvk_8.QxJ9d_1.IFxWkV_5.KQgRr5e_0((Object) substring, "(this as java.lang.Strin…ing(startIndex, endIndex)");
                if (substring != null) {
                    byte[] bytes = substring.getBytes(charset);
                    FSaI4_7.Xgtqvk_8.QxJ9d_1.IFxWkV_5.KQgRr5e_0((Object) bytes, "(this as java.lang.String).getBytes(charset)");
                    KQgRr5e_0(bytes, 0, bytes.length);
                    return this;
                }
                throw new FSaI4_7.Mqv2r_3("null cannot be cast to non-null type java.lang.String");
            }
            throw new IllegalArgumentException(("endIndex > string.length: " + i2 + " > " + str.length()).toString());
        }
        throw new IllegalArgumentException(("endIndex < beginIndex: " + i2 + " < " + i).toString());
    }

    @Override // Nm6q_10.IFxWkV_5
    public X6FRs_4 KQgRr5e_0(byte[] bArr) {
        FSaI4_7.Xgtqvk_8.QxJ9d_1.IFxWkV_5.QxJ9d_1(bArr, "source");
        KQgRr5e_0(bArr, 0, bArr.length);
        return this;
    }

    @Override // Nm6q_10.IFxWkV_5
    public X6FRs_4 KQgRr5e_0(byte[] bArr, int i, int i2) {
        FSaI4_7.Xgtqvk_8.QxJ9d_1.IFxWkV_5.QxJ9d_1(bArr, "source");
        long j = i2;
        PGPF6hQ_2.KQgRr5e_0(bArr.length, i, j);
        int i3 = i2 + i;
        while (i < i3) {
            BVpCZyH_19 KQgRr5e_02 = KQgRr5e_0(1);
            int min = Math.min(i3 - i, 8192 - KQgRr5e_02.QxJ9d_1);
            System.arraycopy(bArr, i, KQgRr5e_02.f320KQgRr5e_0, KQgRr5e_02.QxJ9d_1, min);
            i += min;
            KQgRr5e_02.QxJ9d_1 += min;
        }
        this.f347KQgRr5e_0 += j;
        return this;
    }

    public long KQgRr5e_0(G83uNX_24 g83uNX_24) throws IOException {
        FSaI4_7.Xgtqvk_8.QxJ9d_1.IFxWkV_5.QxJ9d_1(g83uNX_24, "source");
        long j = 0;
        while (true) {
            long KQgRr5e_02 = g83uNX_24.KQgRr5e_0(this, (long) RecyclerView.WGk6X_27.FLAG_BOUNCED_FROM_HIDDEN_LIST);
            if (KQgRr5e_02 == -1) {
                return j;
            }
            j += KQgRr5e_02;
        }
    }

    @Override // Nm6q_10.IFxWkV_5
    public X6FRs_4 KQgRr5e_0(int i) {
        BVpCZyH_19 KQgRr5e_02 = KQgRr5e_0(1);
        byte[] bArr = KQgRr5e_02.f320KQgRr5e_0;
        int i2 = KQgRr5e_02.QxJ9d_1;
        KQgRr5e_02.QxJ9d_1 = i2 + 1;
        bArr[i2] = (byte) i;
        this.f347KQgRr5e_0++;
        return this;
    }

    @Override // Nm6q_10.IMuAHx_6
    public X6FRs_4 KQgRr5e_0(long j) {
        if (j == 0) {
            KQgRr5e_0(48);
            return this;
        }
        int numberOfTrailingZeros = (Long.numberOfTrailingZeros(Long.highestOneBit(j)) / 4) + 1;
        BVpCZyH_19 KQgRr5e_02 = KQgRr5e_0(numberOfTrailingZeros);
        byte[] bArr = KQgRr5e_02.f320KQgRr5e_0;
        int i = KQgRr5e_02.QxJ9d_1;
        for (int i2 = (i + numberOfTrailingZeros) - 1; i2 >= i; i2--) {
            bArr[i2] = KQgRr5e_0[(int) (15 & j)];
            j >>>= 4;
        }
        KQgRr5e_02.QxJ9d_1 += numberOfTrailingZeros;
        this.f347KQgRr5e_0 += numberOfTrailingZeros;
        return this;
    }

    @Override // Nm6q_10.IFxWkV_5
    public final BVpCZyH_19 KQgRr5e_0(int i) {
        boolean z = true;
        if ((i < 1 || i > 8192) ? false : false) {
            BVpCZyH_19 bVpCZyH_19 = this.f348KQgRr5e_0;
            if (bVpCZyH_19 == null) {
                BVpCZyH_19 KQgRr5e_02 = ZzDuCHW_20.KQgRr5e_0();
                this.f348KQgRr5e_0 = KQgRr5e_02;
                KQgRr5e_02.f321QxJ9d_1 = KQgRr5e_02;
                KQgRr5e_02.f318KQgRr5e_0 = KQgRr5e_02;
                return KQgRr5e_02;
            } else if (bVpCZyH_19 != null) {
                BVpCZyH_19 bVpCZyH_192 = bVpCZyH_19.f321QxJ9d_1;
                if (bVpCZyH_192 != null) {
                    if (bVpCZyH_192.QxJ9d_1 + i > 8192 || !bVpCZyH_192.f322QxJ9d_1) {
                        BVpCZyH_19 KQgRr5e_03 = ZzDuCHW_20.KQgRr5e_0();
                        bVpCZyH_192.KQgRr5e_0(KQgRr5e_03);
                        return KQgRr5e_03;
                    }
                    return bVpCZyH_192;
                }
                FSaI4_7.Xgtqvk_8.QxJ9d_1.IFxWkV_5.KQgRr5e_0();
                throw null;
            } else {
                FSaI4_7.Xgtqvk_8.QxJ9d_1.IFxWkV_5.KQgRr5e_0();
                throw null;
            }
        }
        throw new IllegalArgumentException("unexpected capacity".toString());
    }

    @Override // Nm6q_10.G83uNX_24
    public void KQgRr5e_0(X6FRs_4 x6FRs_4, long j) {
        BVpCZyH_19 bVpCZyH_19;
        FSaI4_7.Xgtqvk_8.QxJ9d_1.IFxWkV_5.QxJ9d_1(x6FRs_4, "source");
        if (x6FRs_4 != this) {
            PGPF6hQ_2.KQgRr5e_0(x6FRs_4.f347KQgRr5e_0, 0L, j);
            while (j > 0) {
                BVpCZyH_19 bVpCZyH_192 = x6FRs_4.f348KQgRr5e_0;
                if (bVpCZyH_192 == null) {
                    FSaI4_7.Xgtqvk_8.QxJ9d_1.IFxWkV_5.KQgRr5e_0();
                    throw null;
                }
                int i = bVpCZyH_192.QxJ9d_1;
                if (bVpCZyH_192 != null) {
                    if (j < i - bVpCZyH_192.KQgRr5e_0) {
                        BVpCZyH_19 bVpCZyH_193 = this.f348KQgRr5e_0;
                        if (bVpCZyH_193 == null) {
                            bVpCZyH_19 = null;
                        } else if (bVpCZyH_193 == null) {
                            FSaI4_7.Xgtqvk_8.QxJ9d_1.IFxWkV_5.KQgRr5e_0();
                            throw null;
                        } else {
                            bVpCZyH_19 = bVpCZyH_193.f321QxJ9d_1;
                        }
                        if (bVpCZyH_19 != null && bVpCZyH_19.f322QxJ9d_1) {
                            if ((bVpCZyH_19.QxJ9d_1 + j) - (bVpCZyH_19.f319KQgRr5e_0 ? 0 : bVpCZyH_19.KQgRr5e_0) <= ((long) RecyclerView.WGk6X_27.FLAG_BOUNCED_FROM_HIDDEN_LIST)) {
                                BVpCZyH_19 bVpCZyH_194 = x6FRs_4.f348KQgRr5e_0;
                                if (bVpCZyH_194 != null) {
                                    bVpCZyH_194.KQgRr5e_0(bVpCZyH_19, (int) j);
                                    x6FRs_4.f347KQgRr5e_0 -= j;
                                    this.f347KQgRr5e_0 += j;
                                    return;
                                }
                                FSaI4_7.Xgtqvk_8.QxJ9d_1.IFxWkV_5.KQgRr5e_0();
                                throw null;
                            }
                        }
                        BVpCZyH_19 bVpCZyH_195 = x6FRs_4.f348KQgRr5e_0;
                        if (bVpCZyH_195 == null) {
                            FSaI4_7.Xgtqvk_8.QxJ9d_1.IFxWkV_5.KQgRr5e_0();
                            throw null;
                        }
                        x6FRs_4.f348KQgRr5e_0 = bVpCZyH_195.KQgRr5e_0((int) j);
                    }
                    BVpCZyH_19 bVpCZyH_196 = x6FRs_4.f348KQgRr5e_0;
                    if (bVpCZyH_196 != null) {
                        long j2 = bVpCZyH_196.QxJ9d_1 - bVpCZyH_196.KQgRr5e_0;
                        x6FRs_4.f348KQgRr5e_0 = bVpCZyH_196.KQgRr5e_0();
                        BVpCZyH_19 bVpCZyH_197 = this.f348KQgRr5e_0;
                        if (bVpCZyH_197 == null) {
                            this.f348KQgRr5e_0 = bVpCZyH_196;
                            bVpCZyH_196.f321QxJ9d_1 = bVpCZyH_196;
                            bVpCZyH_196.f318KQgRr5e_0 = bVpCZyH_196;
                        } else if (bVpCZyH_197 != null) {
                            BVpCZyH_19 bVpCZyH_198 = bVpCZyH_197.f321QxJ9d_1;
                            if (bVpCZyH_198 != null) {
                                bVpCZyH_198.KQgRr5e_0(bVpCZyH_196);
                                bVpCZyH_196.m156KQgRr5e_0();
                            } else {
                                FSaI4_7.Xgtqvk_8.QxJ9d_1.IFxWkV_5.KQgRr5e_0();
                                throw null;
                            }
                        } else {
                            FSaI4_7.Xgtqvk_8.QxJ9d_1.IFxWkV_5.KQgRr5e_0();
                            throw null;
                        }
                        x6FRs_4.f347KQgRr5e_0 -= j2;
                        this.f347KQgRr5e_0 += j2;
                        j -= j2;
                    } else {
                        FSaI4_7.Xgtqvk_8.QxJ9d_1.IFxWkV_5.KQgRr5e_0();
                        throw null;
                    }
                } else {
                    FSaI4_7.Xgtqvk_8.QxJ9d_1.IFxWkV_5.KQgRr5e_0();
                    throw null;
                }
            }
            return;
        }
        throw new IllegalArgumentException("source == this".toString());
    }

    @Override // Nm6q_10.G83uNX_24
    public long KQgRr5e_0(X6FRs_4 x6FRs_4, long j) {
        FSaI4_7.Xgtqvk_8.QxJ9d_1.IFxWkV_5.QxJ9d_1(x6FRs_4, "sink");
        if (j >= 0) {
            long j2 = this.f347KQgRr5e_0;
            if (j2 == 0) {
                return -1L;
            }
            if (j > j2) {
                j = j2;
            }
            x6FRs_4.KQgRr5e_0(this, j);
            return j;
        }
        throw new IllegalArgumentException(("byteCount < 0: " + j).toString());
    }

    public long KQgRr5e_0(byte b, long j, long j2) {
        BVpCZyH_19 bVpCZyH_19;
        int i;
        long j3 = j;
        long j4 = j2;
        long j5 = 0;
        if (0 <= j3 && j4 >= j3) {
            long j6 = this.f347KQgRr5e_0;
            if (j4 > j6) {
                j4 = j6;
            }
            long j7 = -1;
            if (j3 != j4 && (bVpCZyH_19 = this.f348KQgRr5e_0) != null) {
                if (PGPF6hQ_2() - j3 < j3) {
                    j5 = PGPF6hQ_2();
                    while (j5 > j3) {
                        bVpCZyH_19 = bVpCZyH_19.f321QxJ9d_1;
                        if (bVpCZyH_19 != null) {
                            j5 -= bVpCZyH_19.QxJ9d_1 - bVpCZyH_19.KQgRr5e_0;
                        } else {
                            FSaI4_7.Xgtqvk_8.QxJ9d_1.IFxWkV_5.KQgRr5e_0();
                            throw null;
                        }
                    }
                    if (bVpCZyH_19 != null) {
                        while (j5 < j4) {
                            byte[] bArr = bVpCZyH_19.f320KQgRr5e_0;
                            int min = (int) Math.min(bVpCZyH_19.QxJ9d_1, (bVpCZyH_19.KQgRr5e_0 + j4) - j5);
                            i = (int) ((bVpCZyH_19.KQgRr5e_0 + j3) - j5);
                            while (i < min) {
                                if (bArr[i] != b) {
                                    i++;
                                }
                            }
                            j5 += bVpCZyH_19.QxJ9d_1 - bVpCZyH_19.KQgRr5e_0;
                            bVpCZyH_19 = bVpCZyH_19.f318KQgRr5e_0;
                            if (bVpCZyH_19 == null) {
                                FSaI4_7.Xgtqvk_8.QxJ9d_1.IFxWkV_5.KQgRr5e_0();
                                throw null;
                            }
                            j3 = j5;
                            j7 = -1;
                        }
                        return j7;
                    }
                    return -1L;
                }
                while (true) {
                    long j8 = (bVpCZyH_19.QxJ9d_1 - bVpCZyH_19.KQgRr5e_0) + j5;
                    if (j8 > j3) {
                        if (bVpCZyH_19 != null) {
                            while (j5 < j4) {
                                byte[] bArr2 = bVpCZyH_19.f320KQgRr5e_0;
                                int min2 = (int) Math.min(bVpCZyH_19.QxJ9d_1, (bVpCZyH_19.KQgRr5e_0 + j4) - j5);
                                i = (int) ((bVpCZyH_19.KQgRr5e_0 + j3) - j5);
                                while (i < min2) {
                                    if (bArr2[i] != b) {
                                        i++;
                                    }
                                }
                                j5 += bVpCZyH_19.QxJ9d_1 - bVpCZyH_19.KQgRr5e_0;
                                bVpCZyH_19 = bVpCZyH_19.f318KQgRr5e_0;
                                if (bVpCZyH_19 == null) {
                                    FSaI4_7.Xgtqvk_8.QxJ9d_1.IFxWkV_5.KQgRr5e_0();
                                    throw null;
                                }
                                j3 = j5;
                            }
                            return -1L;
                        }
                        return -1L;
                    }
                    bVpCZyH_19 = bVpCZyH_19.f318KQgRr5e_0;
                    if (bVpCZyH_19 == null) {
                        FSaI4_7.Xgtqvk_8.QxJ9d_1.IFxWkV_5.KQgRr5e_0();
                        throw null;
                    }
                    j5 = j8;
                }
                return (i - bVpCZyH_19.KQgRr5e_0) + j5;
            }
            return -1L;
        }
        throw new IllegalArgumentException(("size=" + this.f347KQgRr5e_0 + " fromIndex=" + j3 + " toIndex=" + j4).toString());
    }

    @Override // Nm6q_10.IMuAHx_6, Nm6q_10.G83uNX_24
    public KVtv3R_25 KQgRr5e_0() {
        return KVtv3R_25.KQgRr5e_0;
    }

    @Override // Nm6q_10.IFxWkV_5
    public final FSaI4_7 KQgRr5e_0(int i) {
        return i == 0 ? FSaI4_7.f326KQgRr5e_0 : RfjZ_21.KQgRr5e_0.KQgRr5e_0(this, i);
    }
}
