// File: /workspace/github_cpp_makefile_star2_O3/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 0xd65f
movq 0x80(%rbx), %rcx
movslq 0x10(%rcx), %r12
cmpq $0x1, %r12
jne 0xd794
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 0x16c68
movq %r14, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x183ea
movq %rax, %r15
movq %rax, 0xa8(%rbx)
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0xd6bc
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x6300
movq 0xa8(%rbx), %r15
testq %r15, %r15
je 0xd740
cmpb $0x0, 0x31(%r15)
je 0xd803
movq 0x80(%r15), %rax
movq 0x78(%r15), %rcx
subq %rcx, %rax
je 0xd8b6
sarq $0x2, %rax
cmpq $0x3, %rax
jae 0xd8b6
movq 0x78(%rbx), %rcx
movslq 0x10(%rcx), %rcx
leaq 0x31d13(%rip), %r13     # 0x3f410
movq (%r13), %rdx
movq (%rdx,%rcx,8), %rcx
movslq 0x3c(%rcx), %r14
cmpq $0x2, %rax
je 0xd910
cmpq $0x1, %rax
jne 0xdae5
movq %r15, %rdi
callq 0x1801a
cmpl %r14d, %eax
jne 0xd9f3
movq 0x78(%r15), %rax
cmpl %r14d, (%rax)
jne 0xda51
jmp 0xdae5
leaq 0x31cc1(%rip), %r15     # 0x3f408
movq (%r15), %r14
addq $0x48, %r14
leaq 0x20137(%rip), %rsi     # 0x2d88c
movl $0xf, %edx
movq %r14, %rdi
callq 0x6370
movq 0x88(%rbx), %rsi
movq 0x90(%rbx), %rdx
movq %r14, %rdi
callq 0x6370
leaq 0x20182(%rip), %rsi     # 0x2d901
movl $0x1a, %edx
movq %rax, %rdi
callq 0x6370
movq (%r15), %rdi
jmp 0xdada
leaq 0x31c75(%rip), %rcx     # 0x3f410
movq (%rcx), %r13
movq (%r13,%rax,8), %r15
testq %r15, %r15
je 0xdb78
movq (%r15), %rax
movq -0x8(%rax), %rax
movq 0x8(%rax), %rdi
leaq 0x21a1c(%rip), %rbp     # 0x2f1da
cmpq %rbp, %rdi
je 0xd840
cmpb $0x2a, (%rdi)
je 0xd7d8
leaq 0x21a0b(%rip), %rsi     # 0x2f1da
callq 0x6410
testl %eax, %eax
je 0xd840
leaq 0x31c29(%rip), %r14     # 0x3f408
movq (%r14), %rdi
addq $0x48, %rdi
leaq 0x20534(%rip), %rsi     # 0x2dd21
movl $0x24, %edx
callq 0x6370
movq (%r14), %rdi
movq 0x78(%rbx), %rax
jmp 0xd89d
leaq 0x31bfe(%rip), %r14     # 0x3f408
movq (%r14), %rdi
addq $0x48, %rdi
leaq 0x20686(%rip), %rsi     # 0x2de9e
movl $0x22, %edx
callq 0x6370
movq (%r14), %rdi
movl 0x8(%rbx), %esi
movl 0xc(%rbx), %edx
callq 0x1aa40
movq $0x0, 0xa8(%rbx)
jmp 0xdae5
movq (%r13,%r12,8), %r12
testq %r12, %r12
je 0xdb78
movq (%r12), %rax
movq -0x8(%rax), %rax
movq 0x8(%rax), %rdi
cmpq %rbp, %rdi
je 0xd8dd
cmpb $0x2a, (%rdi)
je 0xd874
leaq 0x2196f(%rip), %rsi     # 0x2f1da
callq 0x6410
testl %eax, %eax
je 0xd8dd
leaq 0x31b8d(%rip), %r14     # 0x3f408
movq (%r14), %rdi
addq $0x48, %rdi
leaq 0x20498(%rip), %rsi     # 0x2dd21
movl $0x24, %edx
callq 0x6370
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 0x1aa40
leaq 0x31b4b(%rip), %r14     # 0x3f408
movq (%r14), %rdi
addq $0x48, %rdi
leaq 0x2049f(%rip), %rsi     # 0x2dd6a
movl $0x1b, %edx
callq 0x6370
movq (%r14), %rdi
jmp 0xdada
cmpq %r12, %r15
je 0xd65f
leaq 0x31b1b(%rip), %r14     # 0x3f408
movq (%r14), %rdi
addq $0x48, %rdi
leaq 0x2057a(%rip), %rsi     # 0x2de75
movl $0x28, %edx
callq 0x6370
movq (%r14), %rdi
movl 0x8(%rbx), %esi
movl 0xc(%rbx), %edx
jmp 0xd8a3
movq %r15, %rdi
callq 0x1801a
cmpl $0x2, %eax
jne 0xdaf4
movq 0x78(%r15), %rax
cmpl %r14d, (%rax)
jne 0xda51
leaq 0x31adb(%rip), %r12     # 0x3f410
movq %r12, %rdi
movl %r14d, %esi
callq 0x1a0ec
movq 0x78(%r15), %rcx
movslq 0x4(%rcx), %rcx
testb %al, %al
jne 0xd955
cmpl %ecx, %r14d
je 0xdae5
movq (%r12), %rax
movq (%rax,%rcx,8), %r13
testq %r13, %r13
je 0xdb78
movq (%r13), %rax
movq -0x8(%rax), %rax
movq 0x8(%rax), %rdi
leaq 0x21874(%rip), %rax     # 0x2f1ed
cmpq %rax, %rdi
je 0xdb13
cmpb $0x2a, (%rdi)
je 0xd99b
leaq 0x2185f(%rip), %rsi     # 0x2f1ed
callq 0x6410
testl %eax, %eax
je 0xdb13
leaq 0x31a66(%rip), %r13     # 0x3f408
movq (%r13), %r15
addq $0x48, %r15
leaq 0x20574(%rip), %rsi     # 0x2df25
movl $0x18, %edx
movq %r15, %rdi
callq 0x6370
movq (%r12), %rax
movq (%rax,%r14,8), %rax
movq 0x8(%rax), %rsi
movq 0x10(%rax), %rdx
movq %r15, %rdi
callq 0x6370
leaq 0x24bba(%rip), %rsi     # 0x32597
movl $0x2, %edx
movq %rax, %rdi
callq 0x6370
movq (%r13), %rdi
jmp 0xdada
leaq 0x31a0e(%rip), %rbp     # 0x3f408
movq (%rbp), %r12
addq $0x48, %r12
leaq 0x203bb(%rip), %rsi     # 0x2ddc4
movl $0x27, %edx
movq %r12, %rdi
callq 0x6370
movq (%r13), %rax
movq (%rax,%r14,8), %rax
movq 0x8(%rax), %rsi
movq 0x10(%rax), %rdx
movq %r12, %rdi
callq 0x6370
movq %rax, %r14
leaq 0x203b4(%rip), %rsi     # 0x2ddec
movl $0x21, %edx
movq %rax, %rdi
callq 0x6370
movq %r15, %rdi
callq 0x1801a
cltq
jmp 0xdaaa
leaq 0x319b0(%rip), %rbp     # 0x3f408
movq (%rbp), %r12
addq $0x48, %r12
leaq 0x2045a(%rip), %rsi     # 0x2dec1
movl $0x30, %edx
movq %r12, %rdi
callq 0x6370
movq (%r13), %rax
movq (%rax,%r14,8), %rax
movq 0x8(%rax), %rsi
movq 0x10(%rax), %rdx
movq %r12, %rdi
callq 0x6370
movq %rax, %r14
leaq 0x2045c(%rip), %rsi     # 0x2def2
movl $0xd, %edx
movq %rax, %rdi
callq 0x6370
movq 0x78(%r15), %rax
movslq (%rax), %rax
movq (%r13), %rcx
movq (%rcx,%rax,8), %rax
movq 0x8(%rax), %rsi
movq 0x10(%rax), %rdx
movq %r14, %rdi
callq 0x6370
leaq 0x24ace(%rip), %rsi     # 0x32597
movl $0x2, %edx
movq %rax, %rdi
callq 0x6370
movq (%rbp), %rdi
movl 0x8(%rbx), %esi
movl 0xc(%rbx), %edx
callq 0x1aa40
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x3190d(%rip), %r14     # 0x3f408
movq (%r14), %rdi
addq $0x48, %rdi
leaq 0x203f7(%rip), %rsi     # 0x2df00
movl $0x24, %edx
jmp 0xd8d0
cmpl %r14d, 0x30(%r13)
je 0xdae5
leaq 0x318e8(%rip), %rbp     # 0x3f408
movq (%rbp), %r15
addq $0x48, %r15
leaq 0x203f6(%rip), %rsi     # 0x2df25
movl $0x18, %edx
movq %r15, %rdi
callq 0x6370
movq (%r12), %rax
movq (%rax,%r14,8), %rax
movq 0x8(%rax), %rsi
movq 0x10(%rax), %rdx
movq %r15, %rdi
callq 0x6370
movq %rax, %r14
leaq 0x203e0(%rip), %rsi     # 0x2df3e
movl $0x1a, %edx
movq %rax, %rdi
callq 0x6370
movslq 0x30(%r13), %rax
movq (%r12), %rcx
jmp 0xdaae
callq 0x6350
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0xdb97
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x6300
movq %rbx, %rdi
callq 0x6560
nop