// File: jkeys-ecg-nmsu[P]graph-with-search-algorithms/Graph.cpp
// Function: Graph::scan_tmg(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
void Graph::scan_tmg(const string & file) {	
	string tmg_start, tmg_version, tmg_simple;
	string num_nodes_s, num_edges_s;
	string waypoint, latitude_s, longitude_s;	
	int u_id, v_id, weight;
	double latitude, longitude;
    ifstream fs;
	
	int num_nodes, num_edges;
	
	fs.open(file.c_str()); assert(fs.is_open());
	
	/**** read in header data ****/
	
	fs >> tmg_start >> tmg_version >> tmg_simple >> num_nodes >> num_edges;
	
	assert(tmg_start == "TMG"); assert(tmg_version == "1.0"); assert(tmg_simple == "simple");	
		
	initEmpty(num_edges + 10); //twice num_edges because undirected
	
	/**** read in all nodes ****/
	
	cout << num_nodes << endl << num_edges << endl;	
	
	for (size_t i = 0; i != num_nodes; i++) {
		fs >> waypoint >> latitude >> longitude;
		// cout << waypoint << latitude_s << longitude_s << endl;
				 
		u_id = current_id;
		current_id++;			
			
		Node n(waypoint, u_id); 
		
		n.setLatitude(latitude);
		n.setLongitude(longitude);
		
		m_nodes.push_back(n);	
	} //end for
	
	
	/**** have read in all nodes, now read in all edges ****/
	
	string adjRoads;
	
	
	for (size_t i = 0; i != num_edges; i++) {
		fs >> u_id >> v_id >> adjRoads;
		
		Node u = m_nodes[u_id]; 
		Node v = m_nodes[v_id];
		
		double u_v_distance = calculateDistance(u, v);
				
		Edge u_v(u_id, v_id, u_v_distance);
		Edge v_u(v_id, u_id, u_v_distance); //undirected
		
		addEdge(u, v); addEdge(v, u);
		
		addEdgeObj(u, u_v); addEdgeObj(v, v_u);
		
		setEdgeRoads(m_nodes[u_id], adjRoads);
		setEdgeRoads(m_nodes[v_id], adjRoads);
	} //end for
	
	fs.close();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x5f0, %rsp            # imm = 0x5F0
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x570(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x2320
leaq -0x50(%rbp), %rdi
callq 0x2320
leaq -0x70(%rbp), %rdi
callq 0x2320
leaq -0x90(%rbp), %rdi
callq 0x2320
leaq -0xb0(%rbp), %rdi
callq 0x2320
leaq -0xd0(%rbp), %rdi
callq 0x2320
leaq -0xf0(%rbp), %rdi
callq 0x2320
leaq -0x110(%rbp), %rdi
callq 0x2320
leaq -0x338(%rbp), %rdi
callq 0x22b0
jmp 0x50f3
movq -0x10(%rbp), %rdi
callq 0x2100
movq %rax, %rsi
leaq -0x338(%rbp), %rdi
movl $0x8, %edx
callq 0x2180
jmp 0x5112
leaq -0x338(%rbp), %rdi
callq 0x2390
movb %al, -0x571(%rbp)
jmp 0x5126
movb -0x571(%rbp), %al
testb $0x1, %al
jne 0x5132
jmp 0x5134
jmp 0x5181
leaq 0x14f35(%rip), %rdi     # 0x1a070
leaq 0x14f3b(%rip), %rsi     # 0x1a07d
movl $0xa7, %edx
leaq 0x14f8b(%rip), %rcx     # 0x1a0d9
callq 0x2190
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x340(%rbp)
movl %eax, -0x344(%rbp)
jmp 0x582c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x340(%rbp)
movl %eax, -0x344(%rbp)
jmp 0x5820
leaq -0x338(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x22f0
movq %rax, -0x580(%rbp)
jmp 0x519a
movq -0x580(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x22f0
movq %rax, -0x588(%rbp)
jmp 0x51b3
movq -0x588(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x22f0
movq %rax, -0x590(%rbp)
jmp 0x51cc
movq -0x590(%rbp), %rdi
leaq -0x348(%rbp), %rsi
callq 0x2160
movq %rax, -0x598(%rbp)
jmp 0x51e8
movq -0x598(%rbp), %rdi
leaq -0x34c(%rbp), %rsi
callq 0x2160
jmp 0x51fd
leaq 0x14efa(%rip), %rsi     # 0x1a0fe
leaq -0x30(%rbp), %rdi
callq 0x7b00
movb %al, -0x599(%rbp)
jmp 0x5215
movb -0x599(%rbp), %al
testb $0x1, %al
jne 0x5221
jmp 0x5223
jmp 0x5242
leaq 0x14ed8(%rip), %rdi     # 0x1a102
leaq 0x14e4c(%rip), %rsi     # 0x1a07d
movl $0xad, %edx
leaq 0x14e9c(%rip), %rcx     # 0x1a0d9
callq 0x2190
leaq 0x14ecc(%rip), %rsi     # 0x1a115
leaq -0x50(%rbp), %rdi
callq 0x7b00
movb %al, -0x59a(%rbp)
jmp 0x525a
movb -0x59a(%rbp), %al
testb $0x1, %al
jne 0x5266
jmp 0x5268
jmp 0x5287
leaq 0x14eaa(%rip), %rdi     # 0x1a119
leaq 0x14e07(%rip), %rsi     # 0x1a07d
movl $0xad, %edx
leaq 0x14e57(%rip), %rcx     # 0x1a0d9
callq 0x2190
leaq 0x14ea0(%rip), %rsi     # 0x1a12e
leaq -0x70(%rbp), %rdi
callq 0x7b00
movb %al, -0x59b(%rbp)
jmp 0x529f
movb -0x59b(%rbp), %al
testb $0x1, %al
jne 0x52ab
jmp 0x52ad
jmp 0x52cc
leaq 0x14e81(%rip), %rdi     # 0x1a135
leaq 0x14dc2(%rip), %rsi     # 0x1a07d
movl $0xad, %edx
leaq 0x14e12(%rip), %rcx     # 0x1a0d9
callq 0x2190
movq -0x570(%rbp), %rdi
movl -0x34c(%rbp), %esi
addl $0xa, %esi
callq 0x3c30
jmp 0x52e3
movl -0x348(%rbp), %esi
movq 0x21ce0(%rip), %rdi     # 0x26fd0
callq 0x23d0
movq %rax, -0x5a8(%rbp)
jmp 0x52fe
movq -0x5a8(%rbp), %rdi
movq 0x21cb4(%rip), %rsi     # 0x26fc0
callq 0x2280
movq %rax, -0x5b0(%rbp)
jmp 0x531a
movq -0x5b0(%rbp), %rdi
movl -0x34c(%rbp), %esi
callq 0x23d0
movq %rax, -0x5b8(%rbp)
jmp 0x5335
movq -0x5b8(%rbp), %rdi
movq 0x21c7d(%rip), %rsi     # 0x26fc0
callq 0x2280
jmp 0x534a
movq $0x0, -0x358(%rbp)
movq -0x358(%rbp), %rax
movslq -0x348(%rbp), %rcx
cmpq %rcx, %rax
je 0x5473
leaq -0x338(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
callq 0x22f0
movq %rax, -0x5c0(%rbp)
jmp 0x5388
movq -0x5c0(%rbp), %rdi
leaq -0x128(%rbp), %rsi
callq 0x21e0
movq %rax, -0x5c8(%rbp)
jmp 0x53a4
movq -0x5c8(%rbp), %rdi
leaq -0x130(%rbp), %rsi
callq 0x21e0
jmp 0x53b9
movq -0x570(%rbp), %rax
movl 0x60(%rax), %ecx
movl %ecx, -0x114(%rbp)
movl 0x60(%rax), %ecx
incl %ecx
movl %ecx, 0x60(%rax)
movl -0x114(%rbp), %edx
leaq -0x3d8(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
callq 0xea90
jmp 0x53ec
movsd -0x128(%rbp), %xmm0
leaq -0x3d8(%rbp), %rdi
callq 0xed20
jmp 0x5402
movsd -0x130(%rbp), %xmm0
leaq -0x3d8(%rbp), %rdi
callq 0xed00
jmp 0x5418
movq -0x570(%rbp), %rdi
leaq -0x3d8(%rbp), %rsi
callq 0x78e0
jmp 0x542d
leaq -0x3d8(%rbp), %rdi
callq 0x2bd0
movq -0x358(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x358(%rbp)
jmp 0x5355
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x340(%rbp)
movl %eax, -0x344(%rbp)
leaq -0x3d8(%rbp), %rdi
callq 0x2bd0
jmp 0x5820
leaq -0x3f8(%rbp), %rdi
callq 0x2320
movq $0x0, -0x400(%rbp)
movq -0x400(%rbp), %rax
movslq -0x34c(%rbp), %rcx
cmpq %rcx, %rax
je 0x578e
leaq -0x338(%rbp), %rdi
leaq -0x114(%rbp), %rsi
callq 0x2160
movq %rax, -0x5d0(%rbp)
jmp 0x54bd
movq -0x5d0(%rbp), %rdi
leaq -0x118(%rbp), %rsi
callq 0x2160
movq %rax, -0x5d8(%rbp)
jmp 0x54d9
movq -0x5d8(%rbp), %rdi
leaq -0x3f8(%rbp), %rsi
callq 0x22f0
jmp 0x54ee
movq -0x570(%rbp), %rdi
movslq -0x114(%rbp), %rsi
callq 0x7b30
movq %rax, %rsi
leaq -0x480(%rbp), %rdi
callq 0x2b50
jmp 0x5512
movq -0x570(%rbp), %rdi
movslq -0x118(%rbp), %rsi
callq 0x7b30
movq %rax, %rsi
leaq -0x500(%rbp), %rdi
callq 0x2b50
jmp 0x5536
leaq -0x480(%rbp), %rdi
leaq -0x500(%rbp), %rsi
callq 0x5890
movsd %xmm0, -0x5e0(%rbp)
jmp 0x5553
movsd -0x5e0(%rbp), %xmm0
movsd %xmm0, -0x508(%rbp)
movl -0x114(%rbp), %esi
movl -0x118(%rbp), %edx
movsd -0x508(%rbp), %xmm0
leaq -0x518(%rbp), %rdi
callq 0xee90
jmp 0x5585
movl -0x118(%rbp), %esi
movl -0x114(%rbp), %edx
movsd -0x508(%rbp), %xmm0
leaq -0x528(%rbp), %rdi
callq 0xee90
jmp 0x55a7
movq -0x570(%rbp), %rdi
leaq -0x480(%rbp), %rsi
leaq -0x500(%rbp), %rdx
callq 0x5aa0
jmp 0x55c3
movq -0x570(%rbp), %rdi
leaq -0x500(%rbp), %rsi
leaq -0x480(%rbp), %rdx
callq 0x5aa0
jmp 0x55df
movq -0x570(%rbp), %rdi
leaq -0x480(%rbp), %rsi
leaq -0x518(%rbp), %rdx
callq 0x5af0
jmp 0x55fb
movq -0x570(%rbp), %rdi
leaq -0x500(%rbp), %rsi
leaq -0x528(%rbp), %rdx
callq 0x5af0
jmp 0x5617
movq -0x570(%rbp), %rdi
movslq -0x114(%rbp), %rsi
callq 0x7b30
movq %rax, -0x5e8(%rbp)
leaq -0x548(%rbp), %rdi
leaq -0x3f8(%rbp), %rsi
callq 0x2110
jmp 0x5646
movq -0x5e8(%rbp), %rsi
movq -0x570(%rbp), %rdi
leaq -0x548(%rbp), %rdx
callq 0x5b40
jmp 0x5662
leaq -0x548(%rbp), %rdi
callq 0x2170
movq -0x570(%rbp), %rdi
movslq -0x118(%rbp), %rsi
callq 0x7b30
movq %rax, -0x5f0(%rbp)
leaq -0x568(%rbp), %rdi
leaq -0x3f8(%rbp), %rsi
callq 0x2110
jmp 0x569d
movq -0x5f0(%rbp), %rsi
movq -0x570(%rbp), %rdi
leaq -0x568(%rbp), %rdx
callq 0x5b40
jmp 0x56b9
leaq -0x568(%rbp), %rdi
callq 0x2170
leaq -0x500(%rbp), %rdi
callq 0x2bd0
leaq -0x480(%rbp), %rdi
callq 0x2bd0
movq -0x400(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x400(%rbp)
jmp 0x548a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x340(%rbp)
movl %eax, -0x344(%rbp)
jmp 0x5814
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x340(%rbp)
movl %eax, -0x344(%rbp)
jmp 0x577d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x340(%rbp)
movl %eax, -0x344(%rbp)
jmp 0x5771
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x340(%rbp)
movl %eax, -0x344(%rbp)
leaq -0x548(%rbp), %rdi
callq 0x2170
jmp 0x5771
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x340(%rbp)
movl %eax, -0x344(%rbp)
leaq -0x568(%rbp), %rdi
callq 0x2170
leaq -0x500(%rbp), %rdi
callq 0x2bd0
leaq -0x480(%rbp), %rdi
callq 0x2bd0
jmp 0x5814
leaq -0x338(%rbp), %rdi
callq 0x2080
jmp 0x579c
leaq -0x3f8(%rbp), %rdi
callq 0x2170
leaq -0x338(%rbp), %rdi
callq 0x20b0
leaq -0x110(%rbp), %rdi
callq 0x2170
leaq -0xf0(%rbp), %rdi
callq 0x2170
leaq -0xd0(%rbp), %rdi
callq 0x2170
leaq -0xb0(%rbp), %rdi
callq 0x2170
leaq -0x90(%rbp), %rdi
callq 0x2170
leaq -0x70(%rbp), %rdi
callq 0x2170
leaq -0x50(%rbp), %rdi
callq 0x2170
leaq -0x30(%rbp), %rdi
callq 0x2170
addq $0x5f0, %rsp            # imm = 0x5F0
popq %rbp
retq
leaq -0x3f8(%rbp), %rdi
callq 0x2170
leaq -0x338(%rbp), %rdi
callq 0x20b0
leaq -0x110(%rbp), %rdi
callq 0x2170
leaq -0xf0(%rbp), %rdi
callq 0x2170
leaq -0xd0(%rbp), %rdi
callq 0x2170
leaq -0xb0(%rbp), %rdi
callq 0x2170
leaq -0x90(%rbp), %rdi
callq 0x2170
leaq -0x70(%rbp), %rdi
callq 0x2170
leaq -0x50(%rbp), %rdi
callq 0x2170
leaq -0x30(%rbp), %rdi
callq 0x2170
movq -0x340(%rbp), %rdi
callq 0x23e0
nop