package kotlin.reflect.jvm.internal.calls;

import androidx.media3.container.NalUnitUtil;
import androidx.media3.extractor.text.ttml.TtmlNode;
import defpackage.ck1;
import defpackage.cp4;
import defpackage.cr4;
import defpackage.dp4;
import defpackage.kp6;
import defpackage.n89;
import defpackage.pq6;
import defpackage.q07;
import defpackage.sq3;
import defpackage.st;
import defpackage.to4;
import defpackage.vx8;
import defpackage.y41;
import defpackage.za5;
import defpackage.zr7;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Member;
import java.lang.reflect.Method;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import kotlin.Metadata;
import kotlin.reflect.jvm.internal.KDeclarationContainerImpl;
import kotlin.reflect.jvm.internal.UtilKt;
import kotlin.reflect.jvm.internal.calls.Caller;
import kotlin.reflect.jvm.internal.calls.CallerImpl;
import kotlin.reflect.jvm.internal.impl.builtins.KotlinBuiltIns;
import kotlin.reflect.jvm.internal.impl.descriptors.CallableMemberDescriptor;
import kotlin.reflect.jvm.internal.impl.descriptors.ClassDescriptor;
import kotlin.reflect.jvm.internal.impl.descriptors.ClassifierDescriptor;
import kotlin.reflect.jvm.internal.impl.descriptors.ConstructorDescriptor;
import kotlin.reflect.jvm.internal.impl.descriptors.DeclarationDescriptor;
import kotlin.reflect.jvm.internal.impl.descriptors.FunctionDescriptor;
import kotlin.reflect.jvm.internal.impl.descriptors.ParameterDescriptor;
import kotlin.reflect.jvm.internal.impl.descriptors.ReceiverParameterDescriptor;
import kotlin.reflect.jvm.internal.impl.descriptors.ValueParameterDescriptor;
import kotlin.reflect.jvm.internal.impl.descriptors.runtime.structure.ReflectClassUtilKt;
import kotlin.reflect.jvm.internal.impl.resolve.InlineClassesUtilsKt;
import kotlin.reflect.jvm.internal.impl.types.KotlinType;
import kotlin.reflect.jvm.internal.impl.types.TypeSubstitutionKt;

