// File: jkeys-ecg-nmsu[P]graph-with-search-algorithms/Kruskal.cpp
// Function: Kruskal_MST_cclabels(Graph&)
Graph Kruskal_MST_cclabels ( Graph & g) {	
	Graph r(g.num_nodes() + 1);
	r.copyNodes(g);
	r.copyEdges(g);
	r.reset();
		
	make_set_cc(g);
	
	vector<Edge> E = get_all_edges(g);
	
	// make_edge_heap(E);
	
	sort(E.begin(), E.end(), edge_heap_comp);
	
	// while(!E.empty()) {
	for(int i = 0; i != E.size(); i++) {
		// Edge e = cheapest_edge(E); //get cheapest edge and pop
		Edge e = E.at(i);
		Node u = g.getNode(e.u_id());
		Node v = g.getNode(e.v_id());
		
		if(!same_set_cc(g, u, v)) {
			// cerr << "in cc, sets are disjoint, edge: ";
			// e.print(r);
			
			r.pushEdge(e);			
			union_set_cc(g, u, v);
		}
		
		
	}
	
	return r;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x3e0, %rsp            # imm = 0x3E0
movq %rdi, -0x378(%rbp)
movq %rdi, %rax
movq %rax, -0x380(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movb $0x0, -0x11(%rbp)
movq -0x10(%rbp), %rdi
callq 0x6100
movq -0x378(%rbp), %rdi
movl %eax, %esi
incl %esi
callq 0x3d50
movq -0x378(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x6a10
jmp 0x17623
movq -0x378(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x6a80
jmp 0x17635
movq -0x378(%rbp), %rdi
callq 0x6930
jmp 0x17643
movq -0x10(%rbp), %rdi
callq 0x16c70
jmp 0x1764e
movq -0x10(%rbp), %rsi
leaq -0x40(%rbp), %rdi
callq 0x16d30
jmp 0x1765d
leaq -0x40(%rbp), %rdi
movq %rdi, -0x388(%rbp)
callq 0xc6d0
movq -0x388(%rbp), %rdi
movq %rax, -0x48(%rbp)
callq 0xc550
movq %rax, -0x50(%rbp)
movq -0x48(%rbp), %rdi
movq -0x50(%rbp), %rsi
leaq -0xb80(%rip), %rdx      # 0x16b10
callq 0x18010
jmp 0x17697
movl $0x0, -0x54(%rbp)
movslq -0x54(%rbp), %rax
movq %rax, -0x390(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x7f40
movq %rax, %rcx
movq -0x390(%rbp), %rax
cmpq %rcx, %rax
je 0x1797f
movslq -0x54(%rbp), %rsi
leaq -0x40(%rbp), %rdi
callq 0x7f60
movq %rax, -0x398(%rbp)
jmp 0x176db
movq -0x398(%rbp), %rax
movups (%rax), %xmm0
movaps %xmm0, -0x70(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x3a8(%rbp)
leaq -0x70(%rbp), %rdi
callq 0xeec0
movl %eax, -0x39c(%rbp)
jmp 0x17705
movq -0x3a8(%rbp), %rdi
movl -0x39c(%rbp), %eax
movslq %eax, %rsi
callq 0x5040
movq %rax, -0x3b0(%rbp)
jmp 0x17723
movq -0x3b0(%rbp), %rsi
leaq -0xf0(%rbp), %rdi
callq 0x2b50
jmp 0x17738
movq -0x10(%rbp), %rax
movq %rax, -0x3c0(%rbp)
leaq -0x70(%rbp), %rdi
callq 0xeed0
movl %eax, -0x3b4(%rbp)
jmp 0x17754
movq -0x3c0(%rbp), %rdi
movl -0x3b4(%rbp), %eax
movslq %eax, %rsi
callq 0x5040
movq %rax, -0x3c8(%rbp)
jmp 0x17772
movq -0x3c8(%rbp), %rsi
leaq -0x170(%rbp), %rdi
callq 0x2b50
jmp 0x17787
movq -0x10(%rbp), %rax
movq %rax, -0x3d0(%rbp)
leaq -0x1f0(%rbp), %rdi
leaq -0xf0(%rbp), %rsi
callq 0x2b50
jmp 0x177a7
leaq -0x270(%rbp), %rdi
leaq -0x170(%rbp), %rsi
callq 0x2b50
jmp 0x177bc
movq -0x3d0(%rbp), %rdi
leaq -0x1f0(%rbp), %rsi
leaq -0x270(%rbp), %rdx
callq 0x16f30
movb %al, -0x3d1(%rbp)
jmp 0x177de
movb -0x3d1(%rbp), %al
xorb $-0x1, %al
movb %al, -0x3d2(%rbp)
leaq -0x270(%rbp), %rdi
callq 0x2bd0
leaq -0x1f0(%rbp), %rdi
callq 0x2bd0
movb -0x3d2(%rbp), %al
testb $0x1, %al
jne 0x17813
jmp 0x1793f
movq -0x378(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x5f00
jmp 0x17825
movq -0x10(%rbp), %rax
movq %rax, -0x3e0(%rbp)
leaq -0x2f0(%rbp), %rdi
leaq -0xf0(%rbp), %rsi
callq 0x2b50
jmp 0x17845
leaq -0x370(%rbp), %rdi
leaq -0x170(%rbp), %rsi
callq 0x2b50
jmp 0x1785a
movq -0x3e0(%rbp), %rdi
leaq -0x2f0(%rbp), %rsi
leaq -0x370(%rbp), %rdx
callq 0x170a0
jmp 0x17876
leaq -0x370(%rbp), %rdi
callq 0x2bd0
leaq -0x2f0(%rbp), %rdi
callq 0x2bd0
jmp 0x1793f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x179bb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x17994
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x17971
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x17965
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x178fd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
leaq -0x270(%rbp), %rdi
callq 0x2bd0
leaq -0x1f0(%rbp), %rdi
callq 0x2bd0
jmp 0x17965
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x17931
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
leaq -0x370(%rbp), %rdi
callq 0x2bd0
leaq -0x2f0(%rbp), %rdi
callq 0x2bd0
jmp 0x17965
leaq -0x170(%rbp), %rdi
callq 0x2bd0
leaq -0xf0(%rbp), %rdi
callq 0x2bd0
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
jmp 0x1769e
leaq -0x170(%rbp), %rdi
callq 0x2bd0
leaq -0xf0(%rbp), %rdi
callq 0x2bd0
jmp 0x17994
movb $0x1, -0x11(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x2c50
testb $0x1, -0x11(%rbp)
jne 0x179ab
jmp 0x1799f
leaq -0x40(%rbp), %rdi
callq 0x2c50
jmp 0x179bb
movq -0x378(%rbp), %rdi
callq 0x2c00
movq -0x380(%rbp), %rax
addq $0x3e0, %rsp            # imm = 0x3E0
popq %rbp
retq
movq -0x378(%rbp), %rdi
callq 0x2c00
movq -0x20(%rbp), %rdi
callq 0x23e0