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

import java.io.IOException;
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.m;
import kotlin.reflect.w.internal.y0.i.n;
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 p extends h implements q {

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public static final p f7957f;

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

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

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

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

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

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

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

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

        /* JADX INFO: renamed from: n, reason: collision with root package name */
        public n f7964n = m.f8279f;

        @Override // r.i0.w.b.y0.i.p.a
        public kotlin.reflect.w.internal.y0.i.p a() {
            p pVarM = m();
            if (pVarM.i()) {
                return pVarM;
            }
            throw new v();
        }

        @Override // r.i0.w.b.y0.i.h.b
        public Object clone() {
            b bVar = new b();
            bVar.n(m());
            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 {
            o(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 {
            o(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.n(m());
            return bVar;
        }

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

        public p m() {
            p pVar = new p(this, null);
            if ((this.f7963m & 1) == 1) {
                this.f7964n = this.f7964n.o();
                this.f7963m &= -2;
            }
            pVar.f7960o = this.f7964n;
            return pVar;
        }

        public b n(p pVar) {
            if (pVar == p.f7957f) {
                return this;
            }
            if (!pVar.f7960o.isEmpty()) {
                if (this.f7964n.isEmpty()) {
                    this.f7964n = pVar.f7960o;
                    this.f7963m &= -2;
                } else {
                    if ((this.f7963m & 1) != 1) {
                        this.f7964n = new m(this.f7964n);
                        this.f7963m |= 1;
                    }
                    this.f7964n.addAll(pVar.f7960o);
                }
            }
            this.f8259f = this.f8259f.b(pVar.f7959n);
            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.p.b o(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.p> r1 = kotlin.reflect.w.internal.y0.g.p.f7958m     // 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.p r3 = (kotlin.reflect.w.internal.y0.g.p) r3     // Catch: java.lang.Throwable -> Lf kotlin.reflect.w.internal.y0.i.j -> L11
                if (r3 == 0) goto Le
                r2.n(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.p r4 = (kotlin.reflect.w.internal.y0.g.p) 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.n(r0)
            L1e:
                throw r3
            */
            throw new UnsupportedOperationException("Method not decompiled: r.i0.w.b.y0.g.p.b.o(r.i0.w.b.y0.i.d, r.i0.w.b.y0.i.f):r.i0.w.b.y0.g.p$b");
        }
    }

    static {
        p pVar = new p();
        f7957f = pVar;
        pVar.f7960o = m.f8279f;
    }

    public p() {
        this.f7961p = (byte) -1;
        this.f7962q = -1;
        this.f7959n = c.f8234f;
    }

    public p(d dVar, f fVar, kotlin.reflect.w.internal.y0.g.a aVar) {
        this.f7961p = (byte) -1;
        this.f7962q = -1;
        this.f7960o = m.f8279f;
        c.b bVarN = c.n();
        e eVarK = e.k(bVarN, 1);
        boolean z2 = false;
        boolean z3 = false;
        while (!z2) {
            try {
                try {
                    try {
                        int iO = dVar.o();
                        if (iO != 0) {
                            if (iO == 10) {
                                c cVarF = dVar.f();
                                if (!(z3 & true)) {
                                    this.f7960o = new m();
                                    z3 |= true;
                                }
                                this.f7960o.q(cVarF);
                            } else if (!dVar.r(iO, eVarK)) {
                            }
                        }
                        z2 = true;
                    } catch (IOException e2) {
                        j jVar = new j(e2.getMessage());
                        jVar.f8275f = this;
                        throw jVar;
                    }
                } catch (j e3) {
                    e3.f8275f = this;
                    throw e3;
                }
            } catch (Throwable th) {
                if (z3 & true) {
                    this.f7960o = this.f7960o.o();
                }
                try {
                    eVarK.j();
                } catch (IOException unused) {
                } catch (Throwable th2) {
                    this.f7959n = bVarN.d();
                    throw th2;
                }
                this.f7959n = bVarN.d();
                throw th;
            }
        }
        if (z3 & true) {
            this.f7960o = this.f7960o.o();
        }
        try {
            eVarK.j();
        } catch (IOException unused2) {
        } catch (Throwable th3) {
            this.f7959n = bVarN.d();
            throw th3;
        }
        this.f7959n = bVarN.d();
    }

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

    @Override // kotlin.reflect.w.internal.y0.i.p
    public void d(e eVar) throws IOException {
        f();
        for (int i2 = 0; i2 < this.f7960o.size(); i2++) {
            c cVarL = this.f7960o.l(i2);
            eVar.y(10);
            eVar.m(cVarL);
        }
        eVar.u(this.f7959n);
    }

    @Override // kotlin.reflect.w.internal.y0.i.p
    public int f() {
        int i2 = this.f7962q;
        if (i2 != -1) {
            return i2;
        }
        int iA = 0;
        for (int i3 = 0; i3 < this.f7960o.size(); i3++) {
            iA += e.a(this.f7960o.l(i3));
        }
        int size = this.f7959n.size() + (this.f7960o.size() * 1) + 0 + iA;
        this.f7962q = 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.f7961p;
        if (b2 == 1) {
            return true;
        }
        if (b2 == 0) {
            return false;
        }
        this.f7961p = (byte) 1;
        return true;
    }

    public p(h.b bVar, kotlin.reflect.w.internal.y0.g.a aVar) {
        super(bVar);
        this.f7961p = (byte) -1;
        this.f7962q = -1;
        this.f7959n = bVar.f8259f;
    }
}
