// File: /workspace/github_cpp_makefile_star2_O2/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 0x6ee6
movq %rbx, %rdi
callq 0x45f0
xorpd %xmm0, %xmm0
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3fba
leaq -0x1b0(%rbp), %rdi
movq %r14, %rsi
callq 0x28ba
leaq -0x48(%rbp), %rdi
leaq -0x1b0(%rbp), %rdx
movq %rbx, %rsi
callq 0x6f48
leaq -0x1b0(%rbp), %rdi
callq 0x2918
leaq -0x130(%rbp), %r14
leaq -0xb0(%rbp), %r15
movq -0x48(%rbp), %rax
cmpq -0x40(%rbp), %rax
je 0x9185
movq %r14, %rdi
leaq -0x48(%rbp), %rsi
movq %rbx, %rdx
callq 0x6f72
movq %rbx, %rdi
movq %r14, %rsi
callq 0x40e0
testb %al, %al
jne 0x9178
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3f40
movq %rbx, %rdi
movq %r14, %rsi
callq 0x428a
leaq -0x98(%rbp), %rdi
movq %rax, %rsi
callq 0x5516
movq %rbx, %rdi
movq %r14, %rsi
callq 0x42ce
leaq -0x68(%rbp), %rdi
movq %rax, %rsi
callq 0x53ec
movq -0x80(%rbp), %r14
leaq -0x90(%rbp), %rax
cmpq %rax, %r14
je 0x915c
leaq 0x20(%r14), %r13
leaq -0x2b0(%rbp), %rdi
movq %r13, %rsi
callq 0x28ba
movq %r15, %rdi
leaq -0x68(%rbp), %rsi
callq 0x53ec
movq %r15, %r12
leaq -0x2b0(%rbp), %r15
movq %r15, %rdi
movq %r12, %rsi
callq 0x8c54
movsd %xmm0, -0x30(%rbp)
movq %r12, %rdi
callq 0x2a4a
movq %r15, %rdi
callq 0x2918
movq %rbx, %rdi
movq %r13, %rsi
callq 0x4106
movsd %xmm0, -0x50(%rbp)
movq %r12, %r15
movq %rbx, %rdi
leaq -0x130(%rbp), %rsi
callq 0x4106
cvttsd2si -0x30(%rbp), %eax
cvtsi2sd %eax, %xmm1
movsd %xmm1, -0x30(%rbp)
addsd %xmm1, %xmm0
movsd -0x50(%rbp), %xmm1
ucomisd %xmm0, %xmm1
ja 0x9100
movq %rbx, %rdi
movq %r13, %rsi
callq 0x4106
ucomisd 0x1f6c(%rip), %xmm0     # 0xb068
jne 0x914c
jp 0x914c
movq %rbx, %rdi
leaq -0x130(%rbp), %rsi
callq 0x4106
addsd -0x30(%rbp), %xmm0
movq %rbx, %rdi
movq %r13, %rsi
callq 0x3fba
leaq -0x230(%rbp), %rdi
movq %r13, %rsi
callq 0x28ba
leaq -0x48(%rbp), %rdi
movq %rbx, %rsi
leaq -0x230(%rbp), %r12
movq %r12, %rdx
callq 0x6f48
movq %r12, %rdi
callq 0x2918
movq %r14, %rdi
callq 0x2260
movq %rax, %r14
jmp 0x9051
leaq -0x68(%rbp), %rdi
callq 0x2a4a
leaq -0x98(%rbp), %rdi
callq 0x2aa8
leaq -0x130(%rbp), %r14
movq %r14, %rdi
callq 0x2918
jmp 0x8fe1
leaq -0x48(%rbp), %rdi
callq 0x29d0
addq $0x288, %rsp            # imm = 0x288
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq -0x1b0(%rbp), %rdi
jmp 0x920c
jmp 0x91ae
movq %rax, %rbx
jmp 0x9211
jmp 0x91ba
movq %rax, %rbx
jmp 0x91f9
movq %rax, %rbx
jmp 0x9205
movq %rax, %rbx
leaq -0x230(%rbp), %rdi
jmp 0x91e6
movq %rax, %rbx
leaq -0xb0(%rbp), %rdi
callq 0x2a4a
jmp 0x91df
movq %rax, %rbx
leaq -0x2b0(%rbp), %rdi
callq 0x2918
jmp 0x91f0
movq %rax, %rbx
leaq -0x68(%rbp), %rdi
callq 0x2a4a
leaq -0x98(%rbp), %rdi
callq 0x2aa8
leaq -0x130(%rbp), %rdi
callq 0x2918
leaq -0x48(%rbp), %rdi
callq 0x29d0
movq %rbx, %rdi
callq 0x2370