// File: kelwinfc[P]ci4721-Fernandez-Gyomrey/src/AST/to_tac.cpp
// Function: AST_assignment::to_tac(Tac*)
void AST_assignment::to_tac(Tac* t){
    next_list.clear();

    opd* l = lvalue->to_tac(t);
    opd* r = expr->to_tac(t);
    
    if ( expr->type == BOOLEAN){

        t->backpatch( expr->truelist, t->next_instruction() );
        t->append_quad(inst::CP, l, new opd(true), 0, "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 asignar el valor booleano");

        t->backpatch( expr->falselist, t->next_instruction() );
        t->append_quad(inst::CP, l, new opd(false), 0, "asignación de valor booleano obtenido (false) al lvalue");
    } else {
        t->append_quad(inst::CP, l, r, 0, "asignación de un valor de cualquier tipo obtenido al lvalue");
    }
}

// Assembly:
subq $0x178, %rsp            # imm = 0x178
movq %rdi, 0x170(%rsp)
movq %rsi, 0x168(%rsp)
movq 0x170(%rsp), %rdi
movq %rdi, 0xa0(%rsp)
addq $0x18, %rdi
callq 0x20ad0
movq 0xa0(%rsp), %rax
movq 0x78(%rax), %rdi
movq 0x168(%rsp), %rsi
movq (%rdi), %rax
callq *0x18(%rax)
movq %rax, %rcx
movq 0xa0(%rsp), %rax
movq %rcx, 0x160(%rsp)
movq 0x80(%rax), %rdi
movq 0x168(%rsp), %rsi
movq (%rdi), %rax
callq *0x18(%rax)
movq %rax, %rcx
movq 0xa0(%rsp), %rax
movq %rcx, 0x158(%rsp)
movq 0x80(%rax), %rax
cmpl $0x6, 0x10(%rax)
jne 0x1ac9d
movq 0xa0(%rsp), %rax
movq 0x168(%rsp), %rdi
movq %rdi, 0x78(%rsp)
movq 0x80(%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 0x1a96b
leaq 0x127(%rsp), %rdi
movq %rdi, 0x70(%rsp)
callq 0x66c0
movq 0x70(%rsp), %rdx
leaq 0x391f5(%rip), %rsi     # 0x53b7e
leaq 0x128(%rsp), %rdi
callq 0x7500
jmp 0x1a998
movq 0x98(%rsp), %rcx
movq 0x90(%rsp), %rdx
movq 0x88(%rsp), %rdi
xorl %esi, %esi
movl %esi, %r8d
leaq 0x128(%rsp), %r9
callq 0x4de80
jmp 0x1a9c4
leaq 0x128(%rsp), %rdi
callq 0x6778
leaq 0x127(%rsp), %rdi
callq 0x6400
movq 0xa0(%rsp), %rax
addq $0x18, %rax
movq %rax, 0x58(%rsp)
movq 0x168(%rsp), %rdi
callq 0x4dfb0
movq 0x58(%rsp), %rdi
movl %eax, 0x120(%rsp)
leaq 0x120(%rsp), %rsi
callq 0x20950
movq 0x168(%rsp), %rax
movq %rax, 0x60(%rsp)
leaq 0xff(%rsp), %rdi
movq %rdi, 0x68(%rsp)
callq 0x66c0
movq 0x68(%rsp), %rdx
leaq 0x385bd(%rip), %rsi     # 0x52ffd
leaq 0x100(%rsp), %rdi
callq 0x7500
jmp 0x1aa4f
movq 0x60(%rsp), %rdi
xorl %eax, %eax
movl %eax, %r8d
movl $0x16, %esi
leaq 0x100(%rsp), %r9
movq %r8, %rdx
movq %r8, %rcx
callq 0x4de80
jmp 0x1aa73
leaq 0x100(%rsp), %rdi
callq 0x6778
leaq 0xff(%rsp), %rdi
callq 0x6400
movq 0xa0(%rsp), %rax
movq 0x168(%rsp), %rdi
movq %rdi, 0x30(%rsp)
movq 0x80(%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 0x168(%rsp), %rax
movq %rax, 0x40(%rsp)
movq 0x160(%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 0x1ab00
leaq 0xd7(%rsp), %rdi
movq %rdi, 0x28(%rsp)
callq 0x66c0
movq 0x28(%rsp), %rdx
leaq 0x391c1(%rip), %rsi     # 0x53cdf
leaq 0xd8(%rsp), %rdi
callq 0x7500
jmp 0x1ab2d
movq 0x50(%rsp), %rcx
movq 0x48(%rsp), %rdx
movq 0x40(%rsp), %rdi
xorl %esi, %esi
movl %esi, %r8d
leaq 0xd8(%rsp), %r9
callq 0x4de80
jmp 0x1ab50
leaq 0xd8(%rsp), %rdi
callq 0x6778
leaq 0xd7(%rsp), %rdi
callq 0x6400
jmp 0x1ad76
movq 0x98(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x150(%rsp)
movl %eax, 0x14c(%rsp)
movl $0x18, %esi
callq 0x63a0
jmp 0x1ad7e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x150(%rsp)
movl %eax, 0x14c(%rsp)
jmp 0x1abd1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x150(%rsp)
movl %eax, 0x14c(%rsp)
leaq 0x128(%rsp), %rdi
callq 0x6778
leaq 0x127(%rsp), %rdi
callq 0x6400
jmp 0x1ad7e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x150(%rsp)
movl %eax, 0x14c(%rsp)
jmp 0x1ac1a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x150(%rsp)
movl %eax, 0x14c(%rsp)
leaq 0x100(%rsp), %rdi
callq 0x6778
leaq 0xff(%rsp), %rdi
callq 0x6400
jmp 0x1ad7e
movq 0x50(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x150(%rsp)
movl %eax, 0x14c(%rsp)
movl $0x18, %esi
callq 0x63a0
jmp 0x1ad7e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x150(%rsp)
movl %eax, 0x14c(%rsp)
jmp 0x1ac8b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x150(%rsp)
movl %eax, 0x14c(%rsp)
leaq 0xd8(%rsp), %rdi
callq 0x6778
leaq 0xd7(%rsp), %rdi
callq 0x6400
jmp 0x1ad7e
movq 0x168(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0x160(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0x158(%rsp), %rax
movq %rax, 0x18(%rsp)
leaq 0xaf(%rsp), %rdi
movq %rdi, 0x20(%rsp)
callq 0x66c0
movq 0x20(%rsp), %rdx
leaq 0x38f5f(%rip), %rsi     # 0x53c41
leaq 0xb0(%rsp), %rdi
callq 0x7500
jmp 0x1acf1
movq 0x18(%rsp), %rcx
movq 0x10(%rsp), %rdx
movq 0x8(%rsp), %rdi
xorl %esi, %esi
movl %esi, %r8d
leaq 0xb0(%rsp), %r9
callq 0x4de80
jmp 0x1ad14
leaq 0xb0(%rsp), %rdi
callq 0x6778
leaq 0xaf(%rsp), %rdi
callq 0x6400
jmp 0x1ad76
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x150(%rsp)
movl %eax, 0x14c(%rsp)
jmp 0x1ad67
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x150(%rsp)
movl %eax, 0x14c(%rsp)
leaq 0xb0(%rsp), %rdi
callq 0x6778
leaq 0xaf(%rsp), %rdi
callq 0x6400
jmp 0x1ad7e
addq $0x178, %rsp            # imm = 0x178
retq
movq 0x150(%rsp), %rdi
callq 0x66b0
nopl (%rax,%rax)