// File: zgimbutas[P]mwrap/src/mwrap-cgen.cc
// Function: mex_unpack_inputs(_IO_FILE*, Var*)
void mex_unpack_inputs(FILE* fp, Var* v)
{
    if (!v)
        return;
    if (v->iospec == 'o') {
        mex_unpack_inputs(fp, v->next);
        return;
    }

    if (is_obj(v->tinfo))
        mex_cast_get_p(fp, v->basetype, v->input_label);
    else if (is_array(v->tinfo))
        mex_unpack_input_array(fp, v);
    else if (v->tinfo == VT_scalar ||
             v->tinfo == VT_r_scalar ||
             v->tinfo == VT_p_scalar)
      {
	if ( strcmp(v->basetype,"float") == 0 )
        fprintf(fp,
                "    if( mxGetClassID(prhs[%d]) != mxSINGLE_CLASS )\n"
		"        mw_err_txt_ = \"Invalid scalar argument, mxSINGLE_CLASS expected\";\n"
		"    if (mw_err_txt_) goto mw_err_label;\n"
                "    in%d_ = (%s) mxWrapGetScalar_single(prhs[%d], &mw_err_txt_);\n"
                "    if (mw_err_txt_)\n"
                "        goto mw_err_label;\n\n",
                v->input_label, v->input_label, v->basetype, v->input_label);
	else if ( strcmp(v->basetype,"char") == 0 )
        fprintf(fp,
                "    if( mxGetClassID(prhs[%d]) != mxCHAR_CLASS )\n"
		"        mw_err_txt_ = \"Invalid scalar argument, mxCHAR_CLASS expected\";\n"
		"    if (mw_err_txt_) goto mw_err_label;\n"
                "    in%d_ = (%s) mxWrapGetScalar_char(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
        fprintf(fp,
                "    if( mxGetClassID(prhs[%d]) != mxDOUBLE_CLASS )\n"
		"        mw_err_txt_ = \"Invalid scalar argument, mxDOUBLE_CLASS expected\";\n"
		"    if (mw_err_txt_) goto mw_err_label;\n"
                "    in%d_ = (%s) mxWrapGetScalar(prhs[%d], &mw_err_txt_);\n"
                "    if (mw_err_txt_)\n"
                "        goto mw_err_label;\n\n",
                v->input_label, v->input_label, v->basetype, v->input_label);
      }
    else if (v->tinfo == VT_cscalar   || v->tinfo == VT_zscalar   ||
             v->tinfo == VT_r_cscalar || v->tinfo == VT_r_zscalar ||
             v->tinfo == VT_p_cscalar || v->tinfo == VT_p_zscalar)
      {
	if ( strcmp(v->basetype,"fcomplex") == 0 )
	  {
	    fprintf(fp,
		    "    if( mxGetClassID(prhs[%d]) != mxSINGLE_CLASS )\n"
		    "        mw_err_txt_ = \"Invalid scalar argument, mxSINGLE_CLASS expected\";\n"
		    "    if (mw_err_txt_) goto mw_err_label;\n",
		    v->input_label);
	    fprintf(fp,
		    "    mxWrapGetScalar_single_%s(&in%d_, prhs[%d]);\n\n",
		    v->basetype, v->input_label, v->input_label);
	  }
	else
	  {
	    fprintf(fp,
		    "    if( mxGetClassID(prhs[%d]) != mxDOUBLE_CLASS )\n"
		    "        mw_err_txt_ = \"Invalid scalar argument, mxDOUBLE_CLASS expected\";\n"
		    "    if (mw_err_txt_) goto mw_err_label;\n",
		    v->input_label);
	    fprintf(fp,
		    "    mxWrapGetScalar_%s(&in%d_, prhs[%d]);\n\n",
		    v->basetype, v->input_label, v->input_label);
	  }
      }
    else if (v->tinfo == VT_string)
        mex_unpack_input_string(fp, v);
    else if (v->tinfo == VT_mx)
        fprintf(fp, "    in%d_ = prhs[%d];\n\n",
                v->input_label, v->input_label);

    mex_unpack_inputs(fp, v->next);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0xf56c
jmp 0xf7fe
movq -0x10(%rbp), %rax
movsbl 0x8(%rax), %eax
cmpl $0x6f, %eax
jne 0xf58f
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rsi
callq 0xf550
jmp 0xf7fe
movq -0x10(%rbp), %rax
movl 0x20(%rax), %edi
callq 0xcc90
testb $0x1, %al
jne 0xf5a1
jmp 0xf5bd
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rsi
movq -0x10(%rbp), %rax
movl (%rax), %edx
callq 0xe620
jmp 0xf7ed
movq -0x10(%rbp), %rax
movl 0x20(%rax), %edi
callq 0xcc60
testb $0x1, %al
jne 0xf5cf
jmp 0xf5e1
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0xf180
jmp 0xf7eb
movq -0x10(%rbp), %rax
cmpl $0x6, 0x20(%rax)
je 0xf603
movq -0x10(%rbp), %rax
cmpl $0x10, 0x20(%rax)
je 0xf603
movq -0x10(%rbp), %rax
cmpl $0xc, 0x20(%rax)
jne 0xf6c7
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
leaq 0x5511(%rip), %rsi      # 0x14b23
callq 0x3390
cmpl $0x0, %eax
jne 0xf64b
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movl (%rax), %edx
movq -0x10(%rbp), %rax
movl (%rax), %ecx
movq -0x10(%rbp), %rax
movq 0x10(%rax), %r8
movq -0x10(%rbp), %rax
movl (%rax), %r9d
leaq 0xca87(%rip), %rsi      # 0x1c0c9
movb $0x0, %al
callq 0x33a0
jmp 0xf6c2
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
leaq 0x54e2(%rip), %rsi      # 0x14b3c
callq 0x3390
cmpl $0x0, %eax
jne 0xf693
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movl (%rax), %edx
movq -0x10(%rbp), %rax
movl (%rax), %ecx
movq -0x10(%rbp), %rax
movq 0x10(%rax), %r8
movq -0x10(%rbp), %rax
movl (%rax), %r9d
leaq 0xcb57(%rip), %rsi      # 0x1c1e1
movb $0x0, %al
callq 0x33a0
jmp 0xf6c0
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movl (%rax), %edx
movq -0x10(%rbp), %rax
movl (%rax), %ecx
movq -0x10(%rbp), %rax
movq 0x10(%rax), %r8
movq -0x10(%rbp), %rax
movl (%rax), %r9d
leaq 0xcc39(%rip), %rsi      # 0x1c2f2
movb $0x0, %al
callq 0x33a0
jmp 0xf6c2
jmp 0xf7e9
movq -0x10(%rbp), %rax
cmpl $0x7, 0x20(%rax)
je 0xf707
movq -0x10(%rbp), %rax
cmpl $0x8, 0x20(%rax)
je 0xf707
movq -0x10(%rbp), %rax
cmpl $0x11, 0x20(%rax)
je 0xf707
movq -0x10(%rbp), %rax
cmpl $0x12, 0x20(%rax)
je 0xf707
movq -0x10(%rbp), %rax
cmpl $0xd, 0x20(%rax)
je 0xf707
movq -0x10(%rbp), %rax
cmpl $0xe, 0x20(%rax)
jne 0xf7a2
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
leaq 0x4d6f(%rip), %rsi      # 0x14485
callq 0x3390
cmpl $0x0, %eax
jne 0xf761
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movl (%rax), %edx
leaq 0xccd2(%rip), %rsi      # 0x1c403
movb $0x0, %al
callq 0x33a0
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdx
movq -0x10(%rbp), %rax
movl (%rax), %ecx
movq -0x10(%rbp), %rax
movl (%rax), %r8d
leaq 0xcd51(%rip), %rsi      # 0x1c4a9
movb $0x0, %al
callq 0x33a0
jmp 0xf7a0
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movl (%rax), %edx
leaq 0xcd6a(%rip), %rsi      # 0x1c4dc
movb $0x0, %al
callq 0x33a0
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdx
movq -0x10(%rbp), %rax
movl (%rax), %ecx
movq -0x10(%rbp), %rax
movl (%rax), %r8d
leaq 0xcde9(%rip), %rsi      # 0x1c582
movb $0x0, %al
callq 0x33a0
jmp 0xf7e7
movq -0x10(%rbp), %rax
cmpl $0x9, 0x20(%rax)
jne 0xf7bb
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0xf460
jmp 0xf7e5
movq -0x10(%rbp), %rax
cmpl $0xa, 0x20(%rax)
jne 0xf7e3
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movl (%rax), %edx
movq -0x10(%rbp), %rax
movl (%rax), %ecx
leaq 0xcdd2(%rip), %rsi      # 0x1c5ae
movb $0x0, %al
callq 0x33a0
jmp 0xf7e5
jmp 0xf7e7
jmp 0xf7e9
jmp 0xf7eb
jmp 0xf7ed
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rsi
callq 0xf550
addq $0x10, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)