// File: /workspace/github_cpp_makefile_star2_O2/zgimbutas[P]mwrap/src/mwrap-cgen.cc
// Function: mex_unpack_input_array(_IO_FILE*, Var*)
void mex_unpack_input_array(FILE* fp, Var* v)
{
    if (v->devicespec != 'g'){
    fprintf(fp, "    if (mxGetM(prhs[%d])*mxGetN(prhs[%d]) != 0) {\n",
            v->input_label, v->input_label);
    if (strcmp(v->basetype, "fcomplex") == 0)
      fprintf(fp,
	      "        if( mxGetClassID(prhs[%d]) != mxSINGLE_CLASS )\n"
	      "            mw_err_txt_ = \"Invalid array argument, mxSINGLE_CLASS expected\";\n"
	      "        if (mw_err_txt_) goto mw_err_label;\n"
	      "        in%d_ = mxWrapGetArray_single_%s(prhs[%d], &mw_err_txt_);\n"
	      "        if (mw_err_txt_)\n"
	      "            goto mw_err_label;\n",
	      v->input_label, v->input_label, v->basetype, v->input_label);
    else if (strcmp(v->basetype, "dcomplex") == 0)
      fprintf(fp,
	      "        if( mxGetClassID(prhs[%d]) != mxDOUBLE_CLASS )\n"
	      "            mw_err_txt_ = \"Invalid array argument, mxDOUBLE_CLASS expected\";\n"
	      "        if (mw_err_txt_) goto mw_err_label;\n"
	      "        in%d_ = mxWrapGetArray_%s(prhs[%d], &mw_err_txt_);\n"
	      "        if (mw_err_txt_)\n"
	      "            goto mw_err_label;\n",
	      v->input_label, v->input_label, v->basetype, v->input_label);
    else if (strcmp(v->basetype, "float") == 0)
      if (v->iospec == 'i')
        fprintf(fp,
		"        if( mxGetClassID(prhs[%d]) != mxSINGLE_CLASS )\n"
		"            mw_err_txt_ = \"Invalid array argument, mxSINGLE_CLASS expected\";\n"
		"        if (mw_err_txt_) goto mw_err_label;\n"
                "#if MX_HAS_INTERLEAVED_COMPLEX\n"
                "        in%d_ = mxGetSingles(prhs[%d]);\n"
                "#else\n"
                "        in%d_ = (float*) mxGetData(prhs[%d]);\n"
                "#endif\n",
                v->input_label, v->input_label, v->input_label, v->input_label, v->input_label);
      else
        fprintf(fp,
                "        in%d_ = mxWrapGetArray_single_%s(prhs[%d], &mw_err_txt_);\n"
                "        if (mw_err_txt_)\n"
                "            goto mw_err_label;\n",
                v->input_label, v->basetype, v->input_label);
    else if (strcmp(v->basetype, "double") == 0)
      if (v->iospec == 'i'){
		fprintf(fp,
		"        if( mxGetClassID(prhs[%d]) != mxDOUBLE_CLASS )\n"
		"            mw_err_txt_ = \"Invalid array argument, mxDOUBLE_CLASS expected\";\n"
		"        if (mw_err_txt_) goto mw_err_label;\n"
		"#if MX_HAS_INTERLEAVED_COMPLEX\n"
		"        in%d_ = mxGetDoubles(prhs[%d]);\n"
		"#else\n"
		"        in%d_ = mxGetPr(prhs[%d]);\n"
		"#endif\n",
		v->input_label, v->input_label, v->input_label, v->input_label, v->input_label);
      }
      else
		fprintf(fp,
		"        in%d_ = mxWrapGetArray_%s(prhs[%d], &mw_err_txt_);\n"
		"        if (mw_err_txt_)\n"
		"            goto mw_err_label;\n",
		v->input_label, v->basetype, v->input_label);
    else
      fprintf(fp,
	      "        in%d_ = mxWrapGetArray_%s(prhs[%d], &mw_err_txt_);\n"
	      "        if (mw_err_txt_)\n"
	      "            goto mw_err_label;\n",
	      v->input_label, v->basetype, v->input_label);
    fprintf(fp,
            "    } else\n"
            "        in%d_ = NULL;\n",
            v->input_label);
    fprintf(fp, "\n");
    }

    if (v->devicespec == 'g'){
      if (v->iospec == 'i' || v->iospec == 'b'){
        fprintf(fp,
        "    // extract input GPU array pointer\n"
        "    if(!(mxIsGPUArray(prhs[%d])))\n"
        "        mw_err_txt_ = \"Invalid array argument, gpuArray expected\";\n"
        "    if (mw_err_txt_) goto mw_err_label;\n"
        "    mxGPUArray_in%d_ = mxGPUCreateFromMxArray(prhs[%d]);\n"
        "    in%d_ = (%s *)mxGPUGetDataReadOnly(mxGPUArray_in%d_);\n\n",
        v->input_label, v->input_label, v->input_label, v->input_label, basetype_to_cucomplex(v->basetype), v->input_label);
        }
    }

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x18, %rsp
movq %rsi, %r14
movq %rdi, %rbx
cmpb $0x67, 0x9(%rsi)
je 0x8c52
movl (%r14), %ecx
leaq 0xaf38(%rip), %rsi      # 0x13a7b
movq %rbx, %rdi
movl %ecx, %edx
xorl %eax, %eax
callq 0x32b0
movq 0x10(%r14), %r15
leaq 0x38dc(%rip), %rsi      # 0xc436
movq %r15, %rdi
callq 0x32a0
testl %eax, %eax
je 0x8ba4
leaq 0x38c0(%rip), %rsi      # 0xc42d
movq %r15, %rdi
callq 0x32a0
testl %eax, %eax
je 0x8bb0
leaq 0x3f07(%rip), %rsi      # 0xca87
movq %r15, %rdi
callq 0x32a0
testl %eax, %eax
je 0x8bce
leaq 0x3eed(%rip), %rsi      # 0xca80
movq %r15, %rdi
callq 0x32a0
testl %eax, %eax
je 0x8be4
movl (%r14), %edx
jmp 0x8c0c
movl (%r14), %ecx
leaq 0xaf00(%rip), %rsi      # 0x13aae
jmp 0x8bba
movl (%r14), %ecx
leaq 0xb01f(%rip), %rsi      # 0x13bd9
movq %rbx, %rdi
movl %ecx, %edx
movq %r15, %r8
movl %ecx, %r9d
xorl %eax, %eax
callq 0x32b0
jmp 0x8c2c
cmpb $0x69, 0x8(%r14)
movl (%r14), %edx
jne 0x8c15
movl %edx, (%rsp)
leaq 0xb11b(%rip), %rsi      # 0x13cfd
jmp 0x8bf8
cmpb $0x69, 0x8(%r14)
movl (%r14), %edx
jne 0x8c0c
movl %edx, (%rsp)
leaq 0xb238(%rip), %rsi      # 0x13e30
movq %rbx, %rdi
movl %edx, %ecx
movl %edx, %r8d
movl %edx, %r9d
xorl %eax, %eax
callq 0x32b0
jmp 0x8c2c
leaq 0xb076(%rip), %rsi      # 0x13c89
jmp 0x8c1c
leaq 0xaf42(%rip), %rsi      # 0x13b5e
movq %rbx, %rdi
movq %r15, %rcx
movl %edx, %r8d
xorl %eax, %eax
callq 0x32b0
movl (%r14), %edx
leaq 0xb322(%rip), %rsi      # 0x13f58
movq %rbx, %rdi
xorl %eax, %eax
callq 0x32b0
pushq $0xa
popq %rdi
movq %rbx, %rsi
callq 0x3250
cmpb $0x67, 0x9(%r14)
jne 0x8c93
movzbl 0x8(%r14), %eax
cmpl $0x69, %eax
je 0x8c61
cmpl $0x62, %eax
jne 0x8c93
movl (%r14), %r15d
movq 0x10(%r14), %rdi
callq 0x7500
movl %r15d, 0x8(%rsp)
movq %rax, (%rsp)
leaq 0xb2fd(%rip), %rsi      # 0x13f7a
movq %rbx, %rdi
movl %r15d, %edx
movl %r15d, %ecx
movl %r15d, %r8d
movl %r15d, %r9d
xorl %eax, %eax
callq 0x32b0
addq $0x18, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq