// File: robertomaldonado[P]HypercubeTopologyRouting/transformations.cpp
// Function: int_to_bin_str[abi:cxx11](int, int)
std::string int_to_bin_str(int bit_size, int node){
    int tmp_count = 0;
    std::vector<bool> node_bits;
    std::string output_str = "";
    output_str += std::to_string(node) + "(";
    //Keep adding the bits based on the parity of bits
    while(node != 0){
        if( (node % 2) == 0 ){
            node_bits.push_back(0); node = floor(node/2);
        }else{
            node_bits.push_back(1); node = floor(node/2);
        }
    }
    //Push into the vector of node_bits
    tmp_count = node_bits.size();
    while(  tmp_count < bit_size ){
        node_bits.push_back(0);
        tmp_count++;
    }
    //Add the bits to the output string
    for(int i = node_bits.size()-1; i >= 0; i--)
        output_str += std::to_string(node_bits[i]);
    output_str += ")";

    return output_str;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x110, %rsp            # imm = 0x110
movq %rdi, -0xe0(%rbp)
movq %rdi, %rax
movq %rax, -0xe8(%rbp)
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movl $0x0, -0x14(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x9120
movb $0x0, -0x41(%rbp)
leaq -0x42(%rbp), %rdi
movq %rdi, -0xd8(%rbp)
callq 0x22a0
movq -0xe0(%rbp), %rdi
movq -0xd8(%rbp), %rdx
leaq 0x2644(%rip), %rsi      # 0xb0c3
callq 0x2200
jmp 0x8a86
leaq -0x42(%rbp), %rdi
callq 0x21e0
movl -0x10(%rbp), %esi
leaq -0x98(%rbp), %rdi
callq 0x9190
jmp 0x8aa0
leaq 0x26ce(%rip), %rdx      # 0xb175
leaq -0x78(%rbp), %rdi
leaq -0x98(%rbp), %rsi
callq 0x9140
jmp 0x8ab9
movq -0xe0(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x21f0
jmp 0x8acb
leaq -0x78(%rbp), %rdi
callq 0x2120
leaq -0x98(%rbp), %rdi
callq 0x2120
cmpl $0x0, -0x10(%rbp)
je 0x8bd8
movl -0x10(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
cmpl $0x0, %edx
jne 0x8b99
leaq -0x40(%rbp), %rdi
xorl %esi, %esi
callq 0x92b0
jmp 0x8b0b
movl -0x10(%rbp), %edi
movl %edi, %eax
shrl $0x1f, %eax
addl %eax, %edi
sarl %edi
callq 0x9380
movsd %xmm0, -0xf0(%rbp)
jmp 0x8b26
movsd -0xf0(%rbp), %xmm0
cvttsd2si %xmm0, %eax
movl %eax, -0x10(%rbp)
jmp 0x8bd3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x42(%rbp), %rdi
callq 0x21e0
jmp 0x8d1c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x8d10
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x8b88
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x2120
leaq -0x98(%rbp), %rdi
callq 0x2120
jmp 0x8d10
leaq -0x40(%rbp), %rdi
movl $0x1, %esi
callq 0x92b0
jmp 0x8ba9
movl -0x10(%rbp), %edi
movl %edi, %eax
shrl $0x1f, %eax
addl %eax, %edi
sarl %edi
callq 0x9380
movsd %xmm0, -0xf8(%rbp)
jmp 0x8bc4
movsd -0xf8(%rbp), %xmm0
cvttsd2si %xmm0, %eax
movl %eax, -0x10(%rbp)
jmp 0x8ae0
leaq -0x40(%rbp), %rdi
callq 0x3ac0
movl %eax, -0x14(%rbp)
movl -0x14(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x8c04
leaq -0x40(%rbp), %rdi
xorl %esi, %esi
callq 0x92b0
jmp 0x8bf9
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x8be4
leaq -0x40(%rbp), %rdi
callq 0x3ac0
subq $0x1, %rax
movl %eax, -0x9c(%rbp)
cmpl $0x0, -0x9c(%rbp)
jl 0x8ccc
movslq -0x9c(%rbp), %rsi
leaq -0x40(%rbp), %rdi
callq 0x3b40
movq %rdx, -0x108(%rbp)
movq %rax, -0x100(%rbp)
jmp 0x8c44
movq -0x108(%rbp), %rax
movq -0x100(%rbp), %rcx
movq %rcx, -0xd0(%rbp)
movq %rax, -0xc8(%rbp)
leaq -0xd0(%rbp), %rdi
callq 0x3ba0
movzbl %al, %esi
leaq -0xc0(%rbp), %rdi
callq 0x9190
jmp 0x8c7d
movq -0xe0(%rbp), %rdi
leaq -0xc0(%rbp), %rsi
callq 0x21f0
jmp 0x8c92
leaq -0xc0(%rbp), %rdi
callq 0x2120
movl -0x9c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x9c(%rbp)
jmp 0x8c17
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0xc0(%rbp), %rdi
callq 0x2120
jmp 0x8d10
movq -0xe0(%rbp), %rdi
leaq 0x249d(%rip), %rsi      # 0xb177
callq 0x2190
jmp 0x8ce1
movb $0x1, -0x41(%rbp)
testb $0x1, -0x41(%rbp)
jne 0x8cf7
movq -0xe0(%rbp), %rdi
callq 0x2120
leaq -0x40(%rbp), %rdi
callq 0x3db0
movq -0xe8(%rbp), %rax
addq $0x110, %rsp            # imm = 0x110
popq %rbp
retq
movq -0xe0(%rbp), %rdi
callq 0x2120
leaq -0x40(%rbp), %rdi
callq 0x3db0
movq -0x50(%rbp), %rdi
callq 0x2290
nop