// File: /workspace/github_cpp_makefile_star2_O1/kelwinfc[P]ci4721-Fernandez-Gyomrey/src/AST/check.cpp
// Function: AST_function_call::fill_and_check(symbol_table*)
void AST_function_call::fill_and_check(symbol_table* st){
    
    params->fill_and_check(st);
    
    sym = st->lookup(name);
    
    if ( !sym ){

        logger->buf << "Función '" << name << "' no definida.";
        logger->error(line, column);
        
        type = UNDEFINED;
    } else if ( !sym->is_function ){
        sym = 0;

        logger->buf << "Identificador '" << name << "' no es un nombre de función.";
        logger->error(line, column);
        
        type = UNDEFINED;
    } else {
        symbol_function* f = (symbol_function*)sym;
        
        if ( params->elem.size() != f->params.size() ){
            logger->buf << "Se esperaban " << f->params.size()
                        << " argumentos para la función '" << name
                        << "', " << params->elem.size() << " recibidos.";
            logger->error(line, column);
        } else {
            uint nsize = params->elem.size();
            
            for (uint i=0; i<nsize; i++){
                if ( params->elem[i]->type != INVALID
                     && params->elem[i]->type != f->params[i] )
                {
                    logger->buf << "Argumento " << i << " de '" << name << "' de tipo inválido '"
                                << types.types[params->elem[i]->type]->name << "'.";
                    logger->error(line, column);
                }
            }
        }
        
        type = f->getType();
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rsi, %r14
movq %rdi, %rbx
movq 0x80(%rdi), %rdi
movq (%rdi), %rax
callq *0x8(%rax)
leaq 0x18(%rsp), %r12
movq %r12, -0x10(%r12)
movq 0x50(%rbx), %rsi
movq 0x58(%rbx), %rdx
addq %rsi, %rdx
leaq 0x8(%rsp), %r15
movq %r15, %rdi
callq 0x16c42
movq %r14, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x183ae
movq %rax, 0x70(%rbx)
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0xb8c3
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x62f0
movq 0x70(%rbx), %r14
testq %r14, %r14
je 0xba14
cmpb $0x0, 0x31(%r14)
je 0xba54
movq 0x80(%rbx), %rax
movq 0x18(%rax), %rcx
subq 0x10(%rax), %rcx
movq %rcx, %rax
sarq $0x3, %rax
movq 0x80(%r14), %rdx
subq 0x78(%r14), %rdx
sarq $0x2, %rdx
cmpq %rdx, %rax
jne 0xbab7
shrq $0x3, %rcx
testl %ecx, %ecx
je 0xbb6d
movl %eax, %ebp
xorl %r15d, %r15d
leaq 0x32adf(%rip), %r12     # 0x3e400
movq 0x80(%rbx), %rax
movq 0x10(%rax), %rax
movq (%rax,%r15,8), %rax
movl 0x10(%rax), %eax
cmpl $0x1, %eax
je 0xba03
movq 0x78(%r14), %rcx
cmpl (%rcx,%r15,4), %eax
je 0xba03
movq (%r12), %r13
addq $0x48, %r13
movl $0xa, %edx
movq %r13, %rdi
leaq 0x210f4(%rip), %rsi     # 0x2ca55
callq 0x6360
movq %r13, %rdi
movq %r15, %rsi
callq 0x61e0
movq %rax, %r13
movl $0x5, %edx
movq %rax, %rdi
leaq 0x2116c(%rip), %rsi     # 0x2caef
callq 0x6360
movq 0x50(%rbx), %rsi
movq 0x58(%rbx), %rdx
movq %r13, %rdi
callq 0x6360
movq %rax, %r13
movl $0x15, %edx
movq %rax, %rdi
leaq 0x210b6(%rip), %rsi     # 0x2ca60
callq 0x6360
movq 0x80(%rbx), %rax
movq 0x10(%rax), %rax
movq (%rax,%r15,8), %rax
movslq 0x10(%rax), %rax
leaq 0x32a3f(%rip), %rcx     # 0x3e408
movq (%rcx), %rcx
movq (%rcx,%rax,8), %rax
movq 0x8(%rax), %rsi
movq 0x10(%rax), %rdx
movq %r13, %rdi
callq 0x6360
movl $0x2, %edx
movq %rax, %rdi
leaq 0x25ba8(%rip), %rsi     # 0x31597
callq 0x6360
movq (%r12), %rdi
movl 0x8(%rbx), %esi
movl 0xc(%rbx), %edx
callq 0x1a9e6
incq %r15
cmpq %r15, %rbp
jne 0xb921
jmp 0xbb6d
leaq 0x329e5(%rip), %r15     # 0x3e400
movq (%r15), %r14
addq $0x48, %r14
leaq 0x20fb6(%rip), %rsi     # 0x2c9df
movl $0xa, %edx
movq %r14, %rdi
callq 0x6360
movq 0x50(%rbx), %rsi
movq 0x58(%rbx), %rdx
movq %r14, %rdi
callq 0x6360
leaq 0x20f9d(%rip), %rsi     # 0x2c9ea
movl $0xe, %edx
jmp 0xba9a
movq $0x0, 0x70(%rbx)
leaq 0x3299d(%rip), %r15     # 0x3e400
movq (%r15), %r14
addq $0x48, %r14
leaq 0x20e1b(%rip), %rsi     # 0x2c88c
movl $0xf, %edx
movq %r14, %rdi
callq 0x6360
movq 0x50(%rbx), %rsi
movq 0x58(%rbx), %rdx
movq %r14, %rdi
callq 0x6360
leaq 0x20f64(%rip), %rsi     # 0x2c9f9
movl $0x1e, %edx
movq %rax, %rdi
callq 0x6360
movq (%r15), %rdi
movl 0x8(%rbx), %esi
movl 0xc(%rbx), %edx
callq 0x1a9e6
xorl %eax, %eax
jmp 0xbb75
leaq 0x32942(%rip), %r12     # 0x3e400
movq (%r12), %r15
addq $0x48, %r15
leaq 0x20f4b(%rip), %rsi     # 0x2ca18
movl $0xd, %edx
movq %r15, %rdi
callq 0x6360
movq 0x80(%r14), %rsi
subq 0x78(%r14), %rsi
sarq $0x2, %rsi
movq %r15, %rdi
callq 0x61e0
movq %rax, %r15
leaq 0x20f2b(%rip), %rsi     # 0x2ca26
movl $0x1e, %edx
movq %rax, %rdi
callq 0x6360
movq 0x50(%rbx), %rsi
movq 0x58(%rbx), %rdx
movq %r15, %rdi
callq 0x6360
movq %rax, %r15
leaq 0x20f23(%rip), %rsi     # 0x2ca45
movl $0x3, %edx
movq %rax, %rdi
callq 0x6360
movq 0x80(%rbx), %rax
movq 0x18(%rax), %rsi
subq 0x10(%rax), %rsi
sarq $0x3, %rsi
movq %r15, %rdi
callq 0x61e0
leaq 0x20ef8(%rip), %rsi     # 0x2ca49
movl $0xb, %edx
movq %rax, %rdi
callq 0x6360
movq (%r12), %rdi
movl 0x8(%rbx), %esi
movl 0xc(%rbx), %edx
callq 0x1a9e6
movq %r14, %rdi
callq 0x17fde
movl %eax, 0x10(%rbx)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0xbba1
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x62f0
movq %rbx, %rdi
callq 0x6550
nop