package g0;

/* JADX INFO: renamed from: g0.c, reason: case insensitive filesystem */
/* JADX INFO: loaded from: classes.dex */
public final class C0479c {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    private final int f4028a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    private final byte[] f4029b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    private int f4030c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    private int f4031d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    private int f4032e;

    public C0479c(int i2) {
        this.f4028a = i2;
        this.f4029b = new byte[i2];
    }

    public final synchronized void a() {
        this.f4030c = 0;
        this.f4031d = 0;
        this.f4032e = 0;
    }

    public final synchronized int b(byte[] data, int i2, int i3) {
        kotlin.jvm.internal.l.e(data, "data");
        int i4 = this.f4032e;
        if (i3 > i4) {
            i3 = i4;
        }
        for (int i5 = 0; i5 < i3; i5++) {
            byte[] bArr = this.f4029b;
            int i6 = this.f4031d;
            data[i5 + i2] = bArr[i6];
            this.f4031d = (i6 + 1) % this.f4028a;
            this.f4032e--;
        }
        return i3;
    }

    public final synchronized void c(byte[] byteArray) {
        kotlin.jvm.internal.l.e(byteArray, "byteArray");
        d(byteArray, byteArray.length);
    }

    public final synchronized void d(byte[] byteArray, int i2) {
        try {
            kotlin.jvm.internal.l.e(byteArray, "byteArray");
            for (int i3 = 0; i3 < i2; i3++) {
                byte[] bArr = this.f4029b;
                int i4 = this.f4030c;
                bArr[i4] = byteArray[i3];
                int i5 = this.f4028a;
                this.f4030c = (i4 + 1) % i5;
                int i6 = this.f4032e;
                if (i6 < i5) {
                    this.f4032e = i6 + 1;
                } else {
                    this.f4031d = (this.f4031d + 1) % i5;
                }
            }
        } catch (Throwable th) {
            throw th;
        }
    }

    public final synchronized int e() {
        return this.f4032e;
    }
}
