// File: /workspace/github_cpp_makefile_star2_O3/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 0x7a6c
movq %r14, %rdi
movl %ebx, %esi
callq 0x7539
movl %eax, %r12d
cmpb $0x69, 0x8(%r14)
jne 0x78f6
movq 0x30(%r14), %r14
addl %r12d, %r13d
jmp 0x78d0
movq 0x28(%r14), %rax
movsbl (%rax), %eax
addl $-0x30, %eax
cmpl $0x9, %eax
movl %r15d, -0x2c(%rbp)
jbe 0x7a31
movl 0x20(%r14), %eax
cmpl $0xf, %eax
ja 0x7940
movl $0x8802, %ecx           # imm = 0x8802
btl %eax, %ecx
jae 0x7940
movq 0x10(%r14), %rdi
callq 0x5f6f
leaq 0x6521(%rip), %r15      # 0xde51
testb %al, %al
je 0x79e6
movl 0x20(%r14), %eax
movl -0x2c(%rbp), %r15d
leal -0x2(%rax), %ecx
cmpl $0x3, %ecx
ja 0x7990
movb 0x8(%r14), %cl
cmpb $0x6f, %cl
jne 0x7973
movq 0x18(%r14), %rdx
leaq 0x6511(%rip), %r15      # 0xde6d
testq %rdx, %rdx
je 0x79e6
cmpq $0x0, 0x8(%rdx)
leaq 0x64fc(%rip), %r15      # 0xde6d
je 0x79e6
cmpb $0x6f, %cl
sete %cl
cmpl $0x5, %eax
setne %al
orb %cl, %al
leaq 0x6505(%rip), %r15      # 0xde8d
jne 0x7a1b
jmp 0x79e6
cmpl $0x9, %eax
jg 0x79b7
jne 0x79cc
movq 0x18(%r14), %rax
leaq 0x6544(%rip), %r15      # 0xdee6
testq %rax, %rax
je 0x79e6
cmpq $0x0, 0x8(%rax)
leaq 0x6533(%rip), %r15      # 0xdee6
jne 0x7a1b
jmp 0x79e6
cmpl $0xa, %eax
jne 0x79da
cmpb $0x62, 0x8(%r14)
leaq 0x6547(%rip), %r15      # 0xdf0f
jne 0x7a1b
jmp 0x79e6
leaq 0x64d9(%rip), %r15      # 0xdeac
cmpl $0x6, %eax
jne 0x7a1b
jmp 0x79e6
cmpl $0x13, %eax
jne 0x7a1f
leaq 0x64e2(%rip), %r15      # 0xdec8
movq 0x145eb(%rip), %rax     # 0x1bfd8
movq (%rax), %rdi
leaq 0x6175(%rip), %rsi      # 0xdb6c
movl %ebx, %edx
xorl %eax, %eax
callq 0x3270
movq 0x145d1(%rip), %rax     # 0x1bfd8
movq (%rax), %rdi
movq 0x28(%r14), %rdx
movq %r15, %rsi
xorl %eax, %eax
callq 0x3270
incl %r12d
movl -0x2c(%rbp), %r15d
movq 0x30(%r14), %r14
addl %r15d, %r13d
addl %r12d, %r13d
movl %r13d, %r15d
jmp 0x78cd
movq 0x145a0(%rip), %r15     # 0x1bfd8
movq (%r15), %rdi
leaq 0x612a(%rip), %rsi      # 0xdb6c
movl %ebx, %edx
xorl %eax, %eax
callq 0x3270
movq (%r15), %rdi
movl -0x2c(%rbp), %r15d
movq 0x28(%r14), %rdx
leaq 0x63d8(%rip), %rsi      # 0xde35
xorl %eax, %eax
callq 0x3270
incl %r12d
jmp 0x790d
addl %r15d, %r13d
movl %r13d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq