package ඓ.ῲ.K.ᓣ;

import java.io.FilterInputStream;
import java.io.IOException;
import java.io.InputStream;

/* renamed from: ඓ.ῲ.K.ᓣ.㿎  reason: contains not printable characters */
/* compiled from: MarkEnforcingInputStream */
public class C0849 extends FilterInputStream {

    /* renamed from: ῲ  reason: contains not printable characters */
    public int f4077 = Integer.MIN_VALUE;

    public C0849(InputStream inputStream) {
        super(inputStream);
    }

    @Override // java.io.FilterInputStream, java.io.InputStream
    public int available() throws IOException {
        int i = this.f4077;
        if (i == Integer.MIN_VALUE) {
            return super.available();
        }
        return Math.min(i, super.available());
    }

    public synchronized void mark(int i) {
        super.mark(i);
        this.f4077 = i;
    }

    @Override // java.io.FilterInputStream, java.io.InputStream
    public int read() throws IOException {
        if (m2466(1) == -1) {
            return -1;
        }
        int read = super.read();
        m2467(1);
        return read;
    }

    @Override // java.io.FilterInputStream, java.io.InputStream
    public synchronized void reset() throws IOException {
        super.reset();
        this.f4077 = Integer.MIN_VALUE;
    }

    @Override // java.io.FilterInputStream, java.io.InputStream
    public long skip(long j) throws IOException {
        long r4 = m2466(j);
        if (r4 == -1) {
            return 0;
        }
        long skip = super.skip(r4);
        m2467(skip);
        return skip;
    }

    /* renamed from: ⁱ  reason: contains not printable characters */
    public final long m2466(long j) {
        int i = this.f4077;
        if (i == 0) {
            return -1;
        }
        return (i == Integer.MIN_VALUE || j <= ((long) i)) ? j : (long) i;
    }

    /* renamed from: 㿎  reason: contains not printable characters */
    public final void m2467(long j) {
        int i = this.f4077;
        if (i != Integer.MIN_VALUE && j != -1) {
            this.f4077 = (int) (((long) i) - j);
        }
    }

    @Override // java.io.FilterInputStream, java.io.InputStream
    public int read(byte[] bArr, int i, int i2) throws IOException {
        int r5 = (int) m2466((long) i2);
        if (r5 == -1) {
            return -1;
        }
        int read = super.read(bArr, i, r5);
        m2467((long) read);
        return read;
    }
}
