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

     // Defining structures for the algorithm
     vector <int> visited;
     stack <int> stack;
     stack.push(u);
     visited.push_back(u);

     while (!stack.empty()){
          // Popping the top of the stack
          int curr_v = stack.top();
          // Printing the path
          cout << curr_v << "->";
          stack.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 pushed to the stack and marked as visited
               if (find(visited.begin(), visited.end(), neighbor.first) == visited.end()){
                    visited.push_back(neighbor.first);
                    stack.push(neighbor.first);
               }
          }    
     }
     cout << endl;
     return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x120, %rsp            # imm = 0x120
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq -0x10(%rbp), %rdi
movq %rdi, -0xe8(%rbp)
leaq -0x14(%rbp), %rsi
callq 0x6060
movq -0xe8(%rbp), %rdi
movq %rax, -0x20(%rbp)
callq 0x59a0
movq %rax, -0x28(%rbp)
leaq -0x20(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x6030
testb $0x1, %al
jne 0x43bd
jmp 0x43eb
movq 0x18c04(%rip), %rdi     # 0x1cfc8
leaq 0xec5a(%rip), %rsi      # 0x13025
callq 0x2190
movq %rax, %rdi
movq 0x18bde(%rip), %rsi     # 0x1cfb8
callq 0x21d0
movl $0x0, -0x4(%rbp)
jmp 0x4662
leaq -0x40(%rbp), %rdi
callq 0x5ca0
leaq -0x90(%rbp), %rdi
callq 0x5c70
jmp 0x4402
leaq -0x90(%rbp), %rdi
leaq -0x14(%rbp), %rsi
callq 0x5cc0
jmp 0x4414
leaq -0x40(%rbp), %rdi
leaq -0x14(%rbp), %rsi
callq 0x5ea0
jmp 0x4423
jmp 0x4425
leaq -0x90(%rbp), %rdi
callq 0x5d20
movb %al, -0xe9(%rbp)
jmp 0x4439
movb -0xe9(%rbp), %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x444a
jmp 0x4624
leaq -0x90(%rbp), %rdi
callq 0x5f10
movq %rax, -0xf8(%rbp)
jmp 0x445f
movq -0xf8(%rbp), %rax
movl (%rax), %eax
movl %eax, -0xa0(%rbp)
movl -0xa0(%rbp), %esi
movq 0x18b4d(%rip), %rdi     # 0x1cfc8
callq 0x22b0
movq %rax, -0x100(%rbp)
jmp 0x4489
movq -0x100(%rbp), %rdi
leaq 0xebb0(%rip), %rsi      # 0x13047
callq 0x2190
jmp 0x449e
leaq -0x90(%rbp), %rdi
callq 0x5f30
jmp 0x44ac
movq -0xe8(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
callq 0x5890
movq %rax, -0x108(%rbp)
jmp 0x44c8
movq -0x108(%rbp), %rax
movq %rax, -0xa8(%rbp)
movq -0xa8(%rbp), %rdi
callq 0x5a70
movq %rax, -0xb0(%rbp)
movq -0xa8(%rbp), %rdi
callq 0x5aa0
movq %rax, -0xb8(%rbp)
leaq -0xb0(%rbp), %rdi
leaq -0xb8(%rbp), %rsi
callq 0x5ad0
testb $0x1, %al
jne 0x4518
jmp 0x461f
leaq -0xb0(%rbp), %rdi
callq 0x5b00
movq %rax, -0xc0(%rbp)
leaq -0x40(%rbp), %rdi
movq %rdi, -0x118(%rbp)
callq 0x61e0
movq -0x118(%rbp), %rdi
movq %rax, -0xd0(%rbp)
callq 0x6210
movq %rax, -0xd8(%rbp)
movq -0xc0(%rbp), %rdx
movq -0xd0(%rbp), %rdi
movq -0xd8(%rbp), %rsi
callq 0x6190
movq %rax, -0x110(%rbp)
jmp 0x4578
movq -0x110(%rbp), %rax
movq %rax, -0xc8(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x6210
movq %rax, -0xe0(%rbp)
leaq -0xc8(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
callq 0x6150
testb $0x1, %al
jne 0x45af
jmp 0x460c
movq -0xc0(%rbp), %rsi
leaq -0x40(%rbp), %rdi
callq 0x5ea0
jmp 0x45c1
movq -0xc0(%rbp), %rsi
leaq -0x90(%rbp), %rdi
callq 0x5cc0
jmp 0x45d6
jmp 0x460c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x98(%rbp)
movl %eax, -0x9c(%rbp)
jmp 0x4657
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x98(%rbp)
movl %eax, -0x9c(%rbp)
leaq -0x90(%rbp), %rdi
callq 0x5ff0
jmp 0x4657
jmp 0x460e
leaq -0xb0(%rbp), %rdi
callq 0x5b20
jmp 0x44fc
jmp 0x4425
movq 0x1899d(%rip), %rdi     # 0x1cfc8
movq 0x18986(%rip), %rsi     # 0x1cfb8
callq 0x21d0
jmp 0x4639
movl $0x0, -0x4(%rbp)
leaq -0x90(%rbp), %rdi
callq 0x5ff0
leaq -0x40(%rbp), %rdi
callq 0x5f90
jmp 0x4662
leaq -0x40(%rbp), %rdi
callq 0x5f90
jmp 0x466e
movl -0x4(%rbp), %eax
addq $0x120, %rsp            # imm = 0x120
popq %rbp
retq
movq -0x98(%rbp), %rdi
callq 0x22c0
nopw (%rax,%rax)