// File: /workspace/github_cpp_makefile_star2_O2/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 %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x20, %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 0xb80c
movq 0x80(%rbx), %rcx
cmpl $0x1, 0x10(%rcx)
jne 0xb8d3
leaq 0x88(%rbx), %r15
movq %rsp, %r12
movq %r12, %rdi
movq %r15, %rsi
callq 0x63e0
movq %r14, %rdi
movq %r12, %rsi
xorl %edx, %edx
callq 0x1422e
movq %rax, 0xa8(%rbx)
movq %rsp, %rdi
callq 0x65c8
movq 0xa8(%rbx), %r14
testq %r14, %r14
je 0xb88c
cmpb $0x0, 0x31(%r14)
je 0xb927
movq 0x80(%r14), %rax
subq 0x78(%r14), %rax
setne %cl
sarq $0x2, %rax
cmpq $0x3, %rax
setb %dl
testb %dl, %cl
jne 0xb9d7
leaq 0x2cb84(%rip), %r14     # 0x38400
movq (%r14), %rdi
addq $0x48, %rdi
leaq 0x184e0(%rip), %rsi     # 0x23d6a
jmp 0xb8bb
leaq 0x2cb6d(%rip), %r14     # 0x38400
movq (%r14), %rdi
addq $0x48, %rdi
leaq 0x17feb(%rip), %rsi     # 0x2388c
callq 0x62b0
movq %rax, %rdi
movq %r15, %rsi
callq 0x62a0
leaq 0x18049(%rip), %rsi     # 0x23901
movq %rax, %rdi
callq 0x62b0
movq (%r14), %rdi
movl 0x8(%rbx), %esi
movl 0xc(%rbx), %edx
callq 0x16112
jmp 0xb957
leaq 0x2cb2e(%rip), %r15     # 0x38408
movq (%r15), %rcx
movq (%rcx,%rax,8), %rax
testq %rax, %rax
je 0xbc6b
movq (%rax), %rax
movq -0x8(%rax), %rdi
leaq 0x2b598(%rip), %rsi     # 0x36e90
callq 0x12274
testb %al, %al
je 0xb965
leaq 0x2caf8(%rip), %r14     # 0x38400
movq (%r14), %rdi
addq $0x48, %rdi
leaq 0x1840b(%rip), %rsi     # 0x23d21
callq 0x62b0
movq (%r14), %rdi
movq 0x78(%rbx), %rax
jmp 0xb9bf
leaq 0x2cad2(%rip), %r14     # 0x38400
movq (%r14), %rdi
addq $0x48, %rdi
leaq 0x18562(%rip), %rsi     # 0x23e9e
callq 0x62b0
movq (%r14), %rdi
movl 0x8(%rbx), %esi
movl 0xc(%rbx), %edx
callq 0x16112
andq $0x0, 0xa8(%rbx)
addq $0x20, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
movq 0x80(%rbx), %rax
movslq 0x10(%rax), %rax
movq (%r15), %rcx
movq (%rcx,%rax,8), %rax
testq %rax, %rax
je 0xbc6b
movq (%rax), %rax
movq -0x8(%rax), %rdi
leaq 0x2b502(%rip), %rsi     # 0x36e90
callq 0x12274
testb %al, %al
je 0xba25
leaq 0x2ca5e(%rip), %r14     # 0x38400
movq (%r14), %rdi
addq $0x48, %rdi
leaq 0x18371(%rip), %rsi     # 0x23d21
callq 0x62b0
movq (%r14), %rdi
movq 0x80(%rbx), %rax
movl 0x8(%rax), %esi
movl 0xc(%rax), %edx
addq $0x20, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x16112
movq 0x78(%rbx), %rcx
movslq 0x10(%rcx), %rcx
leaq 0x2ca22(%rip), %r12     # 0x38408
movq (%r12), %rdx
movq (%rdx,%rcx,8), %rcx
movslq 0x3c(%rcx), %r15
cmpq $0x2, %rax
je 0xba71
cmpq $0x1, %rax
jne 0xb957
movq %r14, %rdi
callq 0x13f0c
cmpl %r15d, %eax
jne 0xbb4a
movq 0x78(%r14), %rax
cmpl %r15d, (%rax)
je 0xb957
jmp 0xbba6
movq 0x78(%rbx), %rax
movq 0x80(%rbx), %rcx
movslq 0x10(%rax), %rax
movq (%r15), %rdx
movq (%rdx,%rax,8), %rax
movslq 0x10(%rcx), %rcx
cmpq (%rdx,%rcx,8), %rax
je 0xb80c
leaq 0x2c9b0(%rip), %r14     # 0x38400
movq (%r14), %rdi
addq $0x48, %rdi
leaq 0x18417(%rip), %rsi     # 0x23e75
callq 0x62b0
movq (%r14), %rdi
movl 0x8(%rbx), %esi
movl 0xc(%rbx), %edx
jmp 0xb9c5
movq %r14, %rdi
callq 0x13f0c
cmpl $0x2, %eax
jne 0xbc17
movq 0x78(%r14), %rax
cmpl %r15d, (%rax)
jne 0xbba6
leaq 0x2c972(%rip), %r12     # 0x38408
movq %r12, %rdi
movl %r15d, %esi
callq 0x158ae
movq 0x78(%r14), %rcx
movslq 0x4(%rcx), %rcx
testb %al, %al
jne 0xbab6
cmpl %ecx, %r15d
je 0xb957
movq (%r12), %rax
movq (%rax,%rcx,8), %rax
testq %rax, %rax
je 0xbc6b
movq (%rax), %rax
movq -0x8(%rax), %rdi
leaq 0x2b3d3(%rip), %rsi     # 0x36ea8
callq 0x1227e
testb %al, %al
je 0xbc31
movq 0x78(%r14), %rax
movslq 0x4(%rax), %rax
movq (%r12), %rcx
movq (%rcx,%rax,8), %r13
cmpl %r15d, 0x30(%r13)
je 0xb957
leaq 0x2c8fd(%rip), %r14     # 0x38400
movq (%r14), %rdi
addq $0x48, %rdi
leaq 0x18414(%rip), %rsi     # 0x23f25
callq 0x62b0
movq (%r12), %rcx
movq (%rcx,%r15,8), %rsi
addq $0x8, %rsi
movq %rax, %rdi
callq 0x62a0
leaq 0x1840d(%rip), %rsi     # 0x23f3e
movq %rax, %rdi
callq 0x62b0
movslq 0x30(%r13), %rcx
movq (%r12), %rdx
movq (%rdx,%rcx,8), %rsi
jmp 0xbc53
leaq 0x2c8af(%rip), %r13     # 0x38400
movq (%r13), %rdi
addq $0x48, %rdi
leaq 0x18264(%rip), %rsi     # 0x23dc4
callq 0x62b0
movq (%r12), %rcx
movq (%rcx,%r15,8), %rsi
addq $0x8, %rsi
movq %rax, %rdi
callq 0x62a0
leaq 0x1826c(%rip), %rsi     # 0x23dec
movq %rax, %rdi
callq 0x62b0
movq %rax, %r15
movq %r14, %rdi
callq 0x13f0c
cltq
movq (%r12), %rcx
movq (%rcx,%rax,8), %rsi
addq $0x8, %rsi
movq %r15, %rdi
jmp 0xbbfa
leaq 0x2c853(%rip), %r13     # 0x38400
movq (%r13), %rdi
addq $0x48, %rdi
leaq 0x18305(%rip), %rsi     # 0x23ec1
callq 0x62b0
movq (%r12), %rcx
movq (%rcx,%r15,8), %rsi
addq $0x8, %rsi
movq %rax, %rdi
callq 0x62a0
leaq 0x18316(%rip), %rsi     # 0x23ef2
movq %rax, %rdi
callq 0x62b0
movq 0x78(%r14), %rcx
movslq (%rcx), %rcx
movq (%r12), %rdx
movq (%rdx,%rcx,8), %rsi
addq $0x8, %rsi
movq %rax, %rdi
callq 0x62a0
leaq 0x1c991(%rip), %rsi     # 0x28597
movq %rax, %rdi
callq 0x62b0
movq (%r13), %rdi
jmp 0xb8c3
leaq 0x2c7e2(%rip), %r14     # 0x38400
movq (%r14), %rdi
addq $0x48, %rdi
leaq 0x182d4(%rip), %rsi     # 0x23f00
jmp 0xb8bb
leaq 0x2c7c8(%rip), %r14     # 0x38400
movq (%r14), %rdi
addq $0x48, %rdi
leaq 0x182df(%rip), %rsi     # 0x23f25
callq 0x62b0
movq (%r12), %rcx
movq (%rcx,%r15,8), %rsi
addq $0x8, %rsi
movq %rax, %rdi
callq 0x62a0
leaq 0x1c931(%rip), %rsi     # 0x28597
jmp 0xb8b8
callq 0x6320
movq %rax, %rbx
movq %rsp, %rdi
callq 0x65c8
movq %rbx, %rdi
callq 0x6530
nop