// File: /workspace/github_cpp_makefile_star2_O1/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 0x11381
movq 0x70(%r14), %rdi
callq 0x17fde
cltq
leaq 0x2d57c(%rip), %rcx     # 0x3e408
movq (%rcx), %rcx
movq (%rcx,%rax,8), %r15
movq %r12, %rdi
movq %rbp, %rsi
movq %rbx, %rdx
callq 0x106f8
movq %rax, %rbp
movl $0x18, %edi
callq 0x62e0
movq %rax, 0x8(%rsp)
movq %rax, %rdi
callq 0x1cfb4
movl $0x18, %edi
callq 0x62e0
movq %rax, %rdi
movq 0x70(%r14), %rax
movl 0x40(%rax), %esi
movq %rdi, (%rsp)
movl $0x2, %edx
callq 0x1cfca
movq %rbx, 0x10(%rsp)
movl $0x18, %edi
callq 0x62e0
movq %rax, %rbx
movq %r15, 0x18(%rsp)
movl 0x28(%r15), %esi
addl $-0x4, %esi
movq %rax, %rdi
movl $0x2, %edx
callq 0x1cfca
leaq 0x138(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x1c834(%rip), %rsi     # 0x2d74f
leaq 0x1c85d(%rip), %rdx     # 0x2d77f
leaq 0x128(%rsp), %r13
movq %r13, %rdi
callq 0x6fec
movq %r12, %rdi
xorl %esi, %esi
movq 0x8(%rsp), %rdx
movq %rbp, %rcx
movq %rbx, %r8
movq %r13, %r9
callq 0x2ae24
movq 0x128(%rsp), %rdi
cmpq %r15, %rdi
je 0x10f67
movq 0x138(%rsp), %rsi
incq %rsi
callq 0x62f0
movq %r14, 0x20(%rsp)
movl $0x18, %edi
callq 0x62e0
movq %rax, %r13
movq %rax, %rdi
xorl %esi, %esi
movl $0x2, %edx
callq 0x1cfca
movq %rbp, %r14
movl $0x18, %edi
callq 0x62e0
movq %rax, %rbx
movq %r12, %rdi
callq 0x2af04
addl $0x7, %eax
movq %rbx, %rdi
movl %eax, %esi
movl $0x6, %edx
callq 0x1cfca
leaq 0x118(%rsp), %rbp
movq %rbp, -0x10(%rbp)
leaq 0x1c7bb(%rip), %rsi     # 0x2d780
leaq 0x1c7e8(%rip), %rdx     # 0x2d7b4
leaq 0x108(%rsp), %r15
movq %r15, %rdi
callq 0x6fec
movq %r12, %rdi
movl $0x18, %esi
movq %r13, %rdx
movq (%rsp), %rcx
movq %rbx, %r8
movq %r15, %r9
callq 0x2ae24
movq 0x108(%rsp), %rdi
cmpq %rbp, %rdi
je 0x11013
movq 0x118(%rsp), %rsi
incq %rsi
callq 0x62f0
movl $0x18, %edi
callq 0x62e0
movq %rax, %rbx
movq %r12, %rdi
callq 0x2af04
movq %r14, %rbp
addl $0x7, %eax
movq %rbx, %rdi
movl %eax, %esi
movl $0x6, %edx
callq 0x1cfca
leaq 0xf8(%rsp), %r13
movq %r13, -0x10(%r13)
leaq 0x1c765(%rip), %rsi     # 0x2d7b5
leaq 0x1c79e(%rip), %rdx     # 0x2d7f5
leaq 0xe8(%rsp), %r15
movq %r15, %rdi
callq 0x6fec
movq %r12, %rdi
movl $0x18, %esi
movq 0x8(%rsp), %rdx
movq (%rsp), %rcx
movq %rbx, %r8
movq %r15, %r9
callq 0x2ae24
movq 0x20(%rsp), %r14
movq 0xe8(%rsp), %rdi
cmpq %r13, %rdi
je 0x110a5
movq 0xf8(%rsp), %rsi
incq %rsi
callq 0x62f0
movl $0x18, %edi
callq 0x62e0
movq %rax, %rbx
movq %rax, %rdi
xorl %esi, %esi
movl $0x2, %edx
callq 0x1cfca
leaq 0xd8(%rsp), %r13
movq %r13, -0x10(%r13)
leaq 0x1c722(%rip), %rsi     # 0x2d7f6
leaq 0x1c787(%rip), %rdx     # 0x2d862
leaq 0xc8(%rsp), %r15
movq %r15, %rdi
callq 0x6fec
movq %r12, %rdi
movl $0xa, %esi
movq %rbx, %rdx
xorl %ecx, %ecx
xorl %r8d, %r8d
movq %r15, %r9
callq 0x2ae24
movq 0xc8(%rsp), %rdi
cmpq %r13, %rdi
je 0x11120
movq 0xd8(%rsp), %rsi
incq %rsi
callq 0x62f0
movl $0x18, %edi
callq 0x62e0
movq %rax, %rbx
movq 0x48(%r14), %rax
movl 0x8(%rax), %esi
movq %rbx, %rdi
movl $0x2, %edx
callq 0x1cfca
leaq 0xb8(%rsp), %r13
movq %r13, -0x10(%r13)
leaq 0x1c70f(%rip), %rsi     # 0x2d863
leaq 0x1c723(%rip), %rdx     # 0x2d87e
leaq 0xa8(%rsp), %r15
movq %r15, %rdi
callq 0x6fec
movq %r12, %rdi
movl $0xa, %esi
movq %rbx, %rdx
xorl %ecx, %ecx
xorl %r8d, %r8d
movq %r15, %r9
callq 0x2ae24
movq 0xa8(%rsp), %rdi
cmpq %r13, %rdi
je 0x111a0
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x62f0
movl $0x18, %edi
callq 0x62e0
movq %rax, %rbx
movq %rax, %rdi
movl $0x3e, %esi
movl $0x2, %edx
callq 0x1cfca
leaq 0x98(%rsp), %r13
movq %r13, -0x10(%r13)
leaq 0x1c6ad(%rip), %rsi     # 0x2d87f
leaq 0x1c6d5(%rip), %rdx     # 0x2d8ae
leaq 0x88(%rsp), %r15
movq %r15, %rdi
callq 0x6fec
movq %r12, %rdi
movl $0xa, %esi
movq %rbx, %rdx
xorl %ecx, %ecx
xorl %r8d, %r8d
movq %r15, %r9
callq 0x2ae24
movq 0x88(%rsp), %rdi
cmpq %r13, %rdi
je 0x1121e
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x62f0
movl $0x18, %edi
callq 0x62e0
movq %rax, %rbx
movq 0x48(%r14), %rax
movl 0xc(%rax), %esi
movq %rbx, %rdi
movl $0x2, %edx
callq 0x1cfca
leaq 0x78(%rsp), %r13
movq %r13, -0x10(%r13)
leaq 0x1c660(%rip), %rsi     # 0x2d8af
leaq 0x1c675(%rip), %rdx     # 0x2d8cb
leaq 0x68(%rsp), %r15
movq %r15, %rdi
callq 0x6fec
movq %r12, %rdi
movl $0xa, %esi
movq %rbx, %rdx
xorl %ecx, %ecx
xorl %r8d, %r8d
movq %r15, %r9
callq 0x2ae24
movq 0x68(%rsp), %rdi
cmpq %r13, %rdi
je 0x11292
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x62f0
movl $0x18, %edi
callq 0x62e0
movq %rax, %rbx
movq %rax, %rdi
movl $0x41, %esi
movl $0x2, %edx
callq 0x1cfca
leaq 0x58(%rsp), %r13
movq %r13, -0x10(%r13)
leaq 0x1c60b(%rip), %rsi     # 0x2d8cc
leaq 0x1c632(%rip), %rdx     # 0x2d8fa
leaq 0x48(%rsp), %r15
movq %r15, %rdi
callq 0x6fec
movq %r12, %rdi
movl $0xa, %esi
movq %rbx, %rdx
xorl %ecx, %ecx
xorl %r8d, %r8d
movq %r15, %r9
callq 0x2ae24
movq 0x48(%rsp), %rdi
cmpq %r13, %rdi
movq 0x18(%rsp), %r15
je 0x11309
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x62f0
movl $0x18, %edi
callq 0x62e0
movq %rax, %rbx
movl 0x28(%r15), %esi
addl $-0x4, %esi
movq %rax, %rdi
movl $0x2, %edx
callq 0x1cfca
leaq 0x38(%rsp), %r13
movq %r13, -0x10(%r13)
leaq 0x1c5c1(%rip), %rsi     # 0x2d8fb
leaq 0x1c5f1(%rip), %rdx     # 0x2d932
leaq 0x28(%rsp), %r15
movq %r15, %rdi
callq 0x6fec
movq %r12, %rdi
xorl %esi, %esi
movq (%rsp), %rdx
movq %rbp, %rcx
movq %rbx, %r8
movq %r15, %r9
callq 0x2ae24
movq 0x28(%rsp), %rdi
cmpq %r13, %rdi
je 0x1137c
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x62f0
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 0x114f7
movq 0x38(%rsp), %rsi
jmp 0x114c1
jmp 0x114e7
movq %rax, %r14
movq 0x48(%rsp), %rdi
cmpq %r13, %rdi
je 0x114f7
movq 0x58(%rsp), %rsi
jmp 0x114c1
jmp 0x114e7
movq %rax, %r14
movq 0x68(%rsp), %rdi
cmpq %r13, %rdi
je 0x114f7
movq 0x78(%rsp), %rsi
jmp 0x114c1
jmp 0x114e7
movq %rax, %r14
movq 0x88(%rsp), %rdi
cmpq %r13, %rdi
je 0x114f7
movq 0x98(%rsp), %rsi
jmp 0x114c1
jmp 0x114e7
movq %rax, %r14
movq 0xa8(%rsp), %rdi
cmpq %r13, %rdi
je 0x114f7
movq 0xb8(%rsp), %rsi
jmp 0x114c1
jmp 0x114e7
movq %rax, %r14
movq 0xc8(%rsp), %rdi
cmpq %r13, %rdi
je 0x114f7
movq 0xd8(%rsp), %rsi
jmp 0x114c1
jmp 0x114e7
movq %rax, %r14
movq 0xe8(%rsp), %rdi
cmpq %r13, %rdi
je 0x114f7
movq 0xf8(%rsp), %rsi
jmp 0x114c1
movq %rax, %r14
movq 0x108(%rsp), %rdi
cmpq %rbp, %rdi
je 0x114f7
movq 0x118(%rsp), %rsi
jmp 0x114c1
movq %rax, %r14
movl $0x18, %esi
movq %r13, %rdi
jmp 0x114f2
movq %rax, %r14
movq 0x128(%rsp), %rdi
cmpq %r15, %rdi
je 0x114f7
movq 0x138(%rsp), %rsi
incq %rsi
jmp 0x114f2
jmp 0x114e7
movq %rax, %r14
movl $0x18, %esi
movq (%rsp), %rdi
jmp 0x114f2
movq %rax, %r14
movl $0x18, %esi
movq 0x8(%rsp), %rdi
jmp 0x114f2
jmp 0x114e7
movq %rax, %r14
movl $0x18, %esi
movq %rbx, %rdi
callq 0x62f0
movq %r14, %rdi
callq 0x6550
nop