package kotlin.reflect.w.internal.y0.g;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import kotlin.reflect.w.internal.y0.g.q;
import kotlin.reflect.w.internal.y0.i.a;
import kotlin.reflect.w.internal.y0.i.c;
import kotlin.reflect.w.internal.y0.i.d;
import kotlin.reflect.w.internal.y0.i.e;
import kotlin.reflect.w.internal.y0.i.f;
import kotlin.reflect.w.internal.y0.i.h;
import kotlin.reflect.w.internal.y0.i.j;
import kotlin.reflect.w.internal.y0.i.p;
import kotlin.reflect.w.internal.y0.i.q;
import kotlin.reflect.w.internal.y0.i.v;

/* JADX INFO: loaded from: classes2.dex */
public final class r extends h.d<r> implements q {

    /* JADX INFO: renamed from: m, reason: collision with root package name */
    public static final r f8010m;

    /* JADX INFO: renamed from: n, reason: collision with root package name */
    public static kotlin.reflect.w.internal.y0.i.r<r> f8011n = new a();
    public int A;

    /* JADX INFO: renamed from: o, reason: collision with root package name */
    public final c f8012o;

    /* JADX INFO: renamed from: p, reason: collision with root package name */
    public int f8013p;

    /* JADX INFO: renamed from: q, reason: collision with root package name */
    public int f8014q;

    /* JADX INFO: renamed from: r, reason: collision with root package name */
    public int f8015r;

    /* JADX INFO: renamed from: s, reason: collision with root package name */
    public List<s> f8016s;

    /* JADX INFO: renamed from: t, reason: collision with root package name */
    public q f8017t;

    /* JADX INFO: renamed from: u, reason: collision with root package name */
    public int f8018u;

    /* JADX INFO: renamed from: v, reason: collision with root package name */
    public q f8019v;

    /* JADX INFO: renamed from: w, reason: collision with root package name */
    public int f8020w;

    /* JADX INFO: renamed from: x, reason: collision with root package name */
    public List<kotlin.reflect.w.internal.y0.g.b> f8021x;

    /* JADX INFO: renamed from: y, reason: collision with root package name */
    public List<Integer> f8022y;

    /* JADX INFO: renamed from: z, reason: collision with root package name */
    public byte f8023z;

    public static class a extends kotlin.reflect.w.internal.y0.i.b<r> {
        @Override // kotlin.reflect.w.internal.y0.i.r
        public Object a(d dVar, f fVar) {
            return new r(dVar, fVar, null);
        }
    }

    public static final class b extends h.c<r, b> implements q {

        /* JADX INFO: renamed from: o, reason: collision with root package name */
        public int f8024o;

        /* JADX INFO: renamed from: q, reason: collision with root package name */
        public int f8026q;

        /* JADX INFO: renamed from: s, reason: collision with root package name */
        public q f8028s;

        /* JADX INFO: renamed from: t, reason: collision with root package name */
        public int f8029t;

        /* JADX INFO: renamed from: u, reason: collision with root package name */
        public q f8030u;

        /* JADX INFO: renamed from: v, reason: collision with root package name */
        public int f8031v;

        /* JADX INFO: renamed from: w, reason: collision with root package name */
        public List<kotlin.reflect.w.internal.y0.g.b> f8032w;

        /* JADX INFO: renamed from: x, reason: collision with root package name */
        public List<Integer> f8033x;

        /* JADX INFO: renamed from: p, reason: collision with root package name */
        public int f8025p = 6;

        /* JADX INFO: renamed from: r, reason: collision with root package name */
        public List<s> f8027r = Collections.emptyList();

        public b() {
            q qVar = q.f7965m;
            this.f8028s = qVar;
            this.f8030u = qVar;
            this.f8032w = Collections.emptyList();
            this.f8033x = Collections.emptyList();
        }

        @Override // r.i0.w.b.y0.i.p.a
        public p a() {
            r rVarN = n();
            if (rVarN.i()) {
                return rVarN;
            }
            throw new v();
        }

        @Override // r.i0.w.b.y0.i.h.b
        public Object clone() {
            b bVar = new b();
            bVar.o(n());
            return bVar;
        }

        @Override // kotlin.reflect.w.internal.y0.i.a.AbstractC0155a, r.i0.w.b.y0.i.p.a
        public /* bridge */ /* synthetic */ p.a h(d dVar, f fVar) throws Throwable {
            p(dVar, fVar);
            return this;
        }

        @Override // kotlin.reflect.w.internal.y0.i.a.AbstractC0155a
        /* JADX INFO: renamed from: j */
        public /* bridge */ /* synthetic */ a.AbstractC0155a h(d dVar, f fVar) throws Throwable {
            p(dVar, fVar);
            return this;
        }

        @Override // r.i0.w.b.y0.i.h.b
        /* JADX INFO: renamed from: k */
        public h.b clone() {
            b bVar = new b();
            bVar.o(n());
            return bVar;
        }

        @Override // r.i0.w.b.y0.i.h.b
        public /* bridge */ /* synthetic */ h.b l(h hVar) {
            o((r) hVar);
            return this;
        }

        public r n() {
            r rVar = new r(this, null);
            int i2 = this.f8024o;
            int i3 = (i2 & 1) != 1 ? 0 : 1;
            rVar.f8014q = this.f8025p;
            if ((i2 & 2) == 2) {
                i3 |= 2;
            }
            rVar.f8015r = this.f8026q;
            if ((i2 & 4) == 4) {
                this.f8027r = Collections.unmodifiableList(this.f8027r);
                this.f8024o &= -5;
            }
            rVar.f8016s = this.f8027r;
            if ((i2 & 8) == 8) {
                i3 |= 4;
            }
            rVar.f8017t = this.f8028s;
            if ((i2 & 16) == 16) {
                i3 |= 8;
            }
            rVar.f8018u = this.f8029t;
            if ((i2 & 32) == 32) {
                i3 |= 16;
            }
            rVar.f8019v = this.f8030u;
            if ((i2 & 64) == 64) {
                i3 |= 32;
            }
            rVar.f8020w = this.f8031v;
            if ((this.f8024o & 128) == 128) {
                this.f8032w = Collections.unmodifiableList(this.f8032w);
                this.f8024o &= -129;
            }
            rVar.f8021x = this.f8032w;
            if ((this.f8024o & 256) == 256) {
                this.f8033x = Collections.unmodifiableList(this.f8033x);
                this.f8024o &= -257;
            }
            rVar.f8022y = this.f8033x;
            rVar.f8013p = i3;
            return rVar;
        }

        public b o(r rVar) {
            q qVar;
            q qVar2;
            if (rVar == r.f8010m) {
                return this;
            }
            int i2 = rVar.f8013p;
            if ((i2 & 1) == 1) {
                int i3 = rVar.f8014q;
                this.f8024o |= 1;
                this.f8025p = i3;
            }
            if ((i2 & 2) == 2) {
                int i4 = rVar.f8015r;
                this.f8024o = 2 | this.f8024o;
                this.f8026q = i4;
            }
            if (!rVar.f8016s.isEmpty()) {
                if (this.f8027r.isEmpty()) {
                    this.f8027r = rVar.f8016s;
                    this.f8024o &= -5;
                } else {
                    if ((this.f8024o & 4) != 4) {
                        this.f8027r = new ArrayList(this.f8027r);
                        this.f8024o |= 4;
                    }
                    this.f8027r.addAll(rVar.f8016s);
                }
            }
            if (rVar.t()) {
                q qVarN = rVar.f8017t;
                if ((this.f8024o & 8) == 8 && (qVar2 = this.f8028s) != q.f7965m) {
                    q.c cVarY = q.y(qVar2);
                    cVarY.l(qVarN);
                    qVarN = cVarY.n();
                }
                this.f8028s = qVarN;
                this.f8024o |= 8;
            }
            if ((rVar.f8013p & 8) == 8) {
                int i5 = rVar.f8018u;
                this.f8024o |= 16;
                this.f8029t = i5;
            }
            if (rVar.s()) {
                q qVarN2 = rVar.f8019v;
                if ((this.f8024o & 32) == 32 && (qVar = this.f8030u) != q.f7965m) {
                    q.c cVarY2 = q.y(qVar);
                    cVarY2.l(qVarN2);
                    qVarN2 = cVarY2.n();
                }
                this.f8030u = qVarN2;
                this.f8024o |= 32;
            }
            if ((rVar.f8013p & 32) == 32) {
                int i6 = rVar.f8020w;
                this.f8024o |= 64;
                this.f8031v = i6;
            }
            if (!rVar.f8021x.isEmpty()) {
                if (this.f8032w.isEmpty()) {
                    this.f8032w = rVar.f8021x;
                    this.f8024o &= -129;
                } else {
                    if ((this.f8024o & 128) != 128) {
                        this.f8032w = new ArrayList(this.f8032w);
                        this.f8024o |= 128;
                    }
                    this.f8032w.addAll(rVar.f8021x);
                }
            }
            if (!rVar.f8022y.isEmpty()) {
                if (this.f8033x.isEmpty()) {
                    this.f8033x = rVar.f8022y;
                    this.f8024o &= -257;
                } else {
                    if ((this.f8024o & 256) != 256) {
                        this.f8033x = new ArrayList(this.f8033x);
                        this.f8024o |= 256;
                    }
                    this.f8033x.addAll(rVar.f8022y);
                }
            }
            m(rVar);
            this.f8259f = this.f8259f.b(rVar.f8012o);
            return this;
        }

        /* JADX WARN: Removed duplicated region for block: B:15:0x001b  */
        /*
            Code decompiled incorrectly, please refer to instructions dump.
            To view partially-correct add '--show-bad-code' argument
        */
        public r.i0.w.b.y0.g.r.b p(kotlin.reflect.w.internal.y0.i.d r3, kotlin.reflect.w.internal.y0.i.f r4) throws java.lang.Throwable {
            /*
                r2 = this;
                r0 = 0
                r.i0.w.b.y0.i.r<r.i0.w.b.y0.g.r> r1 = kotlin.reflect.w.internal.y0.g.r.f8011n     // Catch: java.lang.Throwable -> Lf kotlin.reflect.w.internal.y0.i.j -> L11
                java.lang.Object r3 = r1.a(r3, r4)     // Catch: java.lang.Throwable -> Lf kotlin.reflect.w.internal.y0.i.j -> L11
                r.i0.w.b.y0.g.r r3 = (kotlin.reflect.w.internal.y0.g.r) r3     // Catch: java.lang.Throwable -> Lf kotlin.reflect.w.internal.y0.i.j -> L11
                if (r3 == 0) goto Le
                r2.o(r3)
            Le:
                return r2
            Lf:
                r3 = move-exception
                goto L19
            L11:
                r3 = move-exception
                r.i0.w.b.y0.i.p r4 = r3.f8275f     // Catch: java.lang.Throwable -> Lf
                r.i0.w.b.y0.g.r r4 = (kotlin.reflect.w.internal.y0.g.r) r4     // Catch: java.lang.Throwable -> Lf
                throw r3     // Catch: java.lang.Throwable -> L17
            L17:
                r3 = move-exception
                r0 = r4
            L19:
                if (r0 == 0) goto L1e
                r2.o(r0)
            L1e:
                throw r3
            */
            throw new UnsupportedOperationException("Method not decompiled: r.i0.w.b.y0.g.r.b.p(r.i0.w.b.y0.i.d, r.i0.w.b.y0.i.f):r.i0.w.b.y0.g.r$b");
        }
    }

    static {
        r rVar = new r();
        f8010m = rVar;
        rVar.u();
    }

    public r() {
        this.f8023z = (byte) -1;
        this.A = -1;
        this.f8012o = c.f8234f;
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Type inference failed for: r4v0 */
    /* JADX WARN: Type inference failed for: r4v1 */
    /* JADX WARN: Type inference failed for: r4v2, types: [boolean] */
    public r(d dVar, f fVar, kotlin.reflect.w.internal.y0.g.a aVar) {
        List list;
        Object obj;
        Object objH;
        this.f8023z = (byte) -1;
        this.A = -1;
        u();
        c.b bVarN = c.n();
        e eVarK = e.k(bVarN, 1);
        boolean z2 = false;
        int i2 = 0;
        while (true) {
            ?? Q = 4;
            if (z2) {
                if ((i2 & 4) == 4) {
                    this.f8016s = Collections.unmodifiableList(this.f8016s);
                }
                if ((i2 & 128) == 128) {
                    this.f8021x = Collections.unmodifiableList(this.f8021x);
                }
                if ((i2 & 256) == 256) {
                    this.f8022y = Collections.unmodifiableList(this.f8022y);
                }
                try {
                    eVarK.j();
                } catch (IOException unused) {
                } catch (Throwable th) {
                    this.f8012o = bVarN.d();
                    throw th;
                }
                this.f8012o = bVarN.d();
                this.f8262f.i();
                return;
            }
            try {
                try {
                    try {
                        int iO = dVar.o();
                        q.c cVarY = null;
                        switch (iO) {
                            case 0:
                                z2 = true;
                                break;
                            case 8:
                                this.f8013p |= 1;
                                this.f8014q = dVar.l();
                                break;
                            case 16:
                                this.f8013p |= 2;
                                this.f8015r = dVar.l();
                                break;
                            case 26:
                                if ((i2 & 4) != 4) {
                                    this.f8016s = new ArrayList();
                                    i2 |= 4;
                                }
                                list = this.f8016s;
                                obj = s.f8035n;
                                objH = dVar.h(obj, fVar);
                                list.add(objH);
                                break;
                            case 34:
                                if ((this.f8013p & 4) == 4) {
                                    q qVar = this.f8017t;
                                    Objects.requireNonNull(qVar);
                                    cVarY = q.y(qVar);
                                }
                                q qVar2 = (q) dVar.h(q.f7966n, fVar);
                                this.f8017t = qVar2;
                                if (cVarY != null) {
                                    cVarY.l(qVar2);
                                    this.f8017t = cVarY.n();
                                }
                                this.f8013p |= 4;
                                break;
                            case 40:
                                this.f8013p |= 8;
                                this.f8018u = dVar.l();
                                break;
                            case 50:
                                if ((this.f8013p & 16) == 16) {
                                    q qVar3 = this.f8019v;
                                    Objects.requireNonNull(qVar3);
                                    cVarY = q.y(qVar3);
                                }
                                q qVar4 = (q) dVar.h(q.f7966n, fVar);
                                this.f8019v = qVar4;
                                if (cVarY != null) {
                                    cVarY.l(qVar4);
                                    this.f8019v = cVarY.n();
                                }
                                this.f8013p |= 16;
                                break;
                            case 56:
                                this.f8013p |= 32;
                                this.f8020w = dVar.l();
                                break;
                            case 66:
                                if ((i2 & 128) != 128) {
                                    this.f8021x = new ArrayList();
                                    i2 |= 128;
                                }
                                list = this.f8021x;
                                obj = kotlin.reflect.w.internal.y0.g.b.f7656m;
                                objH = dVar.h(obj, fVar);
                                list.add(objH);
                                break;
                            case 248:
                                if ((i2 & 256) != 256) {
                                    this.f8022y = new ArrayList();
                                    i2 |= 256;
                                }
                                list = this.f8022y;
                                objH = Integer.valueOf(dVar.l());
                                list.add(objH);
                                break;
                            case 250:
                                int iD = dVar.d(dVar.l());
                                if ((i2 & 256) != 256 && dVar.b() > 0) {
                                    this.f8022y = new ArrayList();
                                    i2 |= 256;
                                }
                                while (dVar.b() > 0) {
                                    this.f8022y.add(Integer.valueOf(dVar.l()));
                                }
                                dVar.f8248i = iD;
                                dVar.p();
                                break;
                            default:
                                Q = q(dVar, eVarK, fVar, iO);
                                if (Q == 0) {
                                    z2 = true;
                                }
                                break;
                        }
                    } catch (j e2) {
                        e2.f8275f = this;
                        throw e2;
                    }
                } catch (IOException e3) {
                    j jVar = new j(e3.getMessage());
                    jVar.f8275f = this;
                    throw jVar;
                }
            } catch (Throwable th2) {
                if ((i2 & 4) == Q) {
                    this.f8016s = Collections.unmodifiableList(this.f8016s);
                }
                if ((i2 & 128) == 128) {
                    this.f8021x = Collections.unmodifiableList(this.f8021x);
                }
                if ((i2 & 256) == 256) {
                    this.f8022y = Collections.unmodifiableList(this.f8022y);
                }
                try {
                    eVarK.j();
                } catch (IOException unused2) {
                } catch (Throwable th3) {
                    this.f8012o = bVarN.d();
                    throw th3;
                }
                this.f8012o = bVarN.d();
                this.f8262f.i();
                throw th2;
            }
        }
    }

    @Override // kotlin.reflect.w.internal.y0.i.q
    public p b() {
        return f8010m;
    }

    @Override // kotlin.reflect.w.internal.y0.i.p
    public p.a c() {
        b bVar = new b();
        bVar.o(this);
        return bVar;
    }

    @Override // kotlin.reflect.w.internal.y0.i.p
    public void d(e eVar) throws IOException {
        f();
        h.d<MessageType>.a aVarP = p();
        if ((this.f8013p & 1) == 1) {
            eVar.p(1, this.f8014q);
        }
        if ((this.f8013p & 2) == 2) {
            eVar.p(2, this.f8015r);
        }
        for (int i2 = 0; i2 < this.f8016s.size(); i2++) {
            eVar.r(3, this.f8016s.get(i2));
        }
        if ((this.f8013p & 4) == 4) {
            eVar.r(4, this.f8017t);
        }
        if ((this.f8013p & 8) == 8) {
            eVar.p(5, this.f8018u);
        }
        if ((this.f8013p & 16) == 16) {
            eVar.r(6, this.f8019v);
        }
        if ((this.f8013p & 32) == 32) {
            eVar.p(7, this.f8020w);
        }
        for (int i3 = 0; i3 < this.f8021x.size(); i3++) {
            eVar.r(8, this.f8021x.get(i3));
        }
        for (int i4 = 0; i4 < this.f8022y.size(); i4++) {
            eVar.p(31, this.f8022y.get(i4).intValue());
        }
        aVarP.a(200, eVar);
        eVar.u(this.f8012o);
    }

    @Override // kotlin.reflect.w.internal.y0.i.p
    public int f() {
        int i2 = this.A;
        if (i2 != -1) {
            return i2;
        }
        int iC = (this.f8013p & 1) == 1 ? e.c(1, this.f8014q) + 0 : 0;
        if ((this.f8013p & 2) == 2) {
            iC += e.c(2, this.f8015r);
        }
        for (int i3 = 0; i3 < this.f8016s.size(); i3++) {
            iC += e.e(3, this.f8016s.get(i3));
        }
        if ((this.f8013p & 4) == 4) {
            iC += e.e(4, this.f8017t);
        }
        if ((this.f8013p & 8) == 8) {
            iC += e.c(5, this.f8018u);
        }
        if ((this.f8013p & 16) == 16) {
            iC += e.e(6, this.f8019v);
        }
        if ((this.f8013p & 32) == 32) {
            iC += e.c(7, this.f8020w);
        }
        for (int i4 = 0; i4 < this.f8021x.size(); i4++) {
            iC += e.e(8, this.f8021x.get(i4));
        }
        int iD = 0;
        for (int i5 = 0; i5 < this.f8022y.size(); i5++) {
            iD += e.d(this.f8022y.get(i5).intValue());
        }
        int size = this.f8012o.size() + l() + (this.f8022y.size() * 2) + iC + iD;
        this.A = size;
        return size;
    }

    @Override // kotlin.reflect.w.internal.y0.i.p
    public p.a g() {
        return new b();
    }

    @Override // kotlin.reflect.w.internal.y0.i.q
    public final boolean i() {
        byte b2 = this.f8023z;
        if (b2 == 1) {
            return true;
        }
        if (b2 == 0) {
            return false;
        }
        if (!((this.f8013p & 2) == 2)) {
            this.f8023z = (byte) 0;
            return false;
        }
        for (int i2 = 0; i2 < this.f8016s.size(); i2++) {
            if (!this.f8016s.get(i2).i()) {
                this.f8023z = (byte) 0;
                return false;
            }
        }
        if (t() && !this.f8017t.i()) {
            this.f8023z = (byte) 0;
            return false;
        }
        if (s() && !this.f8019v.i()) {
            this.f8023z = (byte) 0;
            return false;
        }
        for (int i3 = 0; i3 < this.f8021x.size(); i3++) {
            if (!this.f8021x.get(i3).i()) {
                this.f8023z = (byte) 0;
                return false;
            }
        }
        if (k()) {
            this.f8023z = (byte) 1;
            return true;
        }
        this.f8023z = (byte) 0;
        return false;
    }

    public boolean s() {
        return (this.f8013p & 16) == 16;
    }

    public boolean t() {
        return (this.f8013p & 4) == 4;
    }

    public final void u() {
        this.f8014q = 6;
        this.f8015r = 0;
        this.f8016s = Collections.emptyList();
        q qVar = q.f7965m;
        this.f8017t = qVar;
        this.f8018u = 0;
        this.f8019v = qVar;
        this.f8020w = 0;
        this.f8021x = Collections.emptyList();
        this.f8022y = Collections.emptyList();
    }

    public r(h.c cVar, kotlin.reflect.w.internal.y0.g.a aVar) {
        super(cVar);
        this.f8023z = (byte) -1;
        this.A = -1;
        this.f8012o = cVar.f8259f;
    }
}
