// File: kelwinfc[P]ci4721-Fernandez-Gyomrey/src/AST/to_tac.cpp
// Function: AST_function::to_tac(Tac*)
void AST_function::to_tac(Tac* t){
    
    func_to_prologue[func->getName()] = t->next_instruction();
    t->append_quad(inst::PROLOGUE,  0, 0, new opd(func),
                            "prologo de funcion " + func->getName()
                  );
    
    instructions->to_tac(t);
    
    t->backpatch( instructions->next_list, t->next_instruction() );
    t->backpatch( instructions->return_list, t->next_instruction() );
    
    func_to_epilogue[func->getName()] = t->next_instruction();
    t->append_quad(inst::EPILOGUE,  0, 0, new opd(func),
                            "epilogo de funcion " + func->getName()
                  );
}

// Assembly:
subq $0x168, %rsp            # imm = 0x168
movq %rdi, 0x160(%rsp)
movq %rsi, 0x158(%rsp)
movq 0x160(%rsp), %rax
movq %rax, 0x68(%rsp)
movq 0x158(%rsp), %rdi
callq 0x4dfb0
movl %eax, %ecx
movq 0x68(%rsp), %rax
movl %ecx, 0x74(%rsp)
movq 0x98(%rax), %rsi
leaq 0x138(%rsp), %rdi
movq %rdi, 0x78(%rsp)
callq 0x295b0
movq 0x78(%rsp), %rsi
leaq 0x54287(%rip), %rdi     # 0x6e3e8
callq 0x20cd0
movq %rax, 0x80(%rsp)
jmp 0x1a170
movq 0x80(%rsp), %rax
movl 0x74(%rsp), %ecx
movl %ecx, (%rax)
leaq 0x138(%rsp), %rdi
callq 0x6778
movq 0x158(%rsp), %rax
movq %rax, 0x58(%rsp)
movl $0x18, %edi
callq 0x6390
movq %rax, %rdi
movq 0x68(%rsp), %rax
movq %rdi, %rcx
movq %rcx, 0x60(%rsp)
movq 0x98(%rax), %rsi
callq 0x37fd0
jmp 0x1a1c0
movq 0x68(%rsp), %rax
movq 0x98(%rax), %rsi
leaq 0xe8(%rsp), %rdi
movq %rdi, 0x50(%rsp)
callq 0x295b0
movq 0x50(%rsp), %rdx
leaq 0x39acd(%rip), %rsi     # 0x53cb7
leaq 0x108(%rsp), %rdi
callq 0x20dc0
jmp 0x1a1f9
movq 0x60(%rsp), %r8
movq 0x58(%rsp), %rdi
xorl %eax, %eax
movl %eax, %ecx
movl $0xe, %esi
leaq 0x108(%rsp), %r9
movq %rcx, %rdx
callq 0x4de80
jmp 0x1a21e
leaq 0x108(%rsp), %rdi
callq 0x6778
leaq 0xe8(%rsp), %rdi
callq 0x6778
movq 0x68(%rsp), %rax
movq 0xa8(%rax), %rdi
movq 0x158(%rsp), %rsi
movq (%rdi), %rax
movq 0x10(%rax), %rax
callq *%rax
movq 0x68(%rsp), %rax
movq 0x158(%rsp), %rdi
movq %rdi, 0x18(%rsp)
movq 0xa8(%rax), %rax
addq $0x18, %rax
movq %rax, 0x20(%rsp)
callq 0x4dfb0
movq 0x18(%rsp), %rdi
movq 0x20(%rsp), %rsi
movl %eax, %edx
callq 0x4dfc0
movq 0x68(%rsp), %rax
movq 0x158(%rsp), %rdi
movq %rdi, 0x28(%rsp)
movq 0xa8(%rax), %rax
addq $0x60, %rax
movq %rax, 0x30(%rsp)
callq 0x4dfb0
movq 0x28(%rsp), %rdi
movq 0x30(%rsp), %rsi
movl %eax, %edx
callq 0x4dfc0
movq 0x158(%rsp), %rdi
callq 0x4dfb0
movl %eax, %ecx
movq 0x68(%rsp), %rax
movl %ecx, 0x3c(%rsp)
movq 0x98(%rax), %rsi
leaq 0xc8(%rsp), %rdi
movq %rdi, 0x40(%rsp)
callq 0x295b0
movq 0x40(%rsp), %rsi
leaq 0x54116(%rip), %rdi     # 0x6e418
callq 0x20cd0
movq %rax, 0x48(%rsp)
jmp 0x1a30e
movq 0x48(%rsp), %rax
movl 0x3c(%rsp), %ecx
movl %ecx, (%rax)
leaq 0xc8(%rsp), %rdi
callq 0x6778
movq 0x158(%rsp), %rax
movq %rax, 0x8(%rsp)
movl $0x18, %edi
callq 0x6390
movq %rax, %rdi
movq 0x68(%rsp), %rax
movq %rdi, %rcx
movq %rcx, 0x10(%rsp)
movq 0x98(%rax), %rsi
callq 0x37fd0
jmp 0x1a35b
movq 0x68(%rsp), %rax
movq 0x98(%rax), %rsi
leaq 0x88(%rsp), %rdi
movq %rdi, (%rsp)
callq 0x295b0
movq (%rsp), %rdx
leaq 0x39948(%rip), %rsi     # 0x53ccb
leaq 0xa8(%rsp), %rdi
callq 0x20dc0
jmp 0x1a392
movq 0x10(%rsp), %r8
movq 0x8(%rsp), %rdi
xorl %eax, %eax
movl %eax, %ecx
movl $0xf, %esi
leaq 0xa8(%rsp), %r9
movq %rcx, %rdx
callq 0x4de80
jmp 0x1a3b7
leaq 0xa8(%rsp), %rdi
callq 0x6778
leaq 0x88(%rsp), %rdi
callq 0x6778
addq $0x168, %rsp            # imm = 0x168
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x130(%rsp)
movl %eax, 0x12c(%rsp)
leaq 0x138(%rsp), %rdi
callq 0x6778
jmp 0x1a4fc
movq 0x60(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x130(%rsp)
movl %eax, 0x12c(%rsp)
movl $0x18, %esi
callq 0x63a0
jmp 0x1a4fc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x130(%rsp)
movl %eax, 0x12c(%rsp)
jmp 0x1a45e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x130(%rsp)
movl %eax, 0x12c(%rsp)
leaq 0x108(%rsp), %rdi
callq 0x6778
leaq 0xe8(%rsp), %rdi
callq 0x6778
jmp 0x1a4fc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x130(%rsp)
movl %eax, 0x12c(%rsp)
leaq 0xc8(%rsp), %rdi
callq 0x6778
jmp 0x1a4fc
movq 0x10(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x130(%rsp)
movl %eax, 0x12c(%rsp)
movl $0x18, %esi
callq 0x63a0
jmp 0x1a4fc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x130(%rsp)
movl %eax, 0x12c(%rsp)
jmp 0x1a4ef
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x130(%rsp)
movl %eax, 0x12c(%rsp)
leaq 0xa8(%rsp), %rdi
callq 0x6778
leaq 0x88(%rsp), %rdi
callq 0x6778
movq 0x130(%rsp), %rdi
callq 0x66b0
nopl (%rax)