c.java 源代码


package s3;

import com.inmobi.media.fd;
import com.mbridge.msdk.playercommon.exoplayer2.C;
import com.mbridge.msdk.playercommon.exoplayer2.extractor.ts.PsExtractor;
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;
import javax.annotation.Nullable;

public final class c implements e, d, Cloneable, ByteChannel {

    private static final byte[] f26136s = {48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 97, 98, 99, 100, 101, 102};

    @Nullable
    o f26137q;

    long f26138r;

    class a extends InputStream {
        a() {
        }

        @Override
        public int available() {
            return (int) Math.min(c.this.f26138r, 2147483647L);
        }

        @Override
        public void close() {
        }

        @Override
        public int read() {
            c cVar = c.this;
            if (cVar.f26138r > 0) {
                return cVar.readByte() & fd.i.NETWORK_LOAD_LIMIT_DISABLED;
            }
            return -1;
        }

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

        @Override
        public int read(byte[] bArr, int i6, int i7) {
            return c.this.read(bArr, i6, i7);
        }
    }

    public c A(f fVar) {
        if (fVar != null) {
            fVar.D(this);
            return this;
        }
        throw new IllegalArgumentException("byteString == null");
    }

    @Override
    public c write(byte[] bArr) {
        if (bArr != null) {
            return write(bArr, 0, bArr.length);
        }
        throw new IllegalArgumentException("source == null");
    }

    @Override
    public c write(byte[] bArr, int i6, int i7) {
        if (bArr != null) {
            long j6 = i7;
            u.b(bArr.length, i6, j6);
            int i8 = i7 + i6;
            while (i6 < i8) {
                o z6 = z(1);
                int min = Math.min(i8 - i6, 8192 - z6.f26172c);
                System.arraycopy(bArr, i6, z6.f26170a, z6.f26172c, min);
                i6 += min;
                z6.f26172c += min;
            }
            this.f26138r += j6;
            return this;
        }
        throw new IllegalArgumentException("source == null");
    }

    public long D(s sVar) throws IOException {
        if (sVar != null) {
            long j6 = 0;
            while (true) {
                long b6 = sVar.b(this, 8192L);
                if (b6 != -1) {
                    j6 += b6;
                } else {
                    return j6;
                }
            }
        } else {
            throw new IllegalArgumentException("source == null");
        }
    }

    @Override
    public c writeByte(int i6) {
        o z6 = z(1);
        byte[] bArr = z6.f26170a;
        int i7 = z6.f26172c;
        z6.f26172c = i7 + 1;
        bArr[i7] = (byte) i6;
        this.f26138r++;
        return this;
    }

    @Override
    public c writeDecimalLong(long j6) {
        boolean z6;
        if (j6 == 0) {
            return writeByte(48);
        }
        int i6 = 1;
        if (j6 < 0) {
            j6 = -j6;
            if (j6 < 0) {
                return writeUtf8("-9223372036854775808");
            }
            z6 = true;
        } else {
            z6 = false;
        }
        if (j6 < 100000000) {
            if (j6 < 10000) {
                if (j6 < 100) {
                    if (j6 >= 10) {
                        i6 = 2;
                    }
                } else if (j6 < 1000) {
                    i6 = 3;
                } else {
                    i6 = 4;
                }
            } else if (j6 < 1000000) {
                if (j6 < 100000) {
                    i6 = 5;
                } else {
                    i6 = 6;
                }
            } else if (j6 < 10000000) {
                i6 = 7;
            } else {
                i6 = 8;
            }
        } else if (j6 < 1000000000000L) {
            if (j6 < 10000000000L) {
                if (j6 < C.NANOS_PER_SECOND) {
                    i6 = 9;
                } else {
                    i6 = 10;
                }
            } else if (j6 < 100000000000L) {
                i6 = 11;
            } else {
                i6 = 12;
            }
        } else if (j6 < 1000000000000000L) {
            if (j6 < 10000000000000L) {
                i6 = 13;
            } else if (j6 < 100000000000000L) {
                i6 = 14;
            } else {
                i6 = 15;
            }
        } else if (j6 < 100000000000000000L) {
            if (j6 < 10000000000000000L) {
                i6 = 16;
            } else {
                i6 = 17;
            }
        } else if (j6 < 1000000000000000000L) {
            i6 = 18;
        } else {
            i6 = 19;
        }
        if (z6) {
            i6++;
        }
        o z7 = z(i6);
        byte[] bArr = z7.f26170a;
        int i7 = z7.f26172c + i6;
        while (j6 != 0) {
            i7--;
            bArr[i7] = f26136s[(int) (j6 % 10)];
            j6 /= 10;
        }
        if (z6) {
            bArr[i7 - 1] = 45;
        }
        z7.f26172c += i6;
        this.f26138r += i6;
        return this;
    }

