package com.google.crypto.tink.shaded.protobuf;

import com.google.crypto.tink.shaded.protobuf.e;
import java.util.Iterator;
import java.util.Map;

/* loaded from: classes3.dex */
final class s0 implements d1 {

    /* renamed from: a, reason: collision with root package name */
    private final o0 f14460a;

    /* renamed from: b, reason: collision with root package name */
    private final j1 f14461b;

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

    /* renamed from: d, reason: collision with root package name */
    private final q f14463d;

    private s0(j1 j1Var, q qVar, o0 o0Var) {
        this.f14461b = j1Var;
        this.f14462c = qVar.e(o0Var);
        this.f14463d = qVar;
        this.f14460a = o0Var;
    }

    private int k(j1 j1Var, Object obj) {
        return j1Var.i(j1Var.g(obj));
    }

    private void l(j1 j1Var, q qVar, Object obj, c1 c1Var, p pVar) {
        Object f10 = j1Var.f(obj);
        t d10 = qVar.d(obj);
        do {
            try {
                if (c1Var.w() == Integer.MAX_VALUE) {
                    return;
                }
            } finally {
                j1Var.o(obj, f10);
            }
        } while (n(c1Var, pVar, qVar, d10, j1Var, f10));
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public static s0 m(j1 j1Var, q qVar, o0 o0Var) {
        return new s0(j1Var, qVar, o0Var);
    }

    private boolean n(c1 c1Var, p pVar, q qVar, t tVar, j1 j1Var, Object obj) {
        int a10 = c1Var.a();
        if (a10 != p1.f14435a) {
            if (p1.b(a10) != 2) {
                return c1Var.C();
            }
            Object b10 = qVar.b(pVar, this.f14460a, p1.a(a10));
            if (b10 == null) {
                return j1Var.m(obj, c1Var);
            }
            qVar.h(c1Var, b10, pVar, tVar);
            return true;
        }
        Object obj2 = null;
        int i10 = 0;
        h hVar = null;
        while (c1Var.w() != Integer.MAX_VALUE) {
            int a11 = c1Var.a();
            if (a11 == p1.f14437c) {
                i10 = c1Var.l();
                obj2 = qVar.b(pVar, this.f14460a, i10);
            } else if (a11 == p1.f14438d) {
                if (obj2 != null) {
                    qVar.h(c1Var, obj2, pVar, tVar);
                } else {
                    hVar = c1Var.z();
                }
            } else if (!c1Var.C()) {
                break;
            }
        }
        if (c1Var.a() != p1.f14436b) {
            throw a0.a();
        }
        if (hVar != null) {
            if (obj2 != null) {
                qVar.i(hVar, obj2, pVar, tVar);
            } else {
                j1Var.d(obj, i10, hVar);
            }
        }
        return true;
    }

    private void o(j1 j1Var, Object obj, q1 q1Var) {
        j1Var.s(j1Var.g(obj), q1Var);
    }

    @Override // com.google.crypto.tink.shaded.protobuf.d1
    public void a(Object obj, Object obj2) {
        f1.F(this.f14461b, obj, obj2);
        if (this.f14462c) {
            f1.D(this.f14463d, obj, obj2);
        }
    }

    @Override // com.google.crypto.tink.shaded.protobuf.d1
    public void b(Object obj) {
        this.f14461b.j(obj);
        this.f14463d.f(obj);
    }

    @Override // com.google.crypto.tink.shaded.protobuf.d1
    public final boolean c(Object obj) {
        return this.f14463d.c(obj).e();
    }

    @Override // com.google.crypto.tink.shaded.protobuf.d1
    public boolean d(Object obj, Object obj2) {
        if (!this.f14461b.g(obj).equals(this.f14461b.g(obj2))) {
            return false;
        }
        if (this.f14462c) {
            return this.f14463d.c(obj).equals(this.f14463d.c(obj2));
        }
        return true;
    }

    @Override // com.google.crypto.tink.shaded.protobuf.d1
    public int e(Object obj) {
        int k10 = k(this.f14461b, obj) + 0;
        return this.f14462c ? k10 + this.f14463d.c(obj).b() : k10;
    }

    @Override // com.google.crypto.tink.shaded.protobuf.d1
    public Object f() {
        return this.f14460a.newBuilderForType().buildPartial();
    }

    @Override // com.google.crypto.tink.shaded.protobuf.d1
    public int g(Object obj) {
        int hashCode = this.f14461b.g(obj).hashCode();
        return this.f14462c ? (hashCode * 53) + this.f14463d.c(obj).hashCode() : hashCode;
    }

    @Override // com.google.crypto.tink.shaded.protobuf.d1
    public void h(Object obj, byte[] bArr, int i10, int i11, e.a aVar) {
        x xVar = (x) obj;
        if (xVar.unknownFields == k1.e()) {
            xVar.unknownFields = k1.l();
        }
        android.support.v4.media.session.b.a(obj);
        throw null;
    }

    @Override // com.google.crypto.tink.shaded.protobuf.d1
    public void i(Object obj, q1 q1Var) {
        Iterator f10 = this.f14463d.c(obj).f();
        if (f10.hasNext()) {
            android.support.v4.media.session.b.a(((Map.Entry) f10.next()).getKey());
            throw null;
        }
        o(this.f14461b, obj, q1Var);
    }

    @Override // com.google.crypto.tink.shaded.protobuf.d1
    public void j(Object obj, c1 c1Var, p pVar) {
        l(this.f14461b, this.f14463d, obj, c1Var, pVar);
    }
}
