package org.bouncycastle.cms.jcajce;

/* JADX INFO: loaded from: E:\ios\vf_dex\classes4.dex */
public class ZlibExpanderProvider implements org.bouncycastle.operator.InputExpanderProvider {

    /* JADX INFO: renamed from: org.bouncycastle.cms.jcajce.ZlibExpanderProvider$1, reason: invalid class name */
    class AnonymousClass1 implements org.bouncycastle.operator.InputExpander {
    }

    private static class LimitedInputStream extends java.io.FilterInputStream {
        private long a;

        /* JADX INFO: Thrown type has an unknown type hierarchy: org.bouncycastle.util.io.StreamOverflowException */
        /* JADX WARN: Code restructure failed: missing block: B:7:0x0019, code lost:
        
            if (r4 >= 0) goto L8;
         */
        @Override // java.io.FilterInputStream, java.io.InputStream
        /*
            Code decompiled incorrectly, please refer to instructions dump.
            To view partially-correct add '--show-bad-code' argument
        */
        public int read() throws org.bouncycastle.util.io.StreamOverflowException, java.io.IOException {
            /*
                r8 = this;
                long r0 = r8.a
                r2 = 0
                int r0 = (r0 > r2 ? 1 : (r0 == r2 ? 0 : -1))
                if (r0 < 0) goto L1c
                java.io.InputStream r0 = r8.in
                int r0 = r0.read()
                if (r0 < 0) goto L1b
                long r4 = r8.a
                r6 = 1
                long r4 = r4 - r6
                r8.a = r4
                int r8 = (r4 > r2 ? 1 : (r4 == r2 ? 0 : -1))
                if (r8 < 0) goto L1c
            L1b:
                return r0
            L1c:
                org.bouncycastle.util.io.StreamOverflowException r8 = new org.bouncycastle.util.io.StreamOverflowException
                java.lang.String r0 = "expanded byte limit exceeded"
                r8.<init>(r0)
                throw r8
            */
            throw new UnsupportedOperationException("Method not decompiled: org.bouncycastle.cms.jcajce.ZlibExpanderProvider.LimitedInputStream.read():int");
        }

        /* JADX INFO: Thrown type has an unknown type hierarchy: org.bouncycastle.util.io.StreamOverflowException */
        @Override // java.io.FilterInputStream, java.io.InputStream
        public int read(byte[] bArr, int i, int i2) throws org.bouncycastle.util.io.StreamOverflowException, java.io.IOException {
            if (i2 < 1) {
                return super.read(bArr, i, i2);
            }
            long j = this.a;
            if (j < 1) {
                read();
                return -1;
            }
            if (j <= i2) {
                i2 = (int) j;
            }
            int i3 = ((java.io.FilterInputStream) this).in.read(bArr, i, i2);
            if (i3 > 0) {
                this.a -= (long) i3;
            }
            return i3;
        }
    }
}