/* JADX INFO: loaded from: classes3.dex */
@Metadata(d1 = {"\u0000R\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u000b\n\u0002\b\u0003\n\u0002\u0010\b\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u0011\n\u0000\n\u0002\u0010\u0000\n\u0002\b\t\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0010 \n\u0002\b\b\b\u0000\u0018\u0000*\f\b\u0000\u0010\u0002 \u0001*\u0004\u0018\u00010\u00012\b\u0012\u0004\u0012\u00028\u00000\u0003:\u0002,-B%\u0012\u0006\u0010\u0005\u001a\u00020\u0004\u0012\f\u0010\u0006\u001a\b\u0012\u0004\u0012\u00028\u00000\u0003\u0012\u0006\u0010\b\u001a\u00020\u0007¢\u0006\u0004\b\t\u0010\nJ\u0015\u0010\u000e\u001a\u00020\r2\u0006\u0010\f\u001a\u00020\u000b¢\u0006\u0004\b\u000e\u0010\u000fJ\u001d\u0010\u0013\u001a\u0004\u0018\u00010\u00122\n\u0010\u0011\u001a\u0006\u0012\u0002\b\u00030\u0010H\u0016¢\u0006\u0004\b\u0013\u0010\u0014R\u0014\u0010\b\u001a\u00020\u00078\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b\b\u0010\u0015R\u001a\u0010\u0016\u001a\b\u0012\u0004\u0012\u00028\u00000\u00038\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b\u0016\u0010\u0017R\u001a\u0010\u0018\u001a\u00028\u00008\u0016X\u0096\u0004¢\u0006\f\n\u0004\b\u0018\u0010\u0019\u001a\u0004\b\u001a\u0010\u001bR\u0014\u0010\u001d\u001a\u00020\u001c8\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b\u001d\u0010\u001eR\u001a\u0010\u001f\u001a\b\u0012\u0004\u0012\u00020\r0\u00108\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b\u001f\u0010 R\u0014\u0010!\u001a\u00020\u00078\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b!\u0010\u0015R\u0014\u0010%\u001a\u00020\"8VX\u0096\u0004¢\u0006\u0006\u001a\u0004\b#\u0010$R\u001a\u0010)\u001a\b\u0012\u0004\u0012\u00020\"0&8VX\u0096\u0004¢\u0006\u0006\u001a\u0004\b'\u0010(R\u0014\u0010*\u001a\u00020\u00078VX\u0096\u0004¢\u0006\u0006\u001a\u0004\b*\u0010+¨\u0006."}, d2 = {"Lkotlin/reflect/jvm/internal/calls/ValueClassAwareCaller;", "Ljava/lang/reflect/Member;", "M", "Lkotlin/reflect/jvm/internal/calls/Caller;", "Lkotlin/reflect/jvm/internal/impl/descriptors/CallableMemberDescriptor;", "descriptor", "oldCaller", "", "isDefault", "<init>", "(Lorg/jetbrains/kotlin/descriptors/CallableMemberDescriptor;Lkotlin/reflect/jvm/internal/calls/Caller;Z)V", "", "index", "Ldp4;", "getRealSlicesOfParameters", "(I)Ldp4;", "", "args", "", "call", "([Ljava/lang/Object;)Ljava/lang/Object;", "Z", "caller", "Lkotlin/reflect/jvm/internal/calls/Caller;", "member", "Ljava/lang/reflect/Member;", "getMember", "()Ljava/lang/reflect/Member;", "Lkotlin/reflect/jvm/internal/calls/ValueClassAwareCaller$BoxUnboxData;", "data", "Lkotlin/reflect/jvm/internal/calls/ValueClassAwareCaller$BoxUnboxData;", "slices", "[Ldp4;", "hasMfvcParameters", "Ljava/lang/reflect/Type;", "getReturnType", "()Ljava/lang/reflect/Type;", "returnType", "", "getParameterTypes", "()Ljava/util/List;", "parameterTypes", "isBoundInstanceCallWithValueClasses", "()Z", "BoxUnboxData", "MultiFieldValueClassPrimaryConstructorCaller", "kotlin-reflection"}, k = 1, mv = {2, 1, 0}, xi = NalUnitUtil.H265_NAL_UNIT_TYPE_UNSPECIFIED)
@vx8
public final class ValueClassAwareCaller<M extends Member> implements Caller<M> {

    @kp6
    private final Caller<M> caller;

    @kp6
    private final BoxUnboxData data;
    private final boolean hasMfvcParameters;
    private final boolean isDefault;
    private final M member;

    @kp6
    private final dp4[] slices;

    @Metadata(d1 = {"\u0000\u001e\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u0011\n\u0002\u0010 \n\u0002\u0018\u0002\n\u0002\b\u000e\b\u0002\u0018\u00002\u00020\u0001B/\u0012\u0006\u0010\u0003\u001a\u00020\u0002\u0012\u0014\u0010\u0007\u001a\u0010\u0012\f\u0012\n\u0012\u0004\u0012\u00020\u0006\u0018\u00010\u00050\u0004\u0012\b\u0010\b\u001a\u0004\u0018\u00010\u0006¢\u0006\u0004\b\t\u0010\nR\u0017\u0010\u0003\u001a\u00020\u00028\u0006¢\u0006\f\n\u0004\b\u0003\u0010\u000b\u001a\u0004\b\f\u0010\rR%\u0010\u0007\u001a\u0010\u0012\f\u0012\n\u0012\u0004\u0012\u00020\u0006\u0018\u00010\u00050\u00048\u0006¢\u0006\f\n\u0004\b\u0007\u0010\u000e\u001a\u0004\b\u000f\u0010\u0010R\u0019\u0010\b\u001a\u0004\u0018\u00010\u00068\u0006¢\u0006\f\n\u0004\b\b\u0010\u0011\u001a\u0004\b\u0012\u0010\u0013¨\u0006\u0014"}, d2 = {"Lkotlin/reflect/jvm/internal/calls/ValueClassAwareCaller$BoxUnboxData;", "", "Ldp4;", "argumentRange", "", "", "Ljava/lang/reflect/Method;", "unboxParameters", "box", "<init>", "(Ldp4;[Ljava/util/List;Ljava/lang/reflect/Method;)V", "Ldp4;", "getArgumentRange", "()Ldp4;", "[Ljava/util/List;", "getUnboxParameters", "()[Ljava/util/List;", "Ljava/lang/reflect/Method;", "getBox", "()Ljava/lang/reflect/Method;", "kotlin-reflection"}, k = 1, mv = {2, 1, 0}, xi = NalUnitUtil.H265_NAL_UNIT_TYPE_UNSPECIFIED)
    public static final class BoxUnboxData {