    @Override
    public c writeHexadecimalUnsignedLong(long j6) {
        if (j6 == 0) {
            return writeByte(48);
        }
        int numberOfTrailingZeros = (Long.numberOfTrailingZeros(Long.highestOneBit(j6)) / 4) + 1;
        o z6 = z(numberOfTrailingZeros);
        byte[] bArr = z6.f26170a;
        int i6 = z6.f26172c;
        for (int i7 = (i6 + numberOfTrailingZeros) - 1; i7 >= i6; i7--) {
            bArr[i7] = f26136s[(int) (15 & j6)];
            j6 >>>= 4;
        }
        z6.f26172c += numberOfTrailingZeros;
        this.f26138r += numberOfTrailingZeros;
        return this;
    }

    @Override
    public c writeInt(int i6) {
        o z6 = z(4);
        byte[] bArr = z6.f26170a;
        int i7 = z6.f26172c;
        int i8 = i7 + 1;
        bArr[i7] = (byte) ((i6 >>> 24) & 255);
        int i9 = i8 + 1;
        bArr[i8] = (byte) ((i6 >>> 16) & 255);
        int i10 = i9 + 1;
        bArr[i9] = (byte) ((i6 >>> 8) & 255);
        bArr[i10] = (byte) (i6 & 255);
        z6.f26172c = i10 + 1;
        this.f26138r += 4;
        return this;
    }

    @Override
    public c writeShort(int i6) {
        o z6 = z(2);
        byte[] bArr = z6.f26170a;
        int i7 = z6.f26172c;
        int i8 = i7 + 1;
        bArr[i7] = (byte) ((i6 >>> 8) & 255);
        bArr[i8] = (byte) (i6 & 255);
        z6.f26172c = i8 + 1;
        this.f26138r += 2;
        return this;
    }

    public c J(String str, int i6, int i7, Charset charset) {
        if (str != null) {
            if (i6 >= 0) {
                if (i7 >= i6) {
                    if (i7 <= str.length()) {
                        if (charset != null) {
                            if (charset.equals(u.f26185a)) {
                                return L(str, i6, i7);
                            }
                            byte[] bytes = str.substring(i6, i7).getBytes(charset);
                            return write(bytes, 0, bytes.length);
                        }
                        throw new IllegalArgumentException("charset == null");
                    }
                    throw new IllegalArgumentException("endIndex > string.length: " + i7 + " > " + str.length());
                }
                throw new IllegalArgumentException("endIndex < beginIndex: " + i7 + " < " + i6);
            }
            throw new IllegalAccessError("beginIndex < 0: " + i6);
        }
        throw new IllegalArgumentException("string == null");
    }

    @Override
    public c writeUtf8(String str) {
        return L(str, 0, str.length());
    }

