package androidx.datastore.preferences.protobuf;

import com.google.android.gms.common.api.Api;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/* loaded from: classes.dex */
public abstract class h {

    /* renamed from: a, reason: collision with root package name */
    int f4076a;

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

    /* renamed from: c, reason: collision with root package name */
    int f4078c;

    /* renamed from: d, reason: collision with root package name */
    i f4079d;

    /* renamed from: e, reason: collision with root package name */
    private boolean f4080e;

    /* JADX INFO: Access modifiers changed from: private */
    /* loaded from: classes.dex */
    public static final class b extends h {

        /* renamed from: f, reason: collision with root package name */
        private final byte[] f4081f;

        /* renamed from: g, reason: collision with root package name */
        private final boolean f4082g;

        /* renamed from: h, reason: collision with root package name */
        private int f4083h;

        /* renamed from: i, reason: collision with root package name */
        private int f4084i;

        /* renamed from: j, reason: collision with root package name */
        private int f4085j;

        /* renamed from: k, reason: collision with root package name */
        private int f4086k;

        /* renamed from: l, reason: collision with root package name */
        private int f4087l;

        /* renamed from: m, reason: collision with root package name */
        private boolean f4088m;

        /* renamed from: n, reason: collision with root package name */
        private int f4089n;

        private void M() {
            int i10 = this.f4083h + this.f4084i;
            this.f4083h = i10;
            int i11 = i10 - this.f4086k;
            int i12 = this.f4089n;
            if (i11 <= i12) {
                this.f4084i = 0;
                return;
            }
            int i13 = i11 - i12;
            this.f4084i = i13;
            this.f4083h = i10 - i13;
        }

        private void P() {
            if (this.f4083h - this.f4085j >= 10) {
                Q();
            } else {
                R();
            }
        }

        private void Q() {
            for (int i10 = 0; i10 < 10; i10++) {
                byte[] bArr = this.f4081f;
                int i11 = this.f4085j;
                this.f4085j = i11 + 1;
                if (bArr[i11] >= 0) {
                    return;
                }
            }
            throw z.e();
        }

        private void R() {
            for (int i10 = 0; i10 < 10; i10++) {
                if (F() >= 0) {
                    return;
                }
            }
            throw z.e();
        }

        @Override // androidx.datastore.preferences.protobuf.h
        public String A() {
            int J = J();
            if (J > 0) {
                int i10 = this.f4083h;
                int i11 = this.f4085j;
                if (J <= i10 - i11) {
                    String e10 = p1.e(this.f4081f, i11, J);
                    this.f4085j += J;
                    return e10;
                }
            }
            if (J == 0) {
                return "";
            }
            if (J <= 0) {
                throw z.f();
            }
            throw z.k();
        }

        @Override // androidx.datastore.preferences.protobuf.h
        public int B() {
            if (e()) {
                this.f4087l = 0;
                return 0;
            }
            int J = J();
            this.f4087l = J;
            if (q1.a(J) != 0) {
                return this.f4087l;
            }
            throw z.b();
        }

        @Override // androidx.datastore.preferences.protobuf.h
        public int C() {
            return J();
        }

        @Override // androidx.datastore.preferences.protobuf.h
        public long D() {
            return K();
        }

        @Override // androidx.datastore.preferences.protobuf.h
        public boolean E(int i10) {
            int b10 = q1.b(i10);
            if (b10 == 0) {
                P();
                return true;
            }
            if (b10 == 1) {
                O(8);
                return true;
            }
            if (b10 == 2) {
                O(J());
                return true;
            }
            if (b10 == 3) {
                N();
                a(q1.c(q1.a(i10), 4));
                return true;
            }
            if (b10 == 4) {
                return false;
            }
            if (b10 != 5) {
                throw z.d();
            }
            O(4);
            return true;
        }

        public byte F() {
            int i10 = this.f4085j;
            if (i10 == this.f4083h) {
                throw z.k();
            }
            byte[] bArr = this.f4081f;
            this.f4085j = i10 + 1;
            return bArr[i10];
        }

        public byte[] G(int i10) {
            if (i10 > 0) {
                int i11 = this.f4083h;
                int i12 = this.f4085j;
                if (i10 <= i11 - i12) {
                    int i13 = i10 + i12;
                    this.f4085j = i13;
                    return Arrays.copyOfRange(this.f4081f, i12, i13);
                }
            }
            if (i10 > 0) {
                throw z.k();
            }
            if (i10 == 0) {
                return y.f4220c;
            }
            throw z.f();
        }

