// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd8, %rsp
movq %r9, %r15
movq %r8, %r13
movq %rdx, %r12
movss %xmm0, 0xc(%rsp)
movq %rsi, %r14
leaq 0x10(%rsp), %rbp
movq %rdi, (%rbp)
movq %rcx, %rdi
movq %rbp, %rsi
callq 0xb040
movq (%rax), %rbx
movq %rbx, %rdi
callq 0xb74e
movq %r13, %rdi
movq %rbp, %rsi
callq 0xaf02
movss (%rax), %xmm0
ucomiss 0xc(%rsp), %xmm0
jbe 0x9d5b
movl 0x118(%rsp), %ebp
cmpb $0x1, 0xd68b(%rip)      # 0x17260
jne 0x9c91
movq 0x10(%rsp), %rsi
leaq 0x98(%rsp), %rdi
callq 0xb0b3
leaq 0x5dcc(%rip), %rsi      # 0xf9c0
leaq 0x38(%rsp), %rdi
leaq 0x98(%rsp), %rdx
callq 0xb08f
leaq 0x5dc7(%rip), %rdx      # 0xf9d4
leaq 0x18(%rsp), %rdi
leaq 0x38(%rsp), %rsi
callq 0x6953
leaq 0x78(%rsp), %rdi
movss 0xc(%rsp), %xmm0
callq 0xb0f5
leaq 0xb8(%rsp), %rdi
leaq 0x18(%rsp), %rsi
leaq 0x78(%rsp), %rdx
callq 0x6972
leaq 0xd676(%rip), %rdx      # 0x172c0
leaq 0xb8(%rsp), %rsi
movl %ebp, %edi
callq 0x96ec
leaq 0xb8(%rsp), %rdi
callq 0x3110
leaq 0x78(%rsp), %rdi
callq 0x3110
leaq 0x18(%rsp), %rdi
callq 0x3110
leaq 0x38(%rsp), %rdi
callq 0x3110
leaq 0x98(%rsp), %rdi
callq 0x3110
movq 0x10(%rsp), %rax
leaq 0x18(%rsp), %rsi
movq %rax, (%rsi)
movss 0xc(%rsp), %xmm0
movss %xmm0, 0x8(%rsi)
movq %r12, %rdi
callq 0xb11a
cmpb $0x1, 0xd5a8(%rip)      # 0x17260
jne 0x9d26
movq 0x10(%rsp), %rsi
leaq 0x38(%rsp), %rdi
callq 0xb0b3
leaq 0x5d15(%rip), %rsi      # 0xf9e5
leaq 0x18(%rsp), %rdi
leaq 0x38(%rsp), %rdx
callq 0xb08f
leaq 0x5d09(%rip), %rdx      # 0xf9ef
leaq 0x58(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0x6953
leaq 0xd5c4(%rip), %rdx      # 0x172c0
leaq 0x58(%rsp), %rsi
movl %ebp, %edi
callq 0x96ec
leaq 0x58(%rsp), %rdi
callq 0x3110
leaq 0x18(%rsp), %rdi
callq 0x3110
leaq 0x38(%rsp), %rdi
callq 0x3110
leaq 0x10(%rsp), %rsi
movq %r15, %rdi
callq 0xb040
movq (%rax), %r15
movq %r15, %rdi
callq 0xb74e
movq 0x110(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0xaff0
movq %r14, (%rax)
movq %r15, %rdi
callq 0x3210
movq %rbx, %rdi
callq 0x3210
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
leaq 0x58(%rsp), %rdi
callq 0x3110
jmp 0x9d87
movq %rax, %r14
leaq 0x18(%rsp), %rdi
callq 0x3110
jmp 0x9d96
movq %rax, %r14
leaq 0x38(%rsp), %rdi
jmp 0x9de9
movq %rax, %r14
leaq 0xb8(%rsp), %rdi
callq 0x3110
jmp 0x9db4
jmp 0x9e03
movq %rax, %r14
leaq 0x78(%rsp), %rdi
callq 0x3110
jmp 0x9dc3
movq %rax, %r14
leaq 0x18(%rsp), %rdi
callq 0x3110
jmp 0x9dd2
movq %rax, %r14
leaq 0x38(%rsp), %rdi
callq 0x3110
jmp 0x9de1
movq %rax, %r14
leaq 0x98(%rsp), %rdi
callq 0x3110
jmp 0x9e06
jmp 0x9e03
movq %rax, %r14
movq %r15, %rdi
callq 0x3210
jmp 0x9e06
jmp 0x9e03
jmp 0x9e03
movq %rax, %r14
movq %rbx, %rdi
callq 0x3210
movq %r14, %rdi
callq 0x3420