    public c L(String str, int i6, int i7) {
        char c6;
        if (str != null) {
            if (i6 >= 0) {
                if (i7 >= i6) {
                    if (i7 <= str.length()) {
                        while (i6 < i7) {
                            char charAt = str.charAt(i6);
                            if (charAt < 128) {
                                o z6 = z(1);
                                byte[] bArr = z6.f26170a;
                                int i8 = z6.f26172c - i6;
                                int min = Math.min(i7, 8192 - i8);
                                int i9 = i6 + 1;
                                bArr[i6 + i8] = (byte) charAt;
                                while (i9 < min) {
                                    char charAt2 = str.charAt(i9);
                                    if (charAt2 >= 128) {
                                        break;
                                    }
                                    bArr[i9 + i8] = (byte) charAt2;
                                    i9++;
                                }
                                int i10 = z6.f26172c;
                                int i11 = (i8 + i9) - i10;
                                z6.f26172c = i10 + i11;
                                this.f26138r += i11;
                                i6 = i9;
                            } else {
                                if (charAt < 2048) {
                                    writeByte((charAt >> 6) | PsExtractor.AUDIO_STREAM);
                                    writeByte((charAt & '?') | 128);
                                } else if (charAt >= 55296 && charAt <= 57343) {
                                    int i12 = i6 + 1;
                                    if (i12 < i7) {
                                        c6 = str.charAt(i12);
                                    } else {
                                        c6 = 0;
                                    }
                                    if (charAt <= 56319 && c6 >= 56320 && c6 <= 57343) {
                                        int i13 = (((charAt & 10239) << 10) | (9215 & c6)) + 65536;
                                        writeByte((i13 >> 18) | PsExtractor.VIDEO_STREAM_MASK);
                                        writeByte(((i13 >> 12) & 63) | 128);
                                        writeByte(((i13 >> 6) & 63) | 128);
                                        writeByte((i13 & 63) | 128);
                                        i6 += 2;
                                    } else {
                                        writeByte(63);
                                        i6 = i12;
                                    }
                                } else {
                                    writeByte((charAt >> '\f') | 224);
                                    writeByte(((charAt >> 6) & 63) | 128);
                                    writeByte((charAt & '?') | 128);
                                }
                                i6++;
                            }
                        }
                        return this;
                    }
                    throw new IllegalArgumentException("endIndex > string.length: " + i7 + " > " + str.length());
                }
                throw new IllegalArgumentException("endIndex < beginIndex: " + i7 + " < " + i6);
            }
            throw new IllegalArgumentException("beginIndex < 0: " + i6);
        }
        throw new IllegalArgumentException("string == null");
    }

    public c M(int i6) {
        if (i6 < 128) {
            writeByte(i6);
        } else if (i6 < 2048) {
            writeByte((i6 >> 6) | PsExtractor.AUDIO_STREAM);
            writeByte((i6 & 63) | 128);
        } else if (i6 < 65536) {
            if (i6 >= 55296 && i6 <= 57343) {
                writeByte(63);
            } else {
                writeByte((i6 >> 12) | 224);
                writeByte(((i6 >> 6) & 63) | 128);
                writeByte((i6 & 63) | 128);
            }
        } else if (i6 <= 1114111) {
            writeByte((i6 >> 18) | PsExtractor.VIDEO_STREAM_MASK);
            writeByte(((i6 >> 12) & 63) | 128);
            writeByte(((i6 >> 6) & 63) | 128);
            writeByte((i6 & 63) | 128);
        } else {
            throw new IllegalArgumentException("Unexpected code point: " + Integer.toHexString(i6));
        }
        return this;
    }

    @Override
    public void a(c cVar, long j6) {
        o oVar;
        int i6;
        if (cVar != null) {
            if (cVar != this) {
                u.b(cVar.f26138r, 0L, j6);
                while (j6 > 0) {
                    o oVar2 = cVar.f26137q;
                    if (j6 < oVar2.f26172c - oVar2.f26171b) {
                        o oVar3 = this.f26137q;
                        if (oVar3 != null) {
                            oVar = oVar3.f26176g;
                        } else {
                            oVar = null;
                        }
                        if (oVar != null && oVar.f26174e) {
                            long j7 = oVar.f26172c + j6;
                            if (oVar.f26173d) {
                                i6 = 0;
                            } else {
                                i6 = oVar.f26171b;
                            }
                            if (j7 - i6 <= 8192) {
                                oVar2.f(oVar, (int) j6);
                                cVar.f26138r -= j6;
                                this.f26138r += j6;
                                return;
                            }
                        }
                        cVar.f26137q = oVar2.e((int) j6);
                    }
                    o oVar4 = cVar.f26137q;
                    long j8 = oVar4.f26172c - oVar4.f26171b;
                    cVar.f26137q = oVar4.b();
                    o oVar5 = this.f26137q;
                    if (oVar5 == null) {
                        this.f26137q = oVar4;
                        oVar4.f26176g = oVar4;
                        oVar4.f26175f = oVar4;
                    } else {
                        oVar5.f26176g.c(oVar4).a();
                    }
                    cVar.f26138r -= j8;
                    this.f26138r += j8;
                    j6 -= j8;
                }
                return;
            }
            throw new IllegalArgumentException("source == this");
        }
        throw new IllegalArgumentException("source == null");
    }

