package ඓ.ῲ.K.ᓣ;

import java.io.FilterInputStream;
import java.io.IOException;
import java.io.InputStream;
import ඓ.K.K.K.C1293;

/* renamed from: ඓ.ῲ.K.ᓣ.ʬ  reason: contains not printable characters */
/* compiled from: ContentLengthInputStream */
public final class C0824 extends FilterInputStream {

    /* renamed from: ʬ  reason: contains not printable characters */
    public int f4047;

    /* renamed from: ῲ  reason: contains not printable characters */
    public final long f4048;

    public C0824(InputStream inputStream, long j) {
        super(inputStream);
        this.f4048 = j;
    }

    @Override // java.io.FilterInputStream, java.io.InputStream
    public synchronized int available() throws IOException {
        return (int) Math.max(this.f4048 - ((long) this.f4047), (long) ((FilterInputStream) this).in.available());
    }

    @Override // java.io.FilterInputStream, java.io.InputStream
    public synchronized int read() throws IOException {
        int read;
        read = super.read();
        m2419(read >= 0 ? 1 : -1);
        return read;
    }

    /* renamed from: K  reason: contains not printable characters */
    public final int m2419(int i) throws IOException {
        if (i >= 0) {
            this.f4047 += i;
        } else if (this.f4048 - ((long) this.f4047) > 0) {
            StringBuilder r0 = C1293.m3416("Failed to read all expected data, expected: ");
            r0.append(this.f4048);
            r0.append(", but read: ");
            r0.append(this.f4047);
            throw new IOException(r0.toString());
        }
        return i;
    }

    @Override // java.io.FilterInputStream, java.io.InputStream
    public int read(byte[] bArr) throws IOException {
        return read(bArr, 0, bArr.length);
    }

    @Override // java.io.FilterInputStream, java.io.InputStream
    public synchronized int read(byte[] bArr, int i, int i2) throws IOException {
        int read;
        read = super.read(bArr, i, i2);
        m2419(read);
        return read;
    }
}