        public int H() {
            int i10 = this.f4085j;
            if (this.f4083h - i10 < 4) {
                throw z.k();
            }
            byte[] bArr = this.f4081f;
            this.f4085j = i10 + 4;
            return (bArr[i10] & 255) | ((bArr[i10 + 1] & 255) << 8) | ((bArr[i10 + 2] & 255) << 16) | ((bArr[i10 + 3] & 255) << 24);
        }

        public long I() {
            int i10 = this.f4085j;
            if (this.f4083h - i10 < 8) {
                throw z.k();
            }
            byte[] bArr = this.f4081f;
            this.f4085j = i10 + 8;
            return ((bArr[i10 + 7] & 255) << 56) | (bArr[i10] & 255) | ((bArr[i10 + 1] & 255) << 8) | ((bArr[i10 + 2] & 255) << 16) | ((bArr[i10 + 3] & 255) << 24) | ((bArr[i10 + 4] & 255) << 32) | ((bArr[i10 + 5] & 255) << 40) | ((bArr[i10 + 6] & 255) << 48);
        }

        /* JADX WARN: Code restructure failed: missing block: B:33:0x0068, code lost:
        
            if (r2[r3] < 0) goto L34;
         */
        /*
            Code decompiled incorrectly, please refer to instructions dump.
        */
        public int J() {
            int i10;
            int i11 = this.f4085j;
            int i12 = this.f4083h;
            if (i12 != i11) {
                byte[] bArr = this.f4081f;
                int i13 = i11 + 1;
                byte b10 = bArr[i11];
                if (b10 >= 0) {
                    this.f4085j = i13;
                    return b10;
                }
                if (i12 - i13 >= 9) {
                    int i14 = i13 + 1;
                    int i15 = b10 ^ (bArr[i13] << 7);
                    if (i15 < 0) {
                        i10 = i15 ^ (-128);
                    } else {
                        int i16 = i14 + 1;
                        int i17 = i15 ^ (bArr[i14] << 14);
                        if (i17 >= 0) {
                            i10 = i17 ^ 16256;
                        } else {
                            i14 = i16 + 1;
                            int i18 = i17 ^ (bArr[i16] << 21);
                            if (i18 < 0) {
                                i10 = i18 ^ (-2080896);
                            } else {
                                i16 = i14 + 1;
                                byte b11 = bArr[i14];
                                i10 = (i18 ^ (b11 << 28)) ^ 266354560;
                                if (b11 < 0) {
                                    i14 = i16 + 1;
                                    if (bArr[i16] < 0) {
                                        i16 = i14 + 1;
                                        if (bArr[i14] < 0) {
                                            i14 = i16 + 1;
                                            if (bArr[i16] < 0) {
                                                i16 = i14 + 1;
                                                if (bArr[i14] < 0) {
                                                    i14 = i16 + 1;
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        i14 = i16;
                    }
                    this.f4085j = i14;
                    return i10;
                }
            }
            return (int) L();
        }

        /* JADX WARN: Code restructure failed: missing block: B:39:0x00b4, code lost:
        
            if (r2[r0] < 0) goto L40;
         */
        /*
            Code decompiled incorrectly, please refer to instructions dump.
        */
        public long K() {
            long j10;
            long j11;
            long j12;
            int i10;
            int i11 = this.f4085j;
            int i12 = this.f4083h;
            if (i12 != i11) {
                byte[] bArr = this.f4081f;
                int i13 = i11 + 1;
                byte b10 = bArr[i11];
                if (b10 >= 0) {
                    this.f4085j = i13;
                    return b10;
                }
                if (i12 - i13 >= 9) {
                    int i14 = i13 + 1;
                    int i15 = b10 ^ (bArr[i13] << 7);
                    if (i15 >= 0) {
                        int i16 = i14 + 1;
                        int i17 = i15 ^ (bArr[i14] << 14);
                        if (i17 >= 0) {
                            i14 = i16;
                            j10 = i17 ^ 16256;
                        } else {
                            i14 = i16 + 1;
                            int i18 = i17 ^ (bArr[i16] << 21);
                            if (i18 < 0) {
                                i10 = i18 ^ (-2080896);
                            } else {
                                long j13 = i18;
                                int i19 = i14 + 1;
                                long j14 = j13 ^ (bArr[i14] << 28);
                                if (j14 >= 0) {
                                    j12 = 266354560;
                                } else {
                                    i14 = i19 + 1;
                                    long j15 = j14 ^ (bArr[i19] << 35);
                                    if (j15 < 0) {
                                        j11 = -34093383808L;
                                    } else {
                                        i19 = i14 + 1;
                                        j14 = j15 ^ (bArr[i14] << 42);
                                        if (j14 >= 0) {
                                            j12 = 4363953127296L;
                                        } else {
                                            i14 = i19 + 1;
                                            j15 = j14 ^ (bArr[i19] << 49);
                                            if (j15 < 0) {
                                                j11 = -558586000294016L;
                                            } else {
                                                int i20 = i14 + 1;
                                                long j16 = (j15 ^ (bArr[i14] << 56)) ^ 71499008037633920L;
                                                i14 = j16 < 0 ? i20 + 1 : i20;
                                                j10 = j16;
                                            }
                                        }
                                    }
                                    j10 = j15 ^ j11;
                                }
                                j10 = j14 ^ j12;
                                i14 = i19;
                            }
                        }
                        this.f4085j = i14;
                        return j10;
                    }
                    i10 = i15 ^ (-128);
                    j10 = i10;
                    this.f4085j = i14;
                    return j10;
                }
            }
            return L();
        }

        long L() {
            long j10 = 0;
            for (int i10 = 0; i10 < 64; i10 += 7) {
                j10 |= (r3 & Byte.MAX_VALUE) << i10;
                if ((F() & 128) == 0) {
                    return j10;
                }
            }
            throw z.e();
        }

        public void N() {
            int B;
            do {
                B = B();
                if (B == 0) {
                    return;
                }
            } while (E(B));
        }

        public void O(int i10) {
            if (i10 >= 0) {
                int i11 = this.f4083h;
                int i12 = this.f4085j;
                if (i10 <= i11 - i12) {
                    this.f4085j = i12 + i10;
                    return;
                }
            }
            if (i10 >= 0) {
                throw z.k();
            }
            throw z.f();
        }

        @Override // androidx.datastore.preferences.protobuf.h
        public void a(int i10) {
            if (this.f4087l != i10) {
                throw z.a();
            }
        }

        @Override // androidx.datastore.preferences.protobuf.h
        public int d() {
            return this.f4085j - this.f4086k;
        }

        @Override // androidx.datastore.preferences.protobuf.h
        public boolean e() {
            return this.f4085j == this.f4083h;
        }

        @Override // androidx.datastore.preferences.protobuf.h
        public void k(int i10) {
            this.f4089n = i10;
            M();
        }

        @Override // androidx.datastore.preferences.protobuf.h
        public int l(int i10) {
            if (i10 < 0) {
                throw z.f();
            }
            int d10 = i10 + d();
            int i11 = this.f4089n;
            if (d10 > i11) {
                throw z.k();
            }
            this.f4089n = d10;
            M();
            return i11;
        }

        @Override // androidx.datastore.preferences.protobuf.h
        public boolean m() {
            return K() != 0;
        }

        @Override // androidx.datastore.preferences.protobuf.h
        public g n() {
            int J = J();
            if (J > 0) {
                int i10 = this.f4083h;
                int i11 = this.f4085j;
                if (J <= i10 - i11) {
                    g E = (this.f4082g && this.f4088m) ? g.E(this.f4081f, i11, J) : g.m(this.f4081f, i11, J);
                    this.f4085j += J;
                    return E;
                }
            }
            return J == 0 ? g.f4042q : g.D(G(J));
        }

        @Override // androidx.datastore.preferences.protobuf.h
        public double o() {
            return Double.longBitsToDouble(I());
        }

        @Override // androidx.datastore.preferences.protobuf.h
        public int p() {
            return J();
        }

        @Override // androidx.datastore.preferences.protobuf.h
        public int q() {
            return H();
        }

        @Override // androidx.datastore.preferences.protobuf.h
        public long r() {
            return I();
        }

        @Override // androidx.datastore.preferences.protobuf.h
        public float s() {
            return Float.intBitsToFloat(H());
        }

        @Override // androidx.datastore.preferences.protobuf.h
        public int t() {
            return J();
        }

        @Override // androidx.datastore.preferences.protobuf.h
        public long u() {
            return K();
        }

        @Override // androidx.datastore.preferences.protobuf.h
        public int v() {
            return H();
        }

        @Override // androidx.datastore.preferences.protobuf.h
        public long w() {
            return I();
        }

        @Override // androidx.datastore.preferences.protobuf.h
        public int x() {
            return h.b(J());
        }

        @Override // androidx.datastore.preferences.protobuf.h
        public long y() {
            return h.c(K());
        }

        @Override // androidx.datastore.preferences.protobuf.h
        public String z() {
            int J = J();
            if (J > 0) {
                int i10 = this.f4083h;
                int i11 = this.f4085j;
                if (J <= i10 - i11) {
                    String str = new String(this.f4081f, i11, J, y.f4218a);
                    this.f4085j += J;
                    return str;
                }
            }
            if (J == 0) {
                return "";
            }
            if (J < 0) {
                throw z.f();
            }
            throw z.k();
        }

        private b(byte[] bArr, int i10, int i11, boolean z10) {
            super();
            this.f4089n = Api.BaseClientBuilder.API_PRIORITY_OTHER;
            this.f4081f = bArr;
            this.f4083h = i11 + i10;
            this.f4085j = i10;
            this.f4086k = i10;
            this.f4082g = z10;
        }
    }

    /* JADX INFO: Access modifiers changed from: private */
    /* loaded from: classes.dex */
    public static final class c extends h {

        /* renamed from: f, reason: collision with root package name */
        private final InputStream f4090f;

        /* renamed from: g, reason: collision with root package name */
        private final byte[] f4091g;

        /* renamed from: h, reason: collision with root package name */
        private int f4092h;

        /* renamed from: i, reason: collision with root package name */
        private int f4093i;

        /* renamed from: j, reason: collision with root package name */
        private int f4094j;

        /* renamed from: k, reason: collision with root package name */
        private int f4095k;

        /* renamed from: l, reason: collision with root package name */
        private int f4096l;

        /* renamed from: m, reason: collision with root package name */
        private int f4097m;

        private g F(int i10) {
            byte[] I = I(i10);
            if (I != null) {
                return g.l(I);
            }
            int i11 = this.f4094j;
            int i12 = this.f4092h;
            int i13 = i12 - i11;
            this.f4096l += i12;
            this.f4094j = 0;
            this.f4092h = 0;
            List<byte[]> J = J(i10 - i13);
            byte[] bArr = new byte[i10];
            System.arraycopy(this.f4091g, i11, bArr, 0, i13);
            for (byte[] bArr2 : J) {
                System.arraycopy(bArr2, 0, bArr, i13, bArr2.length);
                i13 += bArr2.length;
            }
            return g.D(bArr);
        }

        private byte[] H(int i10, boolean z10) {
            byte[] I = I(i10);
            if (I != null) {
                return z10 ? (byte[]) I.clone() : I;
            }
            int i11 = this.f4094j;
            int i12 = this.f4092h;
            int i13 = i12 - i11;
            this.f4096l += i12;
            this.f4094j = 0;
            this.f4092h = 0;
            List<byte[]> J = J(i10 - i13);
            byte[] bArr = new byte[i10];
            System.arraycopy(this.f4091g, i11, bArr, 0, i13);
            for (byte[] bArr2 : J) {
                System.arraycopy(bArr2, 0, bArr, i13, bArr2.length);
                i13 += bArr2.length;
            }
            return bArr;
        }

        private byte[] I(int i10) {
            if (i10 == 0) {
                return y.f4220c;
            }
            if (i10 < 0) {
                throw z.f();
            }
            int i11 = this.f4096l;
            int i12 = this.f4094j;
            int i13 = i11 + i12 + i10;
            if (i13 - this.f4078c > 0) {
                throw z.j();
            }
            int i14 = this.f4097m;
            if (i13 > i14) {
                S((i14 - i11) - i12);
                throw z.k();
            }
            int i15 = this.f4092h - i12;
            int i16 = i10 - i15;
            if (i16 >= 4096 && i16 > this.f4090f.available()) {
                return null;
            }
            byte[] bArr = new byte[i10];
            System.arraycopy(this.f4091g, this.f4094j, bArr, 0, i15);
            this.f4096l += this.f4092h;
            this.f4094j = 0;
            this.f4092h = 0;
            while (i15 < i10) {
                int read = this.f4090f.read(bArr, i15, i10 - i15);
                if (read == -1) {
                    throw z.k();
                }
                this.f4096l += read;
                i15 += read;
            }
            return bArr;
        }

        private List J(int i10) {
            ArrayList arrayList = new ArrayList();
            while (i10 > 0) {
                int min = Math.min(i10, 4096);
                byte[] bArr = new byte[min];
                int i11 = 0;
                while (i11 < min) {
                    int read = this.f4090f.read(bArr, i11, min - i11);
                    if (read == -1) {
                        throw z.k();
                    }
                    this.f4096l += read;
                    i11 += read;
                }
                i10 -= min;
                arrayList.add(bArr);
            }
            return arrayList;
        }

        private void P() {
            int i10 = this.f4092h + this.f4093i;
            this.f4092h = i10;
            int i11 = this.f4096l + i10;
            int i12 = this.f4097m;
            if (i11 <= i12) {
                this.f4093i = 0;
                return;
            }
            int i13 = i11 - i12;
            this.f4093i = i13;
            this.f4092h = i10 - i13;
        }

        private void Q(int i10) {
            if (X(i10)) {
                return;
            }
            if (i10 <= (this.f4078c - this.f4096l) - this.f4094j) {
                throw z.k();
            }
            throw z.j();
        }

        private void T(int i10) {
            if (i10 < 0) {
                throw z.f();
            }
            int i11 = this.f4096l;
            int i12 = this.f4094j;
            int i13 = i11 + i12 + i10;
            int i14 = this.f4097m;
            if (i13 > i14) {
                S((i14 - i11) - i12);
                throw z.k();
            }
            this.f4096l = i11 + i12;
            int i15 = this.f4092h - i12;
            this.f4092h = 0;
            this.f4094j = 0;
            while (i15 < i10) {
                try {
                    long j10 = i10 - i15;
                    long skip = this.f4090f.skip(j10);
                    if (skip < 0 || skip > j10) {
                        throw new IllegalStateException(this.f4090f.getClass() + "#skip returned invalid result: " + skip + "\nThe InputStream implementation is buggy.");
                    }
                    if (skip == 0) {
                        break;
                    } else {
                        i15 += (int) skip;
                    }
                } finally {
                    this.f4096l += i15;
                    P();
                }
            }
            if (i15 >= i10) {
                return;
            }
            int i16 = this.f4092h;
            int i17 = i16 - this.f4094j;
            this.f4094j = i16;
            Q(1);
            while (true) {
                int i18 = i10 - i17;
                int i19 = this.f4092h;
                if (i18 <= i19) {
                    this.f4094j = i18;
                    return;
                } else {
                    i17 += i19;
                    this.f4094j = i19;
                    Q(1);
                }
            }
        }

        private void U() {
            if (this.f4092h - this.f4094j >= 10) {
                V();
            } else {
                W();
            }
        }

        private void V() {
            for (int i10 = 0; i10 < 10; i10++) {
                byte[] bArr = this.f4091g;
                int i11 = this.f4094j;
                this.f4094j = i11 + 1;
                if (bArr[i11] >= 0) {
                    return;
                }
            }
            throw z.e();
        }

        private void W() {
            for (int i10 = 0; i10 < 10; i10++) {
                if (G() >= 0) {
                    return;
                }
            }
            throw z.e();
        }

        private boolean X(int i10) {
            int i11 = this.f4094j;
            int i12 = i11 + i10;
            int i13 = this.f4092h;
            if (i12 <= i13) {
                throw new IllegalStateException("refillBuffer() called when " + i10 + " bytes were already available in buffer");
            }
            int i14 = this.f4078c;
            int i15 = this.f4096l;
            if (i10 > (i14 - i15) - i11 || i15 + i11 + i10 > this.f4097m) {
                return false;
            }
            if (i11 > 0) {
                if (i13 > i11) {
                    byte[] bArr = this.f4091g;
                    System.arraycopy(bArr, i11, bArr, 0, i13 - i11);
                }
                this.f4096l += i11;
                this.f4092h -= i11;
                this.f4094j = 0;
            }
            InputStream inputStream = this.f4090f;
            byte[] bArr2 = this.f4091g;
            int i16 = this.f4092h;
            int read = inputStream.read(bArr2, i16, Math.min(bArr2.length - i16, (this.f4078c - this.f4096l) - i16));
            if (read == 0 || read < -1 || read > this.f4091g.length) {
                throw new IllegalStateException(this.f4090f.getClass() + "#read(byte[]) returned invalid result: " + read + "\nThe InputStream implementation is buggy.");
            }
            if (read <= 0) {
                return false;
            }
            this.f4092h += read;
            P();
            if (this.f4092h >= i10) {
                return true;
            }
            return X(i10);
        }

        @Override // androidx.datastore.preferences.protobuf.h
        public String A() {
            byte[] H;
            int M = M();
            int i10 = this.f4094j;
            int i11 = this.f4092h;
            if (M <= i11 - i10 && M > 0) {
                H = this.f4091g;
                this.f4094j = i10 + M;
            } else {
                if (M == 0) {
                    return "";
                }
                i10 = 0;
                if (M <= i11) {
                    Q(M);
                    H = this.f4091g;
                    this.f4094j = M + 0;
                } else {
                    H = H(M, false);
                }
            }
            return p1.e(H, i10, M);
        }

        @Override // androidx.datastore.preferences.protobuf.h
        public int B() {
            if (e()) {
                this.f4095k = 0;
                return 0;
            }
            int M = M();
            this.f4095k = M;
            if (q1.a(M) != 0) {
                return this.f4095k;
            }
            throw z.b();
        }

        @Override // androidx.datastore.preferences.protobuf.h
        public int C() {
            return M();
        }

        @Override // androidx.datastore.preferences.protobuf.h
        public long D() {
            return N();
        }

        @Override // androidx.datastore.preferences.protobuf.h
        public boolean E(int i10) {
            int b10 = q1.b(i10);
            if (b10 == 0) {
                U();
                return true;
            }
            if (b10 == 1) {
                S(8);
                return true;
            }
            if (b10 == 2) {
                S(M());
                return true;
            }
            if (b10 == 3) {
                R();
                a(q1.c(q1.a(i10), 4));
                return true;
            }
            if (b10 == 4) {
                return false;
            }
            if (b10 != 5) {
                throw z.d();
            }
            S(4);
            return true;
        }

        public byte G() {
            if (this.f4094j == this.f4092h) {
                Q(1);
            }
            byte[] bArr = this.f4091g;
            int i10 = this.f4094j;
            this.f4094j = i10 + 1;
            return bArr[i10];
        }

        public int K() {
            int i10 = this.f4094j;
            if (this.f4092h - i10 < 4) {
                Q(4);
                i10 = this.f4094j;
            }
            byte[] bArr = this.f4091g;
            this.f4094j = i10 + 4;
            return (bArr[i10] & 255) | ((bArr[i10 + 1] & 255) << 8) | ((bArr[i10 + 2] & 255) << 16) | ((bArr[i10 + 3] & 255) << 24);
        }

        public long L() {
            int i10 = this.f4094j;
            if (this.f4092h - i10 < 8) {
                Q(8);
                i10 = this.f4094j;
            }
            byte[] bArr = this.f4091g;
            this.f4094j = i10 + 8;
            return ((bArr[i10 + 7] & 255) << 56) | (bArr[i10] & 255) | ((bArr[i10 + 1] & 255) << 8) | ((bArr[i10 + 2] & 255) << 16) | ((bArr[i10 + 3] & 255) << 24) | ((bArr[i10 + 4] & 255) << 32) | ((bArr[i10 + 5] & 255) << 40) | ((bArr[i10 + 6] & 255) << 48);
        }

        /* JADX WARN: Code restructure failed: missing block: B:33:0x0068, code lost:
        
            if (r2[r3] < 0) goto L34;
         */
        /*
            Code decompiled incorrectly, please refer to instructions dump.
        */
        public int M() {
            int i10;
            int i11 = this.f4094j;
            int i12 = this.f4092h;
            if (i12 != i11) {
                byte[] bArr = this.f4091g;
                int i13 = i11 + 1;
                byte b10 = bArr[i11];
                if (b10 >= 0) {
                    this.f4094j = i13;
                    return b10;
                }
                if (i12 - i13 >= 9) {
                    int i14 = i13 + 1;
                    int i15 = b10 ^ (bArr[i13] << 7);
                    if (i15 < 0) {
                        i10 = i15 ^ (-128);
                    } else {
                        int i16 = i14 + 1;
                        int i17 = i15 ^ (bArr[i14] << 14);
                        if (i17 >= 0) {
                            i10 = i17 ^ 16256;
                        } else {
                            i14 = i16 + 1;
                            int i18 = i17 ^ (bArr[i16] << 21);
                            if (i18 < 0) {
                                i10 = i18 ^ (-2080896);
                            } else {
                                i16 = i14 + 1;
                                byte b11 = bArr[i14];
                                i10 = (i18 ^ (b11 << 28)) ^ 266354560;
                                if (b11 < 0) {
                                    i14 = i16 + 1;
                                    if (bArr[i16] < 0) {
                                        i16 = i14 + 1;
                                        if (bArr[i14] < 0) {
                                            i14 = i16 + 1;
                                            if (bArr[i16] < 0) {
                                                i16 = i14 + 1;
                                                if (bArr[i14] < 0) {
                                                    i14 = i16 + 1;
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        i14 = i16;
                    }
                    this.f4094j = i14;
                    return i10;
                }
            }
            return (int) O();
        }

        /* JADX WARN: Code restructure failed: missing block: B:39:0x00b4, code lost:
        
            if (r2[r0] < 0) goto L40;
         */
        /*
            Code decompiled incorrectly, please refer to instructions dump.
        */
        public long N() {
            long j10;
            long j11;
            long j12;
            int i10;
            int i11 = this.f4094j;
            int i12 = this.f4092h;
            if (i12 != i11) {
                byte[] bArr = this.f4091g;
                int i13 = i11 + 1;
                byte b10 = bArr[i11];
                if (b10 >= 0) {
                    this.f4094j = i13;
                    return b10;
                }
                if (i12 - i13 >= 9) {
                    int i14 = i13 + 1;
                    int i15 = b10 ^ (bArr[i13] << 7);
                    if (i15 >= 0) {
                        int i16 = i14 + 1;
                        int i17 = i15 ^ (bArr[i14] << 14);
                        if (i17 >= 0) {
                            i14 = i16;
                            j10 = i17 ^ 16256;
                        } else {
                            i14 = i16 + 1;
                            int i18 = i17 ^ (bArr[i16] << 21);
                            if (i18 < 0) {
                                i10 = i18 ^ (-2080896);
                            } else {
                                long j13 = i18;
                                int i19 = i14 + 1;
                                long j14 = j13 ^ (bArr[i14] << 28);
                                if (j14 >= 0) {
                                    j12 = 266354560;
                                } else {
                                    i14 = i19 + 1;
                                    long j15 = j14 ^ (bArr[i19] << 35);
                                    if (j15 < 0) {
                                        j11 = -34093383808L;
                                    } else {
                                        i19 = i14 + 1;
                                        j14 = j15 ^ (bArr[i14] << 42);
                                        if (j14 >= 0) {
                                            j12 = 4363953127296L;
                                        } else {
                                            i14 = i19 + 1;
                                            j15 = j14 ^ (bArr[i19] << 49);
                                            if (j15 < 0) {
                                                j11 = -558586000294016L;
                                            } else {
                                                int i20 = i14 + 1;
                                                long j16 = (j15 ^ (bArr[i14] << 56)) ^ 71499008037633920L;
                                                i14 = j16 < 0 ? i20 + 1 : i20;
                                                j10 = j16;
                                            }
                                        }
                                    }
                                    j10 = j15 ^ j11;
                                }
                                j10 = j14 ^ j12;
                                i14 = i19;
                            }
                        }
                        this.f4094j = i14;
                        return j10;
                    }
                    i10 = i15 ^ (-128);
                    j10 = i10;
                    this.f4094j = i14;
                    return j10;
                }
            }
            return O();
        }

        long O() {
            long j10 = 0;
            for (int i10 = 0; i10 < 64; i10 += 7) {
                j10 |= (r3 & Byte.MAX_VALUE) << i10;
                if ((G() & 128) == 0) {
                    return j10;
                }
            }
            throw z.e();
        }

        public void R() {
            int B;
            do {
                B = B();
                if (B == 0) {
                    return;
                }
            } while (E(B));
        }

        public void S(int i10) {
            int i11 = this.f4092h;
            int i12 = this.f4094j;
            if (i10 > i11 - i12 || i10 < 0) {
                T(i10);
            } else {
                this.f4094j = i12 + i10;
            }
        }

        @Override // androidx.datastore.preferences.protobuf.h
        public void a(int i10) {
            if (this.f4095k != i10) {
                throw z.a();
            }
        }

        @Override // androidx.datastore.preferences.protobuf.h
        public int d() {
            return this.f4096l + this.f4094j;
        }

        @Override // androidx.datastore.preferences.protobuf.h
        public boolean e() {
            return this.f4094j == this.f4092h && !X(1);
        }

        @Override // androidx.datastore.preferences.protobuf.h
        public void k(int i10) {
            this.f4097m = i10;
            P();
        }

        @Override // androidx.datastore.preferences.protobuf.h
        public int l(int i10) {
            if (i10 < 0) {
                throw z.f();
            }
            int i11 = i10 + this.f4096l + this.f4094j;
            int i12 = this.f4097m;
            if (i11 > i12) {
                throw z.k();
            }
            this.f4097m = i11;
            P();
            return i12;
        }

        @Override // androidx.datastore.preferences.protobuf.h
        public boolean m() {
            return N() != 0;
        }

        @Override // androidx.datastore.preferences.protobuf.h
        public g n() {
            int M = M();
            int i10 = this.f4092h;
            int i11 = this.f4094j;
            if (M > i10 - i11 || M <= 0) {
                return M == 0 ? g.f4042q : F(M);
            }
            g m10 = g.m(this.f4091g, i11, M);
            this.f4094j += M;
            return m10;
        }

        @Override // androidx.datastore.preferences.protobuf.h
        public double o() {
            return Double.longBitsToDouble(L());
        }

        @Override // androidx.datastore.preferences.protobuf.h
        public int p() {
            return M();
        }

        @Override // androidx.datastore.preferences.protobuf.h
        public int q() {
            return K();
        }

        @Override // androidx.datastore.preferences.protobuf.h
        public long r() {
            return L();
        }

        @Override // androidx.datastore.preferences.protobuf.h
        public float s() {
            return Float.intBitsToFloat(K());
        }

        @Override // androidx.datastore.preferences.protobuf.h
        public int t() {
            return M();
        }

        @Override // androidx.datastore.preferences.protobuf.h
        public long u() {
            return N();
        }

        @Override // androidx.datastore.preferences.protobuf.h
        public int v() {
            return K();
        }

        @Override // androidx.datastore.preferences.protobuf.h
        public long w() {
            return L();
        }

        @Override // androidx.datastore.preferences.protobuf.h
        public int x() {
            return h.b(M());
        }

        @Override // androidx.datastore.preferences.protobuf.h
        public long y() {
            return h.c(N());
        }

        @Override // androidx.datastore.preferences.protobuf.h
        public String z() {
            int M = M();
            if (M > 0) {
                int i10 = this.f4092h;
                int i11 = this.f4094j;
                if (M <= i10 - i11) {
                    String str = new String(this.f4091g, i11, M, y.f4218a);
                    this.f4094j += M;
                    return str;
                }
            }
            if (M == 0) {
                return "";
            }
            if (M > this.f4092h) {
                return new String(H(M, false), y.f4218a);
            }
            Q(M);
            String str2 = new String(this.f4091g, this.f4094j, M, y.f4218a);
            this.f4094j += M;
            return str2;
        }

        private c(InputStream inputStream, int i10) {
            super();
            this.f4097m = Api.BaseClientBuilder.API_PRIORITY_OTHER;
            y.b(inputStream, "input");
            this.f4090f = inputStream;
            this.f4091g = new byte[i10];
            this.f4092h = 0;
            this.f4094j = 0;
            this.f4096l = 0;
        }
    }

    public static int b(int i10) {
        return (-(i10 & 1)) ^ (i10 >>> 1);
    }

    public static long c(long j10) {
        return (-(j10 & 1)) ^ (j10 >>> 1);
    }

    public static h f(InputStream inputStream) {
        return g(inputStream, 4096);
    }

    public static h g(InputStream inputStream, int i10) {
        if (i10 > 0) {
            return inputStream == null ? h(y.f4220c) : new c(inputStream, i10);
        }
        throw new IllegalArgumentException("bufferSize must be > 0");
    }

    public static h h(byte[] bArr) {
        return i(bArr, 0, bArr.length);
    }

    public static h i(byte[] bArr, int i10, int i11) {
        return j(bArr, i10, i11, false);
    }

    static h j(byte[] bArr, int i10, int i11, boolean z10) {
        b bVar = new b(bArr, i10, i11, z10);
        try {
            bVar.l(i11);
            return bVar;
        } catch (z e10) {
            throw new IllegalArgumentException(e10);
        }
    }

    public abstract String A();

    public abstract int B();

    public abstract int C();

    public abstract long D();

    public abstract boolean E(int i10);

    public abstract void a(int i10);

    public abstract int d();

    public abstract boolean e();

    public abstract void k(int i10);

    public abstract int l(int i10);

    public abstract boolean m();

    public abstract g n();

    public abstract double o();

    public abstract int p();

    public abstract int q();

    public abstract long r();

    public abstract float s();

    public abstract int t();

    public abstract long u();

    public abstract int v();

    public abstract long w();

    public abstract int x();

    public abstract long y();

    public abstract String z();

    private h() {
        this.f4077b = 100;
        this.f4078c = Api.BaseClientBuilder.API_PRIORITY_OTHER;
        this.f4080e = false;
    }
}