    @Override
    public long b(c cVar, long j6) {
        if (cVar != null) {
            if (j6 >= 0) {
                long j7 = this.f26138r;
                if (j7 == 0) {
                    return -1L;
                }
                if (j6 > j7) {
                    j6 = j7;
                }
                cVar.a(this, j6);
                return j6;
            }
            throw new IllegalArgumentException("byteCount < 0: " + j6);
        }
        throw new IllegalArgumentException("sink == null");
    }

    @Override
    public c buffer() {
        return this;
    }

    @Override
    public boolean c(long j6, f fVar) {
        return t(j6, fVar, 0, fVar.x());
    }

    @Override
    public void close() {
    }

    public void d() {
        try {
            skip(this.f26138r);
        } catch (EOFException e6) {
            throw new AssertionError(e6);
        }
    }

    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (!(obj instanceof c)) {
            return false;
        }
        c cVar = (c) obj;
        long j6 = this.f26138r;
        if (j6 != cVar.f26138r) {
            return false;
        }
        long j7 = 0;
        if (j6 == 0) {
            return true;
        }
        o oVar = this.f26137q;
        o oVar2 = cVar.f26137q;
        int i6 = oVar.f26171b;
        int i7 = oVar2.f26171b;
        while (j7 < this.f26138r) {
            long min = Math.min(oVar.f26172c - i6, oVar2.f26172c - i7);
            int i8 = 0;
            while (i8 < min) {
                int i9 = i6 + 1;
                int i10 = i7 + 1;
                if (oVar.f26170a[i6] != oVar2.f26170a[i7]) {
                    return false;
                }
                i8++;
                i6 = i9;
                i7 = i10;
            }
            if (i6 == oVar.f26172c) {
                oVar = oVar.f26175f;
                i6 = oVar.f26171b;
            }
            if (i7 == oVar2.f26172c) {
                oVar2 = oVar2.f26175f;
                i7 = oVar2.f26171b;
            }
            j7 += min;
        }
        return true;
    }

    @Override
    public boolean exhausted() {
        if (this.f26138r == 0) {
            return true;
        }
        return false;
    }

    @Override
    public void flush() {
    }

    public c clone() {
        c cVar = new c();
        if (this.f26138r == 0) {
            return cVar;
        }
        o d6 = this.f26137q.d();
        cVar.f26137q = d6;
        d6.f26176g = d6;
        d6.f26175f = d6;
        o oVar = this.f26137q;
        while (true) {
            oVar = oVar.f26175f;
            if (oVar != this.f26137q) {
                cVar.f26137q.f26176g.c(oVar.d());
            } else {
                cVar.f26138r = this.f26138r;
                return cVar;
            }
        }
    }

    public int hashCode() {
        o oVar = this.f26137q;
        if (oVar == null) {
            return 0;
        }
        int i6 = 1;
        do {
            int i7 = oVar.f26172c;
            for (int i8 = oVar.f26171b; i8 < i7; i8++) {
                i6 = (i6 * 31) + oVar.f26170a[i8];
            }
            oVar = oVar.f26175f;
        } while (oVar != this.f26137q);
        return i6;
    }

    @Override
    public long indexOf(byte b6) {
        return indexOf(b6, 0L, Long.MAX_VALUE);
    }

    @Override
    public InputStream inputStream() {
        return new a();
    }

    @Override
    public boolean isOpen() {
        return true;
    }

    public long n() {
        long j6 = this.f26138r;
        if (j6 == 0) {
            return 0L;
        }
        o oVar = this.f26137q.f26176g;
        if (oVar.f26172c < 8192 && oVar.f26174e) {
            return j6 - (r3 - oVar.f26171b);
        }
        return j6;
    }

    public c o(c cVar, long j6, long j7) {
        if (cVar != null) {
            u.b(this.f26138r, j6, j7);
            if (j7 == 0) {
                return this;
            }
            cVar.f26138r += j7;
            o oVar = this.f26137q;
            while (true) {
                int i6 = oVar.f26172c;
                int i7 = oVar.f26171b;
                if (j6 < i6 - i7) {
                    break;
                }
                j6 -= i6 - i7;
                oVar = oVar.f26175f;
            }
            while (j7 > 0) {
                o d6 = oVar.d();
                int i8 = (int) (d6.f26171b + j6);
                d6.f26171b = i8;
                d6.f26172c = Math.min(i8 + ((int) j7), d6.f26172c);
                o oVar2 = cVar.f26137q;
                if (oVar2 == null) {
                    d6.f26176g = d6;
                    d6.f26175f = d6;
                    cVar.f26137q = d6;
                } else {
                    oVar2.f26176g.c(d6);
                }
                j7 -= d6.f26172c - d6.f26171b;
                oVar = oVar.f26175f;
                j6 = 0;
            }
            return this;
        }
        throw new IllegalArgumentException("out == null");
    }

    @Override
    public c emitCompleteSegments() {
        return this;
    }

    public int read(byte[] bArr, int i6, int i7) {
        u.b(bArr.length, i6, i7);
        o oVar = this.f26137q;
        if (oVar == null) {
            return -1;
        }
        int min = Math.min(i7, oVar.f26172c - oVar.f26171b);
        System.arraycopy(oVar.f26170a, oVar.f26171b, bArr, i6, min);
        int i8 = oVar.f26171b + min;
        oVar.f26171b = i8;
        this.f26138r -= min;
        if (i8 == oVar.f26172c) {
            this.f26137q = oVar.b();
            p.a(oVar);
        }
        return min;
    }

    @Override
    public byte readByte() {
        long j6 = this.f26138r;
        if (j6 != 0) {
            o oVar = this.f26137q;
            int i6 = oVar.f26171b;
            int i7 = oVar.f26172c;
            int i8 = i6 + 1;
            byte b6 = oVar.f26170a[i6];
            this.f26138r = j6 - 1;
            if (i8 == i7) {
                this.f26137q = oVar.b();
                p.a(oVar);
            } else {
                oVar.f26171b = i8;
            }
            return b6;
        }
        throw new IllegalStateException("size == 0");
    }

    @Override
    public byte[] readByteArray() {
        try {
            return readByteArray(this.f26138r);
        } catch (EOFException e6) {
            throw new AssertionError(e6);
        }
    }

    @Override
    public f readByteString(long j6) throws EOFException {
        return new f(readByteArray(j6));
    }

    @Override
    public long readDecimalLong() {
        if (this.f26138r != 0) {
            int i6 = 0;
            long j6 = -7;
            boolean z6 = false;
            long j7 = 0;
            boolean z7 = false;
            do {
                o oVar = this.f26137q;
                byte[] bArr = oVar.f26170a;
                int i7 = oVar.f26171b;
                int i8 = oVar.f26172c;
                while (i7 < i8) {
                    byte b6 = bArr[i7];
                    if (b6 >= 48 && b6 <= 57) {
                        int i9 = 48 - b6;
                        if (j7 >= -922337203685477580L && (j7 != -922337203685477580L || i9 >= j6)) {
                            j7 = (j7 * 10) + i9;
                        } else {
                            c writeByte = new c().writeDecimalLong(j7).writeByte(b6);
                            if (!z6) {
                                writeByte.readByte();
                            }
                            throw new NumberFormatException("Number too large: " + writeByte.readUtf8());
                        }
                    } else if (b6 == 45 && i6 == 0) {
                        j6--;
                        z6 = true;
                    } else if (i6 != 0) {
                        z7 = true;
                        if (i7 != i8) {
                            this.f26137q = oVar.b();
                            p.a(oVar);
                        } else {
                            oVar.f26171b = i7;
                        }
                        if (!z7) {
                            break;
                        }
                    } else {
                        throw new NumberFormatException("Expected leading [0-9] or '-' character but was 0x" + Integer.toHexString(b6));
                    }
                    i7++;
                    i6++;
                }
                if (i7 != i8) {
                }
                if (!z7) {
                }
            } while (this.f26137q != null);
            this.f26138r -= i6;
            if (!z6) {
                return -j7;
            }
            return j7;
        }
        throw new IllegalStateException("size == 0");
    }

    @Override
    public void readFully(byte[] bArr) throws EOFException {
        int i6 = 0;
        while (i6 < bArr.length) {
            int read = read(bArr, i6, bArr.length - i6);
            if (read != -1) {
                i6 += read;
            } else {
                throw new EOFException();
            }
        }
    }

    @Override
    public long readHexadecimalUnsignedLong() {
        int i6;
        int i7;
        if (this.f26138r != 0) {
            int i8 = 0;
            long j6 = 0;
            boolean z6 = false;
            do {
                o oVar = this.f26137q;
                byte[] bArr = oVar.f26170a;
                int i9 = oVar.f26171b;
                int i10 = oVar.f26172c;
                while (i9 < i10) {
                    byte b6 = bArr[i9];
                    if (b6 >= 48 && b6 <= 57) {
                        i7 = b6 - 48;
                    } else {
                        if (b6 >= 97 && b6 <= 102) {
                            i6 = b6 - 97;
                        } else if (b6 >= 65 && b6 <= 70) {
                            i6 = b6 - 65;
                        } else if (i8 != 0) {
                            z6 = true;
                            if (i9 != i10) {
                                this.f26137q = oVar.b();
                                p.a(oVar);
                            } else {
                                oVar.f26171b = i9;
                            }
                            if (!z6) {
                                break;
                            }
                        } else {
                            throw new NumberFormatException("Expected leading [0-9a-fA-F] character but was 0x" + Integer.toHexString(b6));
                        }
                        i7 = i6 + 10;
                    }
                    if (((-1152921504606846976L) & j6) == 0) {
                        j6 = (j6 << 4) | i7;
                        i9++;
                        i8++;
                    } else {
                        throw new NumberFormatException("Number too large: " + new c().writeHexadecimalUnsignedLong(j6).writeByte(b6).readUtf8());
                    }
                }
                if (i9 != i10) {
                }
                if (!z6) {
                }
            } while (this.f26137q != null);
            this.f26138r -= i8;
            return j6;
        }
        throw new IllegalStateException("size == 0");
    }

    @Override
    public int readInt() {
        long j6 = this.f26138r;
        if (j6 >= 4) {
            o oVar = this.f26137q;
            int i6 = oVar.f26171b;
            int i7 = oVar.f26172c;
            if (i7 - i6 < 4) {
                return ((readByte() & fd.i.NETWORK_LOAD_LIMIT_DISABLED) << 24) | ((readByte() & fd.i.NETWORK_LOAD_LIMIT_DISABLED) << 16) | ((readByte() & fd.i.NETWORK_LOAD_LIMIT_DISABLED) << 8) | (readByte() & fd.i.NETWORK_LOAD_LIMIT_DISABLED);
            }
            byte[] bArr = oVar.f26170a;
            int i8 = i6 + 1;
            int i9 = i8 + 1;
            int i10 = ((bArr[i6] & fd.i.NETWORK_LOAD_LIMIT_DISABLED) << 24) | ((bArr[i8] & fd.i.NETWORK_LOAD_LIMIT_DISABLED) << 16);
            int i11 = i9 + 1;
            int i12 = i10 | ((bArr[i9] & fd.i.NETWORK_LOAD_LIMIT_DISABLED) << 8);
            int i13 = i11 + 1;
            int i14 = i12 | (bArr[i11] & fd.i.NETWORK_LOAD_LIMIT_DISABLED);
            this.f26138r = j6 - 4;
            if (i13 == i7) {
                this.f26137q = oVar.b();
                p.a(oVar);
            } else {
                oVar.f26171b = i13;
            }
            return i14;
        }
        throw new IllegalStateException("size < 4: " + this.f26138r);
    }

    @Override
    public int readIntLe() {
        return u.c(readInt());
    }

    @Override
    public short readShort() {
        long j6 = this.f26138r;
        if (j6 >= 2) {
            o oVar = this.f26137q;
            int i6 = oVar.f26171b;
            int i7 = oVar.f26172c;
            if (i7 - i6 < 2) {
                return (short) (((readByte() & fd.i.NETWORK_LOAD_LIMIT_DISABLED) << 8) | (readByte() & fd.i.NETWORK_LOAD_LIMIT_DISABLED));
            }
            byte[] bArr = oVar.f26170a;
            int i8 = i6 + 1;
            int i9 = i8 + 1;
            int i10 = ((bArr[i6] & fd.i.NETWORK_LOAD_LIMIT_DISABLED) << 8) | (bArr[i8] & fd.i.NETWORK_LOAD_LIMIT_DISABLED);
            this.f26138r = j6 - 2;
            if (i9 == i7) {
                this.f26137q = oVar.b();
                p.a(oVar);
            } else {
                oVar.f26171b = i9;
            }
            return (short) i10;
        }
        throw new IllegalStateException("size < 2: " + this.f26138r);
    }

    @Override
    public short readShortLe() {
        return u.d(readShort());
    }

    public String readString(long j6, Charset charset) throws EOFException {
        u.b(this.f26138r, 0L, j6);
        if (charset != null) {
            if (j6 <= 2147483647L) {
                if (j6 == 0) {
                    return "";
                }
                o oVar = this.f26137q;
                int i6 = oVar.f26171b;
                if (i6 + j6 > oVar.f26172c) {
                    return new String(readByteArray(j6), charset);
                }
                String str = new String(oVar.f26170a, i6, (int) j6, charset);
                int i7 = (int) (oVar.f26171b + j6);
                oVar.f26171b = i7;
                this.f26138r -= j6;
                if (i7 == oVar.f26172c) {
                    this.f26137q = oVar.b();
                    p.a(oVar);
                }
                return str;
            }
            throw new IllegalArgumentException("byteCount > Integer.MAX_VALUE: " + j6);
        }
        throw new IllegalArgumentException("charset == null");
    }

    public String readUtf8() {
        try {
            return readString(this.f26138r, u.f26185a);
        } catch (EOFException e6) {
            throw new AssertionError(e6);
        }
    }

    @Override
    public String readUtf8LineStrict() throws EOFException {
        return readUtf8LineStrict(Long.MAX_VALUE);
    }

    @Override
    public void require(long j6) throws EOFException {
        if (this.f26138r >= j6) {
        } else {
            throw new EOFException();
        }
    }

    public byte s(long j6) {
        int i6;
        u.b(this.f26138r, j6, 1L);
        long j7 = this.f26138r;
        if (j7 - j6 > j6) {
            o oVar = this.f26137q;
            while (true) {
                int i7 = oVar.f26172c;
                int i8 = oVar.f26171b;
                long j8 = i7 - i8;
                if (j6 < j8) {
                    return oVar.f26170a[i8 + ((int) j6)];
                }
                j6 -= j8;
                oVar = oVar.f26175f;
            }
        } else {
            long j9 = j6 - j7;
            o oVar2 = this.f26137q;
            do {
                oVar2 = oVar2.f26176g;
                int i9 = oVar2.f26172c;
                i6 = oVar2.f26171b;
                j9 += i9 - i6;
            } while (j9 < 0);
            return oVar2.f26170a[i6 + ((int) j9)];
        }
    }

    public long size() {
        return this.f26138r;
    }

    @Override
    public void skip(long j6) throws EOFException {
        while (j6 > 0) {
            if (this.f26137q != null) {
                int min = (int) Math.min(j6, r0.f26172c - r0.f26171b);
                long j7 = min;
                this.f26138r -= j7;
                j6 -= j7;
                o oVar = this.f26137q;
                int i6 = oVar.f26171b + min;
                oVar.f26171b = i6;
                if (i6 == oVar.f26172c) {
                    this.f26137q = oVar.b();
                    p.a(oVar);
                }
            } else {
                throw new EOFException();
            }
        }
    }

    public boolean t(long j6, f fVar, int i6, int i7) {
        if (j6 < 0 || i6 < 0 || i7 < 0 || this.f26138r - j6 < i7 || fVar.x() - i6 < i7) {
            return false;
        }
        for (int i8 = 0; i8 < i7; i8++) {
            if (s(i8 + j6) != fVar.p(i6 + i8)) {
                return false;
            }
        }
        return true;
    }

    @Override
    public t timeout() {
        return t.f26181d;
    }

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

    public f v() {
        return new f(readByteArray());
    }

    public String w(long j6) throws EOFException {
        if (j6 > 0) {
            long j7 = j6 - 1;
            if (s(j7) == 13) {
                String readUtf8 = readUtf8(j7);
                skip(2L);
                return readUtf8;
            }
        }
        String readUtf82 = readUtf8(j6);
        skip(1L);
        return readUtf82;
    }

    public f x() {
        long j6 = this.f26138r;
        if (j6 <= 2147483647L) {
            return y((int) j6);
        }
        throw new IllegalArgumentException("size > Integer.MAX_VALUE: " + this.f26138r);
    }

    public f y(int i6) {
        if (i6 == 0) {
            return f.f26141u;
        }
        return new q(this, i6);
    }

    public o z(int i6) {
        if (i6 >= 1 && i6 <= 8192) {
            o oVar = this.f26137q;
            if (oVar == null) {
                o b6 = p.b();
                this.f26137q = b6;
                b6.f26176g = b6;
                b6.f26175f = b6;
                return b6;
            }
            o oVar2 = oVar.f26176g;
            if (oVar2.f26172c + i6 > 8192 || !oVar2.f26174e) {
                return oVar2.c(p.b());
            }
            return oVar2;
        }
        throw new IllegalArgumentException();
    }

    public long indexOf(byte b6, long j6, long j7) {
        o oVar;
        long j8 = 0;
        if (j6 >= 0 && j7 >= j6) {
            long j9 = this.f26138r;
            long j10 = j7 > j9 ? j9 : j7;
            if (j6 == j10 || (oVar = this.f26137q) == null) {
                return -1L;
            }
            if (j9 - j6 < j6) {
                while (j9 > j6) {
                    oVar = oVar.f26176g;
                    j9 -= oVar.f26172c - oVar.f26171b;
                }
            } else {
                while (true) {
                    long j11 = (oVar.f26172c - oVar.f26171b) + j8;
                    if (j11 >= j6) {
                        break;
                    }
                    oVar = oVar.f26175f;
                    j8 = j11;
                }
                j9 = j8;
            }
            long j12 = j6;
            while (j9 < j10) {
                byte[] bArr = oVar.f26170a;
                int min = (int) Math.min(oVar.f26172c, (oVar.f26171b + j10) - j9);
                for (int i6 = (int) ((oVar.f26171b + j12) - j9); i6 < min; i6++) {
                    if (bArr[i6] == b6) {
                        return (i6 - oVar.f26171b) + j9;
                    }
                }
                j9 += oVar.f26172c - oVar.f26171b;
                oVar = oVar.f26175f;
                j12 = j9;
            }
            return -1L;
        }
        throw new IllegalArgumentException(String.format("size=%s fromIndex=%s toIndex=%s", Long.valueOf(this.f26138r), Long.valueOf(j6), Long.valueOf(j7)));
    }

    @Override
    public String readUtf8LineStrict(long j6) throws EOFException {
        if (j6 >= 0) {
            long j7 = j6 != Long.MAX_VALUE ? j6 + 1 : Long.MAX_VALUE;
            long indexOf = indexOf((byte) 10, 0L, j7);
            if (indexOf != -1) {
                return w(indexOf);
            }
            if (j7 < size() && s(j7 - 1) == 13 && s(j7) == 10) {
                return w(j7);
            }
            c cVar = new c();
            o(cVar, 0L, Math.min(32L, size()));
            throw new EOFException("\\n not found: limit=" + Math.min(size(), j6) + " content=" + cVar.v().q() + (char) 8230);
        }
        throw new IllegalArgumentException("limit < 0: " + j6);
    }

    @Override
    public byte[] readByteArray(long j6) throws EOFException {
        u.b(this.f26138r, 0L, j6);
        if (j6 <= 2147483647L) {
            byte[] bArr = new byte[(int) j6];
            readFully(bArr);
            return bArr;
        }
        throw new IllegalArgumentException("byteCount > Integer.MAX_VALUE: " + j6);
    }

    public String readUtf8(long j6) throws EOFException {
        return readString(j6, u.f26185a);
    }

    @Override
    public int write(ByteBuffer byteBuffer) throws IOException {
        if (byteBuffer != null) {
            int remaining = byteBuffer.remaining();
            int i6 = remaining;
            while (i6 > 0) {
                o z6 = z(1);
                int min = Math.min(i6, 8192 - z6.f26172c);
                byteBuffer.get(z6.f26170a, z6.f26172c, min);
                i6 -= min;
                z6.f26172c += min;
            }
            this.f26138r += remaining;
            return remaining;
        }
        throw new IllegalArgumentException("source == null");
    }

    @Override
    public int read(ByteBuffer byteBuffer) throws IOException {
        o oVar = this.f26137q;
        if (oVar == null) {
            return -1;
        }
        int min = Math.min(byteBuffer.remaining(), oVar.f26172c - oVar.f26171b);
        byteBuffer.put(oVar.f26170a, oVar.f26171b, min);
        int i6 = oVar.f26171b + min;
        oVar.f26171b = i6;
        this.f26138r -= min;
        if (i6 == oVar.f26172c) {
            this.f26137q = oVar.b();
            p.a(oVar);
        }
        return min;
    }
}