// File: /workspace/github_cpp_makefile_star2_O1/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, %r15d
movq %rsi, %rbx
movq %rdi, %r14
movslq 0x8(%rdi), %rsi
cmpq $0x8, %rsi
jg 0xf67e
movq 0x10(%r14), %rax
movq 0x18(%r14), %rcx
movq %rcx, %rdx
subq %rax, %rdx
cmpq $0x10, %rdx
sete %dl
cmpl $0x3, %esi
setl %dil
orb %dl, %dil
je 0xf7d4
cmpq %rax, %rcx
sete %cl
cmpl $0x3, %esi
setge %dl
orb %cl, %dl
je 0xf82c
cmpl $0x3, %esi
jl 0xf7c5
movq (%rax), %rdi
movq 0x8(%rax), %r14
testq %r14, %r14
je 0xf79e
movq 0xc954(%rip), %rax      # 0x1bfc0
cmpb $0x0, (%rax)
je 0xf799
incl 0x8(%r14)
jmp 0xf79e
leaq 0x8(%r14), %r12
leaq 0xccdf(%rip), %rdi      # 0x1c368
movq %r12, %rsi
callq 0x1229c
testq %rax, %rax
je 0xf7fa
leaq 0xccc7(%rip), %rdi      # 0x1c368
movq %r12, %rsi
callq 0x12326
movq (%rax), %r13
movq 0x18(%r13), %rax
subq 0x10(%r13), %rax
movq 0x18(%r14), %rcx
subq 0x10(%r14), %rcx
cmpq %rcx, %rax
jne 0xf84f
leaq 0x10(%r14), %rsi
movq %r13, -0x30(%rbp)
movq %r13, %rdi
movq %rbx, %rdx
movl %r15d, %ecx
callq 0xeefa
movq 0x10(%r14), %r13
movq 0x18(%r14), %r14
cmpq %r14, %r13
je 0xf6fe
movq (%r13), %rdi
movq (%rdi), %rax
movq %rbx, %rsi
movl %r15d, %edx
callq *0x8(%rax)
addq $0x10, %r13
jmp 0xf6e3
leaq 0xcd0b(%rip), %rdi      # 0x1c410
movq %r12, %rsi
callq 0x129ca
testq %rax, %rax
jne 0xf7c5
movl 0xcddb(%rip), %r14d     # 0x1c4f8
leal 0x1(%r14), %eax
movl %eax, 0xcdd1(%rip)      # 0x1c4f8
leaq 0xcce2(%rip), %rdi      # 0x1c410
movq %r12, %rsi
callq 0x12922
movl %r14d, (%rax)
movq 0x8(%rbx), %rsi
cmpq 0x10(%rbx), %rsi
je 0xf753
movl (%r12), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rbx)
jmp 0xf75e
movq %rbx, %rdi
movq %r12, %rdx
callq 0x12182
movq -0x30(%rbp), %rcx
movl (%r12), %r14d
movq 0x8(%rbx), %rax
movl -0x4(%rax), %eax
movl %eax, 0x40(%rcx)
movq 0x28(%rcx), %r15
movq 0x30(%rcx), %r12
cmpq %r12, %r15
je 0xf792
movq (%r15), %rdi
movq (%rdi), %rax
movq %rbx, %rsi
movl %r14d, %edx
callq *0x8(%rax)
addq $0x10, %r15
jmp 0xf778
addq $-0x4, 0x8(%rbx)
jmp 0xf7c5
lock
incl 0x8(%r14)
movq (%rdi), %rax
movq %rbx, %rsi
movl %r15d, %edx
callq *0x8(%rax)
testq %r14, %r14
je 0xf7c5
movq %r14, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x896e
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xcb55(%rip), %rax      # 0x1c330
shlq $0x5, %rsi
addq (%rax), %rsi
movq 0xc807(%rip), %rdi      # 0x1bff0
callq 0x41d0
leaq 0x5181(%rip), %rsi      # 0x14976
jmp 0xf897
movq 0xc7ef(%rip), %rdi      # 0x1bff0
leaq 0x51a2(%rip), %rsi      # 0x149aa
callq 0x4200
movslq (%r12), %rsi
leaq 0xcb18(%rip), %rcx      # 0x1c330
shlq $0x5, %rsi
addq (%rcx), %rsi
movq %rax, %rdi
callq 0x41d0
jmp 0xf8b3
leaq 0xcafd(%rip), %rax      # 0x1c330
shlq $0x5, %rsi
addq (%rax), %rsi
movq 0xc7af(%rip), %rdi      # 0x1bff0
callq 0x41d0
leaq 0x5143(%rip), %rsi      # 0x14990
jmp 0xf897
movslq 0x8(%r14), %rsi
leaq 0xcad6(%rip), %rax      # 0x1c330
shlq $0x5, %rsi
addq (%rax), %rsi
movq 0xc788(%rip), %rdi      # 0x1bff0
callq 0x41d0
leaq 0x5153(%rip), %rsi      # 0x149c7
movq %rax, %rdi
callq 0x4200
movq 0x18(%r13), %rsi
subq 0x10(%r13), %rsi
sarq $0x4, %rsi
movq %rax, %rdi
callq 0x40a0
leaq 0x513a(%rip), %rsi      # 0x149d1
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 0xf8d5
movq %r14, %rdi
callq 0x896e
movq %rbx, %rdi
callq 0x43b0
nop