// File: flastest[P]HeterogeneousParallelDijkstra/BGL_Dijkstra.cc
// Function: relax_vertex(unsigned long, unsigned long, float, std::priority_queue<std::pair<unsigned long, float>, std::vector<std::pair<unsigned long, float>, std::allocator<std::pair<unsigned long, float>>>, Offer_Comparator>&, std::map<unsigned long, std::shared_ptr<std::mutex>, std::less<unsigned long>, std::allocator<std::pair<unsigned long const, std::shared_ptr<std::mutex>>>>, std::map<unsigned long, float, std::less<unsigned long>, std::allocator<std::pair<unsigned long const, float>>>&, std::map<unsigned long, std::shared_ptr<std::mutex>, std::less<unsigned long>, std::allocator<std::pair<unsigned long const, std::shared_ptr<std::mutex>>>>&, std::map<unsigned long, unsigned long, std::less<unsigned long>, std::allocator<std::pair<unsigned long const, unsigned long>>>&, int)
void relax_vertex(vertex_descriptor neighbor,
		   vertex_descriptor origin, 
		   float vd,
		   offer_pqueue_t& offer_pq, 
		   mutex_map_t distance_mutexes,
		   distance_map_t& distances,
		   mutex_map_t& predecessor_mutexes,
		   predecessor_map_t& predecessors,
		   int thread_id )
{
	std::lock_guard<std::mutex> guard(*distance_mutexes[neighbor]);
	//now I can play around with offers[v]
	

	// if the current offer is better than what's in distances, and better than the current offer, 
	// we can replace the old offer with the new one.
	if (vd < distances[neighbor]) 
	{
		/* The following is probbaly for that hybrid data structure
		//uh how do i get a specific offer from the priority queue???
		auto vector_offer = offer_pq[v];
		//UHHHHHHHHHHHHHHH^^^^^^^^^^^


		//if there is no current offer, than this offer is the best.
		if (!vector_offer) {
			//add offer to the pqeuue
			offer_pq.push(offer);
			
		}
		else 
		{
			//if the curresnt offer is better than the old offer, replace also
			if (vd < vector_offer) 
			{
				//this is publishOfferNoMP
				offer_pq.push(offer_t(v,vd));
			}
		}*/
		//this is publishOfferNoMP
		{
			if (DEBUG_THREAD) print_thread_debug(thread_id, "ADDING AN OFFER TO " + std::to_string(neighbor) + "!!! distnace is " + std::to_string(vd) , debug_file_stream);
			//std::lock_guard<std::mutex> guard2(pq_mutex);
			offer_pq.push(offer_t(neighbor,vd));
			if (DEBUG_THREAD) print_thread_debug(thread_id, "updating "+ std::to_string(neighbor) +"'s predecessor", debug_file_stream);
			std::lock_guard<std::mutex> guard(*predecessor_mutexes[neighbor]);
			//now update this node's predecessor 
			predecessors[neighbor] = origin;
		}
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1c0, %rsp            # imm = 0x1C0
movq %rcx, -0x188(%rbp)
movq %rdi, %rax
movq -0x188(%rbp), %rdi
movl 0x18(%rbp), %ecx
movq 0x10(%rbp), %rcx
movq %rax, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movss %xmm0, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
movq %rdi, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq %r9, -0x38(%rbp)
leaq -0x8(%rbp), %rsi
movq %rsi, -0x180(%rbp)
callq 0x1df60
movq %rax, %rdi
callq 0x1e040
movq %rax, %rsi
leaq -0x40(%rbp), %rdi
callq 0x1d9a0
movq -0x180(%rbp), %rsi
movss -0x14(%rbp), %xmm0
movss %xmm0, -0x174(%rbp)
movq -0x30(%rbp), %rdi
callq 0x1da20
movq %rax, -0x170(%rbp)
jmp 0x1b5aa
movss -0x174(%rbp), %xmm1
movq -0x170(%rbp), %rax
movss (%rax), %xmm0
ucomiss %xmm1, %xmm0
jbe 0x1b8f0
testb $0x1, 0x22d43(%rip)     # 0x3e310
je 0x1b73b
movl 0x18(%rbp), %eax
movl %eax, -0x18c(%rbp)
movq -0x8(%rbp), %rsi
leaq -0xd0(%rbp), %rdi
callq 0x1e0c0
jmp 0x1b5ee
leaq 0xf30a(%rip), %rsi      # 0x2a8ff
leaq -0xb0(%rbp), %rdi
leaq -0xd0(%rbp), %rdx
callq 0x1e070
jmp 0x1b60a
leaq 0xf302(%rip), %rdx      # 0x2a913
leaq -0x90(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0xaa10
jmp 0x1b626
movss -0x14(%rbp), %xmm0
leaq -0xf0(%rbp), %rdi
callq 0x1e1a0
jmp 0x1b639
leaq -0x70(%rbp), %rdi
leaq -0x90(%rbp), %rsi
leaq -0xf0(%rbp), %rdx
callq 0xaa60
jmp 0x1b652
movl -0x18c(%rbp), %edi
leaq 0x22d11(%rip), %rdx     # 0x3e370
leaq -0x70(%rbp), %rsi
callq 0x1ab10
jmp 0x1b66a
leaq -0x70(%rbp), %rdi
callq 0x41e0
leaq -0xf0(%rbp), %rdi
callq 0x41e0
leaq -0x90(%rbp), %rdi
callq 0x41e0
leaq -0xb0(%rbp), %rdi
callq 0x41e0
leaq -0xd0(%rbp), %rdi
callq 0x41e0
jmp 0x1b73b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x1b902
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x1b72a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x1b71e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x1b712
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x1b706
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x41e0
leaq -0xf0(%rbp), %rdi
callq 0x41e0
leaq -0x90(%rbp), %rdi
callq 0x41e0
leaq -0xb0(%rbp), %rdi
callq 0x41e0
leaq -0xd0(%rbp), %rdi
callq 0x41e0
jmp 0x1b902
movq -0x20(%rbp), %rax
movq %rax, -0x198(%rbp)
leaq -0x100(%rbp), %rdi
leaq -0x8(%rbp), %rsi
leaq -0x14(%rbp), %rdx
callq 0x1e240
jmp 0x1b75c
movq -0x198(%rbp), %rdi
leaq -0x100(%rbp), %rsi
callq 0x1e1f0
jmp 0x1b771
testb $0x1, 0x22b98(%rip)     # 0x3e310
je 0x1b863
movl 0x18(%rbp), %eax
movl %eax, -0x19c(%rbp)
movq -0x8(%rbp), %rsi
leaq -0x160(%rbp), %rdi
callq 0x1e0c0
jmp 0x1b799
leaq 0xf184(%rip), %rsi      # 0x2a924
leaq -0x140(%rbp), %rdi
leaq -0x160(%rbp), %rdx
callq 0x1e070
jmp 0x1b7b5
leaq 0xf172(%rip), %rdx      # 0x2a92e
leaq -0x120(%rbp), %rdi
leaq -0x140(%rbp), %rsi
callq 0xaa10
jmp 0x1b7d1
movl -0x19c(%rbp), %edi
leaq 0x22b92(%rip), %rdx     # 0x3e370
leaq -0x120(%rbp), %rsi
callq 0x1ab10
jmp 0x1b7ec
leaq -0x120(%rbp), %rdi
callq 0x41e0
leaq -0x140(%rbp), %rdi
callq 0x41e0
leaq -0x160(%rbp), %rdi
callq 0x41e0
jmp 0x1b863
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x1b852
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x1b846
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x120(%rbp), %rdi
callq 0x41e0
leaq -0x140(%rbp), %rdi
callq 0x41e0
leaq -0x160(%rbp), %rdi
callq 0x41e0
jmp 0x1b902
movq -0x38(%rbp), %rdi
leaq -0x8(%rbp), %rsi
callq 0x1df60
movq %rax, -0x1a8(%rbp)
jmp 0x1b879
movq -0x1a8(%rbp), %rdi
callq 0x1e040
movq %rax, %rsi
leaq -0x168(%rbp), %rdi
callq 0x1d9a0
jmp 0x1b896
movq -0x10(%rbp), %rax
movq %rax, -0x1b8(%rbp)
movq 0x10(%rbp), %rdi
leaq -0x8(%rbp), %rsi
callq 0x1de60
movq %rax, -0x1b0(%rbp)
jmp 0x1b8b7
movq -0x1b0(%rbp), %rax
movq -0x1b8(%rbp), %rcx
movq %rcx, (%rax)
leaq -0x168(%rbp), %rdi
callq 0x1d9d0
jmp 0x1b8f0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x168(%rbp), %rdi
callq 0x1d9d0
jmp 0x1b902
leaq -0x40(%rbp), %rdi
callq 0x1d9d0
addq $0x1c0, %rsp            # imm = 0x1C0
popq %rbp
retq
leaq -0x40(%rbp), %rdi
callq 0x1d9d0
movq -0x48(%rbp), %rdi
callq 0x4520
nopw %cs:(%rax,%rax)