// File: 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
movq %rsp, %rbp
subq $0x300, %rsp            # imm = 0x300
movb %dil, %al
andb $0x1, %al
movb %al, -0x5(%rbp)
movl %esi, -0xc(%rbp)
testb $0x1, -0x5(%rbp)
je 0xb07e
movq 0x2ff65(%rip), %rdi     # 0x3afc8
leaq 0x1c180(%rip), %rsi     # 0x271ea
callq 0x4320
movq %rax, %rdi
movq 0x2ff27(%rip), %rsi     # 0x3afa0
callq 0x4380
leaq -0x69(%rbp), %rdi
movq %rdi, -0x238(%rbp)
callq 0x4590
movq -0x238(%rbp), %rdx
leaq 0x1c169(%rip), %rsi     # 0x27205
leaq -0x68(%rbp), %rdi
callq 0xd040
jmp 0xb0a7
leaq -0x48(%rbp), %rdi
leaq -0x68(%rbp), %rsi
movl $0x1, %edx
callq 0x24550
jmp 0xb0bb
leaq -0x68(%rbp), %rdi
callq 0x41d0
leaq -0x69(%rbp), %rdi
callq 0x43a0
leaq -0x48(%rbp), %rdi
callq 0xc720
movq %rax, -0x240(%rbp)
jmp 0xb0df
movq -0x240(%rbp), %rax
movl %eax, -0x80(%rbp)
movl $0x1, %edi
leaq -0x48(%rbp), %rsi
callq 0xcb40
movq %rax, -0x248(%rbp)
jmp 0xb100
movq -0x248(%rbp), %rax
movq %rax, -0x88(%rbp)
leaq -0xb8(%rbp), %rdi
movq %rdi, -0x250(%rbp)
callq 0xcb20
callq 0x4060
movq -0x250(%rbp), %rcx
movq %rax, -0xc0(%rbp)
movl -0xc(%rbp), %r8d
leaq -0xf0(%rbp), %rdi
leaq -0x48(%rbp), %rsi
leaq -0x88(%rbp), %rdx
callq 0x1cbe0
jmp 0xb151
callq 0x4060
movq %rax, -0xf8(%rbp)
leaq -0xf8(%rbp), %rdi
leaq -0xc0(%rbp), %rsi
callq 0xd120
movq %rax, -0x258(%rbp)
jmp 0xb179
movq -0x258(%rbp), %rax
movq %rax, -0x110(%rbp)
leaq -0x110(%rbp), %rdi
callq 0xd0f0
movq %rax, -0x260(%rbp)
jmp 0xb19c
movq -0x260(%rbp), %rax
movq %rax, -0x108(%rbp)
leaq -0x108(%rbp), %rdi
callq 0xd170
movq %rax, -0x268(%rbp)
jmp 0xb1bf
movq -0x268(%rbp), %rax
cvtsi2ss %rax, %xmm0
movss %xmm0, -0xfc(%rbp)
movslq -0x80(%rbp), %rax
movq %rax, -0x278(%rbp)
leaq -0x129(%rbp), %rdi
movq %rdi, -0x270(%rbp)
callq 0xcb60
movq -0x278(%rbp), %rsi
movq -0x270(%rbp), %rdx
leaq -0x128(%rbp), %rdi
callq 0xcb80
jmp 0xb20d
leaq -0x129(%rbp), %rdi
callq 0xcbf0
leaq -0x180(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0xcc10
jmp 0xb22b
movq -0x88(%rbp), %rdx
leaq -0x148(%rbp), %rdi
leaq -0x180(%rbp), %rsi
leaq -0x128(%rbp), %rcx
callq 0x4fa0
jmp 0xb24e
leaq -0x180(%rbp), %rdi
callq 0xcc90
movl $0x0, -0x184(%rbp)
movl -0x184(%rbp), %eax
cmpl -0x80(%rbp), %eax
jge 0xb561
testb $0x1, -0x5(%rbp)
je 0xb44f
movq 0x2fd44(%rip), %rdi     # 0x3afc8
leaq 0x1befd(%rip), %rsi     # 0x27188
callq 0x4320
movq %rax, -0x280(%rbp)
jmp 0xb299
movq -0x280(%rbp), %rdi
movl -0x184(%rbp), %esi
callq 0x4570
movq %rax, -0x288(%rbp)
jmp 0xb2b4
movq -0x288(%rbp), %rdi
movq 0x2fcde(%rip), %rsi     # 0x3afa0
callq 0x4380
jmp 0xb2c9
movq 0x2fcf8(%rip), %rdi     # 0x3afc8
leaq 0x1bebe(%rip), %rsi     # 0x27195
callq 0x4320
movq %rax, -0x290(%rbp)
jmp 0xb2e5
movslq -0x184(%rbp), %rax
movq %rax, -0x190(%rbp)
leaq -0xf0(%rbp), %rdi
leaq -0x190(%rbp), %rsi
callq 0xc610
movq %rax, -0x298(%rbp)
jmp 0xb30f
movq -0x290(%rbp), %rdi
movq -0x298(%rbp), %rax
movss (%rax), %xmm0
callq 0x4270
movq %rax, -0x2a0(%rbp)
jmp 0xb32f
movq -0x2a0(%rbp), %rdi
leaq 0x1bce1(%rip), %rsi     # 0x2701e
callq 0x4320
movq %rax, -0x2a8(%rbp)
jmp 0xb34b
movslq -0x184(%rbp), %rsi
leaq -0x148(%rbp), %rdi
callq 0xccc0
movq -0x2a8(%rbp), %rdi
movl (%rax), %esi
callq 0x4570
movq %rax, -0x2b0(%rbp)
jmp 0xb375
movq -0x2b0(%rbp), %rdi
movq 0x2fc1d(%rip), %rsi     # 0x3afa0
callq 0x4380
jmp 0xb38a
jmp 0xb44f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
jmp 0xb3b2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0x68(%rbp), %rdi
callq 0x41d0
leaq -0x69(%rbp), %rdi
callq 0x43a0
jmp 0xb762
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
jmp 0xb759
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
jmp 0xb74d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
jmp 0xb741
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0x129(%rbp), %rdi
callq 0xcbf0
jmp 0xb741
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
jmp 0xb735
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0x180(%rbp), %rdi
callq 0xcc90
jmp 0xb735
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
jmp 0xb729
movslq -0x184(%rbp), %rax
movq %rax, -0x198(%rbp)
leaq -0xf0(%rbp), %rdi
leaq -0x198(%rbp), %rsi
callq 0xc610
movq %rax, -0x2b8(%rbp)
jmp 0xb479
movq -0x2b8(%rbp), %rax
movss (%rax), %xmm0
movss %xmm0, -0x2bc(%rbp)
movslq -0x184(%rbp), %rsi
leaq -0x148(%rbp), %rdi
callq 0xccc0
movss -0x2bc(%rbp), %xmm0
cvtsi2ssl (%rax), %xmm1
ucomiss %xmm1, %xmm0
jne 0xb4b7
jp 0xb4b7
jmp 0xb54b
movslq -0x184(%rbp), %rax
movq %rax, -0x1a0(%rbp)
leaq -0xf0(%rbp), %rdi
leaq -0x1a0(%rbp), %rsi
callq 0xc610
movq %rax, -0x2c8(%rbp)
jmp 0xb4e1
movq -0x2c8(%rbp), %rax
movss (%rax), %xmm0
xorl %eax, %eax
movss 0x1bb0e(%rip), %xmm1    # 0x27004
ucomiss %xmm1, %xmm0
movb %al, -0x2c9(%rbp)
jne 0xb505
jp 0xb505
jmp 0xb527
movslq -0x184(%rbp), %rsi
leaq -0x148(%rbp), %rdi
callq 0xccc0
cmpl $0x7fffffff, (%rax)     # imm = 0x7FFFFFFF
setne %al
movb %al, -0x2c9(%rbp)
movb -0x2c9(%rbp), %al
testb $0x1, %al
jne 0xb533
jmp 0xb549
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl $0x1, -0x1a4(%rbp)
jmp 0xb6e4
jmp 0xb54b
jmp 0xb54d
movl -0x184(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x184(%rbp)
jmp 0xb264
movq 0x2fa60(%rip), %rdi     # 0x3afc8
leaq 0x1bca2(%rip), %rsi     # 0x27211
callq 0x4320
movq %rax, -0x2d8(%rbp)
jmp 0xb57d
leaq -0x200(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0xcc10
jmp 0xb58f
leaq -0x230(%rbp), %rdi
leaq -0xf0(%rbp), %rsi
callq 0xcce0
jmp 0xb5a4
leaq -0x1c8(%rbp), %rdi
leaq -0x200(%rbp), %rsi
leaq -0x230(%rbp), %rdx
callq 0x4c60
jmp 0xb5c0
movq -0x2d8(%rbp), %rdi
leaq -0x1c8(%rbp), %rsi
callq 0x42e0
movq %rax, -0x2e0(%rbp)
jmp 0xb5dc
movq -0x2e0(%rbp), %rdi
movq 0x2f9b6(%rip), %rsi     # 0x3afa0
callq 0x4380
jmp 0xb5f1
leaq -0x1c8(%rbp), %rdi
callq 0x41d0
leaq -0x230(%rbp), %rdi
callq 0xcd10
leaq -0x200(%rbp), %rdi
callq 0xcc90
movq 0x2f9ac(%rip), %rdi     # 0x3afc8
leaq 0x1bbfa(%rip), %rsi     # 0x2721d
callq 0x4320
movq %rax, -0x2e8(%rbp)
jmp 0xb631
movq -0x2e8(%rbp), %rdi
movss -0xfc(%rbp), %xmm0
callq 0x4270
movq %rax, -0x2f0(%rbp)
jmp 0xb64e
movq -0x2f0(%rbp), %rdi
leaq 0x1bb5a(%rip), %rsi     # 0x271b6
callq 0x4320
movq %rax, -0x2f8(%rbp)
jmp 0xb66a
movq -0x2f8(%rbp), %rdi
movq 0x2f928(%rip), %rsi     # 0x3afa0
callq 0x4380
jmp 0xb67f
cvttss2si -0xfc(%rbp), %eax
movl %eax, -0x4(%rbp)
movl $0x1, -0x1a4(%rbp)
jmp 0xb6e4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
jmp 0xb6d6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
jmp 0xb6ca
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0x1c8(%rbp), %rdi
callq 0x41d0
leaq -0x230(%rbp), %rdi
callq 0xcd10
leaq -0x200(%rbp), %rdi
callq 0xcc90
jmp 0xb729
leaq -0x148(%rbp), %rdi
callq 0xca30
leaq -0x128(%rbp), %rdi
callq 0xcdb0
leaq -0xf0(%rbp), %rdi
callq 0xcd10
leaq -0xb8(%rbp), %rdi
callq 0xce10
leaq -0x48(%rbp), %rdi
callq 0xcc90
movl -0x4(%rbp), %eax
addq $0x300, %rsp            # imm = 0x300
popq %rbp
retq
leaq -0x148(%rbp), %rdi
callq 0xca30
leaq -0x128(%rbp), %rdi
callq 0xcdb0
leaq -0xf0(%rbp), %rdi
callq 0xcd10
leaq -0xb8(%rbp), %rdi
callq 0xce10
leaq -0x48(%rbp), %rdi
callq 0xcc90
movq -0x78(%rbp), %rdi
callq 0x4580
nopl (%rax,%rax)