// File: /workspace/github_cpp_makefile_star2_O3/kelwinfc[P]ci4721-Fernandez-Gyomrey/src/AST/to_tac.cpp
// Function: AST_struct_access::gen_tac_lval(Tac*, int*)
opd *AST_struct_access::gen_tac_lval(Tac* t, int *sta_base){
    opd *din_base = value->gen_tac_lval(t, sta_base);
    if (union_access) {
        union_type *ud = (union_type*)types.types[ sym->getType() ];
        din_base = gen_tac_lval_disp(t, din_base, sta_base);
        opd *t1 = new opd(), *t2 = new opd((int)sym->index);
        t->append_quad(inst::CP, t1, din_base, new opd(ud->width - 4), "cargando identificador de tipo usado en el union");
        // TODO esto apunta a una instrucción que no existe.
        // se asume que justo después de calcular la posición del campo del struct está la siguiente instrucción que se debe ejecutar.
        t->append_quad(inst::IFEQ, new opd(0), t2, new opd(t->next_instruction() + 7, O_LABEL),
            "permitir la asignación por primera vez a una unión");
        t->append_quad(inst::IFEQ, t1, t2, new opd(t->next_instruction() + 7, O_LABEL),
            "validar que en caso estar actualizado el tipo usado, se mantiene");
        t->append_quad(inst::WRITE, new opd(0), 0, 0, "dirección relativa del string en la tabla \"Se trató de utilizar una propiedad no activa de la unión en (\"");
        t->append_quad(inst::WRITE, new opd(value->line), 0, 0, "número de línea del error");
        t->append_quad(inst::WRITE, new opd(62), 0, 0, "dirección relativa del string en la tabla \", \"");
        t->append_quad(inst::WRITE, new opd(value->column), 0, 0, "número de columna del error");
        t->append_quad(inst::WRITE, new opd(65), 0, 0, "dirección relativa del string en la tabla \")\"");
        t->append_quad(inst::CP, t2, din_base, new opd(ud->width - 4),
            "guardando nuevo identificador de tipo usado en el union");
    }
    *sta_base += sym->offset;
    return din_base;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x148, %rsp            # imm = 0x148
movq %rdx, %rbx
movq %rsi, %r12
movq %rdi, %r14
movq 0x48(%rdi), %rdi
movq (%rdi), %rax
callq *0x38(%rax)
movq %rax, %rbp
cmpb $0x1, 0x78(%r14)
jne 0x113e1
movq 0x70(%r14), %rdi
callq 0x1801a
cltq
leaq 0x2e524(%rip), %rcx     # 0x3f410
movq (%rcx), %rcx
movq (%rcx,%rax,8), %r15
movq %r12, %rdi
movq %rbp, %rsi
movq %rbx, %rdx
callq 0x10758
movq %rax, %rbp
movl $0x18, %edi
callq 0x62f0
movq %rax, 0x8(%rsp)
movq %rax, %rdi
callq 0x1d014
movl $0x18, %edi
callq 0x62f0
movq %rax, %rdi
movq 0x70(%r14), %rax
movl 0x40(%rax), %esi
movq %rdi, (%rsp)
movl $0x2, %edx
callq 0x1d02a
movq %rbx, 0x10(%rsp)
movl $0x18, %edi
callq 0x62f0
movq %rax, %rbx
movq %r15, 0x18(%rsp)
movl 0x28(%r15), %esi
addl $-0x4, %esi
movq %rax, %rdi
movl $0x2, %edx
callq 0x1d02a
leaq 0x138(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x1d7d4(%rip), %rsi     # 0x2e74f
leaq 0x1d7fd(%rip), %rdx     # 0x2e77f
leaq 0x128(%rsp), %r13
movq %r13, %rdi
callq 0x7008
movq %r12, %rdi
xorl %esi, %esi
movq 0x8(%rsp), %rdx
movq %rbp, %rcx
movq %rbx, %r8
movq %r13, %r9
callq 0x2b238
movq 0x128(%rsp), %rdi
cmpq %r15, %rdi
je 0x10fc7
movq 0x138(%rsp), %rsi
incq %rsi
callq 0x6300
movq %r14, 0x20(%rsp)
movl $0x18, %edi
callq 0x62f0
movq %rax, %r13
movq %rax, %rdi
xorl %esi, %esi
movl $0x2, %edx
callq 0x1d02a
movq %rbp, %r14
movl $0x18, %edi
callq 0x62f0
movq %rax, %rbx
movq %r12, %rdi
callq 0x2b316
addl $0x7, %eax
movq %rbx, %rdi
movl %eax, %esi
movl $0x6, %edx
callq 0x1d02a
leaq 0x118(%rsp), %rbp
movq %rbp, -0x10(%rbp)
leaq 0x1d75b(%rip), %rsi     # 0x2e780
leaq 0x1d788(%rip), %rdx     # 0x2e7b4
leaq 0x108(%rsp), %r15
movq %r15, %rdi
callq 0x7008
movq %r12, %rdi
movl $0x18, %esi
movq %r13, %rdx
movq (%rsp), %rcx
movq %rbx, %r8
movq %r15, %r9
callq 0x2b238
movq 0x108(%rsp), %rdi
cmpq %rbp, %rdi
je 0x11073
movq 0x118(%rsp), %rsi
incq %rsi
callq 0x6300
movl $0x18, %edi
callq 0x62f0
movq %rax, %rbx
movq %r12, %rdi
callq 0x2b316
movq %r14, %rbp
addl $0x7, %eax
movq %rbx, %rdi
movl %eax, %esi
movl $0x6, %edx
callq 0x1d02a
leaq 0xf8(%rsp), %r13
movq %r13, -0x10(%r13)
leaq 0x1d705(%rip), %rsi     # 0x2e7b5
leaq 0x1d73e(%rip), %rdx     # 0x2e7f5
leaq 0xe8(%rsp), %r15
movq %r15, %rdi
callq 0x7008
movq %r12, %rdi
movl $0x18, %esi
movq 0x8(%rsp), %rdx
movq (%rsp), %rcx
movq %rbx, %r8
movq %r15, %r9
callq 0x2b238
movq 0x20(%rsp), %r14
movq 0xe8(%rsp), %rdi
cmpq %r13, %rdi
je 0x11105
movq 0xf8(%rsp), %rsi
incq %rsi
callq 0x6300
movl $0x18, %edi
callq 0x62f0
movq %rax, %rbx
movq %rax, %rdi
xorl %esi, %esi
movl $0x2, %edx
callq 0x1d02a
leaq 0xd8(%rsp), %r13
movq %r13, -0x10(%r13)
leaq 0x1d6c2(%rip), %rsi     # 0x2e7f6
leaq 0x1d727(%rip), %rdx     # 0x2e862
leaq 0xc8(%rsp), %r15
movq %r15, %rdi
callq 0x7008
movq %r12, %rdi
movl $0xa, %esi
movq %rbx, %rdx
xorl %ecx, %ecx
xorl %r8d, %r8d
movq %r15, %r9
callq 0x2b238
movq 0xc8(%rsp), %rdi
cmpq %r13, %rdi
je 0x11180
movq 0xd8(%rsp), %rsi
incq %rsi
callq 0x6300
movl $0x18, %edi
callq 0x62f0
movq %rax, %rbx
movq 0x48(%r14), %rax
movl 0x8(%rax), %esi
movq %rbx, %rdi
movl $0x2, %edx
callq 0x1d02a
leaq 0xb8(%rsp), %r13
movq %r13, -0x10(%r13)
leaq 0x1d6af(%rip), %rsi     # 0x2e863
leaq 0x1d6c3(%rip), %rdx     # 0x2e87e
leaq 0xa8(%rsp), %r15
movq %r15, %rdi
callq 0x7008
movq %r12, %rdi
movl $0xa, %esi
movq %rbx, %rdx
xorl %ecx, %ecx
xorl %r8d, %r8d
movq %r15, %r9
callq 0x2b238
movq 0xa8(%rsp), %rdi
cmpq %r13, %rdi
je 0x11200
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x6300
movl $0x18, %edi
callq 0x62f0
movq %rax, %rbx
movq %rax, %rdi
movl $0x3e, %esi
movl $0x2, %edx
callq 0x1d02a
leaq 0x98(%rsp), %r13
movq %r13, -0x10(%r13)
leaq 0x1d64d(%rip), %rsi     # 0x2e87f
leaq 0x1d675(%rip), %rdx     # 0x2e8ae
leaq 0x88(%rsp), %r15
movq %r15, %rdi
callq 0x7008
movq %r12, %rdi
movl $0xa, %esi
movq %rbx, %rdx
xorl %ecx, %ecx
xorl %r8d, %r8d
movq %r15, %r9
callq 0x2b238
movq 0x88(%rsp), %rdi
cmpq %r13, %rdi
je 0x1127e
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x6300
movl $0x18, %edi
callq 0x62f0
movq %rax, %rbx
movq 0x48(%r14), %rax
movl 0xc(%rax), %esi
movq %rbx, %rdi
movl $0x2, %edx
callq 0x1d02a
leaq 0x78(%rsp), %r13
movq %r13, -0x10(%r13)
leaq 0x1d600(%rip), %rsi     # 0x2e8af
leaq 0x1d615(%rip), %rdx     # 0x2e8cb
leaq 0x68(%rsp), %r15
movq %r15, %rdi
callq 0x7008
movq %r12, %rdi
movl $0xa, %esi
movq %rbx, %rdx
xorl %ecx, %ecx
xorl %r8d, %r8d
movq %r15, %r9
callq 0x2b238
movq 0x68(%rsp), %rdi
cmpq %r13, %rdi
je 0x112f2
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x6300
movl $0x18, %edi
callq 0x62f0
movq %rax, %rbx
movq %rax, %rdi
movl $0x41, %esi
movl $0x2, %edx
callq 0x1d02a
leaq 0x58(%rsp), %r13
movq %r13, -0x10(%r13)
leaq 0x1d5ab(%rip), %rsi     # 0x2e8cc
leaq 0x1d5d2(%rip), %rdx     # 0x2e8fa
leaq 0x48(%rsp), %r15
movq %r15, %rdi
callq 0x7008
movq %r12, %rdi
movl $0xa, %esi
movq %rbx, %rdx
xorl %ecx, %ecx
xorl %r8d, %r8d
movq %r15, %r9
callq 0x2b238
movq 0x48(%rsp), %rdi
cmpq %r13, %rdi
movq 0x18(%rsp), %r15
je 0x11369
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x6300
movl $0x18, %edi
callq 0x62f0
movq %rax, %rbx
movl 0x28(%r15), %esi
addl $-0x4, %esi
movq %rax, %rdi
movl $0x2, %edx
callq 0x1d02a
leaq 0x38(%rsp), %r13
movq %r13, -0x10(%r13)
leaq 0x1d561(%rip), %rsi     # 0x2e8fb
leaq 0x1d591(%rip), %rdx     # 0x2e932
leaq 0x28(%rsp), %r15
movq %r15, %rdi
callq 0x7008
movq %r12, %rdi
xorl %esi, %esi
movq (%rsp), %rdx
movq %rbp, %rcx
movq %rbx, %r8
movq %r15, %r9
callq 0x2b238
movq 0x28(%rsp), %rdi
cmpq %r13, %rdi
je 0x113dc
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x6300
movq 0x10(%rsp), %rbx
movq 0x70(%r14), %rax
movl 0x34(%rax), %eax
addl %eax, (%rbx)
movq %rbp, %rax
addq $0x148, %rsp            # imm = 0x148
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
movq 0x28(%rsp), %rdi
cmpq %r13, %rdi
je 0x11557
movq 0x38(%rsp), %rsi
jmp 0x11521
jmp 0x11547
movq %rax, %r14
movq 0x48(%rsp), %rdi
cmpq %r13, %rdi
je 0x11557
movq 0x58(%rsp), %rsi
jmp 0x11521
jmp 0x11547
movq %rax, %r14
movq 0x68(%rsp), %rdi
cmpq %r13, %rdi
je 0x11557
movq 0x78(%rsp), %rsi
jmp 0x11521
jmp 0x11547
movq %rax, %r14
movq 0x88(%rsp), %rdi
cmpq %r13, %rdi
je 0x11557
movq 0x98(%rsp), %rsi
jmp 0x11521
jmp 0x11547
movq %rax, %r14
movq 0xa8(%rsp), %rdi
cmpq %r13, %rdi
je 0x11557
movq 0xb8(%rsp), %rsi
jmp 0x11521
jmp 0x11547
movq %rax, %r14
movq 0xc8(%rsp), %rdi
cmpq %r13, %rdi
je 0x11557
movq 0xd8(%rsp), %rsi
jmp 0x11521
jmp 0x11547
movq %rax, %r14
movq 0xe8(%rsp), %rdi
cmpq %r13, %rdi
je 0x11557
movq 0xf8(%rsp), %rsi
jmp 0x11521
movq %rax, %r14
movq 0x108(%rsp), %rdi
cmpq %rbp, %rdi
je 0x11557
movq 0x118(%rsp), %rsi
jmp 0x11521
movq %rax, %r14
movl $0x18, %esi
movq %r13, %rdi
jmp 0x11552
movq %rax, %r14
movq 0x128(%rsp), %rdi
cmpq %r15, %rdi
je 0x11557
movq 0x138(%rsp), %rsi
incq %rsi
jmp 0x11552
jmp 0x11547
movq %rax, %r14
movl $0x18, %esi
movq (%rsp), %rdi
jmp 0x11552
movq %rax, %r14
movl $0x18, %esi
movq 0x8(%rsp), %rdi
jmp 0x11552
jmp 0x11547
movq %rax, %r14
movl $0x18, %esi
movq %rbx, %rdi
callq 0x6300
movq %r14, %rdi
callq 0x6560
nop