// File: /workspace/github_cpp_makefile_star2_O2/guitld[P]Graph-Algorithms/source/Graph.cpp
// Function: Graph::hierholzerPath()
void Graph::hierholzerPath(){

     // Hash map to count the number of edges connected to a vertex
     unordered_map <int, int> edge_count;

     for (auto elem : this->adj_lists)
          edge_count[elem.first] = edgeCount(elem.first);

     // Creating a stack and a vector for the path for the algorithm and path
     stack <int> stack;
     vector <int> circuit;

     stack.push(this->adj_lists.begin()->first);
     int curr_v = this->adj_lists.begin()->first;
     
     while (!stack.empty()){
          // Check if there are edges connected to vertex
          if (edge_count[curr_v]){
               // Pushing vertex to the stack
               stack.push(curr_v);
               // Getting next vertex from its adjacency list
               int next_v = this->adj_lists[curr_v].back().first;
               // Removing the edge
               if (curr_v != next_v){
                    for (auto &elem : this->adj_lists[next_v])
                         if (elem.first == curr_v)
                              this->adj_lists[next_v].remove(elem);
               }
               this->adj_lists[curr_v].pop_back();
               edge_count[curr_v]--;
               edge_count[next_v]--;
               curr_v = next_v;
          }

          else{
               // Popping the stack
               circuit.push_back(curr_v);
               curr_v = stack.top();
               stack.pop();
          }
     }

     // Printing the path
     for (int i=circuit.size()-1; i>=0; i--){
          cout << circuit[i];
          if (i)
               cout<<" -> ";
     }
     cout << endl;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movq %rdi, %rbx
leaq -0xb0(%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)
leaq 0x10(%rdi), %r14
leaq -0xa8(%rbp), %r15
leaq -0xe0(%rbp), %r12
movq %r14, -0x58(%rbp)
movq (%r14), %r14
testq %r14, %r14
je 0x2c21
leaq 0x8(%r14), %rsi
movq %r15, %rdi
callq 0x3a0c
movl -0xa8(%rbp), %esi
movq %rbx, %rdi
callq 0x3a44
movl %eax, %r13d
movq %r12, %rdi
movq %r15, %rsi
callq 0x45d8
movl %r13d, (%rax)
leaq -0xa0(%rbp), %rdi
callq 0x2546
jmp 0x2be0
leaq -0xa8(%rbp), %rdi
callq 0x3a64
andq $0x0, -0x40(%rbp)
xorps %xmm0, %xmm0
movaps %xmm0, -0x50(%rbp)
movq -0x58(%rbp), %r14
movq (%r14), %rsi
addq $0x8, %rsi
leaq -0xa8(%rbp), %rdi
callq 0x4b9c
movq (%r14), %rax
movl 0x8(%rax), %eax
leaq -0x2c(%rbp), %r13
movl %eax, (%r13)
leaq -0xe0(%rbp), %r14
leaq -0x30(%rbp), %r12
movq -0x78(%rbp), %rax
cmpq -0x98(%rbp), %rax
je 0x2d75
movq %r14, %rdi
movq %r13, %rsi
callq 0x45d8
cmpl $0x0, (%rax)
je 0x2cf8
leaq -0xa8(%rbp), %rdi
movq %r13, %rsi
callq 0x4b9c
movq %rbx, %rdi
movq %r13, %rsi
callq 0x4170
movq %r13, %r14
movq 0x8(%rax), %rax
movl 0x10(%rax), %eax
movl %eax, -0x30(%rbp)
cmpl %eax, -0x2c(%rbp)
jne 0x2d35
movq %rbx, %rdi
movq %r14, %r13
movq %r14, %rsi
callq 0x4170
leaq -0xe0(%rbp), %r14
movq %rax, %rdi
callq 0x39fe
movq %r14, %rdi
movq %r13, %rsi
callq 0x45d8
decl (%rax)
movq %r14, %rdi
movq %r12, %rsi
callq 0x45d8
decl (%rax)
movl -0x30(%rbp), %eax
movl %eax, -0x2c(%rbp)
jmp 0x2c69
leaq -0x50(%rbp), %rdi
movq %r13, %rsi
callq 0x3aee
movq -0x78(%rbp), %rax
cmpq -0x70(%rbp), %rax
jne 0x2d1e
movq -0x60(%rbp), %rax
movq -0x8(%rax), %rax
movl $0x200, %ecx            # imm = 0x200
addq %rcx, %rax
movl -0x4(%rax), %eax
movl %eax, -0x2c(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0x4f54
jmp 0x2c69
movq %rbx, %rdi
movq %r12, %rsi
callq 0x4170
movq %rax, %r15
movq %rax, %r13
movq (%r13), %r13
cmpq %r15, %r13
je 0x2cb6
movl 0x10(%r13), %eax
cmpl -0x2c(%rbp), %eax
jne 0x2d46
movq %rbx, %rdi
movq %r12, %rsi
callq 0x4170
leaq 0x10(%r13), %rsi
movq %rax, %rdi
callq 0x3a84
jmp 0x2d46
movq -0x48(%rbp), %rax
subq -0x50(%rbp), %rax
shrq $0x2, %rax
movl %eax, %r15d
decq %r15
movq 0x823a(%rip), %rbx      # 0xafc8
leaq 0x4277(%rip), %r14      # 0x700c
testl %r15d, %r15d
js 0x2dc6
movl %r15d, %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movq -0x50(%rbp), %rcx
movl (%rcx,%rax,4), %esi
movq %rbx, %rdi
callq 0x2230
testl %r15d, %r15d
je 0x2dc1
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2130
decq %r15
jmp 0x2d95
movq 0x81fb(%rip), %rdi      # 0xafc8
callq 0x20c0
leaq -0x50(%rbp), %rdi
callq 0x4b5e
leaq -0xa8(%rbp), %rdi
callq 0x3f54
leaq -0xe0(%rbp), %rdi
callq 0x3fb6
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x2e29
jmp 0x2e29
jmp 0x2e0d
jmp 0x2e29
movq %rax, %rbx
jmp 0x2e41
jmp 0x2e29
jmp 0x2e29
movq %rax, %rbx
leaq -0xa0(%rbp), %rdi
callq 0x2546
jmp 0x2e41
jmp 0x2e29
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x4b5e
leaq -0xa8(%rbp), %rdi
callq 0x3f54
leaq -0xe0(%rbp), %rdi
callq 0x3fb6
movq %rbx, %rdi
callq 0x2240
nop