// File: 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
subq $0x1a0, %rsp            # imm = 0x1A0
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x140(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x5bf0
movq -0x140(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rdi
callq 0x5970
movq %rax, -0x50(%rbp)
movq -0x48(%rbp), %rdi
callq 0x59a0
movq %rax, -0x58(%rbp)
leaq -0x50(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x59d0
testb $0x1, %al
jne 0x3a3e
jmp 0x3ad6
leaq -0x50(%rbp), %rdi
callq 0x5a00
movq %rax, %rsi
leaq -0x78(%rbp), %rdi
callq 0x5a30
jmp 0x3a55
movq -0x140(%rbp), %rdi
movl -0x78(%rbp), %esi
callq 0x5c10
movl %eax, -0x144(%rbp)
jmp 0x3a6c
leaq -0x40(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x5c40
movq %rax, -0x150(%rbp)
jmp 0x3a82
movq -0x150(%rbp), %rax
movl -0x144(%rbp), %ecx
movl %ecx, (%rax)
leaq -0x78(%rbp), %rdi
callq 0x2a40
leaq -0x50(%rbp), %rdi
callq 0x5b40
jmp 0x3a28
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x3e75
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x2a40
jmp 0x3e75
leaq -0xd8(%rbp), %rdi
callq 0x5c70
jmp 0x3ae4
leaq -0xf0(%rbp), %rdi
callq 0x5ca0
movq -0x140(%rbp), %rdi
callq 0x5970
movq %rax, -0xf8(%rbp)
leaq -0xf8(%rbp), %rdi
callq 0x5cf0
movq %rax, %rsi
leaq -0xd8(%rbp), %rdi
callq 0x5cc0
jmp 0x3b20
movq -0x140(%rbp), %rdi
callq 0x5970
movq %rax, -0x108(%rbp)
leaq -0x108(%rbp), %rdi
callq 0x5cf0
movl (%rax), %eax
movl %eax, -0xfc(%rbp)
leaq -0xd8(%rbp), %rdi
callq 0x5d20
movb %al, -0x151(%rbp)
jmp 0x3b5b
movb -0x151(%rbp), %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x3b6c
jmp 0x3dc1
leaq -0x40(%rbp), %rdi
leaq -0xfc(%rbp), %rsi
callq 0x5c40
movq %rax, -0x160(%rbp)
jmp 0x3b85
movq -0x160(%rbp), %rax
cmpl $0x0, (%rax)
je 0x3d73
leaq -0xd8(%rbp), %rdi
leaq -0xfc(%rbp), %rsi
callq 0x5cc0
jmp 0x3baa
movq -0x140(%rbp), %rdi
leaq -0xfc(%rbp), %rsi
callq 0x5890
movq %rax, -0x168(%rbp)
jmp 0x3bc6
movq -0x168(%rbp), %rdi
callq 0x5d40
movl (%rax), %eax
movl %eax, -0x10c(%rbp)
movl -0xfc(%rbp), %eax
cmpl -0x10c(%rbp), %eax
je 0x3cf0
movq -0x140(%rbp), %rdi
leaq -0x10c(%rbp), %rsi
callq 0x5890
movq %rax, -0x170(%rbp)
jmp 0x3c08
movq -0x170(%rbp), %rax
movq %rax, -0x118(%rbp)
movq -0x118(%rbp), %rdi
callq 0x5a70
movq %rax, -0x120(%rbp)
movq -0x118(%rbp), %rdi
callq 0x5aa0
movq %rax, -0x128(%rbp)
leaq -0x120(%rbp), %rdi
leaq -0x128(%rbp), %rsi
callq 0x5ad0
testb $0x1, %al
jne 0x3c58
jmp 0x3cee
leaq -0x120(%rbp), %rdi
callq 0x5b00
movq %rax, -0x130(%rbp)
movq -0x130(%rbp), %rax
movl (%rax), %eax
cmpl -0xfc(%rbp), %eax
jne 0x3cdb
movq -0x140(%rbp), %rdi
leaq -0x10c(%rbp), %rsi
callq 0x5890
movq %rax, -0x178(%rbp)
jmp 0x3c98
movq -0x178(%rbp), %rdi
movq -0x130(%rbp), %rsi
callq 0x5d80
jmp 0x3cad
jmp 0x3cdb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
leaq -0xf0(%rbp), %rdi
callq 0x5f90
leaq -0xd8(%rbp), %rdi
callq 0x5ff0
jmp 0x3e75
jmp 0x3cdd
leaq -0x120(%rbp), %rdi
callq 0x5b20
jmp 0x3c3c
jmp 0x3cf0
movq -0x140(%rbp), %rdi
leaq -0xfc(%rbp), %rsi
callq 0x5890
movq %rax, -0x180(%rbp)
jmp 0x3d0c
movq -0x180(%rbp), %rdi
callq 0x5930
leaq -0x40(%rbp), %rdi
leaq -0xfc(%rbp), %rsi
callq 0x5c40
movq %rax, -0x188(%rbp)
jmp 0x3d31
movq -0x188(%rbp), %rax
movl (%rax), %ecx
decl %ecx
movl %ecx, (%rax)
leaq -0x40(%rbp), %rdi
leaq -0x10c(%rbp), %rsi
callq 0x5c40
movq %rax, -0x190(%rbp)
jmp 0x3d57
movq -0x190(%rbp), %rax
movl (%rax), %ecx
addl $-0x1, %ecx
movl %ecx, (%rax)
movl -0x10c(%rbp), %eax
movl %eax, -0xfc(%rbp)
jmp 0x3dbc
leaq -0xf0(%rbp), %rdi
leaq -0xfc(%rbp), %rsi
callq 0x5ea0
jmp 0x3d88
leaq -0xd8(%rbp), %rdi
callq 0x5f10
movq %rax, -0x198(%rbp)
jmp 0x3d9d
movq -0x198(%rbp), %rax
movl (%rax), %eax
movl %eax, -0xfc(%rbp)
leaq -0xd8(%rbp), %rdi
callq 0x5f30
jmp 0x3dba
jmp 0x3dbc
jmp 0x3b47
leaq -0xf0(%rbp), %rdi
callq 0x5f50
subq $0x1, %rax
movl %eax, -0x134(%rbp)
cmpl $0x0, -0x134(%rbp)
jl 0x3e36
movslq -0x134(%rbp), %rsi
leaq -0xf0(%rbp), %rdi
callq 0x5f70
movl (%rax), %esi
movq 0x191cc(%rip), %rdi     # 0x1cfc8
callq 0x22b0
jmp 0x3e03
cmpl $0x0, -0x134(%rbp)
je 0x3e23
movq 0x191b5(%rip), %rdi     # 0x1cfc8
leaq 0xf206(%rip), %rsi      # 0x13020
callq 0x2190
jmp 0x3e21
jmp 0x3e23
jmp 0x3e25
movl -0x134(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x134(%rbp)
jmp 0x3dd7
movq 0x1918b(%rip), %rdi     # 0x1cfc8
movq 0x19174(%rip), %rsi     # 0x1cfb8
callq 0x21d0
jmp 0x3e4b
leaq -0xf0(%rbp), %rdi
callq 0x5f90
leaq -0xd8(%rbp), %rdi
callq 0x5ff0
leaq -0x40(%rbp), %rdi
callq 0x6010
addq $0x1a0, %rsp            # imm = 0x1A0
popq %rbp
retq
leaq -0x40(%rbp), %rdi
callq 0x6010
movq -0x80(%rbp), %rdi
callq 0x22c0
nopw (%rax,%rax)