// File: 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:
subq $0x1d8, %rsp            # imm = 0x1D8
movq %rdi, 0x1d0(%rsp)
movq %rsi, 0x1c8(%rsp)
movq 0x1d0(%rsp), %rdi
movq %rdi, 0xd8(%rsp)
addq $0x18, %rdi
callq 0x20ad0
movq 0xd8(%rsp), %rcx
xorl %eax, %eax
cmpq 0xa0(%rcx), %rax
jne 0x19b5d
movq 0x1c8(%rsp), %rax
movq %rax, 0xc8(%rsp)
movl $0x18, %edi
callq 0x6390
movq %rax, %rdi
movq 0xd8(%rsp), %rax
movq %rdi, %rcx
movq %rcx, 0xd0(%rsp)
movq 0x98(%rax), %rsi
callq 0x37fd0
jmp 0x19985
movl $0x18, %edi
callq 0x6390
movq %rax, %rcx
movq 0xd8(%rsp), %rax
movq %rcx, 0xb8(%rsp)
movq 0x98(%rax), %rdi
callq 0x295f0
movl %eax, 0xc4(%rsp)
jmp 0x199b7
movl 0xc4(%rsp), %eax
movslq %eax, %rsi
leaq 0x54b18(%rip), %rdi     # 0x6e4e0
callq 0x1fc90
movq 0xb8(%rsp), %rdi
movq (%rax), %rax
movl 0x28(%rax), %esi
movl $0x2, %edx
callq 0x38010
jmp 0x199e7
movl $0x18, %edi
callq 0x6390
movq %rax, %rdi
movq %rdi, %rax
movq %rax, 0xb0(%rsp)
xorl %esi, %esi
movl $0x2, %edx
callq 0x38010
jmp 0x19a0d
leaq 0x197(%rsp), %rdi
movq %rdi, 0xa8(%rsp)
callq 0x66c0
movq 0xa8(%rsp), %rdx
leaq 0x3a124(%rip), %rsi     # 0x53b55
leaq 0x198(%rsp), %rdi
callq 0x7500
jmp 0x19a40
movq 0xb0(%rsp), %r8
movq 0xb8(%rsp), %rcx
movq 0xd0(%rsp), %rdx
movq 0xc8(%rsp), %rdi
movl $0x9, %esi
leaq 0x198(%rsp), %r9
callq 0x4de80
jmp 0x19a74
leaq 0x198(%rsp), %rdi
callq 0x6778
leaq 0x197(%rsp), %rdi
callq 0x6400
jmp 0x1a097
movq 0xd0(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1c0(%rsp)
movl %eax, 0x1bc(%rsp)
movl $0x18, %esi
callq 0x63a0
jmp 0x1a09f
movq 0xb8(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1c0(%rsp)
movl %eax, 0x1bc(%rsp)
movl $0x18, %esi
callq 0x63a0
jmp 0x1a09f
movq 0xb0(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1c0(%rsp)
movl %eax, 0x1bc(%rsp)
movl $0x18, %esi
callq 0x63a0
jmp 0x1a09f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1c0(%rsp)
movl %eax, 0x1bc(%rsp)
jmp 0x19b4b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1c0(%rsp)
movl %eax, 0x1bc(%rsp)
leaq 0x198(%rsp), %rdi
callq 0x6778
leaq 0x197(%rsp), %rdi
callq 0x6400
jmp 0x1a09f
movl $0x18, %edi
callq 0x6390
movq %rax, %rdi
movq 0xd8(%rsp), %rax
movq %rdi, %rcx
movq %rcx, 0xa0(%rsp)
movq 0x98(%rax), %rsi
callq 0x37fd0
jmp 0x19b8b
movq 0xd8(%rsp), %rax
movq 0xa0(%rsp), %rcx
movq %rcx, 0x188(%rsp)
movq 0xa0(%rax), %rdi
movq 0x1c8(%rsp), %rsi
movq (%rdi), %rax
callq *0x18(%rax)
movq %rax, %rcx
movq 0xd8(%rsp), %rax
movq %rcx, 0x180(%rsp)
movq 0xa0(%rax), %rax
cmpl $0x6, 0x10(%rax)
jne 0x19fbe
movq 0xd8(%rsp), %rax
movq 0x1c8(%rsp), %rdi
movq %rdi, 0x78(%rsp)
movq 0xa0(%rax), %rax
addq $0x18, %rax
movq %rax, 0x80(%rsp)
callq 0x4dfb0
movq 0x78(%rsp), %rdi
movq 0x80(%rsp), %rsi
movl %eax, %edx
callq 0x4dfc0
movq 0x1c8(%rsp), %rax
movq %rax, 0x88(%rsp)
movq 0x188(%rsp), %rax
movq %rax, 0x90(%rsp)
movl $0x18, %edi
callq 0x6390
movq %rax, %rdi
movq %rdi, %rax
movq %rax, 0x98(%rsp)
movl $0x1, %esi
callq 0x38470
jmp 0x19c61
leaq 0x15f(%rsp), %rdi
movq %rdi, 0x70(%rsp)
callq 0x66c0
movq 0x70(%rsp), %rdx
leaq 0x39eee(%rip), %rsi     # 0x53b6d
leaq 0x160(%rsp), %rdi
callq 0x7500
jmp 0x19c8e
movq 0x98(%rsp), %rcx
movq 0x90(%rsp), %rdx
movq 0x88(%rsp), %rdi
xorl %esi, %esi
movl %esi, %r8d
leaq 0x160(%rsp), %r9
callq 0x4de80
jmp 0x19cba
leaq 0x160(%rsp), %rdi
callq 0x6778
leaq 0x15f(%rsp), %rdi
callq 0x6400
movq 0xd8(%rsp), %rax
addq $0x18, %rax
movq %rax, 0x58(%rsp)
movq 0x1c8(%rsp), %rdi
callq 0x4dfb0
movq 0x58(%rsp), %rdi
movl %eax, 0x158(%rsp)
leaq 0x158(%rsp), %rsi
callq 0x20950
movq 0x1c8(%rsp), %rax
movq %rax, 0x60(%rsp)
leaq 0x137(%rsp), %rdi
movq %rdi, 0x68(%rsp)
callq 0x66c0
movq 0x68(%rsp), %rdx
leaq 0x39e81(%rip), %rsi     # 0x53bb7
leaq 0x138(%rsp), %rdi
callq 0x7500
jmp 0x19d45
movq 0x60(%rsp), %rdi
xorl %eax, %eax
movl %eax, %r8d
movl $0x16, %esi
leaq 0x138(%rsp), %r9
movq %r8, %rdx
movq %r8, %rcx
callq 0x4de80
jmp 0x19d69
leaq 0x138(%rsp), %rdi
callq 0x6778
leaq 0x137(%rsp), %rdi
callq 0x6400
movq 0xd8(%rsp), %rax
movq 0x1c8(%rsp), %rdi
movq %rdi, 0x30(%rsp)
movq 0xa0(%rax), %rax
addq $0x30, %rax
movq %rax, 0x38(%rsp)
callq 0x4dfb0
movq 0x30(%rsp), %rdi
movq 0x38(%rsp), %rsi
movl %eax, %edx
callq 0x4dfc0
movq 0x1c8(%rsp), %rax
movq %rax, 0x40(%rsp)
movq 0x188(%rsp), %rax
movq %rax, 0x48(%rsp)
movl $0x18, %edi
callq 0x6390
movq %rax, %rdi
movq %rdi, %rax
movq %rax, 0x50(%rsp)
xorl %esi, %esi
callq 0x38470
jmp 0x19df6
leaq 0x10f(%rsp), %rdi
movq %rdi, 0x28(%rsp)
callq 0x66c0
movq 0x28(%rsp), %rdx
leaq 0x39dda(%rip), %rsi     # 0x53bee
leaq 0x110(%rsp), %rdi
callq 0x7500
jmp 0x19e23
movq 0x50(%rsp), %rcx
movq 0x48(%rsp), %rdx
movq 0x40(%rsp), %rdi
xorl %esi, %esi
movl %esi, %r8d
leaq 0x110(%rsp), %r9
callq 0x4de80
jmp 0x19e46
leaq 0x110(%rsp), %rdi
callq 0x6778
leaq 0x10f(%rsp), %rdi
callq 0x6400
jmp 0x1a097
movq 0xa0(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1c0(%rsp)
movl %eax, 0x1bc(%rsp)
movl $0x18, %esi
callq 0x63a0
jmp 0x1a09f
movq 0x98(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1c0(%rsp)
movl %eax, 0x1bc(%rsp)
movl $0x18, %esi
callq 0x63a0
jmp 0x1a09f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1c0(%rsp)
movl %eax, 0x1bc(%rsp)
jmp 0x19ef2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1c0(%rsp)
movl %eax, 0x1bc(%rsp)
leaq 0x160(%rsp), %rdi
callq 0x6778
leaq 0x15f(%rsp), %rdi
callq 0x6400
jmp 0x1a09f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1c0(%rsp)
movl %eax, 0x1bc(%rsp)
jmp 0x19f3b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1c0(%rsp)
movl %eax, 0x1bc(%rsp)
leaq 0x138(%rsp), %rdi
callq 0x6778
leaq 0x137(%rsp), %rdi
callq 0x6400
jmp 0x1a09f
movq 0x50(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1c0(%rsp)
movl %eax, 0x1bc(%rsp)
movl $0x18, %esi
callq 0x63a0
jmp 0x1a09f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1c0(%rsp)
movl %eax, 0x1bc(%rsp)
jmp 0x19fac
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1c0(%rsp)
movl %eax, 0x1bc(%rsp)
leaq 0x110(%rsp), %rdi
callq 0x6778
leaq 0x10f(%rsp), %rdi
callq 0x6400
jmp 0x1a09f
movq 0x1c8(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0x188(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0x180(%rsp), %rax
movq %rax, 0x18(%rsp)
leaq 0xe7(%rsp), %rdi
movq %rdi, 0x20(%rsp)
callq 0x66c0
movq 0x20(%rsp), %rdx
leaq 0x39c2d(%rip), %rsi     # 0x53c30
leaq 0xe8(%rsp), %rdi
callq 0x7500
jmp 0x1a012
movq 0x18(%rsp), %rcx
movq 0x10(%rsp), %rdx
movq 0x8(%rsp), %rdi
xorl %esi, %esi
movl %esi, %r8d
leaq 0xe8(%rsp), %r9
callq 0x4de80
jmp 0x1a035
leaq 0xe8(%rsp), %rdi
callq 0x6778
leaq 0xe7(%rsp), %rdi
callq 0x6400
jmp 0x1a097
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1c0(%rsp)
movl %eax, 0x1bc(%rsp)
jmp 0x1a088
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1c0(%rsp)
movl %eax, 0x1bc(%rsp)
leaq 0xe8(%rsp), %rdi
callq 0x6778
leaq 0xe7(%rsp), %rdi
callq 0x6400
jmp 0x1a09f
addq $0x1d8, %rsp            # imm = 0x1D8
retq
movq 0x1c0(%rsp), %rdi
callq 0x66b0
nopl (%rax)