// File: /workspace/github_cpp_makefile_star2_O2/CHEN-Zhihan[P]Compiler/Node.cpp
// Function: FunctionNode::check(std::vector<int, std::allocator<int>>&, int)
void FunctionNode::check(vector<int>& sList, int functionID) {
    if (sList.back() != GLOBAL) {
        cerr << "Function " << reverseLookup[i] << " can only be defined in the global scope" << endl;
        exit(-1);
    }
    if (functionTable.count(i) != 0) {
        cerr << "Redefinition of function: " << reverseLookup[i] << endl;
        exit(-1);
    }
    variableTable[i] = unordered_set<int>();
    addressTable[i] ={0, unordered_map<int, unordered_map<ID, address> >()};
    int size = 0;
    functionTable[i] = this;
    unordered_set<int> duplicateSet;
    for (auto j = parameters.begin(); j != parameters.end(); ++j) {
        if (functionTable.count((*j)->getID()) != 0) {
            cerr << "Redefinition of function: " << reverseLookup[(*j)->getID()] << endl;
            exit(-1);
        }
        if (duplicateSet.count((*j)->getID()) != 0) {
            cerr << "duplicate parameter '" << reverseLookup[(*j)->getID()] << "' in function definition" << endl;
            exit(-1);
        }
        duplicateSet.insert((*j)->getID());
        variableTable[i].insert((*j)->getID());
        #if DEBUG
            cerr << "add variable " << reverseLookup[(*j)->getID()] << " to " << i << endl;
            cerr << "add variable of size " << (*j)->getDimensions() << " to " << i << " " << (*j)->getID() << endl;
        #endif
        addressTable[i].second[i][(*j)->getID()] = - 3 + (size++) - parameters.size();
        sizeMap[{i, (*j)->getID()}] = vector<int>((*j)->getDimensions());
    }
    #if DEBUG
        cerr << "adding function " << reverseLookup[this->i] << " to " << GLOBAL << endl;
    #endif
    variableTable[GLOBAL].insert(i);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq 0x8(%rsi), %rax
movl -0x4(%rax), %eax
cmpl 0x10539(%rip), %eax     # 0x1d4ac
jne 0xd29f
movq %rdi, -0x38(%rbp)
leaq 0x8(%rdi), %rbx
leaq 0x103c8(%rip), %rdi     # 0x1d350
movq %rbx, %rsi
callq 0x1055c
testq %rax, %rax
jne 0xd2e0
leaq -0x88(%rbp), %r13
andq $0x0, -0x10(%r13)
movq %r13, -0x30(%r13)
movq $0x1, -0x28(%r13)
xorps %xmm0, %xmm0
movups %xmm0, -0x20(%r13)
movl $0x3f800000, -0x10(%r13) # imm = 0x3F800000
movups %xmm0, -0x8(%r13)
leaq 0x103bb(%rip), %rdi     # 0x1d388
movq %rbx, %rsi
callq 0xa758
leaq -0xb8(%rbp), %r15
movq %rax, %rdi
movq %r15, %rsi
callq 0x95e6
movq %r15, %rdi
callq 0x96f6
leaq -0x48(%rbp), %rax
andq $0x0, -0x10(%rax)
movq %rax, -0x30(%rax)
movq $0x1, -0x28(%rax)
xorps %xmm0, %xmm0
movups %xmm0, -0x20(%rax)
movl $0x3f800000, -0x10(%rax) # imm = 0x3F800000
movups %xmm0, -0x8(%rax)
andl $0x0, (%r15)
leaq -0xb0(%rbp), %r12
leaq -0x78(%rbp), %rsi
movq %r12, %rdi
callq 0xf4d2
leaq 0x10434(%rip), %rdi     # 0x1d468
movq %rbx, %rsi
callq 0x9d9e
leaq -0xb8(%rbp), %r14
movq %rax, %rdi
movq %r14, %rsi
callq 0x909c
movq %r12, %rdi
callq 0x982c
leaq -0x78(%rbp), %r12
movq %r12, %rdi
callq 0x982c
leaq 0x102e7(%rip), %rdi     # 0x1d350
movq %rbx, %r15
movq %rbx, %rsi
callq 0x105fc
movq -0x38(%rbp), %rcx
movq %rcx, (%rax)
movq %r13, (%r14)
movq $0x1, 0x8(%r14)
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%r14)
movl $0x3f800000, 0x20(%r14) # imm = 0x3F800000
movups %xmm0, 0x28(%r14)
movq 0x10(%rcx), %r13
pushq $-0x3
popq %rax
movl %eax, -0x30(%rbp)
cmpq 0x18(%rcx), %r13
je 0xd1db
movq (%r13), %rax
movl 0x8(%rax), %eax
movl %eax, -0x78(%rbp)
leaq 0x10290(%rip), %rdi     # 0x1d350
movq %r12, %rsi
callq 0x1055c
testq %rax, %rax
jne 0xd264
movq (%r13), %rax
movl 0x8(%rax), %eax
movl %eax, -0x78(%rbp)
movq %r14, %rdi
movq %r12, %rsi
callq 0x1021c
testq %rax, %rax
jne 0xd217
movq (%r13), %rax
movl 0x8(%rax), %eax
movl %eax, -0x78(%rbp)
movq %r14, %rbx
movq %r14, %rdi
movq %r12, %rsi
callq 0x1093a
leaq 0x1027a(%rip), %rdi     # 0x1d388
movq %r15, %rsi
callq 0xa758
movq (%r13), %rcx
movl 0x8(%rcx), %ecx
movl %ecx, -0x78(%rbp)
movq %rax, %rdi
movq %r12, %rsi
callq 0x1093a
movq -0x38(%rbp), %rax
movq 0x18(%rax), %r14
subq 0x10(%rax), %r14
leaq 0x1032a(%rip), %rdi     # 0x1d468
movq %r15, %rsi
callq 0x9d9e
addq $0x8, %rax
movq %rax, %rdi
movq %r15, %rsi
callq 0xf958
movq (%r13), %rcx
movl 0x8(%rcx), %ecx
movl %ecx, -0x78(%rbp)
movq %rax, %rdi
movq %r12, %rsi
callq 0x10a2a
shrq $0x4, %r14
movl -0x30(%rbp), %ecx
subl %r14d, %ecx
movl %ecx, (%rax)
movq (%r13), %rax
movq 0x18(%rax), %rcx
subq 0x10(%rax), %rcx
shrq $0x4, %rcx
movslq %ecx, %rsi
movq %r12, %rdi
leaq -0x29(%rbp), %rdx
callq 0xeece
movq (%r13), %rax
movl 0x8(%rax), %eax
movl (%r15), %ecx
movl %ecx, -0x40(%rbp)
movl %eax, -0x3c(%rbp)
leaq 0x10304(%rip), %rdi     # 0x1d4b0
leaq -0x40(%rbp), %rsi
callq 0xeb8a
movq %rbx, %r14
movq %rax, %rdi
movq %r12, %rsi
callq 0xb316
movq %r12, %rdi
callq 0xa21e
addq $0x10, %r13
incl -0x30(%rbp)
movq -0x38(%rbp), %rcx
jmp 0xd0a5
leaq 0x101a6(%rip), %rdi     # 0x1d388
leaq 0x102c3(%rip), %rsi     # 0x1d4ac
callq 0xa758
movq %rax, %rdi
movq %r15, %rsi
callq 0xab0e
leaq -0xb8(%rbp), %rdi
callq 0x96f6
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0xfdca(%rip), %rdi      # 0x1cfe8
leaq 0x669e(%rip), %rsi      # 0x138c3
callq 0x31e0
movq (%r13), %rcx
movslq 0x8(%rcx), %rsi
leaq 0x100df(%rip), %rcx     # 0x1d318
shlq $0x5, %rsi
addq (%rcx), %rsi
movq %rax, %rdi
callq 0x31c0
leaq 0x668a(%rip), %rsi      # 0x138d9
movq %rax, %rdi
callq 0x31e0
movq %rax, %rdi
callq 0x3130
jmp 0xd314
movq 0xfd7d(%rip), %rdi      # 0x1cfe8
leaq 0x6004(%rip), %rsi      # 0x13276
callq 0x31e0
movq (%r13), %rcx
movslq 0x8(%rcx), %rsi
leaq 0x10092(%rip), %rcx     # 0x1d318
shlq $0x5, %rsi
addq (%rcx), %rsi
movq %rax, %rdi
callq 0x31c0
movq %rax, %rdi
callq 0x3130
jmp 0xd314
movq %rdi, %rbx
movq 0xfd3f(%rip), %rdi      # 0x1cfe8
leaq 0x65e0(%rip), %rsi      # 0x13890
callq 0x31e0
movslq 0x8(%rbx), %rsi
leaq 0x10058(%rip), %rcx     # 0x1d318
shlq $0x5, %rsi
addq (%rcx), %rsi
movq %rax, %rdi
callq 0x31c0
leaq 0x65c4(%rip), %rsi      # 0x1389a
movq %rax, %rdi
callq 0x31e0
jmp 0xd30c
movq 0xfd01(%rip), %rdi      # 0x1cfe8
leaq 0x5f88(%rip), %rsi      # 0x13276
callq 0x31e0
movslq (%rbx), %rsi
leaq 0x1001b(%rip), %rcx     # 0x1d318
shlq $0x5, %rsi
addq (%rcx), %rsi
movq %rax, %rdi
callq 0x31c0
movq %rax, %rdi
callq 0x3130
pushq $-0x1
popq %rdi
callq 0x3260
movq %rax, %rbx
movq %r12, %rdi
callq 0x982c
leaq -0x78(%rbp), %rdi
callq 0x982c
jmp 0xd361
jmp 0xd352
jmp 0xd352
jmp 0xd352
jmp 0xd352
jmp 0xd352
jmp 0xd352
movq %rax, %rbx
leaq -0x78(%rbp), %rdi
callq 0xa21e
jmp 0xd355
jmp 0xd352
jmp 0xd352
jmp 0xd352
movq %rax, %rbx
leaq -0xb8(%rbp), %rdi
callq 0x96f6
movq %rbx, %rdi
callq 0x3390
nop