// File: /workspace/github_cpp_makefile_star2_O2/CHEN-Zhihan[P]Compiler/Node.cpp
// Function: FunctionNode::match(std::vector<std::shared_ptr<ExprNode>, std::allocator<std::shared_ptr<ExprNode>>> const&, std::vector<int, std::allocator<int>> const&, int) const
void FunctionNode::match(const vector<shared_ptr<ExprNode> >& arguments, const vector<int>& sList, int base) const {
    for (int i = 0; i != arguments.size(); ++i) {
        auto parameter = parameters[i];
        auto argument = arguments[i];
        if (parameter->getDimensions() != 0) {
            if (argument->oper != VAR) {
                cerr << "Invalid " << i << " th argument for function " << reverseLookup[this->i] << endl;
                exit(-1);
            }
            auto v = dynamic_pointer_cast<VarNode>(argument->op[0]);
            auto dimension = sizeMap[{v->getDefinitionScope(sList, base), v->getID()}];
            if (parameter->getDimensions() != dimension.size()) {
                #if DEBUG
                    cerr << "expect " << parameter->getDimensions() <<
                    " got " << dimension.size() << " for function " << reverseLookup[this->i] << endl;
                #endif
                cerr << "Invalid " << i << " th argument for function " << reverseLookup[this->i] << endl;
                exit(-1);
            }
            auto pDimension = parameter->getDimension();
            for (auto j = 1; j != pDimension.size(); ++j) {
                if (pDimension[j] != dimension[j]) {
                    cerr << "Invalid " << i << " th argument for function, dimension not match" << endl;
                    exit(-1);
                }
            }
            v->match();
            sizeMap[{this->i, parameter->getID()}] = dimension;
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movl %ecx, -0x2c(%rbp)
movq %rdx, -0x78(%rbp)
movq %rsi, %r14
movq %rdi, %r12
xorl %ebx, %ebx
leaq -0xa0(%rbp), %r15
movq 0x8(%r14), %rax
subq (%r14), %rax
sarq $0x4, %rax
cmpq %rbx, %rax
je 0xd50b
movq %rbx, %r13
shlq $0x4, %r13
movq 0x10(%r12), %rsi
addq %r13, %rsi
leaq -0x50(%rbp), %rdi
callq 0xf558
addq (%r14), %r13
leaq -0x88(%rbp), %rdi
movq %r13, %rsi
callq 0xf570
movq -0x50(%rbp), %rax
movq 0x18(%rax), %rcx
subq 0x10(%rax), %rcx
shrq $0x4, %rcx
testl %ecx, %ecx
je 0xd4f1
movq -0x88(%rbp), %rsi
cmpl $-0x5, 0x8(%rsi)
jne 0xd5a7
addq $0x18, %rsi
leaq -0x40(%rbp), %rdi
callq 0x67f2
movq -0x40(%rbp), %rdi
movq -0x78(%rbp), %rsi
movl -0x2c(%rbp), %edx
callq 0xbcac
movq -0x40(%rbp), %rcx
movl 0x8(%rcx), %ecx
movl %eax, -0x70(%rbp)
movl %ecx, -0x6c(%rbp)
leaq 0x10087(%rip), %rdi     # 0x1d4b0
leaq -0x70(%rbp), %rsi
callq 0xeb8a
movq %r15, %rdi
movq %rax, %rsi
callq 0xebf4
movq -0x50(%rbp), %rsi
movq 0x18(%rsi), %rax
subq 0x10(%rsi), %rax
shrq $0x4, %rax
cltq
movq -0x98(%rbp), %rcx
subq -0xa0(%rbp), %rcx
sarq $0x2, %rcx
cmpq %rax, %rcx
jne 0xd556
leaq -0x70(%rbp), %rdi
callq 0xd64c
movq -0x70(%rbp), %rax
movq -0x68(%rbp), %rcx
subq %rax, %rcx
sarq $0x2, %rcx
movq -0xa0(%rbp), %rdx
pushq $0x1
popq %rsi
cmpq %rsi, %rcx
je 0xd4a2
movl (%rax,%rsi,4), %edi
leaq 0x1(%rsi), %r8
cmpl (%rdx,%rsi,4), %edi
movq %r8, %rsi
je 0xd48c
jmp 0xd51a
movq -0x40(%rbp), %rax
movb $0x1, 0xd(%rax)
movq -0x50(%rbp), %rax
movl 0x8(%rax), %eax
movl 0x8(%r12), %ecx
movl %ecx, -0x58(%rbp)
movl %eax, -0x54(%rbp)
leaq 0xffed(%rip), %rdi      # 0x1d4b0
leaq -0x58(%rbp), %rsi
callq 0xeb8a
movq %rax, %rdi
movq %r15, %rsi
callq 0xef20
leaq -0x70(%rbp), %rdi
callq 0xa21e
movq %r15, %rdi
callq 0xa21e
leaq -0x38(%rbp), %rdi
callq 0x6b76
leaq -0x80(%rbp), %rdi
callq 0x6b76
leaq -0x48(%rbp), %rdi
callq 0x6b76
incq %rbx
jmp 0xd391
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0xfac7(%rip), %rdi      # 0x1cfe8
leaq 0x63ca(%rip), %rsi      # 0x138f2
callq 0x31e0
movq %rax, %rdi
movl %ebx, %esi
callq 0x3370
leaq 0x63d8(%rip), %rsi      # 0x13916
movq %rax, %rdi
callq 0x31e0
movq %rax, %rdi
callq 0x3130
pushq $-0x1
popq %rdi
callq 0x3260
movq 0xfa8b(%rip), %rdi      # 0x1cfe8
leaq 0x638e(%rip), %rsi      # 0x138f2
callq 0x31e0
movq %rax, %rdi
movl %ebx, %esi
callq 0x3370
leaq 0x6381(%rip), %rsi      # 0x138fb
movq %rax, %rdi
callq 0x31e0
movslq 0x8(%r12), %rsi
leaq 0xfd8a(%rip), %rcx      # 0x1d318
shlq $0x5, %rsi
addq (%rcx), %rsi
movq %rax, %rdi
callq 0x31c0
movq %rax, %rdi
callq 0x3130
jmp 0xd54e
movq 0xfa3a(%rip), %rdi      # 0x1cfe8
leaq 0x633d(%rip), %rsi      # 0x138f2
callq 0x31e0
movq %rax, %rdi
movl %ebx, %esi
callq 0x3370
leaq 0x6330(%rip), %rsi      # 0x138fb
movq %rax, %rdi
callq 0x31e0
movslq 0x8(%r12), %rsi
leaq 0xfd39(%rip), %rcx      # 0x1d318
shlq $0x5, %rsi
addq (%rcx), %rsi
movq %rax, %rdi
callq 0x31c0
movq %rax, %rdi
callq 0x3130
jmp 0xd54e
movq %rax, %rbx
jmp 0xd631
jmp 0xd604
jmp 0xd60b
movq %rax, %rbx
jmp 0xd61c
jmp 0xd610
movq %rax, %rbx
jmp 0xd628
movq %rax, %rbx
leaq -0x70(%rbp), %rdi
callq 0xa21e
leaq -0xa0(%rbp), %rdi
callq 0xa21e
leaq -0x38(%rbp), %rdi
callq 0x6b76
leaq -0x80(%rbp), %rdi
callq 0x6b76
leaq -0x48(%rbp), %rdi
callq 0x6b76
movq %rbx, %rdi
callq 0x3390
nop