// File: /workspace/github_cpp_makefile_star2_O1/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 0xcb62
movq (%rax), %rbx
movq %rbx, %rdi
callq 0x33a0
testl %eax, %eax
jne 0xc39c
leaq 0x8(%rsp), %rsi
movq %r13, %rdi
callq 0xcbc8
movss (%rax), %xmm0
ucomiss 0x4(%rsp), %xmm0
jbe 0xc386
leaq 0xafbd(%rip), %rdi      # 0x172c8
callq 0x33a0
testl %eax, %eax
jne 0xc3a3
movq 0x8(%rsp), %rax
leaq 0x10(%rsp), %rsi
movq %rax, (%rsi)
movss 0x4(%rsp), %xmm0
movss %xmm0, 0x8(%rsi)
movq %r12, %rdi
callq 0xcc2e
leaq 0x8(%rsp), %rsi
movq %r15, %rdi
callq 0xcb62
movq (%rax), %r15
movq %r15, %rdi
callq 0x33a0
testl %eax, %eax
jne 0xc3aa
movq 0x50(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0xccce
movq %r14, (%rax)
leaq 0xafd3(%rip), %rdi      # 0x17340
callq 0x3450
movq %r15, %rdi
callq 0x3210
leaq 0xaf47(%rip), %rdi      # 0x172c8
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 0xc3c5
jmp 0xc3c2
jmp 0xc3d3
movq %rax, %r14
leaq 0xaefc(%rip), %rdi      # 0x172c8
callq 0x3210
jmp 0xc3d6
movq %rax, %r14
movq %rbx, %rdi
callq 0x3210
movq %r14, %rdi
callq 0x34a0