// File: kelwinfc[P]ci4721-Fernandez-Gyomrey/src/AST/to_tac.cpp
// Function: AST_return::to_tac(Tac*)
void AST_return::to_tac(Tac* t){
    opd* r = 0;
    if ( expr ){
        r = expr->to_tac(t);
        if (BOOLEAN == expr->type) {
            r = new opd();
            t->backpatch( expr->truelist, t->next_instruction() );
            t->append_quad(inst::CP, r, new opd(true), 0, "returno del valor booleano obtenido (true)");

            t->append_quad(inst::GOTO, 0, 0, new opd(t->next_instruction() + 2, O_LABEL), "salto después de asignar el valor booleano");

            t->backpatch( expr->falselist, t->next_instruction() );
            t->append_quad(inst::CP, r, new opd(false), 0, "returno de valor booleano obtenido (false)");
        }
    }
    
    return_list.push_back(t->next_instruction());
    t->append_quad(inst::RETURN, r, 0, 0, "retorno de funcion");
}

// Assembly:
subq $0x178, %rsp            # imm = 0x178
movq %rdi, 0x170(%rsp)
movq %rsi, 0x168(%rsp)
movq 0x170(%rsp), %rax
movq %rax, 0xa8(%rsp)
movq $0x0, 0x160(%rsp)
cmpq $0x0, 0x78(%rax)
je 0x1b276
movq 0xa8(%rsp), %rax
movq 0x78(%rax), %rdi
movq 0x168(%rsp), %rsi
movq (%rdi), %rax
callq *0x18(%rax)
movq %rax, %rcx
movq 0xa8(%rsp), %rax
movq %rcx, 0x160(%rsp)
movq 0x78(%rax), %rcx
movl $0x6, %eax
cmpl 0x10(%rcx), %eax
jne 0x1b274
movl $0x18, %edi
callq 0x6390
movq %rax, %rdi
movq %rdi, %rax
movq %rax, 0xa0(%rsp)
callq 0x37ff0
jmp 0x1ae5c
movq 0xa8(%rsp), %rax
movq 0xa0(%rsp), %rcx
movq %rcx, 0x160(%rsp)
movq 0x168(%rsp), %rdi
movq %rdi, 0x78(%rsp)
movq 0x78(%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 0x168(%rsp), %rax
movq %rax, 0x88(%rsp)
movq 0x160(%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 0x1aeee
leaq 0x12f(%rsp), %rdi
movq %rdi, 0x70(%rsp)
callq 0x66c0
movq 0x70(%rsp), %rdx
leaq 0x38e0c(%rip), %rsi     # 0x53d18
leaq 0x130(%rsp), %rdi
callq 0x7500
jmp 0x1af1b
movq 0x98(%rsp), %rcx
movq 0x90(%rsp), %rdx
movq 0x88(%rsp), %rdi
xorl %esi, %esi
movl %esi, %r8d
leaq 0x130(%rsp), %r9
callq 0x4de80
jmp 0x1af47
leaq 0x130(%rsp), %rdi
callq 0x6778
leaq 0x12f(%rsp), %rdi
callq 0x6400
movq 0x168(%rsp), %rax
movq %rax, 0x58(%rsp)
movl $0x18, %edi
callq 0x6390
movq %rax, 0x60(%rsp)
movq 0x168(%rsp), %rdi
callq 0x4dfb0
movl %eax, 0x6c(%rsp)
jmp 0x1af90
movq 0x60(%rsp), %rdi
movl 0x6c(%rsp), %esi
addl $0x2, %esi
movl $0x6, %edx
callq 0x38010
jmp 0x1afa8
leaq 0x107(%rsp), %rdi
movq %rdi, 0x50(%rsp)
callq 0x66c0
movq 0x50(%rsp), %rdx
leaq 0x38037(%rip), %rsi     # 0x52ffd
leaq 0x108(%rsp), %rdi
callq 0x7500
jmp 0x1afd5
movq 0x60(%rsp), %r8
movq 0x58(%rsp), %rdi
xorl %eax, %eax
movl %eax, %ecx
movl $0x16, %esi
leaq 0x108(%rsp), %r9
movq %rcx, %rdx
callq 0x4de80
jmp 0x1affa
leaq 0x108(%rsp), %rdi
callq 0x6778
leaq 0x107(%rsp), %rdi
callq 0x6400
movq 0xa8(%rsp), %rax
movq 0x168(%rsp), %rdi
movq %rdi, 0x28(%rsp)
movq 0x78(%rax), %rax
addq $0x30, %rax
movq %rax, 0x30(%rsp)
callq 0x4dfb0
movq 0x28(%rsp), %rdi
movq 0x30(%rsp), %rsi
movl %eax, %edx
callq 0x4dfc0
movq 0x168(%rsp), %rax
movq %rax, 0x38(%rsp)
movq 0x160(%rsp), %rax
movq %rax, 0x40(%rsp)
movl $0x18, %edi
callq 0x6390
movq %rax, %rdi
movq %rdi, %rax
movq %rax, 0x48(%rsp)
xorl %esi, %esi
callq 0x38470
jmp 0x1b084
leaq 0xdf(%rsp), %rdi
movq %rdi, 0x20(%rsp)
callq 0x66c0
movq 0x20(%rsp), %rdx
leaq 0x38ca1(%rip), %rsi     # 0x53d43
leaq 0xe0(%rsp), %rdi
callq 0x7500
jmp 0x1b0b1
movq 0x48(%rsp), %rcx
movq 0x40(%rsp), %rdx
movq 0x38(%rsp), %rdi
xorl %esi, %esi
movl %esi, %r8d
leaq 0xe0(%rsp), %r9
callq 0x4de80
jmp 0x1b0d4
leaq 0xe0(%rsp), %rdi
callq 0x6778
leaq 0xdf(%rsp), %rdi
callq 0x6400
jmp 0x1b274
movq 0xa0(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x158(%rsp)
movl %eax, 0x154(%rsp)
movl $0x18, %esi
callq 0x63a0
jmp 0x1b37e
movq 0x98(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x158(%rsp)
movl %eax, 0x154(%rsp)
movl $0x18, %esi
callq 0x63a0
jmp 0x1b37e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x158(%rsp)
movl %eax, 0x154(%rsp)
jmp 0x1b180
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x158(%rsp)
movl %eax, 0x154(%rsp)
leaq 0x130(%rsp), %rdi
callq 0x6778
leaq 0x12f(%rsp), %rdi
callq 0x6400
jmp 0x1b37e
movq 0x60(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x158(%rsp)
movl %eax, 0x154(%rsp)
movl $0x18, %esi
callq 0x63a0
jmp 0x1b37e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x158(%rsp)
movl %eax, 0x154(%rsp)
jmp 0x1b1f1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x158(%rsp)
movl %eax, 0x154(%rsp)
leaq 0x108(%rsp), %rdi
callq 0x6778
leaq 0x107(%rsp), %rdi
callq 0x6400
jmp 0x1b37e
movq 0x48(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x158(%rsp)
movl %eax, 0x154(%rsp)
movl $0x18, %esi
callq 0x63a0
jmp 0x1b37e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x158(%rsp)
movl %eax, 0x154(%rsp)
jmp 0x1b262
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x158(%rsp)
movl %eax, 0x154(%rsp)
leaq 0xe0(%rsp), %rdi
callq 0x6778
leaq 0xdf(%rsp), %rdi
callq 0x6400
jmp 0x1b37e
jmp 0x1b276
movq 0xa8(%rsp), %rax
addq $0x60, %rax
movq %rax, (%rsp)
movq 0x168(%rsp), %rdi
callq 0x4dfb0
movq (%rsp), %rdi
movl %eax, 0xd8(%rsp)
leaq 0xd8(%rsp), %rsi
callq 0x20950
movq 0x168(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0x160(%rsp), %rax
movq %rax, 0x10(%rsp)
leaq 0xb7(%rsp), %rdi
movq %rdi, 0x18(%rsp)
callq 0x66c0
movq 0x18(%rsp), %rdx
leaq 0x38a8b(%rip), %rsi     # 0x53d6e
leaq 0xb8(%rsp), %rdi
callq 0x7500
jmp 0x1b2f2
movq 0x10(%rsp), %rdx
movq 0x8(%rsp), %rdi
xorl %eax, %eax
movl %eax, %r8d
movl $0x10, %esi
leaq 0xb8(%rsp), %r9
movq %r8, %rcx
callq 0x4de80
jmp 0x1b318
leaq 0xb8(%rsp), %rdi
callq 0x6778
leaq 0xb7(%rsp), %rdi
callq 0x6400
addq $0x178, %rsp            # imm = 0x178
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x158(%rsp)
movl %eax, 0x154(%rsp)
jmp 0x1b371
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x158(%rsp)
movl %eax, 0x154(%rsp)
leaq 0xb8(%rsp), %rdi
callq 0x6778
leaq 0xb7(%rsp), %rdi
callq 0x6400
movq 0x158(%rsp), %rdi
callq 0x66b0
nopl (%rax,%rax)