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.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 g extends h.d<g> implements q {

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

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

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

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

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

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

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

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

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

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

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

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

        public g n() {
            g gVar = new g(this, null);
            int i2 = (this.f7807o & 1) != 1 ? 0 : 1;
            gVar.f7804q = this.f7808p;
            gVar.f7803p = i2;
            return gVar;
        }

        public b o(g gVar) {
            if (gVar == g.f7800m) {
                return this;
            }
            if ((gVar.f7803p & 1) == 1) {
                int i2 = gVar.f7804q;
                this.f7807o = 1 | this.f7807o;
                this.f7808p = i2;
            }
            m(gVar);
            this.f8259f = this.f8259f.b(gVar.f7802o);
            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.g.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.g> r1 = kotlin.reflect.w.internal.y0.g.g.f7801n     // 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.g r3 = (kotlin.reflect.w.internal.y0.g.g) 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.g r4 = (kotlin.reflect.w.internal.y0.g.g) 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.g.b.p(r.i0.w.b.y0.i.d, r.i0.w.b.y0.i.f):r.i0.w.b.y0.g.g$b");
        }
    }

    static {
        g gVar = new g();
        f7800m = gVar;
        gVar.f7804q = 0;
    }

    public g() {
        this.f7805r = (byte) -1;
        this.f7806s = -1;
        this.f7802o = c.f8234f;
    }

    public g(d dVar, f fVar, kotlin.reflect.w.internal.y0.g.a aVar) {
        this.f7805r = (byte) -1;
        this.f7806s = -1;
        boolean z2 = false;
        this.f7804q = 0;
        c.b bVarN = c.n();
        e eVarK = e.k(bVarN, 1);
        while (!z2) {
            try {
                try {
                    int iO = dVar.o();
                    if (iO != 0) {
                        if (iO == 8) {
                            this.f7803p |= 1;
                            this.f7804q = dVar.l();
                        } else if (!q(dVar, eVarK, fVar, iO)) {
                        }
                    }
                    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) {
                try {
                    eVarK.j();
                } catch (IOException unused) {
                } catch (Throwable th2) {
                    this.f7802o = bVarN.d();
                    throw th2;
                }
                this.f7802o = bVarN.d();
                this.f8262f.i();
                throw th;
            }
        }
        try {
            eVarK.j();
        } catch (IOException unused2) {
        } catch (Throwable th3) {
            this.f7802o = bVarN.d();
            throw th3;
        }
        this.f7802o = bVarN.d();
        this.f8262f.i();
    }

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

    @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.f7803p & 1) == 1) {
            eVar.p(1, this.f7804q);
        }
        aVarP.a(200, eVar);
        eVar.u(this.f7802o);
    }

    @Override // kotlin.reflect.w.internal.y0.i.p
    public int f() {
        int i2 = this.f7806s;
        if (i2 != -1) {
            return i2;
        }
        int size = this.f7802o.size() + l() + ((this.f7803p & 1) == 1 ? 0 + e.c(1, this.f7804q) : 0);
        this.f7806s = 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.f7805r;
        if (b2 == 1) {
            return true;
        }
        if (b2 == 0) {
            return false;
        }
        if (k()) {
            this.f7805r = (byte) 1;
            return true;
        }
        this.f7805r = (byte) 0;
        return false;
    }

    public g(h.c cVar, kotlin.reflect.w.internal.y0.g.a aVar) {
        super(cVar);
        this.f7805r = (byte) -1;
        this.f7806s = -1;
        this.f7802o = cVar.f8259f;
    }
}
