// File: /workspace/github_cpp_makefile_star2_O3/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 -0x30(%rbp), %rax
movl %esi, (%rax)
movl %edx, -0x2c(%rbp)
movq %rax, %rsi
callq 0x57b0
testq %rax, %rax
je 0x369e
leaq -0x2c(%rbp), %rsi
movq %rbx, %rdi
callq 0x57b0
testq %rax, %rax
je 0x369e
xorps %xmm0, %xmm0
movaps %xmm0, -0x50(%rbp)
movq $0x0, -0x40(%rbp)
leaq -0xa0(%rbp), %rdi
movaps %xmm0, 0x40(%rdi)
movaps %xmm0, 0x30(%rdi)
movaps %xmm0, 0x20(%rdi)
movaps %xmm0, 0x10(%rdi)
movaps %xmm0, (%rdi)
xorl %esi, %esi
callq 0x52d6
movq -0x70(%rbp), %rax
movq -0x60(%rbp), %rcx
addq $-0x4, %rcx
cmpq %rcx, %rax
je 0x36e7
movl -0x30(%rbp), %ecx
movl %ecx, (%rax)
addq $0x4, %rax
movq %rax, -0x70(%rbp)
jmp 0x36f7
movq 0x692b(%rip), %rbx      # 0x9fd0
leaq 0x398f(%rip), %rsi      # 0x703b
movl $0x10, %edx
movq %rbx, %rdi
callq 0x2180
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2140
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20f0
xorl %ebx, %ebx
jmp 0x3969
leaq -0xa0(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x547c
leaq -0xa8(%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 -0x90(%rbp), %rax
cmpq %rax, -0x70(%rbp)
je 0x38f4
movl (%rax), %ecx
movl %ecx, -0x34(%rbp)
movq -0x80(%rbp), %rcx
addq $-0x4, %rcx
cmpq %rcx, %rax
je 0x3745
addq $0x4, %rax
jmp 0x3778
movq -0x88(%rbp), %rdi
movl $0x200, %esi            # imm = 0x200
callq 0x2160
movq -0x78(%rbp), %rax
leaq 0x8(%rax), %rcx
movq %rcx, -0x78(%rbp)
movq 0x8(%rax), %rax
movq %rax, -0x88(%rbp)
leaq 0x200(%rax), %rcx
movq %rcx, -0x80(%rbp)
movq %rax, -0x90(%rbp)
movq %rbx, %rdi
leaq -0x34(%rbp), %rsi
callq 0x4d1c
movq %rax, %r12
movq (%rax), %r13
cmpq %r12, %r13
je 0x371c
leaq 0x10(%r13), %r14
movq -0x50(%rbp), %rdi
movq -0x48(%rbp), %rsi
movq %r14, %rdx
callq 0x5811
cmpq -0x48(%rbp), %rax
jne 0x381a
movl -0x34(%rbp), %r15d
leaq -0xd8(%rbp), %rdi
movq %r14, %rsi
callq 0x5026
movl %r15d, (%rax)
movq -0x48(%rbp), %rsi
cmpq -0x40(%rbp), %rsi
je 0x37df
movl (%r14), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, -0x48(%rbp)
jmp 0x37eb
leaq -0x50(%rbp), %rdi
movq %r14, %rdx
callq 0x568e
movq -0x70(%rbp), %rax
movq -0x60(%rbp), %rcx
addq $-0x4, %rcx
cmpq %rcx, %rax
je 0x380b
movl (%r14), %ecx
movl %ecx, (%rax)
addq $0x4, %rax
movq %rax, -0x70(%rbp)
jmp 0x381a
leaq -0xa0(%rbp), %rdi
movq %r14, %rsi
callq 0x547c
movl (%r14), %esi
cmpl -0x2c(%rbp), %esi
je 0x382b
movq (%r13), %r13
jmp 0x3791
movq 0x679e(%rip), %rdi      # 0x9fd0
callq 0x2250
leaq 0x380e(%rip), %rsi      # 0x704c
movl $0x2, %edx
movq %rax, %rdi
callq 0x2180
movl -0x34(%rbp), %ebx
leaq -0xd8(%rbp), %rdi
movq %r14, %rsi
callq 0x5026
movl %ebx, (%rax)
movl -0x2c(%rbp), %eax
xorl %ebx, %ebx
cmpl -0x30(%rbp), %eax
je 0x38c3
movl $0x1, %ebx
leaq -0xd8(%rbp), %r14
leaq -0x2c(%rbp), %r12
movq 0x6750(%rip), %r13      # 0x9fd0
leaq 0x37c5(%rip), %r15      # 0x704c
movq %r14, %rdi
movq %r12, %rsi
callq 0x5026
movl (%rax), %esi
movl %esi, -0x2c(%rbp)
movq %r13, %rdi
callq 0x2250
movl -0x2c(%rbp), %eax
cmpl -0x30(%rbp), %eax
je 0x38c3
movl $0x2, %edx
movq %r13, %rdi
movq %r15, %rsi
callq 0x2180
movl -0x2c(%rbp), %eax
incl %ebx
cmpl -0x30(%rbp), %eax
jne 0x3887
decl %ebx
movq 0x6706(%rip), %rdi      # 0x9fd0
movq (%rdi), %rax
addq -0x18(%rax), %rdi
movl $0xa, %esi
callq 0x2140
movsbl %al, %esi
movq 0x66eb(%rip), %rdi      # 0x9fd0
callq 0x2030
movq %rax, %rdi
callq 0x20f0
jmp 0x393c
movq 0x66d5(%rip), %rbx      # 0x9fd0
leaq 0x374d(%rip), %rsi      # 0x704f
movl $0xd, %edx
movq %rbx, %rdi
callq 0x2180
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x2140
movsbl %al, %esi
movq 0x66a3(%rip), %rdi      # 0x9fd0
callq 0x2030
xorl %ebx, %ebx
movq %rax, %rdi
callq 0x20f0
leaq -0xd8(%rbp), %rdi
callq 0x4c0c
leaq -0xa0(%rbp), %rdi
callq 0x4ba6
movq -0x50(%rbp), %rdi
testq %rdi, %rdi
je 0x3969
movq -0x40(%rbp), %rsi
subq %rdi, %rsi
callq 0x2160
movl %ebx, %eax
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x39a2
movq %rax, %rbx
jmp 0x39ae
jmp 0x3993
jmp 0x3993
jmp 0x3993
jmp 0x3993
jmp 0x3993
jmp 0x3993
movq %rax, %rbx
leaq -0xd8(%rbp), %rdi
callq 0x4c0c
leaq -0xa0(%rbp), %rdi
callq 0x4ba6
movq -0x50(%rbp), %rdi
testq %rdi, %rdi
je 0x39c3
movq -0x40(%rbp), %rsi
subq %rdi, %rsi
callq 0x2160
movq %rbx, %rdi
callq 0x2260
nop