package kotlin.reflect.jvm.internal.impl.protobuf;

import java.io.FilterInputStream;
import java.io.InputStream;
import java.io.OutputStream;
import kotlin.reflect.jvm.internal.impl.protobuf.p;

/* loaded from: classes3.dex */
public abstract class a implements p {

    /* renamed from: p, reason: collision with root package name */
    protected int f26235p = 0;

    /* JADX INFO: Access modifiers changed from: package-private */
    public v b() {
        return new v(this);
    }

    public void c(OutputStream outputStream) {
        int serializedSize = getSerializedSize();
        f I = f.I(outputStream, f.t(f.u(serializedSize) + serializedSize));
        I.n0(serializedSize);
        a(I);
        I.H();
    }

    /* renamed from: kotlin.reflect.jvm.internal.impl.protobuf.a$a, reason: collision with other inner class name */
    /* loaded from: classes3.dex */
    public static abstract class AbstractC0563a implements p.a {
        /* JADX INFO: Access modifiers changed from: protected */
        public static v b(p pVar) {
            return new v(pVar);
        }

        /* renamed from: kotlin.reflect.jvm.internal.impl.protobuf.a$a$a, reason: collision with other inner class name */
        /* loaded from: classes3.dex */
        static final class C0564a extends FilterInputStream {

            /* renamed from: p, reason: collision with root package name */
            private int f26236p;

            /* JADX INFO: Access modifiers changed from: package-private */
            public C0564a(InputStream inputStream, int i10) {
                super(inputStream);
                this.f26236p = i10;
            }

            @Override // java.io.FilterInputStream, java.io.InputStream
            public int available() {
                return Math.min(super.available(), this.f26236p);
            }

            @Override // java.io.FilterInputStream, java.io.InputStream
            public int read() {
                if (this.f26236p <= 0) {
                    return -1;
                }
                int read = super.read();
                if (read >= 0) {
                    this.f26236p--;
                }
                return read;
            }

            @Override // java.io.FilterInputStream, java.io.InputStream
            public long skip(long j10) {
                long skip = super.skip(Math.min(j10, this.f26236p));
                if (skip >= 0) {
                    this.f26236p = (int) (this.f26236p - skip);
                }
                return skip;
            }

            @Override // java.io.FilterInputStream, java.io.InputStream
            public int read(byte[] bArr, int i10, int i11) {
                int i12 = this.f26236p;
                if (i12 <= 0) {
                    return -1;
                }
                int read = super.read(bArr, i10, Math.min(i11, i12));
                if (read >= 0) {
                    this.f26236p -= read;
                }
                return read;
            }
        }
    }
}
