// File: /workspace/github_cpp_makefile_star2_O2/CHEN-Zhihan[P]Compiler/Node.cpp
// Function: CallNode::check(std::vector<int, std::allocator<int>>&, int)
void CallNode::check(vector<int> & sList, int functionID) {
    if (i < 9) {
        if (arguments.size() != 1 and i >= 3) {
            cerr << reverseLookup[i] << " expects 1 argument, got " << arguments.size() << endl;
            exit(-1); 
        }
        if (arguments.size() != 0 and i < 3) {
            cerr << reverseLookup[i] << " expects 0 argument, got " << arguments.size() << endl;
            exit(-1); 
        }
        if (i >= 3) {
            auto first = arguments.front();
            first->check(sList, functionID);
        }
    } else {
        if (functionTable.count(i) == 0) {
            cerr << "Call to undefined function: " << reverseLookup[i] << endl;
            exit(-1);
        }
        auto f = functionTable[i];
        if (f->getNumParameters() != arguments.size()) {
            cerr << reverseLookup[i] << " expects " << f->getNumParameters()
                 << " argument(s), got " << arguments.size() << endl;
            exit(-1);
        }
        f->match(arguments, sList, functionID);
        for (const auto & i: arguments) {
            i->check(sList, functionID);
        }
        if (functionLabel.count(i) == 0) {
            functionLabel[i] = lbl++;
            sList.push_back(i);
            f->checkStmt(sList, i);
            sList.pop_back();
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %edx, %r13d
movq %rsi, %r14
movq %rdi, %rbx
movslq 0x8(%rdi), %rsi
cmpq $0x8, %rsi
jg 0xd931
movq 0x10(%rbx), %rax
movq 0x18(%rbx), %rcx
movq %rcx, %rdx
subq %rax, %rdx
cmpq $0x10, %rdx
jne 0xda08
cmpl $0x2, %esi
jle 0xda56
leaq -0x40(%rbp), %rbx
movq %rbx, %rdi
movq %rax, %rsi
callq 0xf570
movq (%rbx), %rdi
movq (%rdi), %rax
movq %r14, %rsi
movl %r13d, %edx
callq *0x8(%rax)
leaq -0x38(%rbp), %rdi
callq 0x6b76
jmp 0xda16
leaq 0x8(%rbx), %r15
leaq 0xfa14(%rip), %rdi      # 0x1d350
movq %r15, %rsi
callq 0x1055c
testq %rax, %rax
je 0xda25
leaq 0xf9fc(%rip), %rdi      # 0x1d350
movq %r15, %rsi
callq 0x105fc
movq (%rax), %r12
movq 0x18(%r12), %rax
subq 0x10(%r12), %rax
movq 0x18(%rbx), %rcx
subq 0x10(%rbx), %rcx
cmpq %rcx, %rax
jne 0xda79
leaq 0x10(%rbx), %rsi
movq %r12, -0x30(%rbp)
movq %r12, %rdi
movq %r14, %rdx
movl %r13d, %ecx
callq 0xd36a
movq 0x10(%rbx), %r12
movq 0x18(%rbx), %rbx
cmpq %rbx, %r12
je 0xd9b3
movq (%r12), %rdi
movq (%rdi), %rax
movq %r14, %rsi
movl %r13d, %edx
callq *0x8(%rax)
addq $0x10, %r12
jmp 0xd998
leaq 0xfa3e(%rip), %rdi      # 0x1d3f8
movq %r15, %rsi
callq 0x10f78
testq %rax, %rax
jne 0xda16
movl 0xfb13(%rip), %ebx      # 0x1d4e0
leal 0x1(%rbx), %eax
movl %eax, 0xfb0a(%rip)      # 0x1d4e0
leaq 0xfa1b(%rip), %rdi      # 0x1d3f8
movq %r15, %rsi
callq 0x10ea2
movl %ebx, (%rax)
movq %r14, %rdi
movq %r15, %rsi
callq 0xee54
movl (%r15), %edx
movq -0x30(%rbp), %rdi
movq %r14, %rsi
callq 0xcf0e
addq $-0x4, 0x8(%r14)
jmp 0xda16
cmpl $0x3, %esi
jge 0xdac5
cmpq %rax, %rcx
jne 0xda56
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0xf5bc(%rip), %rdi      # 0x1cfe8
leaq 0x5f57(%rip), %rsi      # 0x1398a
callq 0x31e0
movslq (%r15), %rsi
leaq 0xf8d6(%rip), %rcx      # 0x1d318
shlq $0x5, %rsi
addq (%rcx), %rsi
movq %rax, %rdi
callq 0x31c0
jmp 0xdb02
leaq 0xf8bb(%rip), %rax      # 0x1d318
shlq $0x5, %rsi
addq (%rax), %rsi
movq 0xf57d(%rip), %rdi      # 0x1cfe8
callq 0x31c0
leaq 0x5ef9(%rip), %rsi      # 0x13970
jmp 0xdae6
movslq 0x8(%rbx), %rsi
leaq 0xf894(%rip), %rax      # 0x1d318
shlq $0x5, %rsi
addq (%rax), %rsi
movq 0xf556(%rip), %rdi      # 0x1cfe8
callq 0x31c0
leaq 0x5f09(%rip), %rsi      # 0x139a7
movq %rax, %rdi
callq 0x31e0
movq 0x18(%r12), %rsi
subq 0x10(%r12), %rsi
sarq $0x4, %rsi
movq %rax, %rdi
callq 0x3090
leaq 0x5eee(%rip), %rsi      # 0x139b1
jmp 0xdae6
leaq 0xf84c(%rip), %rax      # 0x1d318
shlq $0x5, %rsi
addq (%rax), %rsi
movq 0xf50e(%rip), %rdi      # 0x1cfe8
callq 0x31c0
leaq 0x5e70(%rip), %rsi      # 0x13956
movq %rax, %rdi
callq 0x31e0
movq 0x18(%rbx), %rsi
subq 0x10(%rbx), %rsi
sarq $0x4, %rsi
movq %rax, %rdi
callq 0x3090
movq %rax, %rdi
callq 0x3130
pushq $-0x1
popq %rdi
callq 0x3260
movq %rax, %rbx
leaq -0x38(%rbp), %rdi
callq 0x6b76
movq %rbx, %rdi
callq 0x3390