package x9; /* loaded from: classes2.dex */ final class r { /* renamed from: a, reason: collision with root package name */ final byte[] f15508a; /* renamed from: b, reason: collision with root package name */ int f15509b; /* renamed from: c, reason: collision with root package name */ int f15510c; /* renamed from: d, reason: collision with root package name */ boolean f15511d; /* renamed from: e, reason: collision with root package name */ boolean f15512e; /* renamed from: f, reason: collision with root package name */ r f15513f; /* renamed from: g, reason: collision with root package name */ r f15514g; r() { this.f15508a = new byte[8192]; this.f15512e = true; this.f15511d = false; } public final void a() { r rVar = this.f15514g; if (rVar == this) { throw new IllegalStateException(); } if (rVar.f15512e) { int i10 = this.f15510c - this.f15509b; if (i10 > (8192 - rVar.f15510c) + (rVar.f15511d ? 0 : rVar.f15509b)) { return; } f(rVar, i10); b(); s.a(this); } } public final r b() { r rVar = this.f15513f; r rVar2 = rVar != this ? rVar : null; r rVar3 = this.f15514g; rVar3.f15513f = rVar; this.f15513f.f15514g = rVar3; this.f15513f = null; this.f15514g = null; return rVar2; } public final r c(r rVar) { rVar.f15514g = this; rVar.f15513f = this.f15513f; this.f15513f.f15514g = rVar; this.f15513f = rVar; return rVar; } final r d() { this.f15511d = true; return new r(this.f15508a, this.f15509b, this.f15510c, true, false); } public final r e(int i10) { r b10; if (i10 <= 0 || i10 > this.f15510c - this.f15509b) { throw new IllegalArgumentException(); } if (i10 >= 1024) { b10 = d(); } else { b10 = s.b(); System.arraycopy(this.f15508a, this.f15509b, b10.f15508a, 0, i10); } b10.f15510c = b10.f15509b + i10; this.f15509b += i10; this.f15514g.c(b10); return b10; } public final void f(r rVar, int i10) { if (!rVar.f15512e) { throw new IllegalArgumentException(); } int i11 = rVar.f15510c; if (i11 + i10 > 8192) { if (rVar.f15511d) { throw new IllegalArgumentException(); } int i12 = rVar.f15509b; if ((i11 + i10) - i12 > 8192) { throw new IllegalArgumentException(); } byte[] bArr = rVar.f15508a; System.arraycopy(bArr, i12, bArr, 0, i11 - i12); rVar.f15510c -= rVar.f15509b; rVar.f15509b = 0; } System.arraycopy(this.f15508a, this.f15509b, rVar.f15508a, rVar.f15510c, i10); rVar.f15510c += i10; this.f15509b += i10; } r(byte[] bArr, int i10, int i11, boolean z10, boolean z11) { this.f15508a = bArr; this.f15509b = i10; this.f15510c = i11; this.f15511d = z10; this.f15512e = z11; } }