package com.google.android.play.core.assetpacks;

import java.util.Arrays;

/* loaded from: classes3.dex */
final class g2 {

    /* renamed from: a, reason: collision with root package name */
    private byte[] f13913a = new byte[4096];

    /* renamed from: b, reason: collision with root package name */
    private int f13914b;

    /* renamed from: c, reason: collision with root package name */
    private long f13915c;

    /* renamed from: d, reason: collision with root package name */
    private long f13916d;

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

    /* renamed from: f, reason: collision with root package name */
    private int f13918f;

    /* renamed from: g, reason: collision with root package name */
    private int f13919g;

    /* renamed from: h, reason: collision with root package name */
    private boolean f13920h;

    /* renamed from: i, reason: collision with root package name */
    private String f13921i;

    public g2() {
        d();
    }

    private final int e(int i10, byte[] bArr, int i11, int i12) {
        int i13 = this.f13914b;
        if (i13 >= i10) {
            return 0;
        }
        int min = Math.min(i12, i10 - i13);
        System.arraycopy(bArr, i11, this.f13913a, this.f13914b, min);
        int i14 = this.f13914b + min;
        this.f13914b = i14;
        if (i14 < i10) {
            return -1;
        }
        return min;
    }

    public final int a() {
        return this.f13918f;
    }

    /* JADX WARN: Code restructure failed: missing block: B:10:0x0055, code lost:
    
        if (r3 >= r4) goto L25;
     */
    /* JADX WARN: Code restructure failed: missing block: B:12:0x0058, code lost:
    
        r9.f13913a = java.util.Arrays.copyOf(r9.f13913a, r3);
     */
    /* JADX WARN: Code restructure failed: missing block: B:8:0x0052, code lost:
    
        if (r3 < r4) goto L10;
     */
    /* JADX WARN: Code restructure failed: missing block: B:9:0x0054, code lost:
    
        r3 = r3 + r3;
     */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final int b(byte[] bArr, int i10, int i11) {
        int e10 = e(30, bArr, i10, i11);
        if (e10 == -1) {
            return -1;
        }
        if (this.f13915c == -1) {
            long b10 = n0.b(this.f13913a, 0);
            this.f13915c = b10;
            if (b10 == 67324752) {
                this.f13920h = false;
                this.f13916d = n0.b(this.f13913a, 18);
                this.f13919g = n0.a(this.f13913a, 8);
                this.f13917e = n0.a(this.f13913a, 26);
                int a10 = this.f13917e + 30 + n0.a(this.f13913a, 28);
                this.f13918f = a10;
                int length = this.f13913a.length;
            } else {
                this.f13920h = true;
            }
        }
        int e11 = e(this.f13918f, bArr, i10 + e10, i11 - e10);
        if (e11 == -1) {
            return -1;
        }
        int i12 = e10 + e11;
        if (!this.f13920h && this.f13921i == null) {
            this.f13921i = new String(this.f13913a, 30, this.f13917e);
        }
        return i12;
    }

    public final h3 c() {
        int i10 = this.f13914b;
        int i11 = this.f13918f;
        if (i10 < i11) {
            return new m0(this.f13921i, this.f13916d, this.f13919g, true, this.f13920h, Arrays.copyOf(this.f13913a, i10));
        }
        m0 m0Var = new m0(this.f13921i, this.f13916d, this.f13919g, false, this.f13920h, Arrays.copyOf(this.f13913a, i11));
        d();
        return m0Var;
    }

    public final void d() {
        this.f13914b = 0;
        this.f13917e = -1;
        this.f13915c = -1L;
        this.f13920h = false;
        this.f13918f = 30;
        this.f13916d = -1L;
        this.f13919g = -1;
        this.f13921i = null;
    }
}