        @kp6
        private final dp4 argumentRange;

        @pq6
        private final Method box;

        @kp6
        private final List<Method>[] unboxParameters;

        public BoxUnboxData(@kp6 dp4 dp4Var, @kp6 List<Method>[] listArr, @pq6 Method method) {
            cr4.g(dp4Var, "argumentRange");
            cr4.g(listArr, "unboxParameters");
            this.argumentRange = dp4Var;
            this.unboxParameters = listArr;
            this.box = method;
        }

        @kp6
        public final dp4 getArgumentRange() {
            return this.argumentRange;
        }

        @pq6
        public final Method getBox() {
            return this.box;
        }

        @kp6
        public final List<Method>[] getUnboxParameters() {
            return this.unboxParameters;
        }
    }

    @Metadata(d1 = {"\u0000R\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0010\u0001\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000e\n\u0000\n\u0002\u0010 \n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0006\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0010\u0000\n\u0000\n\u0002\u0010\u0011\n\u0002\b\u0002\u0018\u00002\n\u0012\u0006\u0012\u0004\u0018\u00010\u00020\u0001B-\u0012\u0006\u0010\u0003\u001a\u00020\u0004\u0012\u0006\u0010\u0005\u001a\u00020\u0006\u0012\u0006\u0010\u0007\u001a\u00020\b\u0012\f\u0010\t\u001a\b\u0012\u0004\u0012\u00020\u000b0\n¢\u0006\u0004\b\f\u0010\rJ\u001b\u0010\u001f\u001a\u0004\u0018\u00010 2\n\u0010!\u001a\u0006\u0012\u0002\b\u00030\"H\u0016¢\u0006\u0002\u0010#R\u000e\u0010\u000e\u001a\u00020\u000fX\u0082\u0004¢\u0006\u0002\n\u0000R\u000e\u0010\u0010\u001a\u00020\u000fX\u0082\u0004¢\u0006\u0002\n\u0000R\u001c\u0010\u0011\u001a\u0010\u0012\f\u0012\n\u0012\u0004\u0012\u00020\u000f\u0018\u00010\n0\nX\u0082\u0004¢\u0006\u0002\n\u0000R\u0016\u0010\u0012\u001a\u0004\u0018\u00010\u00028VX\u0096\u0004¢\u0006\u0006\u001a\u0004\b\u0013\u0010\u0014R\u0014\u0010\u0015\u001a\u00020\u00168VX\u0096\u0004¢\u0006\u0006\u001a\u0004\b\u0017\u0010\u0018R!\u0010\u0019\u001a\u0012\u0012\u000e\u0012\f\u0012\b\u0012\u0006\u0012\u0002\b\u00030\u001a0\n0\n¢\u0006\b\n\u0000\u001a\u0004\b\u001b\u0010\u001cR\u001a\u0010\u001d\u001a\b\u0012\u0004\u0012\u00020\u00160\nX\u0096\u0004¢\u0006\b\n\u0000\u001a\u0004\b\u001e\u0010\u001c¨\u0006$"}, d2 = {"Lkotlin/reflect/jvm/internal/calls/ValueClassAwareCaller$MultiFieldValueClassPrimaryConstructorCaller;", "Lkotlin/reflect/jvm/internal/calls/Caller;", "", "descriptor", "Lkotlin/reflect/jvm/internal/impl/descriptors/FunctionDescriptor;", TtmlNode.RUBY_CONTAINER, "Lkotlin/reflect/jvm/internal/KDeclarationContainerImpl;", "constructorDesc", "", "originalParameters", "", "Lkotlin/reflect/jvm/internal/impl/descriptors/ParameterDescriptor;", "<init>", "(Lorg/jetbrains/kotlin/descriptors/FunctionDescriptor;Lkotlin/reflect/jvm/internal/KDeclarationContainerImpl;Ljava/lang/String;Ljava/util/List;)V", "constructorImpl", "Ljava/lang/reflect/Method;", "boxMethod", "parameterUnboxMethods", "member", "getMember", "()Ljava/lang/Void;", "returnType", "Ljava/lang/reflect/Type;", "getReturnType", "()Ljava/lang/reflect/Type;", "originalParametersGroups", "Ljava/lang/Class;", "getOriginalParametersGroups", "()Ljava/util/List;", "parameterTypes", "getParameterTypes", "call", "", "args", "", "([Ljava/lang/Object;)Ljava/lang/Object;", "kotlin-reflection"}, k = 1, mv = {2, 1, 0}, xi = NalUnitUtil.H265_NAL_UNIT_TYPE_UNSPECIFIED)
    @vx8
    public static final class MultiFieldValueClassPrimaryConstructorCaller implements Caller {

