// File: /workspace/github_cpp_makefile_star2_O1/robertomaldonado[P]HypercubeTopologyRouting/links.cpp
// Function: recursive_flip(std::vector<bool, std::allocator<bool>>, std::vector<bool, std::allocator<bool>>, std::vector<bool, std::allocator<bool>>)
void recursive_flip( vector<bool> vector_src, vector<bool> vector_dst, vector<bool> current_xor){
    int current;
    vector<bool> vector_original = vector_src;
        //000 to 011
        // 000, 001, 011 //xored is 010
        // 000, 010, 011 //xored is 000
    current = bin_vector_to_int( bits_for_node, vector_src);
    cout << "Currently at node:  " << current << endl;

    int a = bin_vector_to_int(bits_for_node, vector_src);
    int b = bin_vector_to_int(bits_for_node, vector_dst);
    int c = a^b;
    current_xor = int_to_bin_vector(bits_for_node, c);

    if( c == 0 ){
        cout << "Restart.."<<endl;
        a = bin_vector_to_int(bits_for_node, vector_src);
        vector_src = vector_original;
        vector_src = int_to_bin_vector(bits_for_node, 0);
        c = a^b;
        current_xor = int_to_bin_vector(bits_for_node, c);
    }

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

        if(current_xor[i]) { //If the bits need to be flipped
                // current = bin_vector_to_int( bits_for_node, vector_src);
                // cout << "..." << current << endl;
                // current = bin_vector_to_int( bits_for_node, vector_src);
                // cout << "Currently at node:  " << current << endl;

                // int a = bin_vector_to_int(bits_for_node, vector_src);
                // int b = bin_vector_to_int(bits_for_node, vector_dst);
                // int c = a^b;
                // current_xor = int_to_bin_vector(bits_for_node, c);

                vector_src[i] = !vector_src[i]; //Flip a bit
                current = bin_vector_to_int( bits_for_node, vector_src);

                cout << "Hop to node:  " << current << endl << endl;
                // recursive_flip(vector_src, vector_dst, current_xor);
                
        }
                // recursive_flip(vector_src, vector_dst, current_xor);     
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x128, %rsp            # imm = 0x128
movq %rdx, %rbx
movq %rsi, %r15
movq %rdi, %r13
leaq -0x50(%rbp), %rdi
movq %r13, %rsi
callq 0x3966
movl 0x5ddd(%rip), %r14d     # 0x918c
leaq -0x120(%rbp), %rdi
movq %r13, %rsi
callq 0x3966
leaq -0x120(%rbp), %rsi
movl %r14d, %edi
callq 0x49e8
movl %eax, %r12d
movq -0x120(%rbp), %rdi
testq %rdi, %rdi
je 0x3404
callq 0x2180
xorl %eax, %eax
movq %rax, -0x120(%rbp)
movl %eax, -0x118(%rbp)
movq %rax, -0x110(%rbp)
movl %eax, -0x108(%rbp)
movq %rax, -0x100(%rbp)
movq 0x5bc5(%rip), %rdi      # 0x8fd0
leaq 0x2ca6(%rip), %rsi      # 0x60b8
movl $0x14, %edx
callq 0x21c0
movq 0x5bad(%rip), %rdi      # 0x8fd0
movl %r12d, %esi
callq 0x2270
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2190
movsbl %al, %esi
movq %r14, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2110
movl 0x5d30(%rip), %r14d     # 0x918c
leaq -0xf8(%rbp), %rdi
movq %r13, %rsi
callq 0x3966
leaq -0xf8(%rbp), %rsi
movl %r14d, %edi
callq 0x49e8
movl %eax, %r12d
movq -0xf8(%rbp), %rdi
testq %rdi, %rdi
je 0x34b1
callq 0x2180
xorl %eax, %eax
movq %rax, -0xf8(%rbp)
movl %eax, -0xf0(%rbp)
movq %rax, -0xe8(%rbp)
movl %eax, -0xe0(%rbp)
movq %rax, -0xd8(%rbp)
movl 0x5cd4(%rip), %r14d     # 0x918c
leaq -0xd0(%rbp), %rdi
movq %r15, %rsi
callq 0x3966
leaq -0xd0(%rbp), %rsi
movl %r14d, %edi
callq 0x49e8
movl %eax, %r15d
movq -0xd0(%rbp), %rdi
testq %rdi, %rdi
je 0x350d
callq 0x2180
xorl %eax, %eax
movq %rax, -0xd0(%rbp)
movl %eax, -0xc8(%rbp)
movq %rax, -0xc0(%rbp)
movl %eax, -0xb8(%rbp)
movq %rax, -0xb0(%rbp)
movl %r15d, %edx
xorl %r12d, %edx
movl 0x5c73(%rip), %esi      # 0x918c
leaq -0x148(%rbp), %rdi
callq 0x4a77
movq %rbx, %rdi
callq 0x3d8e
movq -0x128(%rbp), %rax
movq %rax, 0x20(%rbx)
movups -0x148(%rbp), %xmm0
movups -0x138(%rbp), %xmm1
movups %xmm1, 0x10(%rbx)
movups %xmm0, (%rbx)
cmpl %r15d, %r12d
jne 0x3679
movq 0x5a73(%rip), %r14      # 0x8fd0
leaq 0x2b69(%rip), %rsi      # 0x60cd
movl $0x9, %edx
movq %r14, %rdi
callq 0x21c0
movq (%r14), %rax
addq -0x18(%rax), %r14
movq %r14, %rdi
movl $0xa, %esi
callq 0x2190
movsbl %al, %esi
movq 0x5a41(%rip), %rdi      # 0x8fd0
callq 0x2030
movq %rax, %rdi
callq 0x2110
movl 0x5be9(%rip), %r14d     # 0x918c
leaq -0xa8(%rbp), %rdi
movq %r13, %rsi
callq 0x3966
leaq -0xa8(%rbp), %rsi
movl %r14d, %edi
callq 0x49e8
movl %eax, %r12d
movq -0xa8(%rbp), %rdi
testq %rdi, %rdi
je 0x35f8
callq 0x2180
xorl %eax, %eax
movq %rax, -0xa8(%rbp)
movl %eax, -0xa0(%rbp)
movq %rax, -0x98(%rbp)
movl %eax, -0x90(%rbp)
movq %rax, -0x88(%rbp)
leaq -0x50(%rbp), %rsi
movq %r13, %rdi
callq 0x3bac
movl 0x5b82(%rip), %esi      # 0x918c
leaq -0x148(%rbp), %rdi
xorl %edx, %edx
callq 0x4a77
movq %r13, %rdi
callq 0x3d8e
leaq -0x148(%rbp), %rdi
movq 0x20(%rdi), %rax
movq %rax, 0x20(%r13)
movups (%rdi), %xmm0
movups 0x10(%rdi), %xmm1
movups %xmm1, 0x10(%r13)
movups %xmm0, (%r13)
xorl %r15d, %r12d
movl 0x5b43(%rip), %esi      # 0x918c
movl %r12d, %edx
callq 0x4a77
movq %rbx, %rdi
callq 0x3d8e
movq -0x128(%rbp), %rax
movq %rax, 0x20(%rbx)
movups -0x148(%rbp), %xmm0
movups -0x138(%rbp), %xmm1
movups %xmm1, 0x10(%rbx)
movups %xmm0, (%rbx)
movq %r13, -0x58(%rbp)
movq (%rbx), %rax
movq 0x10(%rbx), %rcx
movl 0x18(%rbx), %edx
subq %rax, %rcx
shlq $0x3, %rcx
addq %rdx, %rcx
je 0x37ba
xorl %r15d, %r15d
movq 0x592f(%rip), %r12      # 0x8fd0
xorl %r13d, %r13d
movl $0x1, %edx
movl %r13d, %ecx
shlq %cl, %rdx
movq %r13, %rcx
shrq $0x6, %rcx
movq (%rax,%rcx,8), %rax
btq %r13, %rax
jae 0x379d
movq -0x58(%rbp), %rsi
movq (%rsi), %rax
movq (%rax,%rcx,8), %r9
movq %rdx, %rdi
notq %rdi
andq %r9, %rdi
movq %r9, %r8
orq %rdx, %r8
testq %rdx, %r9
cmovneq %rdi, %r8
movq %r8, (%rax,%rcx,8)
movl 0x5a9c(%rip), %r14d     # 0x918c
leaq -0x80(%rbp), %rdi
callq 0x3966
movl %r14d, %edi
leaq -0x80(%rbp), %rsi
callq 0x49e8
movl %eax, %r14d
movq -0x80(%rbp), %rdi
testq %rdi, %rdi
je 0x372a
callq 0x2180
movq %r15, -0x80(%rbp)
movl %r15d, -0x78(%rbp)
movq %r15, -0x70(%rbp)
movl %r15d, -0x68(%rbp)
movq %r15, -0x60(%rbp)
movl $0xe, %edx
movq %r12, %rdi
leaq 0x299e(%rip), %rsi      # 0x60d7
callq 0x21c0
movq %r12, %rdi
movl %r14d, %esi
callq 0x2270
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2190
movsbl %al, %esi
movq %r14, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2110
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2190
movsbl %al, %esi
movq %r14, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2110
incq %r13
movq (%rbx), %rax
movq 0x10(%rbx), %rcx
movl 0x18(%rbx), %edx
subq %rax, %rcx
leaq (%rdx,%rcx,8), %rcx
cmpq %r13, %rcx
ja 0x36a4
movq -0x50(%rbp), %rdi
testq %rdi, %rdi
je 0x37dc
callq 0x2180
xorl %eax, %eax
movq %rax, -0x50(%rbp)
movl %eax, -0x48(%rbp)
movq %rax, -0x40(%rbp)
movl %eax, -0x38(%rbp)
movq %rax, -0x30(%rbp)
addq $0x128, %rsp            # imm = 0x128
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x3820
jmp 0x38a0
jmp 0x3820
jmp 0x38a0
movq %rax, %rbx
movq -0xa8(%rbp), %rsi
testq %rsi, %rsi
je 0x38a3
leaq -0xa8(%rbp), %rdi
callq 0x23b6
jmp 0x38a3
movq %rax, %rdi
callq 0x3c59
jmp 0x38a0
movq %rax, %rbx
movq -0xd0(%rbp), %rsi
testq %rsi, %rsi
je 0x38a3
leaq -0xd0(%rbp), %rdi
callq 0x2388
jmp 0x38a3
jmp 0x38a0
movq %rax, %rbx
movq -0xf8(%rbp), %rsi
testq %rsi, %rsi
je 0x38a3
leaq -0xf8(%rbp), %rdi
callq 0x235a
jmp 0x38a3
jmp 0x38a0
movq %rax, %rbx
movq -0x120(%rbp), %rsi
testq %rsi, %rsi
je 0x38a3
leaq -0x120(%rbp), %rdi
callq 0x232c
jmp 0x38a3
jmp 0x38a0
jmp 0x38a0
movq %rax, %rbx
movq -0x80(%rbp), %rsi
testq %rsi, %rsi
je 0x38a3
leaq -0x80(%rbp), %rdi
callq 0x23e4
jmp 0x38a3
movq %rax, %rbx
movq -0x50(%rbp), %rdi
testq %rdi, %rdi
je 0x38c5
callq 0x2180
xorl %eax, %eax
movq %rax, -0x50(%rbp)
movl %eax, -0x48(%rbp)
movq %rax, -0x40(%rbp)
movl %eax, -0x38(%rbp)
movq %rax, -0x30(%rbp)
movq %rbx, %rdi
callq 0x2280