// File: /workspace/github_cpp_makefile_star2_O3/flastest[P]HeterogeneousParallelDijkstra/dijkstra_cond_var.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]);
	if (vd < distances[neighbor]) 
	{

		{
			//condition variable now gets to release a thread!
			
			
			//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::scoped_lock<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::scoped_lock<std::mutex> guard(*predecessor_mutexes[neighbor]);
			//now update this node's predecessor 
			predecessors[neighbor] = origin;
			//if(DEBUG_THREAD) print_thread_debug(thread_id, "now done relaxing!", debug_file_stream);
			cond_var_offer_pq.notify_all();
		}
	}
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x20, %rsp
movq %r9, %r15
movq %r8, %r13
movq %rdx, %r12
movss %xmm0, 0x4(%rsp)
movq %rsi, %r14
leaq 0x8(%rsp), %rsi
movq %rdi, (%rsi)
movq %rcx, %rdi
callq 0xc8b0
movq (%rax), %rbx
movq %rbx, %rdi
callq 0x33a0
testl %eax, %eax
jne 0xc0ee
leaq 0x8(%rsp), %rsi
movq %r13, %rdi
callq 0xc916
movss (%rax), %xmm0
ucomiss 0x4(%rsp), %xmm0
jbe 0xc0d8
leaq 0xa26b(%rip), %rdi      # 0x162c8
callq 0x33a0
testl %eax, %eax
jne 0xc0f5
movq 0x8(%rsp), %rax
leaq 0x10(%rsp), %rsi
movq %rax, (%rsi)
movss 0x4(%rsp), %xmm0
movss %xmm0, 0x8(%rsi)
movq %r12, %rdi
callq 0xc97c
leaq 0x8(%rsp), %rsi
movq %r15, %rdi
callq 0xc8b0
movq (%rax), %r15
movq %r15, %rdi
callq 0x33a0
testl %eax, %eax
jne 0xc0fc
movq 0x50(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0xca16
movq %r14, (%rax)
leaq 0xa281(%rip), %rdi      # 0x16340
callq 0x3450
movq %r15, %rdi
callq 0x3210
leaq 0xa1f5(%rip), %rdi      # 0x162c8
callq 0x3210
movq %rbx, %rdi
callq 0x3210
addq $0x20, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
movl %eax, %edi
callq 0x31c0
movl %eax, %edi
callq 0x31c0
movl %eax, %edi
callq 0x31c0
movq %rax, %r14
movq %r15, %rdi
callq 0x3210
jmp 0xc117
jmp 0xc114
jmp 0xc125
movq %rax, %r14
leaq 0xa1aa(%rip), %rdi      # 0x162c8
callq 0x3210
jmp 0xc128
movq %rax, %r14
movq %rbx, %rdi
callq 0x3210
movq %r14, %rdi
callq 0x34a0