// File: /workspace/github_cpp_makefile_star2_O3/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 0xa6c0
movl $0x8802, %ecx           # imm = 0x8802
btl %eax, %ecx
jae 0xa6c0
movl %edx, %r15d
movq 0x10(%r14), %rdi
callq 0x5f6f
testb %al, %al
je 0xa6bc
testb %r15b, %r15b
jne 0xa819
movl 0x4(%r14), %r15d
movq 0x10(%r14), %r12
leaq -0x540(%rbp), %r13
movq %r14, %rdi
movq %r13, %rsi
callq 0x7f5c
leaq 0xb78b(%rip), %rsi      # 0x15e2f
movq %rbx, %rdi
movl %r15d, %edx
movq %r12, %rcx
movq %r13, %r8
xorl %eax, %eax
callq 0x3270
jmp 0xa819
movl 0x20(%r14), %eax
decl %eax
cmpl $0x11, %eax
ja 0xa819
leaq 0x398a(%rip), %rcx      # 0xe05c
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 0x7f5c
movl 0x4(%r14), %r12d
movq 0x10(%r14), %rax
movq %rax, -0x40(%rbp)
movq %r14, %rdi
movq %r15, %rsi
callq 0x7f5c
movl 0x4(%r14), %eax
movq %rax, -0x38(%rbp)
movq 0x10(%r14), %rax
movq %rax, -0x30(%rbp)
movq %r14, %rdi
movq %r15, %rsi
callq 0x7f5c
leaq 0xb82a(%rip), %rsi      # 0x15f54
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 0xa819
movq %rbx, %rdi
movq %r14, %rsi
addq $0x518, %rsp            # imm = 0x518
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xa186
movl 0x4(%r14), %ecx
movq 0x10(%r14), %r8
leaq 0xb6ce(%rip), %rsi      # 0x15e51
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 0x7f5c
movl 0x4(%r14), %r13d
movq %r14, %rdi
movq %r12, %rsi
callq 0x7f5c
leaq 0xb6b6(%rip), %rsi      # 0x15e82
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 0xa819
movl 0x4(%r14), %r15d
leaq -0x540(%rbp), %r12
movq %r14, %rdi
movq %r12, %rsi
callq 0x7f5c
leaq 0xb859(%rip), %rsi      # 0x16062
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