        @kp6
        private final Method boxMethod;

        @kp6
        private final Method constructorImpl;

        @kp6
        private final List<List<Class<?>>> originalParametersGroups;

        @kp6
        private final List<Type> parameterTypes;

        @kp6
        private final List<List<Method>> parameterUnboxMethods;

        /* JADX WARN: Multi-variable type inference failed */
        /* JADX WARN: Type inference failed for: r0v17, types: [java.util.List] */
        /* JADX WARN: Type inference failed for: r0v18, types: [java.lang.Object] */
        /* JADX WARN: Type inference failed for: r0v19, types: [java.util.ArrayList] */
        public MultiFieldValueClassPrimaryConstructorCaller(@kp6 FunctionDescriptor functionDescriptor, @kp6 KDeclarationContainerImpl kDeclarationContainerImpl, @kp6 String str, @kp6 List<? extends ParameterDescriptor> list) {
            ?? Am;
            cr4.g(functionDescriptor, "descriptor");
            cr4.g(kDeclarationContainerImpl, TtmlNode.RUBY_CONTAINER);
            cr4.g(str, "constructorDesc");
            cr4.g(list, "originalParameters");
            Method methodFindMethodBySignature = kDeclarationContainerImpl.findMethodBySignature("constructor-impl", str);
            cr4.d(methodFindMethodBySignature);
            this.constructorImpl = methodFindMethodBySignature;
            Method methodFindMethodBySignature2 = kDeclarationContainerImpl.findMethodBySignature("box-impl", n89.aj(str, "V") + ReflectClassUtilKt.getDesc(kDeclarationContainerImpl.getA()));
            cr4.d(methodFindMethodBySignature2);
            this.boxMethod = methodFindMethodBySignature2;
            List<? extends ParameterDescriptor> list2 = list;
            ArrayList arrayList = new ArrayList(y41.p(list2, 10));
            Iterator it = list2.iterator();
            while (it.hasNext()) {
                KotlinType type = ((ParameterDescriptor) it.next()).getType();
                cr4.f(type, "getType(...)");
                arrayList.add(ValueClassAwareCallerKt.getValueClassUnboxMethods(TypeSubstitutionKt.asSimpleType(type), functionDescriptor));
            }
            this.parameterUnboxMethods = arrayList;
            ArrayList arrayList2 = new ArrayList(y41.p(list2, 10));
            int i = 0;
            for (Object obj : list2) {
                int i2 = i + 1;
                if (i < 0) {
                    y41.bm();
                    throw null;
                }
                ClassifierDescriptor classifierDescriptorMo170getDeclarationDescriptor = ((ParameterDescriptor) obj).getType().getConstructor().mo170getDeclarationDescriptor();
                cr4.e(classifierDescriptorMo170getDeclarationDescriptor, "null cannot be cast to non-null type org.jetbrains.kotlin.descriptors.ClassDescriptor");
                ClassDescriptor classDescriptor = (ClassDescriptor) classifierDescriptorMo170getDeclarationDescriptor;
                List<Method> list3 = this.parameterUnboxMethods.get(i);
                if (list3 != null) {
                    List<Method> list4 = list3;
                    Am = new ArrayList(y41.p(list4, 10));
                    Iterator it2 = list4.iterator();
                    while (it2.hasNext()) {
                        Am.add(((Method) it2.next()).getReturnType());
                    }
                } else {
                    Class<?> javaClass = UtilKt.toJavaClass(classDescriptor);
                    cr4.d(javaClass);
                    Am = y41.am(javaClass);
                }
                arrayList2.add(Am);
                i = i2;
            }
            this.originalParametersGroups = arrayList2;
            this.parameterTypes = y41.ac(arrayList2);
        }

        /* JADX WARN: Multi-variable type inference failed */
        /* JADX WARN: Type inference failed for: r6v1, types: [java.util.List] */
        /* JADX WARN: Type inference failed for: r6v2 */
        /* JADX WARN: Type inference failed for: r6v4, types: [java.util.ArrayList] */
        @Override // kotlin.reflect.jvm.internal.calls.Caller
        @pq6
        public Object call(@kp6 Object[] args) throws IllegalAccessException, InvocationTargetException {
            ?? Am;
            cr4.g(args, "args");
            List<List<Method>> list = this.parameterUnboxMethods;
            cr4.g(list, "other");
            int length = args.length;
            ArrayList<q07> arrayList = new ArrayList(Math.min(y41.p(list, 10), length));
            int i = 0;
            for (Object obj : list) {
                if (i >= length) {
                    break;
                }
                arrayList.add(new q07(args[i], obj));
                i++;
            }
            ArrayList arrayList2 = new ArrayList();
            for (q07 q07Var : arrayList) {
                Object obj2 = q07Var.a;
                List list2 = (List) q07Var.b;
                if (list2 != null) {
                    List list3 = list2;
                    Am = new ArrayList(y41.p(list3, 10));
                    Iterator it = list3.iterator();
                    while (it.hasNext()) {
                        Am.add(((Method) it.next()).invoke(obj2, null));
                    }
                } else {
                    Am = y41.am(obj2);
                }
                y41.i((Iterable) Am, arrayList2);
            }
            Object[] array = arrayList2.toArray(new Object[0]);
            this.constructorImpl.invoke(null, Arrays.copyOf(array, array.length));
            return this.boxMethod.invoke(null, Arrays.copyOf(array, array.length));
        }

        @pq6
        public Void getMember() {
            return null;
        }

        @kp6
        public final List<List<Class<?>>> getOriginalParametersGroups() {
            return this.originalParametersGroups;
        }

        @Override // kotlin.reflect.jvm.internal.calls.Caller
        @kp6
        public List<Type> getParameterTypes() {
            return this.parameterTypes;
        }

        @Override // kotlin.reflect.jvm.internal.calls.Caller
        @kp6
        public Type getReturnType() {
            Class<?> returnType = this.boxMethod.getReturnType();
            cr4.f(returnType, "getReturnType(...)");
            return returnType;
        }

        @Override // kotlin.reflect.jvm.internal.calls.Caller
        public boolean isBoundInstanceCallWithValueClasses() {
            return Caller.DefaultImpls.isBoundInstanceCallWithValueClasses(this);
        }

