// File: /workspace/github_cpp_makefile_star2_O3/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 0x816e
movq %rbx, %rdi
callq 0x5424
xorpd %xmm0, %xmm0
movq %rbx, %rdi
movq %r14, %rsi
callq 0x4c56
leaq -0x2a0(%rbp), %r15
movq %r15, -0x10(%r15)
movq (%r14), %rsi
movq 0x8(%r14), %rdx
addq %rsi, %rdx
leaq -0x2b0(%rbp), %rdi
callq 0x2c2e
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 0x2c2e
leaq -0x48(%rbp), %rdi
leaq -0x2b0(%rbp), %rdx
movq %rbx, %rsi
callq 0x81e2
movq -0x250(%rbp), %rdi
cmpq %r12, %rdi
je 0xb432
callq 0x21f0
movq -0x2b0(%rbp), %rdi
cmpq %r15, %rdi
je 0xb443
callq 0x21f0
movq -0x48(%rbp), %rax
cmpq -0x40(%rbp), %rax
je 0xb78c
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 0x820c
movq %rbx, %rdi
movq %r13, %rsi
callq 0x4da6
testb %al, %al
jne 0xb755
movq %rbx, %rdi
movq %r13, %rsi
callq 0x4bdc
movq %rbx, %rdi
movq %r13, %rsi
callq 0x4f5c
leaq -0xb0(%rbp), %rdi
movq %rax, %rsi
callq 0x6756
movq %rbx, %rdi
movq %r13, %rsi
callq 0x4fa8
movq %r14, %rdi
movq %rax, %rsi
callq 0x6602
movq -0x98(%rbp), %r12
leaq -0xa8(%rbp), %rax
cmpq %rax, %r12
je 0xb722
leaq -0x1a0(%rbp), %rax
movq %rax, -0x1b0(%rbp)
movq 0x20(%r12), %rsi
movq 0x28(%r12), %rdx
addq %rsi, %rdx
leaq -0x1b0(%rbp), %rdi
callq 0x2c2e
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 0x2c2e
movq %r15, %rdi
movq %r14, %rsi
callq 0x6602
leaq -0x1b0(%rbp), %rdi
movq %r15, %rsi
callq 0xadb0
movsd %xmm0, -0x30(%rbp)
movq -0x68(%rbp), %rdi
cmpq %r15, %rdi
je 0xb59a
movq (%rdi), %r13
callq 0x21f0
movq %r13, %rdi
cmpq %r15, %r13
jne 0xb58a
movq -0x150(%rbp), %rdi
leaq -0x140(%rbp), %rax
cmpq %rax, %rdi
je 0xb5b2
callq 0x21f0
movq -0x1b0(%rbp), %rdi
leaq -0x1a0(%rbp), %rax
cmpq %rax, %rdi
je 0xb5ca
callq 0x21f0
leaq 0x20(%r12), %r13
movq %rbx, %rdi
movq %r13, %rsi
callq 0x4dcc
movsd %xmm0, -0x50(%rbp)
movq %rbx, %rdi
leaq -0x230(%rbp), %rsi
callq 0x4dcc
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 0xb62d
movq %rbx, %rdi
movq %r13, %rsi
callq 0x4dcc
ucomisd 0x3a6f(%rip), %xmm0     # 0xf090
jne 0xb712
jp 0xb712
movq %rbx, %rdi
leaq -0x230(%rbp), %rsi
callq 0x4dcc
addsd -0x30(%rbp), %xmm0
movq %rbx, %rdi
movq %r13, %rsi
callq 0x4c56
leaq -0x120(%rbp), %rax
movq %rax, -0x130(%rbp)
movq 0x20(%r12), %rsi
movq 0x28(%r12), %rdx
addq %rsi, %rdx
leaq -0x130(%rbp), %rdi
callq 0x2c2e
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 0x2c2e
leaq -0x48(%rbp), %rdi
movq %rbx, %rsi
leaq -0x130(%rbp), %rdx
callq 0x81e2
movq -0xd0(%rbp), %rdi
leaq -0xc0(%rbp), %rax
cmpq %rax, %rdi
je 0xb6fa
callq 0x21f0
movq -0x130(%rbp), %rdi
leaq -0x120(%rbp), %rax
cmpq %rax, %rdi
je 0xb712
callq 0x21f0
movq %r12, %rdi
callq 0x2280
movq %rax, %r12
jmp 0xb4cb
movq -0x80(%rbp), %rdi
cmpq %r14, %rdi
je 0xb73b
movq (%rdi), %r12
callq 0x21f0
movq %r12, %rdi
cmpq %r14, %r12
jne 0xb72b
leaq -0xb0(%rbp), %rdi
callq 0x2dba
leaq -0x1c0(%rbp), %r12
leaq -0x230(%rbp), %r13
movq -0x1d0(%rbp), %rdi
cmpq %r12, %rdi
je 0xb766
callq 0x21f0
movq -0x230(%rbp), %rdi
leaq -0x220(%rbp), %rax
cmpq %rax, %rdi
je 0xb77e
callq 0x21f0
movq -0x48(%rbp), %rax
cmpq -0x40(%rbp), %rax
jne 0xb467
leaq -0x48(%rbp), %rdi
callq 0x2d86
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 0xb889
movq %rax, %rbx
movq -0x2b0(%rbp), %rdi
cmpq %r15, %rdi
je 0xb88e
callq 0x21f0
jmp 0xb88e
jmp 0xb7d5
movq %rax, %rbx
jmp 0xb88e
jmp 0xb7e7
movq %rax, %rbx
jmp 0xb876
movq %rax, %rbx
jmp 0xb882
movq %rax, %rbx
movq -0x130(%rbp), %rdi
leaq -0x120(%rbp), %rax
jmp 0xb84e
movq %rax, %rbx
leaq -0x130(%rbp), %rdi
jmp 0xb836
movq %rax, %rbx
jmp 0xb82f
movq %rax, %rbx
movq -0x68(%rbp), %rdi
cmpq %r15, %rdi
je 0xb82f
movq (%rdi), %r12
callq 0x21f0
movq %r12, %rdi
cmpq %r15, %r12
jne 0xb81f
leaq -0x1b0(%rbp), %rdi
callq 0x2bc0
jmp 0xb85d
movq %rax, %rbx
movq -0x1b0(%rbp), %rdi
leaq -0x1a0(%rbp), %rax
cmpq %rax, %rdi
je 0xb85d
callq 0x21f0
jmp 0xb85d
movq %rax, %rbx
movq -0x80(%rbp), %rdi
cmpq %r14, %rdi
je 0xb876
movq (%rdi), %r15
callq 0x21f0
movq %r15, %rdi
cmpq %r14, %r15
jne 0xb866
leaq -0xb0(%rbp), %rdi
callq 0x2dba
leaq -0x230(%rbp), %rdi
callq 0x2bc0
leaq -0x48(%rbp), %rdi
callq 0x2d86
movq %rbx, %rdi
callq 0x2380