// File: /workspace/github_cpp_makefile_star2_O2/Davidc2525[P]Leaf/compiler/backend/x86_64_linux/generator.cpp
// Function: x86_64_linux_generator_visitor::visit2(LEAF::AST::Ident*)
void x86_64_linux_generator_visitor::visit2(Ident *ident)
{
    UPDATE_STATICS

    Section *st = assembly->get_program()->section(Sections::text);
    if (this->ax == Load)
    {
        if(ident->obj->type->kind == symbol_table::floatType->kind){
        
        }
        DInstruccion *i = new DInstruccion("mov");
        MemoryOperand *ops = new MemoryOperand();
        ops->add_operand(new RegisterOperand("rbp"));
        ops->add_operand(load_mod::sub, new InmediateIntOperand(ident->obj->adr));
        RegisterOperand *opd = new RegisterOperand(this->reg->getName());
        i->add_operand(opd);
        i->add_operand(ops);
        st->add(i);
    }

    if (this->ax == op_types::Plus)
    {
        DInstruccion *i = new DInstruccion("add");
        MemoryOperand *ops = new MemoryOperand();
        ops->add_operand(new RegisterOperand("rbp"));
        ops->add_operand(load_mod::sub, new InmediateIntOperand(ident->obj->adr));
        RegisterOperand *opd = new RegisterOperand(this->reg->getName());
        i->add_operand(opd);
        i->add_operand(ops);
        st->add(i);
    }

    if (this->ax == op_types::Store)
    {
        DInstruccion *i = new DInstruccion("mov");
        if (ident->obj->type->kind == Struct::Float)
        {
            i->set_instruccion("movss");
        }
        MemoryOperand *ops = new MemoryOperand();
        ops->add_operand(new RegisterOperand("rbp"));
        ops->add_operand(load_mod::sub, new InmediateIntOperand(ident->obj->adr));
        RegisterOperand *opd = new RegisterOperand(this->reg->getName());
        i->add_operand(ops);
        i->add_operand(opd);
        st->add(i);
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %r14
incl 0x8(%rdi)
movq %rsi, %r15
movq 0x10(%rdi), %rax
movq (%rax), %rdi
pushq $0x2
popq %rsi
callq 0xe61c
movq %rax, %rbx
movl 0x38(%r14), %eax
cmpl $0x1, %eax
jne 0x13df9
pushq $0x28
popq %rdi
callq 0x5260
movq %rax, %r12
leaq 0x46bb(%rip), %rsi      # 0x18404
movq %rax, %rdi
callq 0xdf60
pushq $0x20
popq %rdi
callq 0x5260
movq %rax, %r13
movq %rax, %rdi
callq 0xe234
pushq $0x10
popq %rdi
callq 0x5260
movq %rax, %rbp
leaq 0x4224(%rip), %rsi      # 0x17f9a
movq %rax, %rdi
callq 0xe1b2
movq %r13, %rdi
movq %rbp, %rsi
callq 0xe288
pushq $0x10
popq %rdi
callq 0x5260
movq %rax, %rbp
movq 0x8(%r15), %rax
movl 0x30(%rax), %esi
movq %rbp, %rdi
callq 0xe17c
pushq $0x1
popq %rsi
movq %r13, %rdi
movq %rbp, %rdx
callq 0xe24c
pushq $0x10
popq %rdi
callq 0x5260
movq %rax, %rbp
movq 0x20(%r14), %rdi
callq 0xfa1e
movq %rbp, %rdi
movq %rax, %rsi
callq 0xe1b2
movq (%r12), %rax
movq %r12, %rdi
movq %rbp, %rsi
callq *0x20(%rax)
movq (%r12), %rax
movq %r12, %rdi
movq %r13, %rsi
callq *0x20(%rax)
movq %rbx, %rdi
movq %r12, %rsi
callq 0xd750
movl 0x38(%r14), %eax
cmpl $0x2, %eax
jne 0x13ec4
pushq $0x28
popq %rdi
callq 0x5260
movq %rax, %r12
leaq 0x45e7(%rip), %rsi      # 0x183fb
movq %rax, %rdi
callq 0xdf60
pushq $0x20
popq %rdi
callq 0x5260
movq %rax, %r13
movq %rax, %rdi
callq 0xe234
pushq $0x10
popq %rdi
callq 0x5260
movq %rax, %rbp
leaq 0x4159(%rip), %rsi      # 0x17f9a
movq %rax, %rdi
callq 0xe1b2
movq %r13, %rdi
movq %rbp, %rsi
callq 0xe288
pushq $0x10
popq %rdi
callq 0x5260
movq %rax, %rbp
movq 0x8(%r15), %rax
movl 0x30(%rax), %esi
movq %rbp, %rdi
callq 0xe17c
pushq $0x1
popq %rsi
movq %r13, %rdi
movq %rbp, %rdx
callq 0xe24c
pushq $0x10
popq %rdi
callq 0x5260
movq %rax, %rbp
movq 0x20(%r14), %rdi
callq 0xfa1e
movq %rbp, %rdi
movq %rax, %rsi
callq 0xe1b2
movq (%r12), %rax
movq %r12, %rdi
movq %rbp, %rsi
callq *0x20(%rax)
movq (%r12), %rax
movq %r12, %rdi
movq %r13, %rsi
callq *0x20(%rax)
movq %rbx, %rdi
movq %r12, %rsi
callq 0xd750
movl 0x38(%r14), %eax
testl %eax, %eax
je 0x13ed7
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $0x28
popq %rdi
callq 0x5260
movq %rax, %r12
leaq 0x451b(%rip), %rsi      # 0x18404
movq %rax, %rdi
callq 0xdf60
movq 0x8(%r15), %rax
movq 0x18(%rax), %rax
cmpl $0x2, 0x10(%rax)
jne 0x13f10
movq (%r12), %rax
leaq 0x450a(%rip), %rsi      # 0x18414
movq %r12, %rdi
callq *0x10(%rax)
pushq $0x20
popq %rdi
callq 0x5260
movq %rax, %r13
movq %rax, %rdi
callq 0xe234
pushq $0x10
popq %rdi
callq 0x5260
movq %rax, %rbp
leaq 0x4065(%rip), %rsi      # 0x17f9a
movq %rax, %rdi
callq 0xe1b2
movq %r13, %rdi
movq %rbp, %rsi
callq 0xe288
pushq $0x10
popq %rdi
callq 0x5260
movq %rax, %rbp
movq 0x8(%r15), %rax
movl 0x30(%rax), %esi
movq %rbp, %rdi
callq 0xe17c
pushq $0x1
popq %rsi
movq %r13, %rdi
movq %rbp, %rdx
callq 0xe24c
pushq $0x10
popq %rdi
callq 0x5260
movq %rax, %r15
movq 0x20(%r14), %rdi
callq 0xfa1e
movq %r15, %rdi
movq %rax, %rsi
callq 0xe1b2
movq (%r12), %rax
movq %r12, %rdi
movq %r13, %rsi
callq *0x20(%rax)
movq (%r12), %rax
movq %r12, %rdi
movq %r15, %rsi
callq *0x20(%rax)
movq %rbx, %rdi
movq %r12, %rsi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xd750
jmp 0x13ff9
jmp 0x13ff9
jmp 0x13fd6
jmp 0x13fe1
jmp 0x13ff9
jmp 0x13ff9
jmp 0x13fd6
jmp 0x13fe1
jmp 0x13ff9
jmp 0x13ff9
movq %rax, %rbx
pushq $0x20
popq %rsi
movq %r13, %rdi
jmp 0x14002
movq %rax, %rbx
pushq $0x28
popq %rsi
movq %r12, %rdi
jmp 0x14002
movq %rax, %rbx
pushq $0x10
popq %rsi
movq %r15, %rdi
jmp 0x14002
jmp 0x13ff9
movq %rax, %rbx
pushq $0x10
popq %rsi
movq %rbp, %rdi
callq 0x5270
movq %rbx, %rdi
callq 0x5420
nop