// File: /workspace/github_cpp_makefile_star2_O3/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, %r12
movq %rdi, %r13
leaq -0x148(%rbp), %rdi
movq %r13, %rsi
callq 0x3838
movl 0x4ee7(%rip), %r14d     # 0x818c
leaq -0xf8(%rbp), %rdi
movq %r13, %rsi
callq 0x3838
leaq -0xf8(%rbp), %rsi
movl %r14d, %edi
callq 0x4898
movl %eax, %r15d
movq -0xf8(%rbp), %rdi
testq %rdi, %rdi
je 0x32fa
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)
movq 0x4ccf(%rip), %rdi      # 0x7fd0
leaq 0x1db0(%rip), %rsi      # 0x50b8
movl $0x14, %edx
callq 0x21c0
movq 0x4cb7(%rip), %rdi      # 0x7fd0
movl %r15d, %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 0x4e3a(%rip), %r14d     # 0x818c
leaq -0xd0(%rbp), %rdi
movq %r13, %rsi
callq 0x3838
leaq -0xd0(%rbp), %rsi
movl %r14d, %edi
callq 0x4898
movl %eax, %r15d
movq -0xd0(%rbp), %rdi
testq %rdi, %rdi
je 0x33a7
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 0x4dde(%rip), %r14d     # 0x818c
leaq -0xa8(%rbp), %rdi
movq %r12, %rsi
callq 0x3838
leaq -0xa8(%rbp), %rsi
movl %r14d, %edi
callq 0x4898
movl %eax, %r12d
movq -0xa8(%rbp), %rdi
testq %rdi, %rdi
je 0x3403
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)
movl %r12d, %edx
xorl %r15d, %edx
movl 0x4d7d(%rip), %esi      # 0x818c
leaq -0x120(%rbp), %rdi
callq 0x4926
movq %rbx, %rdi
callq 0x3c84
movq -0x100(%rbp), %rax
movq %rax, 0x20(%rbx)
movups -0x120(%rbp), %xmm0
movups -0x110(%rbp), %xmm1
movups %xmm1, 0x10(%rbx)
movups %xmm0, (%rbx)
cmpl %r12d, %r15d
jne 0x355a
movq 0x4b7d(%rip), %r14      # 0x7fd0
leaq 0x1c73(%rip), %rsi      # 0x50cd
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 0x4b4b(%rip), %rdi      # 0x7fd0
callq 0x2030
movq %rax, %rdi
callq 0x2110
movl 0x4cf3(%rip), %r14d     # 0x818c
leaq -0x80(%rbp), %rdi
movq %r13, %rsi
callq 0x3838
leaq -0x80(%rbp), %rsi
movl %r14d, %edi
callq 0x4898
movl %eax, %r12d
movq -0x80(%rbp), %rdi
testq %rdi, %rdi
je 0x34d6
callq 0x2180
xorl %eax, %eax
movq %rax, -0x80(%rbp)
movl %eax, -0x78(%rbp)
movq %rax, -0x70(%rbp)
movl %eax, -0x68(%rbp)
movq %rax, -0x60(%rbp)
leaq -0x148(%rbp), %rsi
movq %r13, %rdi
callq 0x3a8c
movl 0x4ca1(%rip), %esi      # 0x818c
leaq -0x120(%rbp), %rdi
xorl %edx, %edx
callq 0x4926
movq %r13, %rdi
callq 0x3c84
leaq -0x120(%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 0x4c62(%rip), %esi      # 0x818c
movl %r12d, %edx
callq 0x4926
movq %rbx, %rdi
callq 0x3c84
movq -0x100(%rbp), %rax
movq %rax, 0x20(%rbx)
movups -0x120(%rbp), %xmm0
movups -0x110(%rbp), %xmm1
movups %xmm1, 0x10(%rbx)
movups %xmm0, (%rbx)
movq %r13, -0x58(%rbp)
movq (%rbx), %rax
movq 0x10(%rbx), %rdx
movl 0x18(%rbx), %esi
movq %rdx, %rcx
subq %rax, %rcx
shlq $0x3, %rcx
addq %rsi, %rcx
je 0x36a2
xorl %r15d, %r15d
movq 0x4a4b(%rip), %r12      # 0x7fd0
xorl %r13d, %r13d
movl $0x1, %edi
movl %r13d, %ecx
shlq %cl, %rdi
movl %r13d, %ecx
shrl $0x6, %ecx
movq (%rax,%rcx,8), %r8
btq %r13, %r8
jae 0x368a
movq -0x58(%rbp), %rsi
movq (%rsi), %rax
movq (%rax,%rcx,8), %rdx
movq %rdi, %r9
notq %r9
andq %rdx, %r9
movq %rdx, %r8
orq %rdi, %r8
testq %rdi, %rdx
cmovneq %r9, %r8
movq %r8, (%rax,%rcx,8)
movl 0x4bb9(%rip), %r14d     # 0x818c
leaq -0x50(%rbp), %rdi
callq 0x3838
movl %r14d, %edi
leaq -0x50(%rbp), %rsi
callq 0x4898
movl %eax, %r14d
movq -0x50(%rbp), %rdi
testq %rdi, %rdi
je 0x360d
callq 0x2180
movq %r15, -0x50(%rbp)
movl %r15d, -0x48(%rbp)
movq %r15, -0x40(%rbp)
movl %r15d, -0x38(%rbp)
movq %r15, -0x30(%rbp)
movl $0xe, %edx
movq %r12, %rdi
leaq 0x1abb(%rip), %rsi      # 0x50d7
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
movq (%rbx), %rax
movq 0x10(%rbx), %rdx
movl 0x18(%rbx), %esi
incq %r13
movq %rdx, %rcx
subq %rax, %rcx
movl %esi, %edi
leaq (%rdi,%rcx,8), %rcx
cmpq %r13, %rcx
ja 0x3588
movq -0x148(%rbp), %rdi
testq %rdi, %rdi
je 0x36b3
callq 0x2180
addq $0x128, %rsp            # imm = 0x128
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x36f1
jmp 0x3784
jmp 0x36f1
jmp 0x3784
movq %rax, %rbx
movq -0x80(%rbp), %rsi
testq %rsi, %rsi
je 0x3787
leaq -0x80(%rbp), %rdi
callq 0x235a
jmp 0x3787
movq %rax, %rdi
callq 0x3b4b
jmp 0x3784
movq %rax, %rbx
movq -0xa8(%rbp), %rsi
testq %rsi, %rsi
je 0x3787
leaq -0xa8(%rbp), %rdi
callq 0x232c
jmp 0x3787
jmp 0x3784
movq %rax, %rbx
movq -0xd0(%rbp), %rsi
testq %rsi, %rsi
je 0x3787
leaq -0xd0(%rbp), %rdi
callq 0x22fe
jmp 0x3787
jmp 0x3784
movq %rax, %rbx
movq -0xf8(%rbp), %rsi
testq %rsi, %rsi
je 0x3787
leaq -0xf8(%rbp), %rdi
callq 0x22d0
jmp 0x3787
jmp 0x3784
jmp 0x3784
movq %rax, %rbx
movq -0x50(%rbp), %rdi
testq %rdi, %rdi
je 0x3787
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)
jmp 0x3787
movq %rax, %rbx
movq -0x148(%rbp), %rdi
testq %rdi, %rdi
je 0x3798
callq 0x2180
movq %rbx, %rdi
callq 0x2280