// File: /workspace/github_cpp_makefile_star2_O1/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 %r13d, %r13d
testq %r14, %r14
je 0x7b4c
movq %r14, %rdi
movl %ebx, %esi
callq 0x760d
movl %eax, %r12d
cmpb $0x69, 0x8(%r14)
je 0x7b40
movq 0x28(%r14), %rax
movsbl (%rax), %eax
addl $-0x30, %eax
cmpl $0x9, %eax
jbe 0x7ac8
movl 0x20(%r14), %eax
cmpl $0xf, %eax
ja 0x79fc
movl $0x8802, %ecx           # imm = 0x8802
btl %eax, %ecx
jae 0x79fc
movq 0x10(%r14), %rdi
callq 0x608e
leaq 0x647d(%rip), %r15      # 0xde71
testb %al, %al
je 0x7b0b
movl 0x20(%r14), %eax
leal -0x2(%rax), %ecx
cmpl $0x3, %ecx
ja 0x7a35
cmpb $0x6f, 0x8(%r14)
jne 0x7a35
movq 0x18(%r14), %rcx
leaq 0x6473(%rip), %r15      # 0xde8d
testq %rcx, %rcx
je 0x7b0b
cmpq $0x0, 0x8(%rcx)
leaq 0x645e(%rip), %r15      # 0xde8d
je 0x7b0b
leal -0x5(%rax), %ecx
cmpl $0x5, %ecx
ja 0x7ab6
leaq 0x6130(%rip), %rdx      # 0xdb74
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
leaq 0x647a(%rip), %r15      # 0xdecc
jmpq *%rcx
cmpb $0x6f, 0x8(%r14)
leaq 0x644d(%rip), %r15      # 0xdead
jne 0x7b0b
cmpl $0x9, %eax
jg 0x7a9d
jne 0x7aff
movq 0x18(%r14), %rcx
leaq 0x648a(%rip), %r15      # 0xdf06
testq %rcx, %rcx
je 0x7b0b
cmpq $0x0, 0x8(%rcx)
leaq 0x6475(%rip), %r15      # 0xdf06
je 0x7b0b
cmpl $0xa, %eax
je 0x7aa2
jmp 0x7b40
cmpl $0xa, %eax
jne 0x7ab6
cmpb $0x62, 0x8(%r14)
leaq 0x6481(%rip), %r15      # 0xdf2f
jne 0x7b40
jmp 0x7b0b
cmpl $0x13, %eax
jne 0x7b40
leaq 0x6422(%rip), %r15      # 0xdee8
jmp 0x7b0b
movq 0x14509(%rip), %r15     # 0x1bfd8
movq (%r15), %rdi
leaq 0x60b3(%rip), %rsi      # 0xdb8c
movl %ebx, %edx
xorl %eax, %eax
callq 0x3270
movq (%r15), %rdi
movq 0x28(%r14), %rdx
leaq 0x6365(%rip), %rsi      # 0xde55
xorl %eax, %eax
callq 0x3270
incl %r12d
jmp 0x79d1
leaq 0x63c6(%rip), %r15      # 0xdecc
cmpl $0x6, %eax
jne 0x7b40
movq 0x144c6(%rip), %rax     # 0x1bfd8
movq (%rax), %rdi
leaq 0x6070(%rip), %rsi      # 0xdb8c
movl %ebx, %edx
xorl %eax, %eax
callq 0x3270
movq 0x144ac(%rip), %rax     # 0x1bfd8
movq (%rax), %rdi
movq 0x28(%r14), %rdx
movq %r15, %rsi
xorl %eax, %eax
callq 0x3270
incl %r12d
movq 0x30(%r14), %r14
addl %r12d, %r13d
jmp 0x799d
movl %r13d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq