// File: /workspace/github_cpp_makefile_star2_O2/guitld[P]Graph-Algorithms/source/Graph.cpp
// Function: Graph::BFS(int, int)
int Graph::BFS(int u, int v){
     if (adj_lists.find(u) == adj_lists.end() || adj_lists.find(v) == adj_lists.end()){
          cout << "Vertex not found" << endl;
          return 0;
     }

     // Defining structures for the algorithm
     vector <int> visited;
     queue <int> queue;
     queue.push(u);
     unordered_map <int, int> parentNode;
     
     while (!queue.empty()){
          // Popping first item of the queue
          int curr_v = queue.front();
          queue.pop();
          // Looping through its neighbors
          for (auto const &neighbor : adj_lists[curr_v]){
               // If the neighbor vertex is not marked as visited, the vertex is added to the queue and marked as visited
               // The father vertex is setted in the parent hash map
               if (find(visited.begin(), visited.end(), neighbor.first) == visited.end()){
                    parentNode[neighbor.first] = curr_v;
                    visited.push_back(neighbor.first);
                    queue.push(neighbor.first);
               }
               // If the vertex was found, loops through the parent hash map to print the BFS path
               if (neighbor.first == v){
                    cout << v << "<-";
                    parentNode[get<0>(neighbor)] = curr_v;
                    int count = 0;
                    while (v != u){
                         v = parentNode[v];
                         cout << v;
                         if (v != u)
                              cout << "<-";
                         count++;
                    }
                    cout << endl;
                    return count;
               }
          }
     }
     cout << "No path found" << endl;
     return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movq %rdi, %rbx
leaq -0x34(%rbp), %rax
movl %esi, (%rax)
movl %edx, -0x2c(%rbp)
movq %rax, %rsi
callq 0x4fba
testq %rax, %rax
je 0x3014
leaq -0x2c(%rbp), %rsi
movq %rbx, %rdi
callq 0x4fba
testq %rax, %rax
je 0x3014
xorps %xmm0, %xmm0
movaps %xmm0, -0x50(%rbp)
andq $0x0, -0x40(%rbp)
leaq -0xe0(%rbp), %rdi
callq 0x3b14
leaq -0xe0(%rbp), %rdi
leaq -0x34(%rbp), %rsi
callq 0x4b9c
leaq -0x60(%rbp), %rax
movq %rax, -0x30(%rax)
movq $0x1, -0x28(%rax)
xorps %xmm0, %xmm0
movups %xmm0, -0x20(%rax)
movl $0x3f800000, -0x10(%rax) # imm = 0x3F800000
movups %xmm0, -0x8(%rax)
movq %rbx, -0x58(%rbp)
movq -0xd0(%rbp), %rax
cmpq %rax, -0xb0(%rbp)
je 0x3034
movl (%rax), %eax
movl %eax, -0x30(%rbp)
leaq -0xe0(%rbp), %rdi
callq 0x4fdc
movq %rbx, %rdi
leaq -0x30(%rbp), %rsi
callq 0x4170
movq %rax, %r12
movq %rax, %rbx
movq (%rbx), %rbx
cmpq %r12, %rbx
je 0x3005
leaq 0x10(%rbx), %r13
movq -0x50(%rbp), %rdi
movq -0x48(%rbp), %rsi
movq %r13, %rdx
callq 0x5043
cmpq -0x48(%rbp), %rax
jne 0x2f78
movl -0x30(%rbp), %r15d
leaq -0x90(%rbp), %rdi
movq %r13, %rsi
callq 0x45d8
movl %r15d, (%rax)
leaq -0x50(%rbp), %rdi
movq %r13, %rsi
callq 0x3aee
leaq -0xe0(%rbp), %rdi
movq %r13, %rsi
callq 0x4b9c
movl (%r13), %esi
cmpl -0x2c(%rbp), %esi
jne 0x2f21
movq 0x8040(%rip), %rdi      # 0xafc8
callq 0x2230
movq %rax, %rdi
leaq 0x408b(%rip), %rsi      # 0x7022
callq 0x2130
movl -0x30(%rbp), %r14d
leaq -0x90(%rbp), %rdi
movq %r13, %rsi
callq 0x45d8
movl %r14d, (%rax)
xorl %r14d, %r14d
movq 0x800c(%rip), %r15      # 0xafc8
movl -0x2c(%rbp), %eax
cmpl -0x34(%rbp), %eax
je 0x2ffd
leaq -0x90(%rbp), %rdi
leaq -0x2c(%rbp), %rsi
callq 0x45d8
movl (%rax), %esi
movl %esi, -0x2c(%rbp)
movq %r15, %rdi
callq 0x2230
movl -0x2c(%rbp), %eax
cmpl -0x34(%rbp), %eax
je 0x2ff8
movq %r15, %rdi
leaq 0x402f(%rip), %rsi      # 0x7022
callq 0x2130
incl %r14d
jmp 0x2fbc
movq %r15, %rdi
callq 0x20c0
cmpq %r12, %rbx
movq -0x58(%rbp), %rbx
je 0x2eea
jmp 0x3052
movq 0x7fad(%rip), %rdi      # 0xafc8
leaq 0x3fef(%rip), %rsi      # 0x7011
callq 0x2130
movq %rax, %rdi
callq 0x20c0
xorl %r14d, %r14d
jmp 0x3073
movq 0x7f8d(%rip), %rdi      # 0xafc8
leaq 0x3fe3(%rip), %rsi      # 0x7025
callq 0x2130
xorl %r14d, %r14d
movq %rax, %rdi
callq 0x20c0
leaq -0x90(%rbp), %rdi
callq 0x3fb6
leaq -0xe0(%rbp), %rdi
callq 0x3f54
leaq -0x50(%rbp), %rdi
callq 0x4b5e
movl %r14d, %eax
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x30ad
movq %rax, %rbx
jmp 0x30b9
jmp 0x309e
jmp 0x309e
jmp 0x309e
jmp 0x309e
jmp 0x309e
jmp 0x309e
movq %rax, %rbx
leaq -0x90(%rbp), %rdi
callq 0x3fb6
leaq -0xe0(%rbp), %rdi
callq 0x3f54
leaq -0x50(%rbp), %rdi
callq 0x4b5e
movq %rbx, %rdi
callq 0x2240