// File: /workspace/github_cpp_makefile_star2_O3/flastest[P]HeterogeneousParallelDijkstra/parallel_workloads.cc
// Function: test_a_graph(bool, int)
int test_a_graph(bool TEST_DEBUG, int num_threads)
{
	if (TEST_DEBUG) std::cout<<"loading graph from a graph"<<std::endl;
	graph_t g = cit_graph_from_file("a_graph.txt",true);
	
	//number of nodes in g
	int num_nodes = num_vertices(g);


	//get a source node...
	vertex_descriptor s = vertex(1, g);

	predecessor_map_t pred;

	auto startTime = chrono::high_resolution_clock::now();
	distance_map_t parallel_results = parallel_dijkstra(g, s, pred, num_threads);
	auto endTime = chrono::high_resolution_clock::now();

	float t = chrono::duration_cast<std::chrono::microseconds>( endTime - startTime ).count();

	std::vector<vertex_descriptor> p_BGL(num_nodes);

	std::vector<int> BGL_results = testBGL ( g,  s, p_BGL);
	
	
	for (int i = 0 ; i < num_nodes; i++)
	{
		if(TEST_DEBUG)
		{	
			std::cout<<"test number "<<i<<std::endl;
			std::cout<<"comparing " <<parallel_results[i] <<" and "<<BGL_results[i]<<std::endl;
		}
		if(parallel_results[i] != BGL_results[i])
		{
			if(parallel_results[i] != INFINITY && BGL_results[i] !=  2147483647) return -1;
		}
		
		//not sure if I need to check predecessors because they might be different
	}
	std::cout<< "results are" << print_dijkstra_results(g, parallel_results) <<std::endl;
	std::cout<<"test a graph took " << t << "microseconds"<<std::endl;
	return t;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1c8, %rsp            # imm = 0x1C8
movl %esi, %ebx
movl %edi, 0xc(%rsp)
testl %edi, %edi
je 0x89c6
movq 0xd645(%rip), %r14      # 0x15fd0
leaq 0x7984(%rip), %rsi      # 0x10316
movl $0x1a, %edx
movq %r14, %rdi
callq 0x3300
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x3290
movsbl %al, %esi
movq %r14, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x31d0
leaq 0x80(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x7958(%rip), %rsi      # 0x10331
leaq 0x795c(%rip), %rdx      # 0x1033c
leaq 0x70(%rsp), %r14
movq %r14, %rdi
callq 0xa112
leaq 0x90(%rsp), %rdi
movq %r14, %rsi
movl $0x1, %edx
callq 0xe81f
movq 0x70(%rsp), %rdi
cmpq %r15, %rdi
je 0x8a1c
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x32b0
leaq 0x90(%rsp), %r15
movq 0x20(%r15), %rbp
subq 0x18(%r15), %rbp
leaq 0x68(%rsp), %r12
movq $0x1, (%r12)
leaq 0x130(%rsp), %rax
movl $0x0, (%rax)
xorl %ecx, %ecx
movq %rcx, 0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
movq %rcx, 0x20(%rax)
callq 0x3060
movq %rax, %r14
leaq 0xc8(%rsp), %rdi
leaq 0x128(%rsp), %rcx
movq %r15, %rsi
movq %r12, %rdx
movl %ebx, %r8d
callq 0xc5b5
shrq $0x5, %rbp
callq 0x3060
subq %r14, %rax
movabsq $0x20c49ba5e353f7cf, %rcx # imm = 0x20C49BA5E353F7CF
imulq %rcx
movq %rdx, 0x48(%rsp)
movslq %ebp, %rsi
leaq 0x50(%rsp), %rdi
leaq 0x10(%rsp), %rdx
callq 0x9ade
leaq 0x190(%rsp), %rdi
leaq 0x90(%rsp), %rsi
callq 0x9b6c
movq 0x68(%rsp), %rdx
leaq 0x30(%rsp), %rdi
leaq 0x190(%rsp), %r14
leaq 0x50(%rsp), %rcx
movq %r14, %rsi
callq 0x4141
leaq 0x1a8(%rsp), %rbx
movq 0x18(%rbx), %rdi
movl $0x1, %esi
callq 0x32b0
movq %rbx, %rdi
callq 0x9d84
movq -0x18(%rbx), %rdi
cmpq %r14, %rdi
je 0x8b1f
movq (%rdi), %rbx
movl $0x28, %esi
callq 0x32b0
movq %rbx, %rdi
cmpq %r14, %rbx
jne 0x8b0a
testl %ebp, %ebp
jle 0x8c82
andl $0x7fffffff, %ebp       # imm = 0x7FFFFFFF
xorl %r15d, %r15d
movq 0xd499(%rip), %r12      # 0x15fd0
leaq 0xc8(%rsp), %r13
leaq 0x10(%rsp), %r14
cmpb $0x0, 0xc(%rsp)
je 0x8c1d
movl $0xc, %edx
movq %r12, %rdi
leaq 0x7756(%rip), %rsi      # 0x102b4
callq 0x3300
movq %r12, %rdi
movl %r15d, %esi
callq 0x3480
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3290
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x31d0
movl $0xa, %edx
movq %r12, %rdi
leaq 0x771a(%rip), %rsi      # 0x102c1
callq 0x3300
movq %r15, 0x10(%rsp)
movq %r13, %rdi
movq %r14, %rsi
callq 0x99a8
xorps %xmm0, %xmm0
cvtss2sd (%rax), %xmm0
movq %r12, %rdi
callq 0x33f0
movq %rax, %rbx
movl $0x5, %edx
movq %rax, %rdi
leaq 0x756d(%rip), %rsi      # 0x1014a
callq 0x3300
movq 0x30(%rsp), %rax
movl (%rax,%r15,4), %esi
movq %rbx, %rdi
callq 0x3480
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3290
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x31d0
movq %r15, 0x10(%rsp)
movq %r13, %rdi
movq %r14, %rsi
callq 0x99a8
movq 0x30(%rsp), %rcx
xorps %xmm0, %xmm0
cvtsi2ssl (%rcx,%r15,4), %xmm0
movss (%rax), %xmm1
ucomiss %xmm0, %xmm1
jne 0x8c46
jnp 0x8c76
movq %r15, 0x10(%rsp)
movq %r13, %rdi
movq %r14, %rsi
callq 0x99a8
movss (%rax), %xmm0
ucomiss 0x74cf(%rip), %xmm0     # 0x10130
jae 0x8c76
movq 0x30(%rsp), %rdi
cmpl $0x7fffffff, (%rdi,%r15,4) # imm = 0x7FFFFFFF
jne 0x8e1b
incq %r15
cmpq %r15, %rbp
jne 0x8b44
movq 0xd347(%rip), %rdi      # 0x15fd0
leaq 0x76ad(%rip), %rsi      # 0x1033d
movl $0xb, %edx
callq 0x3300
leaq 0x158(%rsp), %rdi
leaq 0x90(%rsp), %rsi
callq 0x9b6c
leaq 0xf8(%rsp), %rdi
leaq 0xc8(%rsp), %rsi
callq 0x9e16
leaq 0x10(%rsp), %rdi
leaq 0x158(%rsp), %r14
leaq 0xf8(%rsp), %rdx
movq %r14, %rsi
callq 0x3adb
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
movq 0xd2de(%rip), %rdi      # 0x15fd0
callq 0x3300
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3290
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x31d0
leaq 0x20(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x8d3c
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x32b0
leaq 0xf8(%rsp), %rdi
callq 0x9fea
leaq 0x170(%rsp), %rbx
movq 0x18(%rbx), %rdi
movl $0x1, %esi
callq 0x32b0
movq %rbx, %rdi
callq 0x9d84
movq -0x18(%rbx), %rdi
cmpq %r14, %rdi
je 0x8d85
movq (%rdi), %rbx
movl $0x28, %esi
callq 0x32b0
movq %rbx, %rdi
cmpq %r14, %rbx
jne 0x8d70
movq 0xd244(%rip), %rdi      # 0x15fd0
leaq 0x75b6(%rip), %rsi      # 0x10349
movl $0x12, %edx
callq 0x3300
movq 0x48(%rsp), %rcx
movq %rcx, %rax
shrq $0x3f, %rax
sarq $0x7, %rcx
addq %rax, %rcx
cvtsi2ss %rcx, %xmm0
movss %xmm0, 0xc(%rsp)
cvtss2sd %xmm0, %xmm0
movq 0xd20a(%rip), %rdi      # 0x15fd0
callq 0x33f0
movq %rax, %r14
leaq 0x750d(%rip), %rsi      # 0x102e2
movl $0xc, %edx
movq %rax, %rdi
callq 0x3300
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x3290
movsbl %al, %esi
movq %r14, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x31d0
cvttss2si 0xc(%rsp), %ebp
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
jne 0x8e20
jmp 0x8e2d
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x32b0
leaq 0xa8(%rsp), %r14
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x8e4c
movq 0x60(%rsp), %rsi
subq %rdi, %rsi
callq 0x32b0
leaq 0xc8(%rsp), %rdi
callq 0x9fea
leaq 0x128(%rsp), %rdi
callq 0xa02c
movq 0xc0(%rsp), %rdi
movl $0x1, %esi
callq 0x32b0
movq %r14, %rdi
callq 0x9d84
movq 0x90(%rsp), %rdi
leaq 0x90(%rsp), %r14
cmpq %r14, %rdi
je 0x8eaa
movq (%rdi), %rbx
movl $0x28, %esi
callq 0x32b0
movq %rbx, %rdi
cmpq %r14, %rbx
jne 0x8e95
movl %ebp, %eax
addq $0x1c8, %rsp            # imm = 0x1C8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x8f41
movq %rax, %rbx
jmp 0x8f4e
jmp 0x8f65
movq %rax, %rbx
leaq 0x190(%rsp), %rdi
callq 0x9c06
jmp 0x8f7f
movq %rax, %rbx
jmp 0x8f7f
movq %rax, %rbx
jmp 0x8f96
movq %rax, %rbx
jmp 0x8fa3
movq %rax, %rbx
movq 0x70(%rsp), %rdi
cmpq %r15, %rdi
je 0x8fbd
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x32b0
jmp 0x8fbd
movq %rax, %rbx
leaq 0x20(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x8f41
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x32b0
leaq 0xf8(%rsp), %rdi
callq 0x9fea
leaq 0x158(%rsp), %rdi
callq 0x9c06
jmp 0x8f68
jmp 0x8f65
jmp 0x8f65
jmp 0x8f65
jmp 0x8f65
movq %rax, %rbx
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x8f7f
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x32b0
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x8f96
movq 0x60(%rsp), %rsi
subq %rdi, %rsi
callq 0x32b0
leaq 0xc8(%rsp), %rdi
callq 0x9fea
leaq 0x128(%rsp), %rdi
callq 0xa02c
leaq 0x90(%rsp), %rdi
callq 0x9c06
movq %rbx, %rdi
callq 0x34a0