// File: flastest[P]HeterogeneousParallelDijkstra/BBO_graph_creator.cc
// Function: graph_from_file(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, bool)
graph_t graph_from_file(std::string name, bool truncate_early)
{

	int counter = 1000;

	std::ifstream infile(name);

	int biggest_player_id = 0;

	std::vector<Edge> edge_vec;

	std::vector<int> weight_vec;

	std::string input;

	while (std::getline(infile,input))// >> ", 0," >>team_a>>", 0,">>team_b>>", 0")
	{
		if(truncate_early && counter <= 0)
		{
			break;
		}	

		counter--;

		if (input.substr(0,1) != "#" && input.substr(0,1) != "R")
		{
			if (DEBUG_LOGS) std::cout<<"checking line "<<input<<std::endl;
			// let's say we have 0, 0, 0/1, 0, 2/3, 0
			std::string team_a = remove_a_comma (remove_a_comma (input));
			//now we have 0/1, 0, 2/3, 0

			//let's obtain team_b
			std::string team_b = remove_a_comma (remove_a_comma (team_a));
			//now team_b is 2/3, 0
			team_b = team_b.substr(0,team_b.find(","));

			//now fix team_a which is 0/1, 0, 2/3, 0
			team_a = team_a.substr(0,team_a.find(","));

			if (DEBUG_LOGS) std::cout<<"team a is "<<team_a<<std::endl;
			if (DEBUG_LOGS) std::cout<<"team b is "<<team_b<<std::endl;


			//for each teammmate in team_a, we need to add an edge from that teammate to every member in team_b

			auto team_a_vec = get_teammates(team_a);
			auto team_b_vec = get_teammates(team_b);

			for(int teammate : team_a_vec)
			{
				for(int opponent : team_b_vec)
				{
					edge_vec.push_back(Edge(teammate,opponent));
					weight_vec.push_back(1);

				}
				if (teammate > biggest_player_id) 
				{
					biggest_player_id = teammate;
				}
			}

			for(int opponent : team_b_vec)
			{
				//infclude the following for bidirectional graph
				/*
				for(int teammate : team_a_vec)
				{
					edge_vec.push_back(Edge(opponent,teammate));
					weight_vec.push_back(1);

				}
				*/
				
				//to keep track of how many nodes we have
				if (opponent > biggest_player_id) 
				{
					biggest_player_id = opponent;
				}
			}
		}
	}

	//evidence that IDK how to use arrays
	Edge edge_array[edge_vec.size() ]; 

	for (uint32_t i = 0; i < edge_vec.size(); i++)
	{
		edge_array[i] = edge_vec[i];
	}

	int weights[weight_vec.size()]; 

	for (uint32_t i = 0; i < weight_vec.size(); i++)
	{
		weights[i] = 1;
	}	


	int num_arcs = sizeof(edge_array) / sizeof(Edge);

	int num_nodes = biggest_player_id;

	graph_t g(edge_array, edge_array + num_arcs, weights, num_nodes);

	return g;

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x590, %rsp            # imm = 0x590
movq %rdi, -0x4e8(%rbp)
movb %dl, %al
movq %rdi, %rcx
movq %rcx, -0x4e0(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
andb $0x1, %al
movb %al, -0x11(%rbp)
movl $0x3e8, -0x18(%rbp)     # imm = 0x3E8
leaq -0x220(%rbp), %rdi
movl $0x8, %edx
callq 0x44a0
movl $0x0, -0x224(%rbp)
leaq -0x240(%rbp), %rdi
callq 0x27600
leaq -0x258(%rbp), %rdi
callq 0x27530
leaq -0x278(%rbp), %rdi
callq 0x4410
leaq -0x220(%rbp), %rdi
leaq -0x278(%rbp), %rsi
callq 0x40a0
movq %rax, -0x4f0(%rbp)
jmp 0x263ed
movq -0x4f0(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x43f0
movb %al, -0x4f1(%rbp)
jmp 0x2640b
movb -0x4f1(%rbp), %al
testb $0x1, %al
jne 0x2641a
jmp 0x26bec
testb $0x1, -0x11(%rbp)
je 0x26442
cmpl $0x0, -0x18(%rbp)
jg 0x26442
jmp 0x26bec
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x280(%rbp)
movl %eax, -0x284(%rbp)
jmp 0x26e5b
movl -0x18(%rbp), %eax
decl %eax
movl %eax, -0x18(%rbp)
movb $0x0, -0x2c9(%rbp)
xorl %eax, %eax
movl %eax, %edx
leaq -0x2a8(%rbp), %rdi
leaq -0x278(%rbp), %rsi
movl $0x1, %ecx
callq 0x4350
jmp 0x2646f
leaq 0x49fd(%rip), %rsi      # 0x2ae73
leaq -0x2a8(%rbp), %rdi
callq 0x27620
movb %al, -0x4f2(%rbp)
jmp 0x2648a
movb -0x4f2(%rbp), %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, -0x4f3(%rbp)
jne 0x2649f
jmp 0x264ed
xorl %eax, %eax
movl %eax, %edx
leaq -0x2c8(%rbp), %rdi
leaq -0x278(%rbp), %rsi
movl $0x1, %ecx
callq 0x4350
jmp 0x264bd
movb $0x1, -0x2c9(%rbp)
leaq 0x49aa(%rip), %rsi      # 0x2ae75
leaq -0x2c8(%rbp), %rdi
callq 0x27620
movb %al, -0x4f4(%rbp)
jmp 0x264df
movb -0x4f4(%rbp), %al
movb %al, -0x4f3(%rbp)
jmp 0x264ed
movb -0x4f3(%rbp), %al
movb %al, -0x4f5(%rbp)
testb $0x1, -0x2c9(%rbp)
jne 0x26504
jmp 0x26510
leaq -0x2c8(%rbp), %rdi
callq 0x41e0
leaq -0x2a8(%rbp), %rdi
callq 0x41e0
movb -0x4f5(%rbp), %al
testb $0x1, %al
jne 0x2652b
jmp 0x26be7
testb $0x1, 0x18069(%rip)     # 0x3e59b
je 0x265d7
movq 0x17a89(%rip), %rdi     # 0x3dfc8
leaq 0x4931(%rip), %rsi      # 0x2ae77
callq 0x4310
movq %rax, -0x500(%rbp)
jmp 0x26554
movq -0x500(%rbp), %rdi
leaq -0x278(%rbp), %rsi
callq 0x42f0
movq %rax, -0x508(%rbp)
jmp 0x26570
movq -0x508(%rbp), %rdi
movq 0x17a1a(%rip), %rsi     # 0x3df98
callq 0x4370
jmp 0x26585
jmp 0x265d7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x280(%rbp)
movl %eax, -0x284(%rbp)
jmp 0x265c6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x280(%rbp)
movl %eax, -0x284(%rbp)
testb $0x1, -0x2c9(%rbp)
jne 0x265b8
jmp 0x265c4
leaq -0x2c8(%rbp), %rdi
callq 0x41e0
jmp 0x265c6
leaq -0x2a8(%rbp), %rdi
callq 0x41e0
jmp 0x26e5b
leaq -0x330(%rbp), %rdi
leaq -0x278(%rbp), %rsi
callq 0x4150
jmp 0x265ec
leaq -0x310(%rbp), %rdi
leaq -0x330(%rbp), %rsi
callq 0x26300
jmp 0x26601
leaq -0x2f0(%rbp), %rdi
leaq -0x310(%rbp), %rsi
callq 0x26300
jmp 0x26616
leaq -0x310(%rbp), %rdi
callq 0x41e0
leaq -0x330(%rbp), %rdi
callq 0x41e0
leaq -0x390(%rbp), %rdi
leaq -0x2f0(%rbp), %rsi
callq 0x4150
jmp 0x26643
leaq -0x370(%rbp), %rdi
leaq -0x390(%rbp), %rsi
callq 0x26300
jmp 0x26658
leaq -0x350(%rbp), %rdi
leaq -0x370(%rbp), %rsi
callq 0x26300
jmp 0x2666d
leaq -0x370(%rbp), %rdi
callq 0x41e0
leaq -0x390(%rbp), %rdi
callq 0x41e0
leaq 0x47e5(%rip), %rsi      # 0x2ae71
xorl %eax, %eax
movl %eax, %edx
movq %rdx, -0x510(%rbp)
leaq -0x350(%rbp), %rdi
movq %rdi, -0x518(%rbp)
callq 0x45a0
movq -0x518(%rbp), %rsi
movq -0x510(%rbp), %rdx
movq %rax, %rcx
leaq -0x3b0(%rbp), %rdi
callq 0x4350
jmp 0x266c9
leaq -0x350(%rbp), %rdi
leaq -0x3b0(%rbp), %rsi
movq %rsi, -0x530(%rbp)
callq 0x43d0
movq -0x530(%rbp), %rdi
callq 0x41e0
leaq 0x477b(%rip), %rsi      # 0x2ae71
xorl %eax, %eax
movl %eax, %edx
movq %rdx, -0x520(%rbp)
leaq -0x2f0(%rbp), %rdi
movq %rdi, -0x528(%rbp)
callq 0x45a0
movq -0x528(%rbp), %rsi
movq -0x520(%rbp), %rdx
movq %rax, %rcx
leaq -0x3d0(%rbp), %rdi
callq 0x4350
jmp 0x26733
leaq -0x2f0(%rbp), %rdi
leaq -0x3d0(%rbp), %rsi
callq 0x43d0
leaq -0x3d0(%rbp), %rdi
callq 0x41e0
testb $0x1, 0x17e42(%rip)     # 0x3e59b
je 0x26865
movq 0x17862(%rip), %rdi     # 0x3dfc8
leaq 0x4719(%rip), %rsi      # 0x2ae86
callq 0x4310
movq %rax, -0x538(%rbp)
jmp 0x2677b
movq -0x538(%rbp), %rdi
leaq -0x2f0(%rbp), %rsi
callq 0x42f0
movq %rax, -0x540(%rbp)
jmp 0x26797
movq -0x540(%rbp), %rdi
movq 0x177f3(%rip), %rsi     # 0x3df98
callq 0x4370
jmp 0x267ac
jmp 0x26865
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x280(%rbp)
movl %eax, -0x284(%rbp)
jmp 0x267e3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x280(%rbp)
movl %eax, -0x284(%rbp)
leaq -0x310(%rbp), %rdi
callq 0x41e0
leaq -0x330(%rbp), %rdi
callq 0x41e0
jmp 0x26e5b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x280(%rbp)
movl %eax, -0x284(%rbp)
jmp 0x26bd6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x280(%rbp)
movl %eax, -0x284(%rbp)
jmp 0x2683d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x280(%rbp)
movl %eax, -0x284(%rbp)
leaq -0x370(%rbp), %rdi
callq 0x41e0
leaq -0x390(%rbp), %rdi
callq 0x41e0
jmp 0x26bd6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x280(%rbp)
movl %eax, -0x284(%rbp)
jmp 0x26bca
testb $0x1, 0x17d2f(%rip)     # 0x3e59b
je 0x268bd
movq 0x17753(%rip), %rdi     # 0x3dfc8
leaq 0x4615(%rip), %rsi      # 0x2ae91
callq 0x4310
movq %rax, -0x548(%rbp)
jmp 0x2688a
movq -0x548(%rbp), %rdi
leaq -0x350(%rbp), %rsi
callq 0x42f0
movq %rax, -0x550(%rbp)
jmp 0x268a6
movq -0x550(%rbp), %rdi
movq 0x176e4(%rip), %rsi     # 0x3df98
callq 0x4370
jmp 0x268bb
jmp 0x268bd
leaq -0x408(%rbp), %rdi
leaq -0x2f0(%rbp), %rsi
callq 0x4150
jmp 0x268d2
leaq -0x3e8(%rbp), %rdi
leaq -0x408(%rbp), %rsi
callq 0x25f50
jmp 0x268e7
leaq -0x408(%rbp), %rdi
callq 0x41e0
leaq -0x440(%rbp), %rdi
leaq -0x350(%rbp), %rsi
callq 0x4150
jmp 0x26908
leaq -0x420(%rbp), %rdi
leaq -0x440(%rbp), %rsi
callq 0x25f50
jmp 0x2691d
leaq -0x440(%rbp), %rdi
callq 0x41e0
leaq -0x3e8(%rbp), %rax
movq %rax, -0x448(%rbp)
movq -0x448(%rbp), %rdi
callq 0xb0f0
movq %rax, -0x450(%rbp)
movq -0x448(%rbp), %rdi
callq 0x27650
movq %rax, -0x458(%rbp)
leaq -0x450(%rbp), %rdi
leaq -0x458(%rbp), %rsi
callq 0x27680
testb $0x1, %al
jne 0x26979
jmp 0x26b01
leaq -0x450(%rbp), %rdi
callq 0x10f30
movl (%rax), %eax
movl %eax, -0x45c(%rbp)
leaq -0x420(%rbp), %rax
movq %rax, -0x468(%rbp)
movq -0x468(%rbp), %rdi
callq 0xb0f0
movq %rax, -0x470(%rbp)
movq -0x468(%rbp), %rdi
callq 0x27650
movq %rax, -0x478(%rbp)
leaq -0x470(%rbp), %rdi
leaq -0x478(%rbp), %rsi
callq 0x27680
testb $0x1, %al
jne 0x269dd
jmp 0x26ad4
leaq -0x470(%rbp), %rdi
callq 0x10f30
movl (%rax), %eax
movl %eax, -0x47c(%rbp)
leaq -0x484(%rbp), %rdi
leaq -0x45c(%rbp), %rsi
leaq -0x47c(%rbp), %rdx
callq 0x276f0
jmp 0x26a0d
leaq -0x240(%rbp), %rdi
leaq -0x484(%rbp), %rsi
callq 0x276c0
jmp 0x26a22
movl $0x1, -0x488(%rbp)
leaq -0x258(%rbp), %rdi
leaq -0x488(%rbp), %rsi
callq 0x27720
jmp 0x26a41
jmp 0x26a43
leaq -0x470(%rbp), %rdi
callq 0x27750
jmp 0x269c1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x280(%rbp)
movl %eax, -0x284(%rbp)
leaq -0x408(%rbp), %rdi
callq 0x41e0
jmp 0x26bca
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x280(%rbp)
movl %eax, -0x284(%rbp)
jmp 0x26bbe
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x280(%rbp)
movl %eax, -0x284(%rbp)
leaq -0x440(%rbp), %rdi
callq 0x41e0
jmp 0x26bbe
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x280(%rbp)
movl %eax, -0x284(%rbp)
leaq -0x420(%rbp), %rdi
callq 0xb120
jmp 0x26bbe
movl -0x45c(%rbp), %eax
cmpl -0x224(%rbp), %eax
jle 0x26aee
movl -0x45c(%rbp), %eax
movl %eax, -0x224(%rbp)
jmp 0x26af0
leaq -0x450(%rbp), %rdi
callq 0x27750
jmp 0x2695d
leaq -0x420(%rbp), %rax
movq %rax, -0x490(%rbp)
movq -0x490(%rbp), %rdi
callq 0xb0f0
movq %rax, -0x498(%rbp)
movq -0x490(%rbp), %rdi
callq 0x27650
movq %rax, -0x4a0(%rbp)
leaq -0x498(%rbp), %rdi
leaq -0x4a0(%rbp), %rsi
callq 0x27680
testb $0x1, %al
jne 0x26b4e
jmp 0x26b8c
leaq -0x498(%rbp), %rdi
callq 0x10f30
movl (%rax), %eax
movl %eax, -0x4a4(%rbp)
movl -0x4a4(%rbp), %eax
cmpl -0x224(%rbp), %eax
jle 0x26b7c
movl -0x4a4(%rbp), %eax
movl %eax, -0x224(%rbp)
jmp 0x26b7e
leaq -0x498(%rbp), %rdi
callq 0x27750
jmp 0x26b35
leaq -0x420(%rbp), %rdi
callq 0xb120
leaq -0x3e8(%rbp), %rdi
callq 0xb120
leaq -0x350(%rbp), %rdi
callq 0x41e0
leaq -0x2f0(%rbp), %rdi
callq 0x41e0
jmp 0x26be7
leaq -0x3e8(%rbp), %rdi
callq 0xb120
leaq -0x350(%rbp), %rdi
callq 0x41e0
leaq -0x2f0(%rbp), %rdi
callq 0x41e0
jmp 0x26e5b
jmp 0x263d1
leaq -0x240(%rbp), %rdi
callq 0x27770
movq %rax, %rcx
movq %rcx, %rax
movq %rax, -0x560(%rbp)
movq %rsp, %rdx
movq %rdx, -0x4b0(%rbp)
leaq 0xf(,%rcx,8), %rdx
andq $-0x10, %rdx
movq %rsp, %rcx
subq %rdx, %rcx
movq %rcx, -0x558(%rbp)
movq %rcx, %rsp
movq %rax, -0x4b8(%rbp)
cmpq $0x0, %rax
je 0x26c91
movq -0x558(%rbp), %rax
movq -0x560(%rbp), %rdx
shlq $0x3, %rdx
movq %rax, %rcx
addq %rdx, %rcx
movq %rcx, -0x570(%rbp)
movq %rax, -0x568(%rbp)
movq -0x568(%rbp), %rdi
movq %rdi, -0x578(%rbp)
callq 0x27790
jmp 0x26c73
movq -0x570(%rbp), %rcx
movq -0x578(%rbp), %rax
addq $0x8, %rax
cmpq %rcx, %rax
movq %rax, -0x568(%rbp)
jne 0x26c5e
movl $0x0, -0x4bc(%rbp)
movl -0x4bc(%rbp), %eax
movq %rax, -0x580(%rbp)
leaq -0x240(%rbp), %rdi
callq 0x27770
movq %rax, %rcx
movq -0x580(%rbp), %rax
cmpq %rcx, %rax
jae 0x26d05
movl -0x4bc(%rbp), %eax
movl %eax, %esi
leaq -0x240(%rbp), %rdi
callq 0x277b0
movq %rax, %rsi
movq -0x558(%rbp), %rax
movl -0x4bc(%rbp), %ecx
leaq (%rax,%rcx,8), %rdi
callq 0x277d0
jmp 0x26cf2
jmp 0x26cf4
movl -0x4bc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4bc(%rbp)
jmp 0x26c9b
leaq -0x258(%rbp), %rdi
callq 0x19aa0
movq %rax, %rcx
movq %rcx, %rax
leaq 0xf(,%rcx,4), %rdx
andq $-0x10, %rdx
movq %rsp, %rcx
subq %rdx, %rcx
movq %rcx, -0x588(%rbp)
movq %rcx, %rsp
movq %rax, -0x4c8(%rbp)
movl $0x0, -0x4cc(%rbp)
movl -0x4cc(%rbp), %eax
movq %rax, -0x590(%rbp)
leaq -0x258(%rbp), %rdi
callq 0x19aa0
movq %rax, %rcx
movq -0x590(%rbp), %rax
cmpq %rcx, %rax
jae 0x26d91
movq -0x588(%rbp), %rax
movl -0x4cc(%rbp), %ecx
movl $0x1, (%rax,%rcx,4)
movl -0x4cc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4cc(%rbp)
jmp 0x26d44
movq -0x588(%rbp), %rcx
movq -0x558(%rbp), %rsi
movq -0x4e8(%rbp), %rdi
movq -0x560(%rbp), %rax
movl %eax, -0x4d0(%rbp)
movl -0x224(%rbp), %eax
movl %eax, -0x4d4(%rbp)
movb $0x0, -0x4d5(%rbp)
movslq -0x4d0(%rbp), %rax
leaq (%rsi,%rax,8), %rdx
movslq -0x4d4(%rbp), %r8
subq $0x10, %rsp
movq %rsp, %rax
leaq -0x4d6(%rbp), %r9
movq %r9, (%rax)
xorl %eax, %eax
movl %eax, %r9d
callq 0xb180
addq $0x10, %rsp
jmp 0x26df9
movb $0x1, -0x4d5(%rbp)
testb $0x1, -0x4d5(%rbp)
jne 0x26e15
movq -0x4e8(%rbp), %rdi
callq 0xb380
movq -0x4b0(%rbp), %rax
movq %rax, %rsp
leaq -0x278(%rbp), %rdi
callq 0x41e0
leaq -0x258(%rbp), %rdi
callq 0xb120
leaq -0x240(%rbp), %rdi
callq 0x27800
leaq -0x220(%rbp), %rdi
callq 0x40d0
movq -0x4e0(%rbp), %rax
movq %rbp, %rsp
popq %rbp
retq
leaq -0x278(%rbp), %rdi
callq 0x41e0
leaq -0x258(%rbp), %rdi
callq 0xb120
leaq -0x240(%rbp), %rdi
callq 0x27800
leaq -0x220(%rbp), %rdi
callq 0x40d0
movq -0x280(%rbp), %rdi
callq 0x4520
nopw (%rax,%rax)