// File: /workspace/github_cpp_makefile_star2_O2/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, -0x30(%rbp)
movq %rsi, %r12
movq %rdi, %r14
leaq -0x120(%rbp), %rdi
movq %r14, %rsi
callq 0x3180
movl 0x53ea(%rip), %r15d     # 0x8174
leaq -0xf8(%rbp), %rdi
movq %r14, %rsi
callq 0x3180
leaq -0xf8(%rbp), %rsi
movl %r15d, %edi
callq 0x418c
movl %eax, %r15d
leaq -0xf8(%rbp), %rdi
callq 0x31fe
movq 0x520a(%rip), %rdi      # 0x7fc8
leaq 0x22f3(%rip), %rsi      # 0x50b8
callq 0x2160
movq %rax, %rdi
movl %r15d, %esi
callq 0x2240
movq %rax, %rdi
callq 0x20d0
movl 0x5390(%rip), %r15d     # 0x8174
leaq -0xd0(%rbp), %rdi
movq %r14, %rsi
callq 0x3180
leaq -0xd0(%rbp), %rsi
movl %r15d, %edi
callq 0x418c
movl %eax, %r15d
leaq -0xd0(%rbp), %rdi
callq 0x31fe
movl 0x535c(%rip), %r13d     # 0x8174
leaq -0xa8(%rbp), %rdi
movq %r12, %rsi
callq 0x3180
leaq -0xa8(%rbp), %rsi
movl %r13d, %edi
callq 0x418c
movl %eax, %r12d
leaq -0xa8(%rbp), %rdi
callq 0x31fe
movl %r12d, %edx
xorl %r15d, %edx
movl 0x5323(%rip), %esi      # 0x8174
leaq -0x58(%rbp), %rdi
callq 0x4207
leaq -0x58(%rbp), %r13
movq -0x30(%rbp), %rdi
movq %r13, %rsi
callq 0x3382
movq %r13, %rdi
callq 0x31fe
cmpl %r12d, %r15d
jne 0x2f21
movq 0x5146(%rip), %rdi      # 0x7fc8
leaq 0x2244(%rip), %rsi      # 0x50cd
callq 0x2160
movq %rax, %rdi
callq 0x20d0
movl 0x52d7(%rip), %r12d     # 0x8174
leaq -0x80(%rbp), %rdi
movq %r14, %rsi
callq 0x3180
leaq -0x80(%rbp), %rsi
movl %r12d, %edi
callq 0x418c
movl %eax, %r12d
leaq -0x80(%rbp), %rdi
callq 0x31fe
leaq -0x120(%rbp), %rsi
movq %r14, %rdi
callq 0x33d4
movl 0x529e(%rip), %esi      # 0x8174
leaq -0x58(%rbp), %rdi
xorl %edx, %edx
callq 0x4207
movq %r14, %rdi
movq %r13, %rsi
callq 0x3382
movq %r13, %rdi
callq 0x31fe
xorl %r15d, %r12d
movl 0x5277(%rip), %esi      # 0x8174
leaq -0x58(%rbp), %rdi
movl %r12d, %edx
callq 0x4207
leaq -0x58(%rbp), %r15
movq -0x30(%rbp), %rdi
movq %r15, %rsi
callq 0x3382
movq %r15, %rdi
callq 0x31fe
xorl %r15d, %r15d
leaq -0x148(%rbp), %rbx
movq -0x30(%rbp), %rdi
movq 0x10(%rdi), %rax
movl 0x18(%rdi), %ecx
subq (%rdi), %rax
leaq (%rcx,%rax,8), %rax
cmpq %r15, %rax
jbe 0x2fea
movq %r15, %rsi
callq 0x315e
testq %rdx, (%rax)
je 0x2fe2
movq %r14, %rdi
movq %r15, %rsi
callq 0x315e
movq %rdx, %r13
movq %r14, %rdi
movq (%rax), %r14
movq %rdi, %r12
movq %r15, %rsi
callq 0x315e
testq %r13, %r14
je 0x2f83
notq %rdx
andq (%rax), %rdx
jmp 0x2f86
orq (%rax), %rdx
movq %r12, %r14
movq %rdx, (%rax)
movl 0x51e1(%rip), %r13d     # 0x8174
movq %rbx, %rdi
movq %r12, %rsi
callq 0x3180
movl %r13d, %edi
movq %rbx, %rsi
callq 0x418c
movl %eax, %r13d
movq %rbx, %rdi
callq 0x31fe
movq 0x500d(%rip), %rdi      # 0x7fc8
leaq 0x2115(%rip), %rsi      # 0x50d7
callq 0x2160
movq %rax, %rdi
movl %r13d, %esi
callq 0x2240
movq %rax, %rdi
callq 0x20d0
movq %rax, %rdi
callq 0x20d0
incq %r15
jmp 0x2f2b
leaq -0x120(%rbp), %rdi
callq 0x31fe
addq $0x128, %rsp            # imm = 0x128
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x305a
jmp 0x305a
movq %rax, %rbx
leaq -0x80(%rbp), %rdi
jmp 0x3051
jmp 0x305a
movq %rax, %rbx
leaq -0xa8(%rbp), %rdi
jmp 0x3051
jmp 0x305a
movq %rax, %rbx
leaq -0xd0(%rbp), %rdi
jmp 0x3051
jmp 0x305a
movq %rax, %rbx
leaq -0xf8(%rbp), %rdi
jmp 0x3051
jmp 0x305a
jmp 0x305a
jmp 0x305a
jmp 0x305a
movq %rax, %rbx
leaq -0x148(%rbp), %rdi
callq 0x31fe
jmp 0x305d
jmp 0x305a
movq %rax, %rbx
leaq -0x120(%rbp), %rdi
callq 0x31fe
movq %rbx, %rdi
callq 0x2250