// File: /workspace/github_cpp_makefile_star2_O1/Davidc2525[P]Leaf/tree.cpp
// Function: EffectiveAddr::toString()
char *EffectiveAddr::toString()
{
    RegisterProvider *rp = RegisterManager::getInstance()->getProviderBy(64);
    string *addr = new string();

    /**
     * TODO: delete
     * TODO: colocar el registro dependiendo de la arquitectura
    */
    if (withBp)
    {
        //  RegisterProvider *rp = RegisterManager::getInstance()->getProviderBy(64);

        addr->append(rp->get_by_name("rbp")->getName());
        addr->append("+");
    }

    if (!this->parts.empty())
    {
        //std::sort(regis.begin(), regis.end(), compareEfectivePart);

        for (int i = 0; i < parts.size(); i++)
        {

            if (i != 0)
                addr->append(modoToString(parts[i]->mode));
            if (parts[i]->type == Reg)
            {

                addr->append(rp->get(parts[i]->load)->getName());
            }
            else if (parts[i]->type == Num)
            {
                addr->append(to_string(parts[i]->load));
            }
        }
    }

    return (char *)addr->c_str();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdi, %rbx
callq 0x11b02
movq %rax, %rdi
movl $0x40, %esi
callq 0x11b6c
movq %rax, 0x8(%rsp)
movl $0x20, %edi
callq 0x5290
movq %rax, %r15
addq $0x10, %rax
movq %rax, (%r15)
movq $0x0, 0x8(%r15)
movb $0x0, 0x10(%r15)
cmpb $0x1, (%rbx)
jne 0x108fc
movq 0x8(%rsp), %rdi
movq (%rdi), %rax
leaq 0xa643(%rip), %rsi      # 0x1af1a
callq *0x10(%rax)
movq %rax, %rdi
callq 0x1196c
movq %r15, %rdi
movq %rax, %rsi
callq 0x54b0
leaq 0xa528(%rip), %rsi      # 0x1ae1c
movq %r15, %rdi
callq 0x54b0
movq 0x8(%rbx), %rax
cmpq 0x10(%rbx), %rax
je 0x10a5c
movq 0x8(%rbx), %rax
cmpq %rax, 0x10(%rbx)
je 0x10a5c
leaq 0x20(%rsp), %r14
xorl %r12d, %r12d
movq %r15, 0x30(%rsp)
testq %r12, %r12
je 0x10945
movq (%rax,%r12,8), %rax
movslq 0x4(%rax), %rax
leaq 0x14d47(%rip), %rcx     # 0x25680
movq (%rcx,%rax,8), %rsi
movq %r15, %rdi
callq 0x54b0
movq 0x8(%rbx), %rcx
movq (%rcx,%r12,8), %rax
movl 0x8(%rax), %edx
cmpl $0x1, %edx
je 0x10982
testl %edx, %edx
jne 0x10a41
movl (%rax), %esi
movq 0x8(%rsp), %rdi
movq (%rdi), %rax
callq *0x8(%rax)
movq %rax, %rdi
callq 0x1196c
movq %r15, %rdi
movq %rax, %rsi
callq 0x54b0
jmp 0x10a41
movq (%rcx,%r12,8), %rax
movl (%rax), %r15d
movl %r15d, %ebp
negl %ebp
cmovsl %r15d, %ebp
movl $0x1, %r13d
cmpl $0xa, %ebp
jb 0x109e3
movl $0x4, %r13d
movl %ebp, %eax
movl $0xd1b71759, %esi       # imm = 0xD1B71759
cmpl $0x63, %eax
jbe 0x109da
cmpl $0x3e7, %eax            # imm = 0x3E7
jbe 0x109e0
cmpl $0x2710, %eax           # imm = 0x2710
jb 0x109e3
movl %eax, %ecx
imulq %rsi, %rcx
shrq $0x2d, %rcx
addl $0x4, %r13d
cmpl $0x1869f, %eax          # imm = 0x1869F
movl %ecx, %eax
ja 0x109aa
addl $-0x3, %r13d
jmp 0x109e3
addl $-0x2, %r13d
jmp 0x109e3
decl %r13d
shrl $0x1f, %r15d
movl %r15d, %esi
addl %r13d, %esi
movq %r14, 0x10(%rsp)
leaq 0x10(%rsp), %rdi
movl $0x2d, %edx
callq 0x5310
movq 0x10(%rsp), %rdi
addq %r15, %rdi
movl %r13d, %esi
movl %ebp, %edx
callq 0x7d81
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
movq 0x30(%rsp), %r15
movq %r15, %rdi
callq 0x50f0
movq 0x10(%rsp), %rdi
cmpq %r14, %rdi
je 0x10a41
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x52a0
incq %r12
movq 0x8(%rbx), %rax
movq 0x10(%rbx), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
cmpq %r12, %rcx
ja 0x10925
movq (%r15), %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq 0x10(%rsp), %rdi
cmpq %r14, %rdi
je 0x10a88
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x52a0
movq %rbx, %rdi
callq 0x5470