// File: /workspace/github_cpp_makefile_star2_O3/Manca[P]algorithms1/./assignment3.hpp
// Function: assignment3::Graph::mincut()
int mincut()
        {
            std::map<int, std::vector<int>> contractedList = adjacencyList; // make a copy of starting list
            size_t n = contractedList.size();
            
            // random generator
            std::random_device rd;
            std::mt19937 gen(rd());
            
            while (n > 2)
            {
                // random vertex from the list of vertices (we know that there are 200 of them,
                // but the correct way should be random vertex from min key to max key
                std::uniform_int_distribution<int> vertexDistribution(1, 200);
                int u = vertexDistribution(gen);

                // if randomly selected u has already been deleted from the list, let's skip it
                if (contractedList.count(u) == 0)
                    continue;
                
                // random edge selection for the given first vertex
                size_t uSize = contractedList[u].size();
                std::uniform_int_distribution<int > edgeDistribution(0, (int)(uSize - 1)); // [a,b]
                int e = edgeDistribution(gen);
                
                // find a node in adjacency list for given vertex represented by e
                int v = contractedList[u].at(e);
                // let's see if the node actually exists in the list
                if (contractedList.count(v) == 0 || u == v)
                    continue;
                
                // merge two nodes into one (we'll use u here and copy all the neighbors of v to u's its adjancency list)
                for (int node : contractedList[v])
                    contractedList[u].push_back(node);
                
                // point other vertices that were pointing to v to u
                for (const auto& map_el : contractedList)
                    for (int& neighbor : contractedList[map_el.first])  // we'll mutate neighbor here
                        if (neighbor == v)
                            neighbor = u;
                
         
                // erase the adjacency list of v and decrease number of nodes by one
                contractedList.erase(v);
                n--;
                
                // finally, let's clean all self loops in a merged node
                size_t i = 0;
                while (i < contractedList[u].size())
                    if (contractedList[u].at(i) == u)
                        contractedList[u].erase(begin(contractedList[u]) + i);
                    else i++;
            }
            
            // last two nodes and their sizes (corresponding to number of crossing edges)
            int u = -1, v = -1;
            size_t uSize = -1, vSize = -1;
            for (const auto& map_el : contractedList)
            {
                if (u == -1)
                {
                    u = map_el.first;
                    uSize = map_el.second.size();
                }
                else
                {
                    v = map_el.first;
                    vSize = map_el.second.size();
                }
            }
            
            // uSize must be the same as vSize
            assert(uSize == vSize);
            
            size_t currentMinCut = uSize;   // either uSize or vSize
            _minCut =  currentMinCut < _minCut ? currentMinCut : _minCut;
            
            return (int)_minCut;
        }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2768, %rsp           # imm = 0x2768
movq %rdi, %r14
leaq 0x28(%rsp), %rbx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x74d8
movq 0x28(%rbx), %r15
leaq 0x13e0(%rsp), %rdi
callq 0x746e
leaq 0x13e0(%rsp), %rdi
callq 0x2260
movq %r14, 0x18(%rsp)
movl %eax, %eax
movq %rax, 0x58(%rsp)
movl $0x1, %ecx
movq %rax, %rdx
shrq $0x1e, %rdx
xorl %eax, %edx
imull $0x6c078965, %edx, %eax # imm = 0x6C078965
addl %ecx, %eax
movq %rax, 0x58(%rsp,%rcx,8)
incq %rcx
cmpq $0x270, %rcx            # imm = 0x270
jne 0x6843
movq $0x270, 0x13d8(%rsp) # imm = 0x270
leaq 0x30(%rsp), %r14
cmpq $0x3, %r15
jb 0x6b13
leaq 0x28(%rsp), %r12
leaq 0x4(%rsp), %r13
movabsq $0xc800000001, %rax     # imm = 0xC800000001
movq %rax, 0x20(%rsp)
leaq 0x20(%rsp), %rdi
leaq 0x58(%rsp), %rsi
movq %rdi, %rdx
callq 0x76de
movl %eax, 0x4(%rsp)
movq 0x38(%rsp), %r8
testq %r8, %r8
je 0x6b09
movq %r14, %rdi
movq %rdi, %rcx
movq %r8, %rdx
movl 0x20(%r8), %esi
xorl %r8d, %r8d
cmpl %eax, %esi
setl %r8b
movq %rdx, %rdi
cmovlq %rcx, %rdi
movq 0x10(%rdx,%r8,8), %r8
testq %r8, %r8
jne 0x68c0
cmpq %r14, %rdi
je 0x6b09
cmpl %eax, %esi
cmovlq %rcx, %rdx
cmpl 0x20(%rdx), %eax
jl 0x6b09
movq %r12, %rdi
movq %r13, %rsi
callq 0x61cc
movq 0x8(%rax), %rcx
subq (%rax), %rcx
shrq $0x2, %rcx
decl %ecx
movl $0x0, 0x10(%rsp)
movl %ecx, 0x14(%rsp)
leaq 0x10(%rsp), %rdi
leaq 0x58(%rsp), %rsi
movq %rdi, %rdx
callq 0x76de
movl %eax, %ebx
movq %r12, %rdi
movq %r13, %rsi
callq 0x61cc
movslq %ebx, %rsi
movq (%rax), %rcx
movq 0x8(%rax), %rdx
subq %rcx, %rdx
sarq $0x2, %rdx
cmpq %rsi, %rdx
jbe 0x6bda
movl (%rcx,%rsi,4), %eax
movl %eax, 0x8(%rsp)
movq 0x38(%rsp), %r8
testq %r8, %r8
je 0x6b09
movq %r14, %rdi
movq %rdi, %rcx
movq %r8, %rdx
movl 0x20(%r8), %esi
xorl %r8d, %r8d
cmpl %eax, %esi
setl %r8b
movq %rdx, %rdi
cmovlq %rcx, %rdi
movq 0x10(%rdx,%r8,8), %r8
testq %r8, %r8
jne 0x6971
cmpq %r14, %rdi
je 0x6b09
cmpl %eax, %esi
cmovlq %rcx, %rdx
cmpl 0x20(%rdx), %eax
jl 0x6b09
cmpl %eax, 0x4(%rsp)
je 0x6b09
movq %r12, %rdi
leaq 0x8(%rsp), %rsi
callq 0x61cc
movq (%rax), %rbx
movq 0x8(%rax), %rbp
cmpq %rbp, %rbx
je 0x6a0e
movl (%rbx), %eax
movl %eax, 0xc(%rsp)
movq %r12, %rdi
movq %r13, %rsi
callq 0x61cc
movq 0x8(%rax), %rsi
cmpq 0x10(%rax), %rsi
je 0x69fb
movl 0xc(%rsp), %ecx
movl %ecx, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rax)
jmp 0x6a08
movq %rax, %rdi
leaq 0xc(%rsp), %rdx
callq 0x733a
addq $0x4, %rbx
jmp 0x69cb
movq 0x40(%rsp), %rbx
cmpq %r14, %rbx
je 0x6a54
leaq 0x20(%rbx), %rsi
movq %r12, %rdi
callq 0x61cc
movq (%rax), %rcx
movq 0x8(%rax), %rax
cmpq %rax, %rcx
je 0x6a44
movl (%rcx), %edx
cmpl 0x8(%rsp), %edx
jne 0x6a3e
movl 0x4(%rsp), %edx
movl %edx, (%rcx)
addq $0x4, %rcx
jmp 0x6a2b
movq %rbx, %rdi
callq 0x2150
movq %rax, %rbx
cmpq %r14, %rax
jne 0x6a18
movq %r12, %rdi
leaq 0x8(%rsp), %rsi
callq 0x793c
movq %r12, %rdi
movq %rax, %rsi
callq 0x79ba
decq %r15
xorl %ebx, %ebx
movq %r12, %rdi
movq %r13, %rsi
callq 0x61cc
movq 0x8(%rax), %rcx
subq (%rax), %rcx
sarq $0x2, %rcx
cmpq %rcx, %rbx
jae 0x6b09
movq %r12, %rdi
movq %r13, %rsi
callq 0x61cc
movq (%rax), %rcx
movq 0x8(%rax), %rdx
subq %rcx, %rdx
sarq $0x2, %rdx
cmpq %rbx, %rdx
jbe 0x6bc9
movl (%rcx,%rbx,4), %eax
cmpl 0x4(%rsp), %eax
jne 0x6b01
movq %r12, %rdi
movq %r13, %rsi
callq 0x61cc
movq %rax, %rbp
movq %r12, %rdi
movq %r13, %rsi
callq 0x61cc
movq (%rax), %rax
leaq (%rax,%rbx,4), %rsi
addq $0x4, %rsi
movq 0x8(%rbp), %rdx
cmpq %rdx, %rsi
je 0x6af4
leaq (%rax,%rbx,4), %rdi
subq %rsi, %rdx
callq 0x22c0
movq 0x8(%rbp), %rdx
addq $-0x4, %rdx
movq %rdx, 0x8(%rbp)
jmp 0x6a71
incq %rbx
jmp 0x6a71
cmpq $0x2, %r15
ja 0x688a
movq 0x40(%rsp), %rax
cmpq %r14, %rax
je 0x6b83
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movq $-0x1, %rbx
movq $-0x1, %r15
cmpl $-0x1, %ebp
je 0x6b43
movq 0x30(%rax), %rbx
subq 0x28(%rax), %rbx
sarq $0x2, %rbx
jmp 0x6b52
movl 0x20(%rax), %ebp
movq 0x30(%rax), %r15
subq 0x28(%rax), %r15
sarq $0x2, %r15
movq %rax, %rdi
callq 0x2150
cmpq %r14, %rax
jne 0x6b30
cmpq %rbx, %r15
je 0x6b8a
leaq 0x3c94(%rip), %rdi      # 0xa7ff
leaq 0x3c9c(%rip), %rsi      # 0xa80e
leaq 0x3ca7(%rip), %rcx      # 0xa820
movl $0xa4, %edx
callq 0x2120
movq $-0x1, %r15
movq 0x18(%rsp), %rax
movq 0x30(%rax), %rbx
cmpq %rbx, %r15
cmovbq %r15, %rbx
movq %rbx, 0x30(%rax)
leaq 0x13e0(%rsp), %rdi
callq 0x21a0
leaq 0x28(%rsp), %rdi
callq 0x6c3a
movl %ebx, %eax
addq $0x2768, %rsp           # imm = 0x2768
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x3c79(%rip), %rdi      # 0xa849
movq %rbx, %rsi
xorl %eax, %eax
callq 0x2290
leaq 0x3c68(%rip), %rdi      # 0xa849
xorl %eax, %eax
callq 0x2290
jmp 0x6c05
jmp 0x6c27
jmp 0x6c05
movq %rax, %rbx
jmp 0x6c15
jmp 0x6c05
jmp 0x6c05
jmp 0x6c05
jmp 0x6c05
jmp 0x6c05
jmp 0x6c05
jmp 0x6c05
jmp 0x6c05
jmp 0x6c05
movq %rax, %rbx
leaq 0x13e0(%rsp), %rdi
callq 0x21a0
leaq 0x28(%rsp), %rdi
callq 0x6c3a
movq %rbx, %rdi
callq 0x2310
movq %rax, %rdi
callq 0x6c2f