// File: /workspace/github_cpp_makefile_star2_O3/kelwinfc[P]ci4721-Fernandez-Gyomrey/src/AST/check.cpp
// Function: AST_variable_declaration::fill_and_check(symbol_table*)
void AST_variable_declaration::fill_and_check(symbol_table* st){

    if (types.has_type(sym->getName())) {
        logger->buf << "Identificador '" << sym->getName()
                    << "' ya existe como tipo '" << types.get_type(sym->getName())->name << "'.";
        logger->error(sym->getLine(), sym->getColumn());
    }

    sym->offset    = st->accumulated_offset;
    sym->width     = types.types[sym->getType()]->width;
    sym->alignment = types.types[sym->getType()]->alignment;
    
    int level;
    symbol* previous = st->lookup(sym->getName(), &level);
    
    if ( value ){
        value->fill_and_check(st);
    }
    
    if ( previous ){
        if ( previous->is_function ){
            logger->buf << "Identificador '" << sym->getName()
                        << "' ya fue definido previamente como función en "
                        << sym->getLine() << ':' << sym->getColumn();
            logger->error(sym->getLine(), sym->getColumn());
        } else if ( level == 0 ){
            logger->buf << "Identificador '" << sym->getName()
                        << "' ya fue definido previamente en "
                        << sym->getLine() << ':' << sym->getColumn();
            logger->error(sym->getLine(), sym->getColumn());
        } else {
            st->insert(sym);
        }
    } else {
        st->insert(sym);
    }
    
    if ( value
         && value->type != sym->getType()
         && value->type != INVALID
         && sym->getType() != INVALID
       )
    {
        logger->buf << "Inicialización de '" << sym->getName()
                    << "' con tipo inválido '" << types.types[value->type]->name
                    << "', esperado '" << types.types[sym->getType()]->name << "'.";
        logger->error(line, column);
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %rsi, %r15
movq %rdi, %rbx
movq 0x98(%rdi), %rsi
leaq 0x78(%rsp), %r12
movq %r12, %rdi
callq 0x17ff4
leaq 0x33850(%rip), %r14     # 0x3f410
movq %r14, %rdi
movq %r12, %rsi
callq 0x1a04e
movl %eax, %ebp
leaq 0x88(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xbbee
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x6300
testb %bpl, %bpl
je 0xbcfb
leaq 0x3380a(%rip), %rbp     # 0x3f408
movq (%rbp), %r12
addq $0x48, %r12
leaq 0x21c7f(%rip), %rsi     # 0x2d88c
movl $0xf, %edx
movq %r12, %rdi
callq 0x6370
movq 0x98(%rbx), %rsi
leaq 0x10(%rsp), %r13
movq %r13, %rdi
callq 0x17ff4
movq (%r13), %rsi
movq 0x8(%r13), %rdx
movq %r12, %rdi
callq 0x6370
movq %rax, %r12
leaq 0x21e2e(%rip), %rsi     # 0x2da76
movl $0x17, %edx
movq %rax, %rdi
callq 0x6370
movq 0x98(%rbx), %rsi
leaq 0x38(%rsp), %rdi
callq 0x17ff4
leaq 0x337a3(%rip), %rdi     # 0x3f410
leaq 0x38(%rsp), %rsi
callq 0x1a12e
movq 0x8(%rax), %rsi
movq 0x10(%rax), %rdx
movq %r12, %rdi
callq 0x6370
leaq 0x26909(%rip), %rsi     # 0x32597
movl $0x2, %edx
movq %rax, %rdi
callq 0x6370
leaq 0x48(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xbcb6
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x6300
leaq 0x20(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xbcd1
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x6300
movq (%rbp), %r12
movq 0x98(%rbx), %rdi
callq 0x1801e
movl %eax, %ebp
movq 0x98(%rbx), %rdi
callq 0x18022
movq %r12, %rdi
movl %ebp, %esi
movl %eax, %edx
callq 0x1aa40
movl 0xc(%r15), %eax
movq 0x98(%rbx), %rdi
movl %eax, 0x34(%rdi)
callq 0x1801a
cltq
movq (%r14), %rcx
movq (%rcx,%rax,8), %rax
movl 0x28(%rax), %eax
movq 0x98(%rbx), %rdi
movl %eax, 0x38(%rdi)
callq 0x1801a
cltq
movq (%r14), %rcx
movq (%rcx,%rax,8), %rax
movl 0x2c(%rax), %eax
movq 0x98(%rbx), %rsi
movl %eax, 0x3c(%rsi)
leaq 0x58(%rsp), %r12
movq %r12, %rdi
callq 0x17ff4
leaq 0x34(%rsp), %rdx
movq %r15, %rdi
movq %r12, %rsi
callq 0x183ea
movq %rax, %r12
leaq 0x68(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xbd7a
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x6300
movq 0xa0(%rbx), %rdi
testq %rdi, %rdi
je 0xbd8f
movq (%rdi), %rax
movq %r15, %rsi
callq *0x8(%rax)
testq %r12, %r12
je 0xbe53
cmpb $0x1, 0x31(%r12)
jne 0xbe4c
leaq 0x3365d(%rip), %r13     # 0x3f408
movq (%r13), %r15
addq $0x48, %r15
leaq 0x21ad2(%rip), %rsi     # 0x2d88c
movl $0xf, %edx
movq %r15, %rdi
callq 0x6370
movq 0x98(%rbx), %rsi
leaq 0x10(%rsp), %r12
movq %r12, %rdi
callq 0x17ff4
movq (%r12), %rsi
movq 0x8(%r12), %rdx
movq %r15, %rdi
callq 0x6370
movq %rax, %r15
leaq 0x21c98(%rip), %rsi     # 0x2da8e
movl $0x2f, %edx
movq %rax, %rdi
callq 0x6370
movq 0x98(%rbx), %rdi
callq 0x1801e
movq %r15, %rdi
movl %eax, %esi
callq 0x6540
leaq 0xf(%rsp), %rsi
movb $0x3a, (%rsi)
movl $0x1, %edx
movq %rax, %rdi
callq 0x6370
movq %rax, %r15
movq 0x98(%rbx), %rdi
callq 0x18022
movq %r15, %rdi
movl %eax, %esi
callq 0x6540
jmp 0xbf0a
cmpl $0x0, 0x34(%rsp)
je 0xbe67
movq 0x98(%rbx), %rsi
movq %r15, %rdi
callq 0x184e6
jmp 0xbf4f
leaq 0x3359a(%rip), %r13     # 0x3f408
movq (%r13), %r15
addq $0x48, %r15
leaq 0x21a0f(%rip), %rsi     # 0x2d88c
movl $0xf, %edx
movq %r15, %rdi
callq 0x6370
movq 0x98(%rbx), %rsi
leaq 0x10(%rsp), %r12
movq %r12, %rdi
callq 0x17ff4
movq (%r12), %rsi
movq 0x8(%r12), %rdx
movq %r15, %rdi
callq 0x6370
movq %rax, %r15
leaq 0x21c05(%rip), %rsi     # 0x2dabe
movl $0x21, %edx
movq %rax, %rdi
callq 0x6370
movq 0x98(%rbx), %rdi
callq 0x1801e
movq %r15, %rdi
movl %eax, %esi
callq 0x6540
leaq 0xf(%rsp), %rsi
movb $0x3a, (%rsi)
movl $0x1, %edx
movq %rax, %rdi
callq 0x6370
movq %rax, %r15
movq 0x98(%rbx), %rdi
callq 0x18022
movq %r15, %rdi
movl %eax, %esi
callq 0x6540
leaq 0x20(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xbf25
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x6300
movq (%r13), %r15
movq 0x98(%rbx), %rdi
callq 0x1801e
movl %eax, %ebp
movq 0x98(%rbx), %rdi
callq 0x18022
movq %r15, %rdi
movl %ebp, %esi
movl %eax, %edx
callq 0x1aa40
movq 0xa0(%rbx), %rax
testq %rax, %rax
je 0xc097
movl 0x10(%rax), %ebp
movq 0x98(%rbx), %rdi
callq 0x1801a
cmpl %eax, %ebp
je 0xc097
movq 0xa0(%rbx), %rax
cmpl $0x1, 0x10(%rax)
je 0xc097
movq 0x98(%rbx), %rdi
callq 0x1801a
cmpl $0x1, %eax
je 0xc097
leaq 0x33465(%rip), %r13     # 0x3f408
movq (%r13), %r15
addq $0x48, %r15
leaq 0x21b2e(%rip), %rsi     # 0x2dae0
movl $0x14, %edx
movq %r15, %rdi
callq 0x6370
movq 0x98(%rbx), %rsi
leaq 0x10(%rsp), %r12
movq %r12, %rdi
callq 0x17ff4
movq (%r12), %rsi
movq 0x8(%r12), %rdx
movq %r15, %rdi
callq 0x6370
movq %rax, %r15
leaq 0x21b07(%rip), %rsi     # 0x2daf5
movl $0x16, %edx
movq %rax, %rdi
callq 0x6370
movq 0xa0(%rbx), %rax
movslq 0x10(%rax), %rax
movq (%r14), %rcx
movq (%rcx,%rax,8), %rax
movq 0x8(%rax), %rsi
movq 0x10(%rax), %rdx
movq %r15, %rdi
callq 0x6370
movq %rax, %r15
leaq 0x21843(%rip), %rsi     # 0x2d86a
movl $0xd, %edx
movq %rax, %rdi
callq 0x6370
movq 0x98(%rbx), %rdi
callq 0x1801a
cltq
movq (%r14), %rcx
movq (%rcx,%rax,8), %rax
movq 0x8(%rax), %rsi
movq 0x10(%rax), %rdx
movq %r15, %rdi
callq 0x6370
leaq 0x26537(%rip), %rsi     # 0x32597
movl $0x2, %edx
movq %rax, %rdi
callq 0x6370
leaq 0x20(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xc088
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x6300
movq (%r13), %rdi
movl 0x8(%rbx), %esi
movl 0xc(%rbx), %edx
callq 0x1aa40
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xc105
jmp 0xc105
movq %rax, %rbx
leaq 0x68(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xc123
movq 0x68(%rsp), %rsi
jmp 0xc11b
movq %rax, %rbx
leaq 0x88(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xc123
movq 0x88(%rsp), %rsi
jmp 0xc11b
movq %rax, %rbx
leaq 0x48(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xc108
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x6300
jmp 0xc108
jmp 0xc105
movq %rax, %rbx
leaq 0x20(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xc123
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x6300
movq %rbx, %rdi
callq 0x6560
nop