// File: /workspace/github_cpp_makefile_star2_O1/kelwinfc[P]ci4721-Fernandez-Gyomrey/src/AST/check.cpp
// Function: AST_map::fill_and_check(symbol_table*)
void AST_map::fill_and_check(symbol_table* st){
    
    src->fill_and_check(st);
    dst->fill_and_check(st);
    
    if ( src->type != INVALID && dst->type != INVALID )
    {
        if ( typeid(*types.types[src->type]) != typeid(array_descriptor) ){
            logger->buf << "Expresion debe evaluar tipo arreglo.";
            logger->error(src->line, src->column);
            return;
        } else if (typeid(*types.types[dst->type]) != typeid(array_descriptor)){
            logger->buf << "Expresion debe evaluar tipo arreglo.";
            logger->error(dst->line, dst->column);
            return;
        } else if ( types.types[src->type] != types.types[dst->type] ){
            logger->buf << "Ambos arreglos deben ser del mismo tipo.";
            logger->error(line, column);
            return;
        }
    }
    
    sym = st->lookup(function);
    
    if ( sym ){
        
        if ( !sym->is_function ){
            logger->buf << "Esperada identificador de funcion.";
            logger->error(line, column);
            sym = 0;
        } else {
            symbol_function* s = (symbol_function*)sym;
            
            array_descriptor* ad=(array_descriptor*)types.types[src->type];
            TYPE base = ad->base;
            
            if ( s->params.size() == 0 || s->params.size() > 2 ){
                logger->buf << "Funcion con firma invalida.";
                logger->error(line, column);
                
            } else if ( s->params.size() == 1 ){
                if ( s->getType() != base ){
                    logger->buf << "Se espera funcion con retorno de tipo '"
                                << types.types[base]->name
                                << "', recibida funcion con retorno '"
                                << types.types[s->getType()]->name << "'.";
                    logger->error(line, column);
                    
                } else if ( s->params[0] != base ){
                    logger->buf << "Se espera funcion con primer argumento de tipo '"
                                << types.types[base]->name
                                << "', recibido '"
                                << types.types[s->params[0]]->name << "'.";
                    logger->error(line, column);
                    
                }
            } else if ( s->params.size() == 2 ){
                if ( s->getType() != NONE ){
                    logger->buf << "Se espera funcion con retorno vacio.";
                    logger->error(line, column);
                    
                } else if ( s->params[0] != base ){
                    logger->buf << "Se espera funcion con primer argumento de tipo '"
                                << types.types[base]->name
                                << "', recibido '"
                                << types.types[s->params[0]]->name << "'.";
                    logger->error(line, column);
                    
                } else {
                    if ( types.is_base(base) ){
                        if ( typeid(*(types.types[s->params[1]]))
                             == typeid(pointer_descriptor) )
                        {
                            pointer_descriptor* pd =
                               (pointer_descriptor*)(types.types[s->params[1]]);
                            
                            if ( pd->base != base ){
                                logger->buf << "Se espera referencia a '"
                                            << types.types[base]->name
                                            << "', recibida referencia a '"
                                            << types.types[pd->base]->name << "'.";
                                logger->error(line, column);
                            }
                        } else {
                            logger->buf << "Se espera referencia a '"
                                        << types.types[base]->name << "'.";
                            logger->error(line, column);
                        }
                    } else {
                        if ( base != s->params[1] ){
                            if ( typeid(*(types.types[s->params[1]]))
                                 == typeid(pointer_descriptor) )
                            {
                                pointer_descriptor* pd =
                                 (pointer_descriptor*)types.types[s->params[1]];
                                
                                if ( pd->base != base ){
                                    logger->buf << "Se espera referencia a '"
                                                << types.types[base]->name
                                                << "', recibida referencia a '"
                                                << types.types[pd->base]->name << "'.";
                                    logger->error(line, column);
                                }
                            } else {
                                logger->buf << "Se espera referencia a '"
                                            << types.types[base]->name << "'.";
                                logger->error(line, column);
                            }
                        }
                    }
                }
            }
        }
    } else {
        logger->buf << "Identificador '" << function << "' no definido previamente.";
        logger->error(line, column);
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rsi, %r14
movq %rdi, %rbx
movq 0x78(%rdi), %rdi
movq (%rdi), %rax
callq *0x8(%rax)
movq 0x80(%rbx), %rdi
movq (%rdi), %rax
movq %r14, %rsi
callq *0x8(%rax)
movq 0x78(%rbx), %rax
movslq 0x10(%rax), %rax
cmpq $0x1, %rax
je 0xd675
movq 0x80(%rbx), %rcx
movslq 0x10(%rcx), %r12
cmpq $0x1, %r12
jne 0xd786
leaq 0x18(%rsp), %r12
movq %r12, -0x10(%r12)
movq 0x88(%rbx), %rsi
movq 0x90(%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, 0xa8(%rbx)
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0xd6c8
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x62f0
movq 0xa8(%rbx), %r12
testq %r12, %r12
je 0xd727
cmpb $0x0, 0x31(%r12)
je 0xd7f9
movq 0x80(%r12), %rax
subq 0x78(%r12), %rax
setne %cl
sarq $0x2, %rax
cmpq $0x3, %rax
setb %dl
testb %dl, %cl
jne 0xd8be
leaq 0x30cf6(%rip), %r14     # 0x3e400
movq (%r14), %rdi
addq $0x48, %rdi
leaq 0x1f652(%rip), %rsi     # 0x2cd6a
movl $0x1b, %edx
callq 0x6360
movq (%r14), %rdi
jmp 0xd776
leaq 0x30cd2(%rip), %r15     # 0x3e400
movq (%r15), %r14
addq $0x48, %r14
leaq 0x1f150(%rip), %rsi     # 0x2c88c
movl $0xf, %edx
movq %r14, %rdi
callq 0x6360
movq 0x88(%rbx), %rsi
movq 0x90(%rbx), %rdx
movq %r14, %rdi
callq 0x6360
leaq 0x1f19b(%rip), %rsi     # 0x2c901
movl $0x1a, %edx
movq %rax, %rdi
callq 0x6360
movq (%r15), %rdi
movl 0x8(%rbx), %esi
movl 0xc(%rbx), %edx
callq 0x1a9e6
jmp 0xd831
leaq 0x30c7b(%rip), %rcx     # 0x3e408
movq (%rcx), %r13
movq (%r13,%rax,8), %r15
testq %r15, %r15
je 0xdb99
movq (%r15), %rax
movq -0x8(%rax), %rax
movq 0x8(%rax), %rdi
leaq 0x20a2a(%rip), %rbp     # 0x2e1da
cmpq %rbp, %rdi
je 0xd840
cmpb $0x2a, (%rdi)
je 0xd7ce
leaq 0x20a15(%rip), %rsi     # 0x2e1da
callq 0x6400
testl %eax, %eax
je 0xd840
leaq 0x30c2b(%rip), %r14     # 0x3e400
movq (%r14), %rdi
addq $0x48, %rdi
leaq 0x1f53e(%rip), %rsi     # 0x2cd21
movl $0x24, %edx
callq 0x6360
movq (%r14), %rdi
movq 0x78(%rbx), %rax
jmp 0xd8a5
leaq 0x30c00(%rip), %r14     # 0x3e400
movq (%r14), %rdi
addq $0x48, %rdi
leaq 0x1f690(%rip), %rsi     # 0x2ce9e
movl $0x22, %edx
callq 0x6360
movq (%r14), %rdi
movl 0x8(%rbx), %esi
movl 0xc(%rbx), %edx
callq 0x1a9e6
movq $0x0, 0xa8(%rbx)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq (%r13,%r12,8), %r12
testq %r12, %r12
je 0xdb99
movq (%r12), %rax
movq -0x8(%rax), %rax
movq 0x8(%rax), %rdi
cmpq %rbp, %rdi
je 0xd90d
cmpb $0x2a, (%rdi)
je 0xd87c
leaq 0x2096b(%rip), %rsi     # 0x2e1da
callq 0x6400
testl %eax, %eax
je 0xd90d
leaq 0x30b7d(%rip), %r14     # 0x3e400
movq (%r14), %rdi
addq $0x48, %rdi
leaq 0x1f490(%rip), %rsi     # 0x2cd21
movl $0x24, %edx
callq 0x6360
movq (%r14), %rdi
movq 0x80(%rbx), %rax
movl 0x8(%rax), %esi
movl 0xc(%rax), %edx
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1a9e6
movq 0x78(%rbx), %rcx
movslq 0x10(%rcx), %rcx
leaq 0x30b3b(%rip), %r13     # 0x3e408
movq (%r13), %rdx
movq (%rdx,%rcx,8), %rcx
movslq 0x3c(%rcx), %r14
cmpq $0x2, %rax
je 0xd943
cmpq $0x1, %rax
jne 0xd831
movq %r12, %rdi
callq 0x17fde
cmpl %r14d, %eax
jne 0xda26
movq 0x78(%r12), %rax
cmpl %r14d, (%rax)
je 0xd831
jmp 0xda84
cmpq %r12, %r15
je 0xd675
leaq 0x30ae3(%rip), %r14     # 0x3e400
movq (%r14), %rdi
addq $0x48, %rdi
leaq 0x1f54a(%rip), %rsi     # 0x2ce75
movl $0x28, %edx
callq 0x6360
movq (%r14), %rdi
movl 0x8(%rbx), %esi
movl 0xc(%rbx), %edx
jmp 0xd8ab
movq %r12, %rdi
callq 0x17fde
cmpl $0x2, %eax
jne 0xdb13
movq 0x78(%r12), %rax
cmpl %r14d, (%rax)
jne 0xda84
leaq 0x30a9f(%rip), %r15     # 0x3e408
movq %r15, %rdi
movl %r14d, %esi
callq 0x1a092
movq 0x78(%r12), %rcx
movslq 0x4(%rcx), %rcx
testb %al, %al
jne 0xd98a
cmpl %ecx, %r14d
je 0xd831
movq (%r15), %rax
movq (%rax,%rcx,8), %r13
testq %r13, %r13
je 0xdb99
movq (%r13), %rax
movq -0x8(%rax), %rax
movq 0x8(%rax), %rdi
leaq 0x20840(%rip), %rax     # 0x2e1ed
cmpq %rax, %rdi
je 0xdb32
cmpb $0x2a, (%rdi)
je 0xd9cf
leaq 0x2082b(%rip), %rsi     # 0x2e1ed
callq 0x6400
testl %eax, %eax
je 0xdb32
leaq 0x30a2a(%rip), %r13     # 0x3e400
movq (%r13), %r12
addq $0x48, %r12
leaq 0x1f540(%rip), %rsi     # 0x2cf25
movl $0x18, %edx
movq %r12, %rdi
callq 0x6360
movq (%r15), %rax
movq (%rax,%r14,8), %rax
movq 0x8(%rax), %rsi
movq 0x10(%rax), %rdx
movq %r12, %rdi
callq 0x6360
leaq 0x23b87(%rip), %rsi     # 0x31597
movl $0x2, %edx
movq %rax, %rdi
callq 0x6360
movq (%r13), %rdi
jmp 0xd776
leaq 0x309d3(%rip), %rbp     # 0x3e400
movq (%rbp), %r15
addq $0x48, %r15
leaq 0x1f388(%rip), %rsi     # 0x2cdc4
movl $0x27, %edx
movq %r15, %rdi
callq 0x6360
movq (%r13), %rax
movq (%rax,%r14,8), %rax
movq 0x8(%rax), %rsi
movq 0x10(%rax), %rdx
movq %r15, %rdi
callq 0x6360
movq %rax, %r14
leaq 0x1f381(%rip), %rsi     # 0x2cdec
movl $0x21, %edx
movq %rax, %rdi
callq 0x6360
movq %r12, %rdi
callq 0x17fde
cltq
jmp 0xdade
leaq 0x30975(%rip), %rbp     # 0x3e400
movq (%rbp), %r15
addq $0x48, %r15
leaq 0x1f427(%rip), %rsi     # 0x2cec1
movl $0x30, %edx
movq %r15, %rdi
callq 0x6360
movq (%r13), %rax
movq (%rax,%r14,8), %rax
movq 0x8(%rax), %rsi
movq 0x10(%rax), %rdx
movq %r15, %rdi
callq 0x6360
movq %rax, %r14
leaq 0x1f429(%rip), %rsi     # 0x2cef2
movl $0xd, %edx
movq %rax, %rdi
callq 0x6360
movq 0x78(%r12), %rax
movslq (%rax), %rax
movq (%r13), %rcx
movq (%rcx,%rax,8), %rax
movq 0x8(%rax), %rsi
movq 0x10(%rax), %rdx
movq %r14, %rdi
callq 0x6360
leaq 0x23a9a(%rip), %rsi     # 0x31597
movl $0x2, %edx
movq %rax, %rdi
callq 0x6360
movq (%rbp), %rdi
jmp 0xd776
leaq 0x308e6(%rip), %r14     # 0x3e400
movq (%r14), %rdi
addq $0x48, %rdi
leaq 0x1f3d8(%rip), %rsi     # 0x2cf00
movl $0x24, %edx
jmp 0xd71d
cmpl %r14d, 0x30(%r13)
je 0xd831
leaq 0x308bd(%rip), %rbp     # 0x3e400
movq (%rbp), %r12
addq $0x48, %r12
leaq 0x1f3d3(%rip), %rsi     # 0x2cf25
movl $0x18, %edx
movq %r12, %rdi
callq 0x6360
movq (%r15), %rax
movq (%rax,%r14,8), %rax
movq 0x8(%rax), %rsi
movq 0x10(%rax), %rdx
movq %r12, %rdi
callq 0x6360
movq %rax, %r14
leaq 0x1f3be(%rip), %rsi     # 0x2cf3e
movl $0x1a, %edx
movq %rax, %rdi
callq 0x6360
movslq 0x30(%r13), %rax
movq (%r15), %rcx
jmp 0xdae2
callq 0x6340
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0xdbb8
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x62f0
movq %rbx, %rdi
callq 0x6550