// File: /workspace/github_cpp_makefile_star2_O1/Manca[P]algorithms2/./assignment1.hpp
// Function: assignment1::prims_algorithm::prims_algorithm(std::map<int, std::vector<std::tuple<int, int, int>, std::allocator<std::tuple<int, int, int>>>, std::less<int>, std::allocator<std::pair<int const, std::vector<std::tuple<int, int, int>, std::allocator<std::tuple<int, int, int>>>>>>&)
long long prims_algorithm(Graph& g)
        {
            long long result = 0;
            std::vector<int> X = { 1 };		// vertices spanned by tree T so far (initialize X with first vertex in first edge)
            std::vector<Edge> T;			// T is initially empty (tree_so_far)

            while (X.size() != g.size())
            {
                // let's go over all vertices in X so far and find adjancent min cost nodes
                Edge min_cost_edge;
                int min = 9999999;
                for (int u : X)	// always need to find the cheapest edge from whole set of adjacent vertices to set X
                {
                    // search min cost edge
                    for (auto edge : g[u])
                    {
                        if (std::find(X.begin(), X.end(), std::get<1>(edge)) == X.end()) // if target vertex is not in X
                        {
                            if (std::get<2>(edge) < min)
                            {
                                min_cost_edge = edge;
                                min = std::get<2>(edge);
                            }
                        }
                    }
                }
                // finally add the cheapest node overall (going out from X) and add destination node to X
                T.push_back(min_cost_edge);
                X.push_back(std::get<1>(min_cost_edge));	// add destination vertex to X
            }

            for (auto e : T)
            {
                result += std::get<2>(e);
            }

            return result;
        }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rdi, %rbx
leaq 0x50(%rsp), %r14
movl $0x1, (%r14)
leaq 0x18(%rsp), %r15
leaq 0xc(%rsp), %rcx
movl $0x1, %edx
movq %r15, %rdi
movq %r14, %rsi
callq 0x8770
xorps %xmm0, %xmm0
movaps %xmm0, (%r14)
movq $0x0, 0x10(%r14)
movq (%r15), %r12
movq 0x8(%r15), %r13
movq %r13, %rax
subq %r12, %rax
sarq $0x2, %rax
movq %rbx, 0x48(%rsp)
cmpq 0x28(%rbx), %rax
je 0x2dcc
leaq 0x3c(%rsp), %r15
movq $0x0, 0xc(%rsp)
movl $0x0, 0x14(%rsp)
cmpq %r13, %r12
je 0x2d4b
movl $0x98967f, %ebp         # imm = 0x98967F
movl (%r12), %eax
movl %eax, 0x34(%rsp)
movq 0x48(%rsp), %rdi
leaq 0x34(%rsp), %rsi
callq 0x87ae
movq (%rax), %r14
movq 0x8(%rax), %rbx
cmpq %rbx, %r14
je 0x2d42
movl 0x8(%r14), %eax
movl %eax, 0x40(%rsp)
movq (%r14), %rax
movq %rax, 0x38(%rsp)
movq 0x18(%rsp), %rdi
movq 0x20(%rsp), %rsi
movq %r15, %rdx
callq 0xb6b0
cmpq 0x20(%rsp), %rax
jne 0x2d3c
movl 0x38(%rsp), %eax
cmpl %ebp, %eax
jge 0x2d3c
movq 0x3c(%rsp), %rcx
movq %rcx, 0x10(%rsp)
movl %eax, 0xc(%rsp)
movl %eax, %ebp
addq $0xc, %r14
jmp 0x2cf6
addq $0x4, %r12
cmpq %r13, %r12
jne 0x2cd8
movq 0x58(%rsp), %rsi
cmpq 0x60(%rsp), %rsi
je 0x2d6e
movl 0x14(%rsp), %eax
movl %eax, 0x8(%rsi)
movq 0xc(%rsp), %rax
movq %rax, (%rsi)
addq $0xc, 0x58(%rsp)
jmp 0x2d7d
leaq 0x50(%rsp), %rdi
leaq 0xc(%rsp), %rdx
callq 0xb74a
movq 0x20(%rsp), %rsi
cmpq 0x28(%rsp), %rsi
je 0x2d9a
movl 0x10(%rsp), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x20(%rsp)
jmp 0x2da9
leaq 0x18(%rsp), %rdi
leaq 0x10(%rsp), %rdx
callq 0xb8d2
movq 0x18(%rsp), %r12
movq 0x20(%rsp), %r13
movq %r13, %rax
subq %r12, %rax
sarq $0x2, %rax
movq 0x48(%rsp), %rcx
cmpq 0x28(%rcx), %rax
jne 0x2cbd
movq 0x50(%rsp), %rdi
movq 0x58(%rsp), %rax
xorl %ebx, %ebx
cmpq %rax, %rdi
je 0x2def
movq %rdi, %rcx
movslq (%rcx), %rdx
addq %rdx, %rbx
addq $0xc, %rcx
cmpq %rax, %rcx
jne 0x2de0
testq %rdi, %rdi
je 0x2df9
callq 0x2200
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x2e08
callq 0x2200
movq %rbx, %rax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x2e1e
jmp 0x2e1e
movq %rax, %rbx
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x2e30
callq 0x2200
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x2e3f
callq 0x2200
movq %rbx, %rdi
callq 0x2360