// File: jkeys-ecg-nmsu[P]graph-with-search-algorithms/Dijkstra.cpp
// Function: Dijkstra_list(Graph&, Node&)
void Dijkstra_list(Graph & g, Node & s) {
	ListPriorityQueue 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);
		
		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) {		//if v has not been visited
				g.setDist(*v, g.dist(u) + edgeWeight);	//v.dist == u.dist + 1
				q.change_priority(g, *v);						//push the adjacent node to back of the queue
			}
		} //end adjNodes loop
	} //end while	
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x330, %rsp            # imm = 0x330
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rsi
leaq -0x28(%rbp), %rdi
callq 0xef10
movq -0x8(%rbp), %rdi
callq 0x6810
jmp 0x14cbb
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
xorps %xmm0, %xmm0
callq 0x5d50
jmp 0x14ccd
movq -0x8(%rbp), %rax
movq %rax, -0x2c0(%rbp)
movq -0x10(%rbp), %rsi
leaq -0xb8(%rbp), %rdi
callq 0x2b50
jmp 0x14cea
movq -0x2c0(%rbp), %rsi
leaq -0x28(%rbp), %rdi
leaq -0xb8(%rbp), %rdx
callq 0xf110
jmp 0x14d03
leaq -0xb8(%rbp), %rdi
callq 0x2bd0
leaq -0x28(%rbp), %rdi
callq 0x16200
movb %al, -0x2c1(%rbp)
jmp 0x14d20
movb -0x2c1(%rbp), %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x14d31
jmp 0x150f3
movq -0x8(%rbp), %rdx
leaq -0x138(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0xefc0
jmp 0x14d47
movq -0x8(%rbp), %rdi
leaq -0x138(%rbp), %rsi
callq 0x62e0
movq %rax, -0x2d0(%rbp)
jmp 0x14d60
movq -0x2d0(%rbp), %rsi
leaq -0x168(%rbp), %rdi
callq 0x8750
jmp 0x14d75
movq -0x8(%rbp), %rdi
leaq -0x138(%rbp), %rsi
callq 0x6360
movq %rax, -0x2d8(%rbp)
jmp 0x14d8e
movq -0x2d8(%rbp), %rsi
leaq -0x180(%rbp), %rdi
callq 0x8870
jmp 0x14da3
leaq -0x168(%rbp), %rdi
callq 0x8780
movq %rax, -0x188(%rbp)
leaq -0x168(%rbp), %rdi
callq 0x87e0
movq %rax, -0x190(%rbp)
leaq -0x188(%rbp), %rdi
leaq -0x190(%rbp), %rsi
callq 0x87b0
testb $0x1, %al
jne 0x14de5
jmp 0x150a4
leaq -0x188(%rbp), %rdi
callq 0x8810
movq %rax, %rsi
leaq -0x218(%rbp), %rdi
callq 0x2b50
jmp 0x14e02
leaq -0x230(%rbp), %rdi
leaq -0x180(%rbp), %rsi
callq 0x8870
jmp 0x14e17
leaq -0x218(%rbp), %rdi
leaq -0x230(%rbp), %rsi
callq 0x14bb0
movsd %xmm0, -0x2e0(%rbp)
jmp 0x14e34
movsd -0x2e0(%rbp), %xmm0
cvttsd2si %xmm0, %eax
movl %eax, -0x2f4(%rbp)
leaq -0x230(%rbp), %rdi
callq 0x30b0
leaq -0x218(%rbp), %rdi
callq 0x2bd0
movl -0x2f4(%rbp), %eax
movl %eax, -0x194(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x2f0(%rbp)
leaq -0x188(%rbp), %rdi
callq 0x8810
movq -0x2f0(%rbp), %rdi
movq %rax, %rsi
callq 0x5fe0
movsd %xmm0, -0x2e8(%rbp)
jmp 0x14e9a
movq -0x8(%rbp), %rdi
leaq -0x138(%rbp), %rsi
callq 0x5fe0
movsd %xmm0, -0x300(%rbp)
jmp 0x14eb4
movsd -0x2e8(%rbp), %xmm0
movsd -0x300(%rbp), %xmm1
cvtsi2sdl -0x194(%rbp), %xmm2
addsd %xmm2, %xmm1
ucomisd %xmm1, %xmm0
ja 0x14f26
movq -0x8(%rbp), %rax
movq %rax, -0x310(%rbp)
leaq -0x188(%rbp), %rdi
callq 0x8810
movq -0x310(%rbp), %rdi
movq %rax, %rsi
callq 0x5fe0
movsd %xmm0, -0x308(%rbp)
jmp 0x14f06
movsd -0x308(%rbp), %xmm0
movsd 0x5152(%rip), %xmm1     # 0x1a068
ucomisd %xmm1, %xmm0
jne 0x15088
jp 0x15088
movq -0x8(%rbp), %rax
movq %rax, -0x328(%rbp)
leaq -0x188(%rbp), %rdi
callq 0x8810
movq %rax, -0x320(%rbp)
movq -0x8(%rbp), %rdi
leaq -0x138(%rbp), %rsi
callq 0x5fe0
movsd %xmm0, -0x318(%rbp)
jmp 0x14f5e
movq -0x320(%rbp), %rsi
movq -0x328(%rbp), %rdi
movsd -0x318(%rbp), %xmm0
cvtsi2sdl -0x194(%rbp), %xmm1
addsd %xmm1, %xmm0
callq 0x5d50
jmp 0x14f87
movq -0x8(%rbp), %rax
movq %rax, -0x330(%rbp)
leaq -0x188(%rbp), %rdi
callq 0x8810
movq %rax, %rsi
leaq -0x2b0(%rbp), %rdi
callq 0x2b50
jmp 0x14faf
movq -0x330(%rbp), %rsi
leaq -0x28(%rbp), %rdi
leaq -0x2b0(%rbp), %rdx
callq 0xf140
jmp 0x14fc8
leaq -0x2b0(%rbp), %rdi
callq 0x2bd0
jmp 0x15088
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x15105
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0xb8(%rbp), %rdi
callq 0x2bd0
jmp 0x15105
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x150e5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x150d9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x150cd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x15060
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x230(%rbp), %rdi
callq 0x30b0
leaq -0x218(%rbp), %rdi
callq 0x2bd0
jmp 0x150cd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x2b0(%rbp), %rdi
callq 0x2bd0
jmp 0x150cd
jmp 0x1508a
leaq -0x188(%rbp), %rdi
xorl %esi, %esi
callq 0x8830
movq %rax, -0x2b8(%rbp)
jmp 0x14db6
leaq -0x180(%rbp), %rdi
callq 0x30b0
leaq -0x168(%rbp), %rdi
callq 0x3530
leaq -0x138(%rbp), %rdi
callq 0x2bd0
jmp 0x14d0f
leaq -0x180(%rbp), %rdi
callq 0x30b0
leaq -0x168(%rbp), %rdi
callq 0x3530
leaq -0x138(%rbp), %rdi
callq 0x2bd0
jmp 0x15105
leaq -0x28(%rbp), %rdi
callq 0x16220
addq $0x330, %rsp            # imm = 0x330
popq %rbp
retq
leaq -0x28(%rbp), %rdi
callq 0x16220
movq -0x30(%rbp), %rdi
callq 0x23e0
nopw (%rax,%rax)