// File: /workspace/github_cpp_makefile_star2_O2/kelwinfc[P]ci4721-Fernandez-Gyomrey/src/AST/to_tac.cpp
// Function: AST_variable_declaration::to_tac(Tac*)
void AST_variable_declaration::to_tac(Tac* t){
    next_list.clear();
    if (0 == value) {
        t->append_quad(inst::INIT, new opd(sym),
            new opd(types.types[ sym->getType() ]->width), new opd(0),
            "inicialización en cero");
        return;
    }
    opd* l = new opd(sym);
    opd* r = value->to_tac(t);
    
    if ( value->type == BOOLEAN){

        t->backpatch( value->truelist, t->next_instruction() );
        t->append_quad(inst::CP, l, new opd(true), 0,
                                "declaración con asignación del valor booleano "
                                "obtenido (true) al lvalue");
        
        next_list.push_back( t->next_instruction() );
        t->append_quad(inst::GOTO, 0, 0, 0, "salto después de declarar y asignar el valor booleano");

        t->backpatch( value->falselist, t->next_instruction() );
        t->append_quad(inst::CP, l, new opd(false), 0, "declaración con asignación de valor booleano obtenido al lvalue");
    } else {
        t->append_quad(inst::CP, l, r, 0, "declaración con asignación de un valor de cualquier tipo obtenido al lvalue");
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq %rsi, %r14
movq %rdi, %r15
leaq 0x18(%rdi), %r12
movq %r12, %rdi
callq 0x124ce
movq 0xa0(%r15), %r13
pushq $0x18
popq %rdi
callq 0x62d0
movq %rax, %rbx
movq 0x98(%r15), %rsi
testq %r13, %r13
je 0xf398
movq %rbx, %rdi
callq 0x18140
movq 0xa0(%r15), %rdi
movq (%rdi), %rax
movq %r14, %rsi
callq *0x18(%rax)
movq 0xa0(%r15), %rbp
cmpl $0x6, 0x10(%rbp)
jne 0xf42c
addq $0x18, %rbp
movq %r14, %rdi
callq 0x2138a
movq %r14, %rdi
movq %rbp, %rsi
movl %eax, %edx
callq 0x21394
pushq $0x18
popq %rdi
callq 0x62d0
movq %rax, %r13
pushq $0x1
popq %rsi
movq %rax, %rdi
callq 0x1837e
leaq 0x158d5(%rip), %rsi     # 0x24b81
leaq 0x68(%rsp), %rdi
leaq 0x4(%rsp), %rdx
callq 0x6d6c
leaq 0x68(%rsp), %r9
movq %r14, %rdi
xorl %esi, %esi
movq %rbx, %rdx
movq %r13, %rcx
xorl %r8d, %r8d
callq 0x212de
leaq 0x68(%rsp), %rdi
callq 0x65c8
movq %r14, %rdi
callq 0x2138a
leaq 0x4(%rsp), %rsi
movl %eax, (%rsi)
movq %r12, %rdi
callq 0x1243c
leaq 0x158d0(%rip), %rsi     # 0x24bcb
leaq 0x48(%rsp), %rdi
leaq 0x4(%rsp), %rdx
callq 0x6d6c
pushq $0x16
popq %rsi
leaq 0x48(%rsp), %r9
movq %r14, %rdi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x212de
leaq 0x48(%rsp), %rdi
callq 0x65c8
movq 0xa0(%r15), %r15
addq $0x30, %r15
movq %r14, %rdi
callq 0x2138a
movq %r14, %rdi
movq %r15, %rsi
movl %eax, %edx
callq 0x21394
pushq $0x18
popq %rdi
callq 0x62d0
movq %rax, %r15
movq %rax, %rdi
xorl %esi, %esi
callq 0x1837e
leaq 0x1589b(%rip), %rsi     # 0x24c02
leaq 0x28(%rsp), %rdi
leaq 0x4(%rsp), %rdx
callq 0x6d6c
leaq 0x28(%rsp), %r9
movq %r14, %rdi
xorl %esi, %esi
movq %rbx, %rdx
movq %r15, %rcx
xorl %r8d, %r8d
callq 0x212de
leaq 0x28(%rsp), %rdi
jmp 0xf462
movq %rbx, %rdi
callq 0x18140
pushq $0x18
popq %rdi
callq 0x62d0
movq %rax, %r12
movq 0x98(%r15), %rdi
callq 0x13f0c
cltq
leaq 0x29048(%rip), %rcx     # 0x38408
movq (%rcx), %rcx
movq (%rcx,%rax,8), %rax
movl 0x28(%rax), %esi
pushq $0x2
popq %rdx
movq %r12, %rdi
callq 0x1815e
pushq $0x18
popq %rdi
callq 0x62d0
movq %rax, %r15
pushq $0x2
popq %rdx
movq %rax, %rdi
xorl %esi, %esi
callq 0x1815e
leaq 0x15775(%rip), %rsi     # 0x24b69
leaq 0x88(%rsp), %rdi
leaq 0x4(%rsp), %rdx
callq 0x6d6c
pushq $0x9
popq %rsi
leaq 0x88(%rsp), %r9
movq %r14, %rdi
movq %rbx, %rdx
movq %r12, %rcx
movq %r15, %r8
callq 0x212de
leaq 0x88(%rsp), %rdi
jmp 0xf462
movq %rax, %r13
leaq 0x1580e(%rip), %rsi     # 0x24c44
leaq 0x8(%rsp), %rdi
leaq 0x4(%rsp), %rdx
callq 0x6d6c
leaq 0x8(%rsp), %r9
movq %r14, %rdi
xorl %esi, %esi
movq %rbx, %rdx
movq %r13, %rcx
xorl %r8d, %r8d
callq 0x212de
leaq 0x8(%rsp), %rdi
callq 0x65c8
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
leaq 0x28(%rsp), %rdi
jmp 0xf4c1
jmp 0xf4c8
jmp 0xf4cd
movq %rax, %r14
leaq 0x48(%rsp), %rdi
jmp 0xf4c1
jmp 0xf4c8
movq %rax, %r14
leaq 0x68(%rsp), %rdi
jmp 0xf4c1
movq %rax, %r14
leaq 0x8(%rsp), %rdi
jmp 0xf4c1
jmp 0xf4c8
jmp 0xf4c8
movq %rax, %r14
pushq $0x18
popq %rsi
movq %r13, %rdi
jmp 0xf4ee
movq %rax, %r14
leaq 0x88(%rsp), %rdi
callq 0x65c8
jmp 0xf4f3
movq %rax, %r14
jmp 0xf4f3
movq %rax, %r14
pushq $0x18
popq %rsi
movq %r15, %rdi
jmp 0xf4ee
jmp 0xf4da
movq %rax, %r14
pushq $0x18
popq %rsi
movq %rbx, %rdi
jmp 0xf4ee
movq %rax, %r14
pushq $0x18
popq %rsi
movq %r12, %rdi
callq 0x62e0
movq %r14, %rdi
callq 0x6530
nop