// File: /workspace/github_cpp_makefile_star2_O2/zgimbutas[P]mwrap/src/mwrap-typecheck.cc
// Function: typecheck_args(Var*, int)
int typecheck_args(Var* v, int line)
{
    if (!v)
        return 0;

    int err = assign_tinfo(v, line);
    if (v->iospec == 'i')
        return err + typecheck_args(v->next, line);

    if (isdigit(v->name[0])) {
        fprintf(stderr, "Error (%d): ", line);
        fprintf(stderr, "Number %s cannot be output\n", v->name);
        ++err;
    }

    if ((v->tinfo == VT_obj || v->tinfo == VT_p_obj || v->tinfo == VT_r_obj) &&
        !is_mxarray_type(v->basetype)) {
        fprintf(stderr, "Error (%d): ", line);
        fprintf(stderr, "Object %s cannot be output\n", v->name);
        ++err;
    } else if ((v->tinfo == VT_array || 
                v->tinfo == VT_carray ||
                v->tinfo == VT_zarray ||
                v->tinfo == VT_rarray) && 
               v->iospec == 'o' && 
               !(v->qual && v->qual->args)) {
        fprintf(stderr, "Error (%d): ", line);
        fprintf(stderr, "Output array %s must have dims\n", v->name);
        ++err;
    } else if (v->tinfo == VT_rarray && v->iospec != 'o') {
        fprintf(stderr, "Error (%d): ", line);
        fprintf(stderr, "Array ref %s *must* be output\n", v->name);
        ++err;
    } else if (v->tinfo == VT_scalar) {
        fprintf(stderr, "Error (%d): ", line);
        fprintf(stderr, "Scalar %s cannot be output\n", v->name);
        ++err;
    } else if (v->tinfo == VT_const) {
        fprintf(stderr, "Error (%d): ", line);
        fprintf(stderr, "Constant %s cannot be output\n", v->name);
        ++err;
    } else if (v->tinfo == VT_string && 
               !(v->qual && v->qual->args)) {
        fprintf(stderr, "Error (%d): ", line);
        fprintf(stderr, "String %s cannot be output without size\n", v->name);
        ++err;
    } else if (v->tinfo == VT_mx && v->iospec == 'b') {
        fprintf(stderr, "Error (%d): ", line);
        fprintf(stderr, "mxArray %s cannot be used for inout\n", v->name);
        ++err;
    }
    return err + typecheck_args(v->next, line);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %esi, %ebx
movq %rdi, %r14
xorl %r15d, %r15d
xorl %r13d, %r13d
testq %r14, %r14
je 0x7210
movq %r14, %rdi
movl %ebx, %esi
callq 0x6c73
movl %eax, %r12d
cmpb $0x69, 0x8(%r14)
jne 0x70ad
movq 0x30(%r14), %r14
addl %r12d, %r13d
jmp 0x7087
movq 0x28(%r14), %rax
movsbl (%rax), %eax
addl $-0x30, %eax
cmpl $0x9, %eax
movl %r15d, -0x2c(%rbp)
jbe 0x71d9
movl 0x20(%r14), %eax
cmpl $0xf, %eax
ja 0x70f3
movl $0x8802, %ecx           # imm = 0x8802
btl %eax, %ecx
jae 0x70f3
movq 0x10(%r14), %rdi
callq 0x5781
leaq 0x5d6a(%rip), %r15      # 0xce51
testb %al, %al
je 0x7191
movl 0x20(%r14), %eax
leal -0x2(%rax), %ecx
cmpl $0x3, %ecx
ja 0x713f
movb 0x8(%r14), %cl
cmpb $0x6f, %cl
jne 0x7122
movq 0x18(%r14), %rdx
leaq 0x5d5e(%rip), %r15      # 0xce6d
testq %rdx, %rdx
je 0x7191
cmpq $0x0, 0x8(%rdx)
leaq 0x5d4d(%rip), %r15      # 0xce6d
je 0x7191
cmpb $0x6f, %cl
sete %cl
cmpl $0x5, %eax
setne %al
orb %cl, %al
leaq 0x5d56(%rip), %r15      # 0xce8d
jne 0x71c6
jmp 0x7191
cmpl $0x9, %eax
je 0x7173
cmpl $0xa, %eax
je 0x7163
leaq 0x5d5c(%rip), %r15      # 0xceac
cmpl $0x6, %eax
je 0x7191
cmpl $0x13, %eax
jne 0x71c6
leaq 0x5d67(%rip), %r15      # 0xcec8
jmp 0x7191
cmpb $0x62, 0x8(%r14)
leaq 0x5da0(%rip), %r15      # 0xcf0f
jne 0x71c6
jmp 0x7191
movq 0x18(%r14), %rax
leaq 0x5d68(%rip), %r15      # 0xcee6
testq %rax, %rax
je 0x7191
cmpq $0x0, 0x8(%rax)
leaq 0x5d57(%rip), %r15      # 0xcee6
jne 0x71c6
movq 0x13e40(%rip), %rax     # 0x1afd8
movq (%rax), %rdi
leaq 0x59ca(%rip), %rsi      # 0xcb6c
movl %ebx, %edx
xorl %eax, %eax
callq 0x32b0
movq 0x13e26(%rip), %rax     # 0x1afd8
movq (%rax), %rdi
movq 0x28(%r14), %rdx
movq %r15, %rsi
xorl %eax, %eax
callq 0x32b0
incl %r12d
movq 0x30(%r14), %r14
addl -0x2c(%rbp), %r13d
addl %r12d, %r13d
movl %r13d, %r15d
jmp 0x7084
movq 0x13df8(%rip), %r15     # 0x1afd8
movq (%r15), %rdi
leaq 0x5982(%rip), %rsi      # 0xcb6c
movl %ebx, %edx
xorl %eax, %eax
callq 0x32b0
movq (%r15), %rdi
movq 0x28(%r14), %rdx
leaq 0x5c34(%rip), %rsi      # 0xce35
xorl %eax, %eax
callq 0x32b0
incl %r12d
jmp 0x70c4
addl %r15d, %r13d
movl %r13d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq