// File: /workspace/github_cpp_makefile_star2_O1/jkeys-ecg-nmsu[P]graph-with-search-algorithms/Dijkstra.cpp
// Function: Dijkstra_heap(Graph&, Node&)
void Dijkstra_heap(Graph & g, Node & s) {
	HeapPriorityQueue q(g);
	
	g.resetAllDist();	
	g.setDist(s, 0); //s is the root 
	
	q.insert(g, s);
	
	while ( !q.empty() ) {
		Node u = q.remove_min(g);
		
		//instead of using a decrease-key operation on the heap, 
		//we will simply insert redundant nodes and skip visited nodes;
		//this means more nodes will be inserted, but since heap is already logarithmic,
		//the increase in runtime will not be significant		
		if (g.visited(u)) continue; //skip already visited nodes
		
		g.setVisited(u);
		
		set<Node> uAdjNodes = g.getAdjNodes(u);
		list<Edge> uEdges = g.getEdges(u);
		
		// for every adjacent node v: (u)--->(v)
		for(set<Node>::iterator v = uAdjNodes.begin(); v != uAdjNodes.end(); v++) {
			int edgeWeight = findEdgeWeight(*v, uEdges);

			if(g.dist(*v) > g.dist(u) + edgeWeight || g.dist(*v) == M_INFINITY) {
				g.setDist(*v, g.dist(u) + edgeWeight);	
				q.insert(g, *v);						
			}
		} //end adjNodes loop
	} //end while		
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x288, %rsp            # imm = 0x288
movq %rsi, %r14
movq %rdi, %rbx
leaq -0x48(%rbp), %rdi
movq %rbx, %rsi
callq 0x80ee
movq %rbx, %rdi
callq 0x53e0
xorpd %xmm0, %xmm0
movq %rbx, %rdi
movq %r14, %rsi
callq 0x4c18
leaq -0x2a0(%rbp), %r15
movq %r15, -0x10(%r15)
movq (%r14), %rsi
movq 0x8(%r14), %rdx
addq %rsi, %rdx
leaq -0x2b0(%rbp), %rdi
callq 0x2bfe
movupd 0x20(%r14), %xmm0
movupd 0x30(%r14), %xmm1
movups 0x40(%r14), %xmm2
movups 0x50(%r14), %xmm3
leaq -0x250(%rbp), %rdi
movups %xmm3, -0x10(%rdi)
movups %xmm2, -0x20(%rdi)
movupd %xmm1, -0x30(%rdi)
movupd %xmm0, -0x40(%rdi)
leaq -0x240(%rbp), %r12
movq %r12, -0x10(%r12)
movq 0x60(%r14), %rsi
movq 0x68(%r14), %rdx
addq %rsi, %rdx
callq 0x2bfe
leaq -0x48(%rbp), %rdi
leaq -0x2b0(%rbp), %rdx
movq %rbx, %rsi
callq 0x8162
movq -0x250(%rbp), %rdi
cmpq %r12, %rdi
je 0xb3c6
callq 0x21f0
movq -0x2b0(%rbp), %rdi
cmpq %r15, %rdi
je 0xb3d7
callq 0x21f0
movq -0x48(%rbp), %rax
cmpq -0x40(%rbp), %rax
je 0xb720
leaq -0x1c0(%rbp), %r12
leaq -0x230(%rbp), %r13
leaq -0x80(%rbp), %r14
leaq -0x68(%rbp), %r15
movq %r13, %rdi
leaq -0x48(%rbp), %rsi
movq %rbx, %rdx
callq 0x818c
movq %rbx, %rdi
movq %r13, %rsi
callq 0x4d68
testb %al, %al
jne 0xb6e9
movq %rbx, %rdi
movq %r13, %rsi
callq 0x4b9e
movq %rbx, %rdi
movq %r13, %rsi
callq 0x4f1e
leaq -0xb0(%rbp), %rdi
movq %rax, %rsi
callq 0x66b0
movq %rbx, %rdi
movq %r13, %rsi
callq 0x4f6a
movq %r14, %rdi
movq %rax, %rsi
callq 0x655c
movq -0x98(%rbp), %r12
leaq -0xa8(%rbp), %rax
cmpq %rax, %r12
je 0xb6b6
leaq -0x1a0(%rbp), %rax
movq %rax, -0x1b0(%rbp)
movq 0x20(%r12), %rsi
movq 0x28(%r12), %rdx
addq %rsi, %rdx
leaq -0x1b0(%rbp), %rdi
callq 0x2bfe
movupd 0x40(%r12), %xmm0
movupd 0x50(%r12), %xmm1
movups 0x60(%r12), %xmm2
movups 0x70(%r12), %xmm3
leaq -0x1a0(%rbp), %rax
movups %xmm3, 0x40(%rax)
movups %xmm2, 0x30(%rax)
movupd %xmm1, 0x20(%rax)
movupd %xmm0, 0x10(%rax)
leaq -0x140(%rbp), %rax
movq %rax, -0x150(%rbp)
movq 0x80(%r12), %rsi
movq 0x88(%r12), %rdx
addq %rsi, %rdx
leaq -0x150(%rbp), %rdi
callq 0x2bfe
movq %r15, %rdi
movq %r14, %rsi
callq 0x655c
leaq -0x1b0(%rbp), %rdi
movq %r15, %rsi
callq 0xad34
movsd %xmm0, -0x30(%rbp)
movq -0x68(%rbp), %rdi
cmpq %r15, %rdi
je 0xb52e
movq (%rdi), %r13
callq 0x21f0
movq %r13, %rdi
cmpq %r15, %r13
jne 0xb51e
movq -0x150(%rbp), %rdi
leaq -0x140(%rbp), %rax
cmpq %rax, %rdi
je 0xb546
callq 0x21f0
movq -0x1b0(%rbp), %rdi
leaq -0x1a0(%rbp), %rax
cmpq %rax, %rdi
je 0xb55e
callq 0x21f0
leaq 0x20(%r12), %r13
movq %rbx, %rdi
movq %r13, %rsi
callq 0x4d8e
movsd %xmm0, -0x50(%rbp)
movq %rbx, %rdi
leaq -0x230(%rbp), %rsi
callq 0x4d8e
cvttsd2si -0x30(%rbp), %eax
xorps %xmm1, %xmm1
cvtsi2sd %eax, %xmm1
movsd %xmm1, -0x30(%rbp)
addsd %xmm1, %xmm0
movsd -0x50(%rbp), %xmm1
ucomisd %xmm0, %xmm1
ja 0xb5c1
movq %rbx, %rdi
movq %r13, %rsi
callq 0x4d8e
ucomisd 0x3adb(%rip), %xmm0     # 0xf090
jne 0xb6a6
jp 0xb6a6
movq %rbx, %rdi
leaq -0x230(%rbp), %rsi
callq 0x4d8e
addsd -0x30(%rbp), %xmm0
movq %rbx, %rdi
movq %r13, %rsi
callq 0x4c18
leaq -0x120(%rbp), %rax
movq %rax, -0x130(%rbp)
movq 0x20(%r12), %rsi
movq 0x28(%r12), %rdx
addq %rsi, %rdx
leaq -0x130(%rbp), %rdi
callq 0x2bfe
leaq 0x40(%r12), %rax
movupd (%rax), %xmm0
movupd 0x10(%rax), %xmm1
movups 0x20(%rax), %xmm2
movups 0x30(%rax), %xmm3
leaq -0x120(%rbp), %rax
movups %xmm3, 0x40(%rax)
movups %xmm2, 0x30(%rax)
movupd %xmm1, 0x20(%rax)
movupd %xmm0, 0x10(%rax)
leaq -0xc0(%rbp), %rax
movq %rax, -0xd0(%rbp)
movq 0x80(%r12), %rsi
movq 0x88(%r12), %rdx
addq %rsi, %rdx
leaq -0xd0(%rbp), %rdi
callq 0x2bfe
leaq -0x48(%rbp), %rdi
movq %rbx, %rsi
leaq -0x130(%rbp), %rdx
callq 0x8162
movq -0xd0(%rbp), %rdi
leaq -0xc0(%rbp), %rax
cmpq %rax, %rdi
je 0xb68e
callq 0x21f0
movq -0x130(%rbp), %rdi
leaq -0x120(%rbp), %rax
cmpq %rax, %rdi
je 0xb6a6
callq 0x21f0
movq %r12, %rdi
callq 0x2280
movq %rax, %r12
jmp 0xb45f
movq -0x80(%rbp), %rdi
cmpq %r14, %rdi
je 0xb6cf
movq (%rdi), %r12
callq 0x21f0
movq %r12, %rdi
cmpq %r14, %r12
jne 0xb6bf
leaq -0xb0(%rbp), %rdi
callq 0x2d76
leaq -0x1c0(%rbp), %r12
leaq -0x230(%rbp), %r13
movq -0x1d0(%rbp), %rdi
cmpq %r12, %rdi
je 0xb6fa
callq 0x21f0
movq -0x230(%rbp), %rdi
leaq -0x220(%rbp), %rax
cmpq %rax, %rdi
je 0xb712
callq 0x21f0
movq -0x48(%rbp), %rax
cmpq -0x40(%rbp), %rax
jne 0xb3fb
leaq -0x48(%rbp), %rdi
callq 0x2d42
addq $0x288, %rsp            # imm = 0x288
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq -0x2b0(%rbp), %rdi
jmp 0xb81d
movq %rax, %rbx
movq -0x2b0(%rbp), %rdi
cmpq %r15, %rdi
je 0xb822
callq 0x21f0
jmp 0xb822
jmp 0xb769
movq %rax, %rbx
jmp 0xb822
jmp 0xb77b
movq %rax, %rbx
jmp 0xb80a
movq %rax, %rbx
jmp 0xb816
movq %rax, %rbx
movq -0x130(%rbp), %rdi
leaq -0x120(%rbp), %rax
jmp 0xb7e2
movq %rax, %rbx
leaq -0x130(%rbp), %rdi
jmp 0xb7ca
movq %rax, %rbx
jmp 0xb7c3
movq %rax, %rbx
movq -0x68(%rbp), %rdi
cmpq %r15, %rdi
je 0xb7c3
movq (%rdi), %r12
callq 0x21f0
movq %r12, %rdi
cmpq %r15, %r12
jne 0xb7b3
leaq -0x1b0(%rbp), %rdi
callq 0x2b90
jmp 0xb7f1
movq %rax, %rbx
movq -0x1b0(%rbp), %rdi
leaq -0x1a0(%rbp), %rax
cmpq %rax, %rdi
je 0xb7f1
callq 0x21f0
jmp 0xb7f1
movq %rax, %rbx
movq -0x80(%rbp), %rdi
cmpq %r14, %rdi
je 0xb80a
movq (%rdi), %r15
callq 0x21f0
movq %r15, %rdi
cmpq %r14, %r15
jne 0xb7fa
leaq -0xb0(%rbp), %rdi
callq 0x2d76
leaq -0x230(%rbp), %rdi
callq 0x2b90
leaq -0x48(%rbp), %rdi
callq 0x2d42
movq %rbx, %rdi
callq 0x2380