// File: /workspace/github_cpp_makefile_star2_O3/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 0x87ac
xorps %xmm0, %xmm0
movaps %xmm0, (%r14)
movq $0x0, 0x10(%r14)
movq (%r15), %r14
movq 0x8(%r15), %rbp
movq %rbp, %rax
subq %r14, %rax
sarq $0x2, %rax
movq %rbx, 0x48(%rsp)
cmpq 0x28(%rbx), %rax
jne 0x2cc0
xorl %ebx, %ebx
jmp 0x2e17
leaq 0x3c(%rsp), %r12
movq $0x0, 0xc(%rsp)
movl $0x0, 0x14(%rsp)
cmpq %rbp, %r14
je 0x2d60
movl $0x98967f, %r15d        # imm = 0x98967F
movl (%r14), %eax
movl %eax, 0x34(%rsp)
movq 0x48(%rsp), %rdi
leaq 0x34(%rsp), %rsi
callq 0x87ea
movq (%rax), %r13
movq 0x8(%rax), %rbx
cmpq %rbx, %r13
je 0x2d57
movq 0x20(%rsp), %rsi
movl 0x8(%r13), %eax
movl %eax, 0x40(%rsp)
movq (%r13), %rax
movq %rax, 0x38(%rsp)
movq 0x18(%rsp), %rdi
movq %r12, %rdx
callq 0xb6de
movq 0x20(%rsp), %rsi
cmpq %rsi, %rax
jne 0x2d4e
movl 0x38(%rsp), %eax
cmpl %r15d, %eax
jge 0x2d4e
movq 0x3c(%rsp), %rcx
movq %rcx, 0x10(%rsp)
movl %eax, 0xc(%rsp)
movl %eax, %r15d
addq $0xc, %r13
cmpq %rbx, %r13
jne 0x2d0c
addq $0x4, %r14
cmpq %rbp, %r14
jne 0x2ce5
movq 0x58(%rsp), %rsi
cmpq 0x60(%rsp), %rsi
je 0x2d83
movl 0x14(%rsp), %eax
movl %eax, 0x8(%rsi)
movq 0xc(%rsp), %rax
movq %rax, (%rsi)
addq $0xc, 0x58(%rsp)
jmp 0x2d92
leaq 0x50(%rsp), %rdi
leaq 0xc(%rsp), %rdx
callq 0xb784
movq 0x20(%rsp), %rbp
cmpq 0x28(%rsp), %rbp
je 0x2db0
movl 0x10(%rsp), %eax
movl %eax, (%rbp)
addq $0x4, %rbp
movq %rbp, 0x20(%rsp)
jmp 0x2dc7
leaq 0x18(%rsp), %rdi
movq %rbp, %rsi
leaq 0x10(%rsp), %rdx
callq 0xb90c
movq 0x20(%rsp), %rbp
movq 0x18(%rsp), %r14
movq %rbp, %rax
subq %r14, %rax
sarq $0x2, %rax
movq 0x48(%rsp), %rcx
cmpq 0x28(%rcx), %rax
jne 0x2cc5
movq 0x50(%rsp), %rdi
movq 0x58(%rsp), %rax
xorl %ebx, %ebx
cmpq %rax, %rdi
je 0x2e08
movq %rdi, %rcx
movslq (%rcx), %rdx
addq %rdx, %rbx
addq $0xc, %rcx
cmpq %rax, %rcx
jne 0x2df9
testq %rdi, %rdi
je 0x2e17
callq 0x21f0
movq 0x18(%rsp), %r14
testq %r14, %r14
je 0x2e24
movq %r14, %rdi
callq 0x21f0
movq %rbx, %rax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x2e3a
jmp 0x2e3a
movq %rax, %rbx
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x2e4c
callq 0x21f0
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x2e5b
callq 0x21f0
movq %rbx, %rdi
callq 0x2350