// File: /workspace/github_cpp_makefile_star2_O3/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 0xdfdb(%rip), %eax      # 0x1c4c4
jne 0xe8c7
movq %rdi, -0x40(%rbp)
leaq 0x8(%rdi), %rbx
leaq 0xde6a(%rip), %rdi      # 0x1c368
movq %rbx, %rsi
callq 0x11d24
testq %rax, %rax
jne 0xe908
leaq -0x90(%rbp), %r13
movq $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 0xde5a(%rip), %rdi      # 0x1c3a0
movq %rbx, %rsi
callq 0xb9ba
leaq -0xc0(%rbp), %rsi
movq %rax, %rdi
callq 0x4820
leaq -0xc0(%rbp), %r15
movq %r15, %rdi
callq 0xad94
leaq -0x50(%rbp), %rax
movq $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)
movl $0x0, (%r15)
leaq -0xb8(%rbp), %r12
leaq -0x80(%rbp), %rdx
movq %r12, %rdi
movq %rdx, %rsi
callq 0x10fde
leaq 0xdec6(%rip), %rdi      # 0x1c480
movq %rbx, %rsi
callq 0xb1ce
leaq -0xc0(%rbp), %r14
movq %rax, %rdi
movq %r14, %rsi
callq 0xa97c
movq %r12, %rdi
callq 0xae0a
leaq -0x80(%rbp), %rdi
callq 0xae0a
leaq 0xdd7c(%rip), %rdi      # 0x1c368
movq %rbx, %rsi
callq 0x11d86
movq -0x40(%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), %r15
cmpq 0x18(%rcx), %r15
je 0xe7cd
xorl %r12d, %r12d
leaq -0x80(%rbp), %r13
movq (%r15), %rax
movl 0x8(%rax), %eax
movl %eax, -0x80(%rbp)
leaq 0xdd28(%rip), %rdi      # 0x1c368
movq %r13, %rsi
callq 0x11d24
testq %rax, %rax
jne 0xe87b
movq (%r15), %rax
movslq 0x8(%rax), %rcx
movq -0xc0(%rbp), %rdi
movq -0xb8(%rbp), %r8
movq %rcx, %rax
xorl %edx, %edx
divq %r8
movq (%rdi,%rdx,8), %rax
testq %rax, %rax
je 0xe6a9
movq %rdx, %rsi
movq (%rax), %r9
cmpl 0x8(%r9), %ecx
je 0xe810
movq (%r9), %r9
testq %r9, %r9
je 0xe6a9
movslq 0x8(%r9), %rdi
movq %rdi, %rax
xorl %edx, %edx
divq %r8
cmpq %rsi, %rdx
jne 0xe6a9
cmpl %edi, %ecx
jne 0xe687
jmp 0xe810
movl %ecx, -0x34(%rbp)
leaq -0xc0(%rbp), %rdi
movq %rdi, -0x80(%rbp)
leaq -0x34(%rbp), %rsi
movq %r13, %rdx
callq 0x12024
leaq 0xdcd6(%rip), %rdi      # 0x1c3a0
movq %rbx, %rsi
callq 0xb9ba
movq (%r15), %rcx
movl 0x8(%rcx), %ecx
movl %ecx, -0x34(%rbp)
movq %rax, -0x80(%rbp)
movq %rax, %rdi
leaq -0x34(%rbp), %rsi
movq %r13, %rdx
callq 0x12024
movq -0x40(%rbp), %rax
movq 0x18(%rax), %r14
subq 0x10(%rax), %r14
leaq 0xdd7f(%rip), %rdi      # 0x1c480
movq %rbx, %rsi
callq 0xb1ce
addq $0x8, %rax
movq %rax, %rdi
movq %rbx, %rsi
callq 0x11302
movq (%r15), %rcx
movl 0x8(%rcx), %ecx
movl %ecx, -0x80(%rbp)
movq %rax, %rdi
movq %r13, %rsi
callq 0x120dc
shrq $0x4, %r14
movl %r12d, %ecx
subl %r14d, %ecx
addl $-0x3, %ecx
movl %ecx, (%rax)
movq (%r15), %rax
movq 0x18(%rax), %rcx
subq 0x10(%rax), %rcx
shrq $0x4, %rcx
movslq %ecx, %rsi
movq %r13, %rdi
leaq -0x29(%rbp), %rdx
callq 0x10960
movq (%r15), %rax
movl 0x8(%rax), %eax
movl (%rbx), %ecx
movl %ecx, -0x34(%rbp)
movl %eax, -0x30(%rbp)
leaq 0xdd5a(%rip), %rdi      # 0x1c4c8
leaq -0x34(%rbp), %rsi
callq 0x10704
movq (%rax), %rdi
movq -0x80(%rbp), %rcx
movq %rcx, (%rax)
movq -0x78(%rbp), %rcx
movq %rcx, 0x8(%rax)
movq -0x70(%rbp), %rcx
movq %rcx, 0x10(%rax)
xorps %xmm0, %xmm0
movaps %xmm0, -0x80(%rbp)
movq $0x0, -0x70(%rbp)
testq %rdi, %rdi
je 0xe7b8
callq 0x41e0
movq -0x80(%rbp), %rdi
testq %rdi, %rdi
je 0xe7b8
callq 0x41e0
incl %r12d
addq $0x10, %r15
movq -0x40(%rbp), %rax
cmpq 0x18(%rax), %r15
jne 0xe630
leaq 0xdbcc(%rip), %rdi      # 0x1c3a0
leaq 0xdce9(%rip), %rsi      # 0x1c4c4
callq 0xb9ba
leaq -0x80(%rbp), %rdx
movq %rax, (%rdx)
movq %rax, %rdi
movq %rbx, %rsi
callq 0xbcaa
leaq -0xc0(%rbp), %rdi
callq 0xad94
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0xd7d1(%rip), %rdi      # 0x1bfe8
leaq 0x60c5(%rip), %rsi      # 0x148e3
movl $0x15, %edx
callq 0x4260
movq (%r15), %rax
movslq 0x8(%rax), %rax
leaq 0xdafa(%rip), %rcx      # 0x1c330
movq (%rcx), %rcx
shlq $0x5, %rax
movq (%rcx,%rax), %rsi
movq 0x8(%rcx,%rax), %rdx
movq 0xd79b(%rip), %rdi      # 0x1bfe8
callq 0x4260
movq %rax, %rbx
leaq 0x609d(%rip), %rsi      # 0x148f9
movl $0x18, %edx
movq %rax, %rdi
callq 0x4260
movq %rbx, %rdi
callq 0x4120
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x42a0
movq 0xd766(%rip), %rdi      # 0x1bfe8
leaq 0x5a0d(%rip), %rsi      # 0x14296
movl $0x1a, %edx
callq 0x4260
movq (%r15), %rax
movslq 0x8(%rax), %rax
leaq 0xda8f(%rip), %rcx      # 0x1c330
movq (%rcx), %rcx
shlq $0x5, %rax
movq (%rcx,%rax), %rsi
movq 0x8(%rcx,%rax), %rdx
movq 0xd730(%rip), %rdi      # 0x1bfe8
callq 0x4260
movq %rax, %rdi
callq 0x4120
jmp 0xe871
movq %rdi, %rbx
movq 0xd717(%rip), %rdi      # 0x1bfe8
leaq 0x5fd8(%rip), %rsi      # 0x148b0
callq 0x4200
movslq 0x8(%rbx), %rsi
leaq 0xda48(%rip), %rcx      # 0x1c330
shlq $0x5, %rsi
addq (%rcx), %rsi
movq %rax, %rdi
callq 0x41d0
leaq 0x5fbc(%rip), %rsi      # 0x148ba
movq %rax, %rdi
callq 0x4200
jmp 0xe934
movq 0xd6d9(%rip), %rdi      # 0x1bfe8
leaq 0x5980(%rip), %rsi      # 0x14296
callq 0x4200
movslq (%rbx), %rsi
leaq 0xda0b(%rip), %rcx      # 0x1c330
shlq $0x5, %rsi
addq (%rcx), %rsi
movq %rax, %rdi
callq 0x41d0
movq %rax, %rdi
callq 0x4120
jmp 0xe871
movq %rax, %rbx
movq %r12, %rdi
callq 0xae0a
leaq -0x80(%rbp), %rdi
callq 0xae0a
jmp 0xe991
movq %rax, %rdi
callq 0x85ab
jmp 0xe982
jmp 0xe982
jmp 0xe982
jmp 0xe982
movq %rax, %rbx
movq -0x80(%rbp), %rdi
testq %rdi, %rdi
je 0xe985
callq 0x41e0
jmp 0xe985
jmp 0xe982
jmp 0xe982
jmp 0xe982
jmp 0xe982
movq %rax, %rbx
leaq -0xc0(%rbp), %rdi
callq 0xad94
movq %rbx, %rdi
callq 0x43b0
nop