        @Override // kotlin.reflect.jvm.internal.calls.Caller
        /* JADX INFO: renamed from: getMember */
        public /* bridge */ /* synthetic */ Member mo162getMember() {
            return (Member) getMember();
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:27:0x0082 A[LOOP:1: B:25:0x007c->B:27:0x0082, LOOP_END] */
    /* JADX WARN: Removed duplicated region for block: B:57:0x010e  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public ValueClassAwareCaller(@kp6 CallableMemberDescriptor callableMemberDescriptor, @kp6 Caller<? extends M> caller, boolean z) {
        Class inlineClass;
        BoxUnboxData boxUnboxData;
        KotlinType kotlinTypeSubstitutedUnderlyingType;
        Iterator<T> it;
        cr4.g(callableMemberDescriptor, "descriptor");
        cr4.g(caller, "oldCaller");
        this.isDefault = z;
        boolean z2 = false;
        if (caller instanceof CallerImpl.Method.BoundStatic) {
            ReceiverParameterDescriptor extensionReceiverParameter = callableMemberDescriptor.getExtensionReceiverParameter();
            extensionReceiverParameter = extensionReceiverParameter == null ? callableMemberDescriptor.getDispatchReceiverParameter() : extensionReceiverParameter;
            KotlinType type = extensionReceiverParameter != null ? extensionReceiverParameter.getType() : null;
            if (type != null && InlineClassesUtilsKt.needsMfvcFlattening(type)) {
                if (z) {
                    List<ValueParameterDescriptor> valueParameters = callableMemberDescriptor.getValueParameters();
                    cr4.f(valueParameters, "getValueParameters(...)");
                    List<ValueParameterDescriptor> list = valueParameters;
                    if (!(list instanceof Collection) || !list.isEmpty()) {
                        Iterator<T> it2 = list.iterator();
                        while (it2.hasNext()) {
                            if (((ValueParameterDescriptor) it2.next()).declaresDefaultValue()) {
                                List<Method> mfvcUnboxMethods = ValueClassAwareCallerKt.getMfvcUnboxMethods(TypeSubstitutionKt.asSimpleType(type));
                                cr4.d(mfvcUnboxMethods);
                                List<Method> list2 = mfvcUnboxMethods;
                                ArrayList arrayList = new ArrayList(y41.p(list2, 10));
                                it = list2.iterator();
                                while (it.hasNext()) {
                                    arrayList.add(((Method) it.next()).invoke(((CallerImpl.Method.BoundStatic) caller).getBoundReceiver(), null));
                                }
                                caller = new CallerImpl.Method.BoundStaticMultiFieldValueClass(((CallerImpl.Method) caller).mo162getMember(), arrayList.toArray(new Object[0]));
                            }
                        }
                    }
                } else {
                    List<Method> mfvcUnboxMethods2 = ValueClassAwareCallerKt.getMfvcUnboxMethods(TypeSubstitutionKt.asSimpleType(type));
                    cr4.d(mfvcUnboxMethods2);
                    List<Method> list22 = mfvcUnboxMethods2;
                    ArrayList arrayList2 = new ArrayList(y41.p(list22, 10));
                    it = list22.iterator();
                    while (it.hasNext()) {
                    }
                    caller = new CallerImpl.Method.BoundStaticMultiFieldValueClass(((CallerImpl.Method) caller).mo162getMember(), arrayList2.toArray(new Object[0]));
                }
            }
        }
        this.caller = (Caller<M>) caller;
        this.member = (M) caller.mo162getMember();
        KotlinType returnType = callableMemberDescriptor.getReturnType();
        cr4.d(returnType);
        boolean z3 = callableMemberDescriptor instanceof FunctionDescriptor;
        Method boxMethod = ((z3 && ((FunctionDescriptor) callableMemberDescriptor).isSuspend() && (kotlinTypeSubstitutedUnderlyingType = InlineClassesUtilsKt.substitutedUnderlyingType(returnType)) != null && KotlinBuiltIns.isPrimitiveType(kotlinTypeSubstitutedUnderlyingType)) || (inlineClass = ValueClassAwareCallerKt.toInlineClass(returnType)) == null) ? null : ValueClassAwareCallerKt.getBoxMethod(inlineClass, callableMemberDescriptor);
        if (InlineClassesUtilsKt.isGetterOfUnderlyingPropertyOfValueClass(callableMemberDescriptor)) {
            boxUnboxData = new BoxUnboxData(dp4.d, new List[0], boxMethod);
        } else {
            int i = -1;
            if ((!(caller instanceof CallerImpl.Method.BoundStatic) || caller.getIsCallByToValueClassMangledMethod()) && !(caller instanceof CallerImpl.Method.BoundStaticMultiFieldValueClass)) {
                if (callableMemberDescriptor instanceof ConstructorDescriptor) {
                    if (!(caller instanceof BoundCaller)) {
                        i = 0;
                    }
                } else if (callableMemberDescriptor.getDispatchReceiverParameter() != null && !(caller instanceof BoundCaller)) {
                    DeclarationDescriptor containingDeclaration = callableMemberDescriptor.getContainingDeclaration();
                    cr4.f(containingDeclaration, "getContainingDeclaration(...)");
                    if (!InlineClassesUtilsKt.isValueClass(containingDeclaration)) {
                        i = 1;
                    }
                }
            }
            int i2 = caller instanceof CallerImpl.Method.BoundStaticMultiFieldValueClass ? -caller.getReceiverComponentsCount() : i;
            List listMakeKotlinParameterTypes = ValueClassAwareCallerKt.makeKotlinParameterTypes(callableMemberDescriptor, caller.mo162getMember(), new sq3() { // from class: kotlin.reflect.jvm.internal.calls.ValueClassAwareCaller$$Lambda$0
                @Override // defpackage.sq3
                public Object invoke(Object obj) {
                    return Boolean.valueOf(ValueClassAwareCaller.data$lambda$5$lambda$3((ClassDescriptor) obj));
                }
            });
            Iterator it3 = listMakeKotlinParameterTypes.iterator();
            int size = 0;
            while (it3.hasNext()) {
                List<Method> mfvcUnboxMethods3 = ValueClassAwareCallerKt.getMfvcUnboxMethods(TypeSubstitutionKt.asSimpleType((KotlinType) it3.next()));
                size += mfvcUnboxMethods3 != null ? mfvcUnboxMethods3.size() : 1;
            }
            int i3 = size + i2 + (this.isDefault ? ((size + 31) / 32) + 1 : 0) + ((z3 && ((FunctionDescriptor) callableMemberDescriptor).isSuspend()) ? 1 : 0);
            ValueClassAwareCallerKt.checkParametersSize(this, i3, callableMemberDescriptor, this.isDefault);
            dp4 dp4VarG = zr7.g(Math.max(i, 0), listMakeKotlinParameterTypes.size() + i);
            List[] listArr = new List[i3];
            int i4 = 0;
            while (i4 < i3) {
                listArr[i4] = (i4 > dp4VarG.b || dp4VarG.a > i4) ? null : ValueClassAwareCallerKt.getValueClassUnboxMethods(TypeSubstitutionKt.asSimpleType((KotlinType) listMakeKotlinParameterTypes.get(i4 - i)), callableMemberDescriptor);
                i4++;
            }
            boxUnboxData = new BoxUnboxData(dp4VarG, listArr, boxMethod);
        }
        this.data = boxUnboxData;
        za5 za5VarS = y41.s();
        Caller<M> caller2 = this.caller;
        int length = caller2 instanceof CallerImpl.Method.BoundStaticMultiFieldValueClass ? ((CallerImpl.Method.BoundStaticMultiFieldValueClass) caller2).getBoundReceiverComponents().length : caller2 instanceof CallerImpl.Method.BoundStatic ? 1 : 0;
        if (length > 0) {
            za5VarS.add(zr7.g(0, length));
        }
        List<Method>[] unboxParameters = boxUnboxData.getUnboxParameters();
        int length2 = unboxParameters.length;
        int i5 = 0;
        while (i5 < length2) {
            List<Method> list3 = unboxParameters[i5];
            int size2 = (list3 != null ? list3.size() : 1) + length;
            za5VarS.add(zr7.g(length, size2));
            i5++;
            length = size2;
        }
        this.slices = (dp4[]) y41.n(za5VarS).toArray(new dp4[0]);
        Iterable argumentRange = this.data.getArgumentRange();
        if (!(argumentRange instanceof Collection) || !((Collection) argumentRange).isEmpty()) {
            Iterator<Integer> it4 = argumentRange.iterator();
            while (true) {
                if (!((cp4) it4).c) {
                    break;
                }
                List<Method> list4 = this.data.getUnboxParameters()[((to4) it4).nextInt()];
                if (list4 != null && list4.size() > 1) {
                    z2 = true;
                    break;
                }
            }
        }
        this.hasMfvcParameters = z2;
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static final boolean data$lambda$5$lambda$3(ClassDescriptor classDescriptor) {
        cr4.g(classDescriptor, "$this$makeKotlinParameterTypes");
        return InlineClassesUtilsKt.isValueClass(classDescriptor);
    }

    @Override // kotlin.reflect.jvm.internal.calls.Caller
    @pq6
    public Object call(@kp6 Object[] args) throws IllegalAccessException, InvocationTargetException {
        Object objInvoke;
        Object objDefaultPrimitiveValue;
        Object objDefaultPrimitiveValue2;
        cr4.g(args, "args");
        dp4 argumentRange = this.data.getArgumentRange();
        List<Method>[] unboxParameters = this.data.getUnboxParameters();
        Method box = this.data.getBox();
        boolean zIsEmpty = argumentRange.isEmpty();
        int i = argumentRange.b;
        int i2 = argumentRange.a;
        if (!zIsEmpty) {
            if (this.hasMfvcParameters) {
                za5 za5Var = new za5(args.length);
                for (int i3 = 0; i3 < i2; i3++) {
                    za5Var.add(args[i3]);
                }
                if (i2 <= i) {
                    while (true) {
                        List<Method> list = unboxParameters[i2];
                        Object obj = args[i2];
                        if (list != null) {
                            for (Method method : list) {
                                if (obj != null) {
                                    objDefaultPrimitiveValue2 = method.invoke(obj, null);
                                } else {
                                    Class<?> returnType = method.getReturnType();
                                    cr4.f(returnType, "getReturnType(...)");
                                    objDefaultPrimitiveValue2 = UtilKt.defaultPrimitiveValue(returnType);
                                }
                                za5Var.add(objDefaultPrimitiveValue2);
                            }
                        } else {
                            za5Var.add(obj);
                        }
                        if (i2 == i) {
                            break;
                        }
                        i2++;
                    }
                }
                int i4 = i + 1;
                int length = args.length - 1;
                if (i4 <= length) {
                    while (true) {
                        za5Var.add(args[i4]);
                        if (i4 == length) {
                            break;
                        }
                        i4++;
                    }
                }
                args = y41.n(za5Var).toArray(new Object[0]);
            } else {
                int length2 = args.length;
                Object[] objArr = new Object[length2];
                for (int i5 = 0; i5 < length2; i5++) {
                    if (i5 > i || i2 > i5) {
                        objDefaultPrimitiveValue = args[i5];
                    } else {
                        List<Method> list2 = unboxParameters[i5];
                        Method method2 = list2 != null ? (Method) y41.bd(list2) : null;
                        objDefaultPrimitiveValue = args[i5];
                        if (method2 != null) {
                            if (objDefaultPrimitiveValue != null) {
                                objDefaultPrimitiveValue = method2.invoke(objDefaultPrimitiveValue, null);
                            } else {
                                Class<?> returnType2 = method2.getReturnType();
                                cr4.f(returnType2, "getReturnType(...)");
                                objDefaultPrimitiveValue = UtilKt.defaultPrimitiveValue(returnType2);
                            }
                        }
                    }
                    objArr[i5] = objDefaultPrimitiveValue;
                }
                args = objArr;
            }
        }
        Object objCall = this.caller.call(args);
        return (objCall == ck1.a || box == null || (objInvoke = box.invoke(null, objCall)) == null) ? objCall : objInvoke;
    }

    @Override // kotlin.reflect.jvm.internal.calls.Caller
    /* JADX INFO: renamed from: getMember */
    public M mo162getMember() {
        return this.member;
    }

    @Override // kotlin.reflect.jvm.internal.calls.Caller
    @kp6
    public List<Type> getParameterTypes() {
        return this.caller.getParameterTypes();
    }

    @kp6
    public final dp4 getRealSlicesOfParameters(int index) {
        if (index >= 0) {
            dp4[] dp4VarArr = this.slices;
            if (index < dp4VarArr.length) {
                return dp4VarArr[index];
            }
        }
        dp4[] dp4VarArr2 = this.slices;
        if (dp4VarArr2.length == 0) {
            return new dp4(index, index, 1);
        }
        int length = ((dp4) st.ah(dp4VarArr2)).b + 1 + (index - dp4VarArr2.length);
        return new dp4(length, length, 1);
    }

    @Override // kotlin.reflect.jvm.internal.calls.Caller
    @kp6
    public Type getReturnType() {
        return this.caller.getReturnType();
    }

    @Override // kotlin.reflect.jvm.internal.calls.Caller
    public boolean isBoundInstanceCallWithValueClasses() {
        return this.caller instanceof CallerImpl.Method.BoundInstance;
    }
}
