// File: /workspace/github_cpp_makefile_star2_O1/zgimbutas[P]mwrap/src/mwrap-cgen.cc
// Function: mex_marshal_result(_IO_FILE*, Var*, bool)
void mex_marshal_result(FILE* fp, Var* v, bool return_flag)
{
    char namebuf[1280];
    if (is_obj(v->tinfo) && is_mxarray_type(v->basetype)) {
        if (!return_flag)
            fprintf(fp, "    plhs[%d] = mxWrapSet_%s(%s);\n",
                    v->output_label, v->basetype, vname(v,namebuf));
    } else if (is_obj(v->tinfo))
        fprintf(fp, "    plhs[%d] = mxWrapCreateP(out%d_, \"%s:%%p\");\n",
                v->output_label, v->output_label, v->basetype);
    else if (is_array(v->tinfo) ||
             v->tinfo == VT_rarray)
        mex_marshal_array(fp, v);
    else if (v->tinfo == VT_scalar ||
             v->tinfo == VT_r_scalar ||
             v->tinfo == VT_p_scalar)
        fprintf(fp,
		"#if MX_HAS_INTERLEAVED_COMPLEX\n"
                "    plhs[%d] = mxCreateDoubleMatrix(1, 1, mxREAL);\n"
                "    *mxGetDoubles(plhs[%d]) = %s;\n"
		"#else\n"
                "    plhs[%d] = mxCreateDoubleMatrix(1, 1, mxREAL);\n"
                "    *mxGetPr(plhs[%d]) = %s;\n"
		"#endif\n",
                v->output_label, v->output_label, vname(v, namebuf),
		v->output_label, v->output_label, vname(v, namebuf));
    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)
        fprintf(fp,
		"#if MX_HAS_INTERLEAVED_COMPLEX\n"
                "    plhs[%d] = mxCreateDoubleMatrix(1, 1, mxCOMPLEX);\n"
                "    *mxGetComplexDoubles(plhs[%d]) = %s;\n"
		"#else\n"
                "    plhs[%d] = mxCreateDoubleMatrix(1, 1, mxCOMPLEX);\n"
                "    *mxGetPr(plhs[%d]) = real_%s(%s);\n"
                "    *mxGetPi(plhs[%d]) = imag_%s(%s);\n"
		"#endif\n",
                v->output_label,
                v->output_label, vname(v, namebuf),
                v->output_label,
                v->output_label, v->basetype, vname(v, namebuf),
                v->output_label, v->basetype, vname(v, namebuf));
    else if (v->tinfo == VT_string)
        fprintf(fp, "    plhs[%d] = mxCreateString(%s);\n",
                v->output_label, vname(v, namebuf));
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x518, %rsp            # imm = 0x518
movq %rsi, %r14
movq %rdi, %rbx
movl 0x20(%rsi), %eax
cmpl $0xf, %eax
ja 0xa7e9
movl $0x8802, %ecx           # imm = 0x8802
btl %eax, %ecx
jae 0xa7e9
movl %edx, %r15d
movq 0x10(%r14), %rdi
callq 0x608e
testb %al, %al
je 0xa7e9
testb %r15b, %r15b
jne 0xa946
movl 0x4(%r14), %r15d
movq 0x10(%r14), %r12
leaq -0x540(%rbp), %r13
movq %r14, %rdi
movq %r13, %rsi
callq 0x7fe0
leaq 0xb67e(%rip), %rsi      # 0x15e4f
movq %rbx, %rdi
movl %r15d, %edx
movq %r12, %rcx
movq %r13, %r8
xorl %eax, %eax
callq 0x3270
jmp 0xa946
movl 0x20(%r14), %eax
decl %eax
cmpl $0x11, %eax
ja 0xa946
leaq 0x387d(%rip), %rcx      # 0xe07c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl 0x4(%r14), %r13d
leaq -0x540(%rbp), %r15
movq %r14, %rdi
movq %r15, %rsi
callq 0x7fe0
movl 0x4(%r14), %r12d
movq 0x10(%r14), %rax
movq %rax, -0x40(%rbp)
movq %r14, %rdi
movq %r15, %rsi
callq 0x7fe0
movl 0x4(%r14), %eax
movq %rax, -0x38(%rbp)
movq 0x10(%r14), %rax
movq %rax, -0x30(%rbp)
movq %r14, %rdi
movq %r15, %rsi
callq 0x7fe0
leaq 0xb71d(%rip), %rsi      # 0x15f74
movq %rbx, %rdi
movl %r13d, %edx
movl %r13d, %ecx
movq %r15, %r8
movl %r12d, %r9d
xorl %eax, %eax
pushq %r15
pushq -0x30(%rbp)
pushq -0x38(%rbp)
pushq %r15
pushq -0x40(%rbp)
pushq %r12
callq 0x3270
addq $0x30, %rsp
jmp 0xa946
movq %rbx, %rdi
movq %r14, %rsi
addq $0x518, %rsp            # imm = 0x518
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xa2b5
movl 0x4(%r14), %ecx
movq 0x10(%r14), %r8
leaq 0xb5c1(%rip), %rsi      # 0x15e71
movq %rbx, %rdi
movl %ecx, %edx
xorl %eax, %eax
addq $0x518, %rsp            # imm = 0x518
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3270
movl 0x4(%r14), %r15d
leaq -0x540(%rbp), %r12
movq %r14, %rdi
movq %r12, %rsi
callq 0x7fe0
movl 0x4(%r14), %r13d
movq %r14, %rdi
movq %r12, %rsi
callq 0x7fe0
leaq 0xb5a9(%rip), %rsi      # 0x15ea2
movq %rbx, %rdi
movl %r15d, %edx
movl %r15d, %ecx
movq %r12, %r8
movl %r13d, %r9d
xorl %eax, %eax
pushq %r12
pushq %r13
callq 0x3270
addq $0x10, %rsp
jmp 0xa946
movl 0x4(%r14), %r15d
leaq -0x540(%rbp), %r12
movq %r14, %rdi
movq %r12, %rsi
callq 0x7fe0
leaq 0xb74c(%rip), %rsi      # 0x16082
movq %rbx, %rdi
movl %r15d, %edx
movq %r12, %rcx
xorl %eax, %eax
callq 0x3270
addq $0x518, %rsp            # imm = 0x518
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq