// File: /workspace/github_cpp_makefile_star2_O3/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
pushq %rax
movl %edx, %r13d
movq %rsi, %rbx
movq %rdi, %r14
movslq 0x8(%rdi), %rsi
cmpq $0x8, %rsi
jg 0xf139
movq 0x10(%r14), %rax
movq 0x18(%r14), %rcx
movq %rcx, %rdx
subq %rax, %rdx
cmpq $0x10, %rdx
jne 0xf212
cmpl $0x2, %esi
jle 0xf224
movq (%rax), %rdi
movq 0x8(%rax), %r14
testq %r14, %r14
je 0xf29e
movq 0xce91(%rip), %rax      # 0x1bfb8
cmpb $0x0, (%rax)
je 0xf299
incl 0x8(%r14)
jmp 0xf29e
leaq 0x8(%r14), %r15
leaq 0xd224(%rip), %rdi      # 0x1c368
movq %r15, %rsi
callq 0x11d24
testq %rax, %rax
je 0xf2d4
leaq 0xd20c(%rip), %rdi      # 0x1c368
movq %r15, -0x30(%rbp)
movq %r15, %rsi
callq 0x11d86
movq (%rax), %r12
movq 0x18(%r12), %rax
subq 0x10(%r12), %rax
movq 0x18(%r14), %rcx
subq 0x10(%r14), %rcx
cmpq %rcx, %rax
jne 0xf305
leaq 0x10(%r14), %rsi
movq %r12, %rdi
movq %rbx, %rdx
movl %r13d, %ecx
callq 0xe99a
movq 0x10(%r14), %r15
movq 0x18(%r14), %r14
cmpq %r14, %r15
je 0xf1ba
movq (%r15), %rdi
movq (%rdi), %rax
movq %rbx, %rsi
movl %r13d, %edx
callq *0x8(%rax)
addq $0x10, %r15
jmp 0xf1a0
leaq 0xd24f(%rip), %rdi      # 0x1c410
movq -0x30(%rbp), %r15
movq %r15, %rsi
callq 0x1243e
testq %rax, %rax
jne 0xf2c5
movl 0xd31b(%rip), %r14d     # 0x1c4f8
leal 0x1(%r14), %eax
movl %eax, 0xd311(%rip)      # 0x1c4f8
leaq 0xd222(%rip), %rdi      # 0x1c410
movq %r15, %rsi
callq 0x1237e
movl %r14d, (%rax)
movq 0x8(%rbx), %rsi
cmpq 0x10(%rbx), %rsi
je 0xf24a
movl (%r15), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rbx)
jmp 0xf259
cmpl $0x3, %esi
jge 0xf351
cmpq %rax, %rcx
je 0xf2c5
leaq 0xd105(%rip), %rax      # 0x1c330
shlq $0x5, %rsi
addq (%rax), %rsi
movq 0xcdaf(%rip), %rdi      # 0x1bfe8
callq 0x41d0
leaq 0x574b(%rip), %rsi      # 0x14990
jmp 0xf372
movq %rbx, %rdi
movq %r15, %rdx
callq 0x11c0a
movq 0x8(%rbx), %rsi
movl (%r15), %r14d
movl -0x4(%rsi), %eax
movl %eax, 0x40(%r12)
movq 0x28(%r12), %r15
movq 0x30(%r12), %r12
cmpq %r12, %r15
je 0xf28f
movq (%r15), %rdi
movq (%rdi), %rax
movq %rbx, %rsi
movl %r14d, %edx
callq *0x8(%rax)
addq $0x10, %r15
cmpq %r12, %r15
jne 0xf273
movq 0x8(%rbx), %rsi
addq $-0x4, %rsi
movq %rsi, 0x8(%rbx)
jmp 0xf2c5
lock
incl 0x8(%r14)
movq (%rdi), %rax
movq %rbx, %rsi
movl %r13d, %edx
callq *0x8(%rax)
testq %r14, %r14
je 0xf2c5
movq %r14, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x864c
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0xcd0d(%rip), %rdi      # 0x1bfe8
leaq 0x56c8(%rip), %rsi      # 0x149aa
callq 0x4200
movslq (%r15), %rsi
leaq 0xd03f(%rip), %rcx      # 0x1c330
shlq $0x5, %rsi
addq (%rcx), %rsi
movq %rax, %rdi
callq 0x41d0
jmp 0xf38e
movslq 0x8(%r14), %rsi
leaq 0xd020(%rip), %rax      # 0x1c330
shlq $0x5, %rsi
addq (%rax), %rsi
movq 0xccca(%rip), %rdi      # 0x1bfe8
callq 0x41d0
leaq 0x569d(%rip), %rsi      # 0x149c7
movq %rax, %rdi
callq 0x4200
movq 0x18(%r12), %rsi
subq 0x10(%r12), %rsi
sarq $0x4, %rsi
movq %rax, %rdi
callq 0x40a0
leaq 0x5682(%rip), %rsi      # 0x149d1
jmp 0xf372
leaq 0xcfd8(%rip), %rax      # 0x1c330
shlq $0x5, %rsi
addq (%rax), %rsi
movq 0xcc82(%rip), %rdi      # 0x1bfe8
callq 0x41d0
leaq 0x5604(%rip), %rsi      # 0x14976
movq %rax, %rdi
callq 0x4200
movq 0x18(%r14), %rsi
subq 0x10(%r14), %rsi
sarq $0x4, %rsi
movq %rax, %rdi
callq 0x40a0
movq %rax, %rdi
callq 0x4120
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x42a0
movq %rax, %rbx
testq %r14, %r14
je 0xf3b0
movq %r14, %rdi
callq 0x864c
movq %rbx, %rdi
callq 0x43b0