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.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.i;
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.r;
import kotlin.reflect.w.internal.y0.i.v;

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

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

    /* JADX INFO: renamed from: n, reason: collision with root package name */
    public static r<s> f8035n = new a();

    /* JADX INFO: renamed from: o, reason: collision with root package name */
    public final kotlin.reflect.w.internal.y0.i.c f8036o;

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

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

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

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

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

    /* JADX INFO: renamed from: u, reason: collision with root package name */
    public List<q> f8042u;

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

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

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

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

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

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

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

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

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

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

        /* JADX INFO: renamed from: s, reason: collision with root package name */
        public c f8051s = c.INV;

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

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

        @Override // r.i0.w.b.y0.i.p.a
        public p a() {
            s sVarN = n();
            if (sVarN.i()) {
                return sVarN;
            }
            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((s) hVar);
            return this;
        }

        public s n() {
            s sVar = new s(this, null);
            int i2 = this.f8047o;
            int i3 = (i2 & 1) != 1 ? 0 : 1;
            sVar.f8038q = this.f8048p;
            if ((i2 & 2) == 2) {
                i3 |= 2;
            }
            sVar.f8039r = this.f8049q;
            if ((i2 & 4) == 4) {
                i3 |= 4;
            }
            sVar.f8040s = this.f8050r;
            if ((i2 & 8) == 8) {
                i3 |= 8;
            }
            sVar.f8041t = this.f8051s;
            if ((i2 & 16) == 16) {
                this.f8052t = Collections.unmodifiableList(this.f8052t);
                this.f8047o &= -17;
            }
            sVar.f8042u = this.f8052t;
            if ((this.f8047o & 32) == 32) {
                this.f8053u = Collections.unmodifiableList(this.f8053u);
                this.f8047o &= -33;
            }
            sVar.f8043v = this.f8053u;
            sVar.f8037p = i3;
            return sVar;
        }

        public b o(s sVar) {
            if (sVar == s.f8034m) {
                return this;
            }
            int i2 = sVar.f8037p;
            if ((i2 & 1) == 1) {
                int i3 = sVar.f8038q;
                this.f8047o |= 1;
                this.f8048p = i3;
            }
            if ((i2 & 2) == 2) {
                int i4 = sVar.f8039r;
                this.f8047o = 2 | this.f8047o;
                this.f8049q = i4;
            }
            if ((i2 & 4) == 4) {
                boolean z2 = sVar.f8040s;
                this.f8047o = 4 | this.f8047o;
                this.f8050r = z2;
            }
            if ((i2 & 8) == 8) {
                c cVar = sVar.f8041t;
                Objects.requireNonNull(cVar);
                this.f8047o = 8 | this.f8047o;
                this.f8051s = cVar;
            }
            if (!sVar.f8042u.isEmpty()) {
                if (this.f8052t.isEmpty()) {
                    this.f8052t = sVar.f8042u;
                    this.f8047o &= -17;
                } else {
                    if ((this.f8047o & 16) != 16) {
                        this.f8052t = new ArrayList(this.f8052t);
                        this.f8047o |= 16;
                    }
                    this.f8052t.addAll(sVar.f8042u);
                }
            }
            if (!sVar.f8043v.isEmpty()) {
                if (this.f8053u.isEmpty()) {
                    this.f8053u = sVar.f8043v;
                    this.f8047o &= -33;
                } else {
                    if ((this.f8047o & 32) != 32) {
                        this.f8053u = new ArrayList(this.f8053u);
                        this.f8047o |= 32;
                    }
                    this.f8053u.addAll(sVar.f8043v);
                }
            }
            m(sVar);
            this.f8259f = this.f8259f.b(sVar.f8036o);
            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.s.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.s> r1 = kotlin.reflect.w.internal.y0.g.s.f8035n     // 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.s r3 = (kotlin.reflect.w.internal.y0.g.s) 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.s r4 = (kotlin.reflect.w.internal.y0.g.s) 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.s.b.p(r.i0.w.b.y0.i.d, r.i0.w.b.y0.i.f):r.i0.w.b.y0.g.s$b");
        }
    }

    public enum c implements i.a {
        IN(0),
        OUT(1),
        INV(2);


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

        c(int i2) {
            this.f8058p = i2;
        }

        public static c b(int i2) {
            if (i2 == 0) {
                return IN;
            }
            if (i2 == 1) {
                return OUT;
            }
            if (i2 != 2) {
                return null;
            }
            return INV;
        }

        @Override // r.i0.w.b.y0.i.i.a
        public final int a() {
            return this.f8058p;
        }
    }

    static {
        s sVar = new s();
        f8034m = sVar;
        sVar.s();
    }

    public s() {
        this.f8044w = -1;
        this.f8045x = (byte) -1;
        this.f8046y = -1;
        this.f8036o = kotlin.reflect.w.internal.y0.i.c.f8234f;
    }

    public s(d dVar, f fVar, kotlin.reflect.w.internal.y0.g.a aVar) {
        List list;
        Object objH;
        this.f8044w = -1;
        this.f8045x = (byte) -1;
        this.f8046y = -1;
        s();
        c.b bVarN = kotlin.reflect.w.internal.y0.i.c.n();
        e eVarK = e.k(bVarN, 1);
        boolean z2 = false;
        int i2 = 0;
        while (!z2) {
            try {
                try {
                    try {
                        int iO = dVar.o();
                        if (iO != 0) {
                            if (iO == 8) {
                                this.f8037p |= 1;
                                this.f8038q = dVar.l();
                            } else if (iO == 16) {
                                this.f8037p |= 2;
                                this.f8039r = dVar.l();
                            } else if (iO == 24) {
                                this.f8037p |= 4;
                                this.f8040s = dVar.e();
                            } else if (iO != 32) {
                                if (iO == 42) {
                                    if ((i2 & 16) != 16) {
                                        this.f8042u = new ArrayList();
                                        i2 |= 16;
                                    }
                                    list = this.f8042u;
                                    objH = dVar.h(q.f7966n, fVar);
                                } else if (iO == 48) {
                                    if ((i2 & 32) != 32) {
                                        this.f8043v = new ArrayList();
                                        i2 |= 32;
                                    }
                                    list = this.f8043v;
                                    objH = Integer.valueOf(dVar.l());
                                } else if (iO == 50) {
                                    int iD = dVar.d(dVar.l());
                                    if ((i2 & 32) != 32 && dVar.b() > 0) {
                                        this.f8043v = new ArrayList();
                                        i2 |= 32;
                                    }
                                    while (dVar.b() > 0) {
                                        this.f8043v.add(Integer.valueOf(dVar.l()));
                                    }
                                    dVar.f8248i = iD;
                                    dVar.p();
                                } else if (!q(dVar, eVarK, fVar, iO)) {
                                }
                                list.add(objH);
                            } else {
                                int iL = dVar.l();
                                c cVarB = c.b(iL);
                                if (cVarB == null) {
                                    eVarK.y(iO);
                                    eVarK.y(iL);
                                } else {
                                    this.f8037p |= 8;
                                    this.f8041t = cVarB;
                                }
                            }
                        }
                        z2 = true;
                    } catch (j e2) {
                        e2.f8275f = this;
                        throw e2;
                    }
                } catch (IOException e3) {
                    j jVar = new j(e3.getMessage());
                    jVar.f8275f = this;
                    throw jVar;
                }
            } catch (Throwable th) {
                if ((i2 & 16) == 16) {
                    this.f8042u = Collections.unmodifiableList(this.f8042u);
                }
                if ((i2 & 32) == 32) {
                    this.f8043v = Collections.unmodifiableList(this.f8043v);
                }
                try {
                    eVarK.j();
                } catch (IOException unused) {
                } catch (Throwable th2) {
                    this.f8036o = bVarN.d();
                    throw th2;
                }
                this.f8036o = bVarN.d();
                this.f8262f.i();
                throw th;
            }
        }
        if ((i2 & 16) == 16) {
            this.f8042u = Collections.unmodifiableList(this.f8042u);
        }
        if ((i2 & 32) == 32) {
            this.f8043v = Collections.unmodifiableList(this.f8043v);
        }
        try {
            eVarK.j();
        } catch (IOException unused2) {
        } catch (Throwable th3) {
            this.f8036o = bVarN.d();
            throw th3;
        }
        this.f8036o = bVarN.d();
        this.f8262f.i();
    }

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

    @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.f8037p & 1) == 1) {
            eVar.p(1, this.f8038q);
        }
        if ((this.f8037p & 2) == 2) {
            eVar.p(2, this.f8039r);
        }
        if ((this.f8037p & 4) == 4) {
            boolean z2 = this.f8040s;
            eVar.y(24);
            eVar.t(z2 ? 1 : 0);
        }
        if ((this.f8037p & 8) == 8) {
            eVar.n(4, this.f8041t.f8058p);
        }
        for (int i2 = 0; i2 < this.f8042u.size(); i2++) {
            eVar.r(5, this.f8042u.get(i2));
        }
        if (this.f8043v.size() > 0) {
            eVar.y(50);
            eVar.y(this.f8044w);
        }
        for (int i3 = 0; i3 < this.f8043v.size(); i3++) {
            eVar.q(this.f8043v.get(i3).intValue());
        }
        aVarP.a(1000, eVar);
        eVar.u(this.f8036o);
    }

    @Override // kotlin.reflect.w.internal.y0.i.p
    public int f() {
        int i2 = this.f8046y;
        if (i2 != -1) {
            return i2;
        }
        int iC = (this.f8037p & 1) == 1 ? e.c(1, this.f8038q) + 0 : 0;
        if ((this.f8037p & 2) == 2) {
            iC += e.c(2, this.f8039r);
        }
        if ((this.f8037p & 4) == 4) {
            iC += e.i(3) + 1;
        }
        if ((this.f8037p & 8) == 8) {
            iC += e.b(4, this.f8041t.f8058p);
        }
        for (int i3 = 0; i3 < this.f8042u.size(); i3++) {
            iC += e.e(5, this.f8042u.get(i3));
        }
        int iD = 0;
        for (int i4 = 0; i4 < this.f8043v.size(); i4++) {
            iD += e.d(this.f8043v.get(i4).intValue());
        }
        int iD2 = iC + iD;
        if (!this.f8043v.isEmpty()) {
            iD2 = iD2 + 1 + e.d(iD);
        }
        this.f8044w = iD;
        int size = this.f8036o.size() + l() + iD2;
        this.f8046y = 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.f8045x;
        if (b2 == 1) {
            return true;
        }
        if (b2 == 0) {
            return false;
        }
        int i2 = this.f8037p;
        if (!((i2 & 1) == 1)) {
            this.f8045x = (byte) 0;
            return false;
        }
        if (!((i2 & 2) == 2)) {
            this.f8045x = (byte) 0;
            return false;
        }
        for (int i3 = 0; i3 < this.f8042u.size(); i3++) {
            if (!this.f8042u.get(i3).i()) {
                this.f8045x = (byte) 0;
                return false;
            }
        }
        if (k()) {
            this.f8045x = (byte) 1;
            return true;
        }
        this.f8045x = (byte) 0;
        return false;
    }

    public final void s() {
        this.f8038q = 0;
        this.f8039r = 0;
        this.f8040s = false;
        this.f8041t = c.INV;
        this.f8042u = Collections.emptyList();
        this.f8043v = Collections.emptyList();
    }

    public s(h.c cVar, kotlin.reflect.w.internal.y0.g.a aVar) {
        super(cVar);
        this.f8044w = -1;
        this.f8045x = (byte) -1;
        this.f8046y = -1;
        this.f8036o = cVar.f8259f;
    }
}
