// File: datourat[P]IP-label-for-graph-reachability/Graph.cpp
// Function: Graph::PrintReOrderedGraph(std::vector<int, std::allocator<int>> const&)
void Graph::PrintReOrderedGraph(const vector<int>& order){
	ofstream output((name+"_ReOrdered.gra").c_str());
	if(output.is_open()==false){
		cout << name+"_ReOrdered.gra" << " cannot be opened." << endl;
		quit();
	}

	vector< vector<int> > ReOrderedGraph(vsize, vector<int>());
	int u, v;
	for(int i=0; i<vsize; i++){
		u=order[i];
		for(int j=0; j<graph[i].outList.size(); j++){
			v=order[graph[i].outList[j]];
			ReOrderedGraph[u].push_back(v);
		}
	}

	for(int u=0; u<vsize; u++){
		sort(ReOrderedGraph[u].begin(), ReOrderedGraph[u].end());
	}

	output << "graph_for_greach" << endl;
	output << vsize << endl;
	for(int i=0; i<vsize; i++){
		output << i << ": ";
		for(int j=0; j<ReOrderedGraph[i].size(); j++){
			output << ReOrderedGraph[i][j] << " ";
		}
		output << "#" << endl;
	}


	output.close();
}

// Assembly:
subq $0x358, %rsp            # imm = 0x358
movq %rdi, 0x350(%rsp)
movq %rsi, 0x348(%rsp)
movq 0x350(%rsp), %rsi
movq %rsi, 0x80(%rsp)
addq $0x10, %rsi
leaq 0x1df40(%rip), %rdx     # 0x284f2
leaq 0x128(%rsp), %rdi
movq %rdi, 0x88(%rsp)
callq 0x4c30
movq 0x88(%rsp), %rdi
callq 0x3120
movq %rax, %rsi
leaq 0x148(%rsp), %rdi
movl $0x10, %edx
callq 0x3320
jmp 0xa5eb
leaq 0x128(%rsp), %rdi
callq 0x31b0
leaq 0x148(%rsp), %rdi
callq 0x3220
movb %al, 0x7f(%rsp)
jmp 0xa60b
movb 0x7f(%rsp), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0xa700
movq 0x80(%rsp), %rsi
addq $0x10, %rsi
leaq 0x1dec2(%rip), %rdx     # 0x284f2
leaq 0xf8(%rsp), %rdi
callq 0x4c30
jmp 0xa63f
movq 0x2a992(%rip), %rdi     # 0x34fd8
leaq 0xf8(%rsp), %rsi
callq 0x3270
movq %rax, 0x70(%rsp)
jmp 0xa65a
movq 0x70(%rsp), %rdi
leaq 0x1de9b(%rip), %rsi     # 0x28501
callq 0x32c0
movq %rax, 0x68(%rsp)
jmp 0xa672
movq 0x68(%rsp), %rdi
movq 0x2a94a(%rip), %rsi     # 0x34fc8
callq 0x3300
jmp 0xa685
leaq 0xf8(%rsp), %rdi
callq 0x31b0
callq 0x4da0
jmp 0xa699
jmp 0xa700
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x120(%rsp)
movl %eax, 0x11c(%rsp)
leaq 0x128(%rsp), %rdi
callq 0x31b0
jmp 0xab8a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x120(%rsp)
movl %eax, 0x11c(%rsp)
jmp 0xab7d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x120(%rsp)
movl %eax, 0x11c(%rsp)
leaq 0xf8(%rsp), %rdi
callq 0x31b0
jmp 0xab7d
movq 0x80(%rsp), %rax
movslq 0xc(%rax), %rax
movq %rax, 0x50(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0xc0(%rsp)
movq $0x0, 0xd0(%rsp)
leaq 0xc0(%rsp), %rdi
movq %rdi, 0x58(%rsp)
callq 0x11160
leaq 0xbf(%rsp), %rdi
movq %rdi, 0x60(%rsp)
callq 0x13260
movq 0x50(%rsp), %rsi
movq 0x58(%rsp), %rdx
movq 0x60(%rsp), %rcx
leaq 0xe0(%rsp), %rdi
callq 0x13270
jmp 0xa76a
leaq 0xbf(%rsp), %rdi
callq 0x132f0
leaq 0xc0(%rsp), %rdi
callq 0x115a0
movl $0x0, 0xb0(%rsp)
movq 0x80(%rsp), %rcx
movl 0xb0(%rsp), %eax
cmpl 0xc(%rcx), %eax
jge 0xa913
movq 0x348(%rsp), %rdi
movslq 0xb0(%rsp), %rsi
callq 0x13300
movl (%rax), %eax
movl %eax, 0xb8(%rsp)
movl $0x0, 0xac(%rsp)
movq 0x80(%rsp), %rdi
movslq 0xac(%rsp), %rax
movq %rax, 0x48(%rsp)
addq $0x48, %rdi
movslq 0xb0(%rsp), %rsi
callq 0x11d60
movq %rax, %rdi
addq $0x18, %rdi
callq 0x4c10
movq %rax, %rcx
movq 0x48(%rsp), %rax
cmpq %rcx, %rax
jae 0xa8fb
movq 0x80(%rsp), %rdi
movq 0x348(%rsp), %rax
movq %rax, 0x40(%rsp)
addq $0x48, %rdi
movslq 0xb0(%rsp), %rsi
callq 0x11d60
movq %rax, %rdi
addq $0x18, %rdi
movslq 0xac(%rsp), %rsi
callq 0x12960
movq 0x40(%rsp), %rdi
movslq (%rax), %rsi
callq 0x13300
movl (%rax), %eax
movl %eax, 0xb4(%rsp)
movslq 0xb8(%rsp), %rsi
leaq 0xe0(%rsp), %rdi
callq 0x4bf0
movq %rax, %rdi
leaq 0xb4(%rsp), %rsi
callq 0x12660
jmp 0xa88a
jmp 0xa88c
movl 0xac(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xac(%rsp)
jmp 0xa7d0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x120(%rsp)
movl %eax, 0x11c(%rsp)
leaq 0xbf(%rsp), %rdi
callq 0x132f0
leaq 0xc0(%rsp), %rdi
callq 0x115a0
jmp 0xab7d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x120(%rsp)
movl %eax, 0x11c(%rsp)
leaq 0xe0(%rsp), %rdi
callq 0x11480
jmp 0xab7d
jmp 0xa8fd
movl 0xb0(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xb0(%rsp)
jmp 0xa78f
movl $0x0, 0xa8(%rsp)
movq 0x80(%rsp), %rcx
movl 0xa8(%rsp), %eax
cmpl 0xc(%rcx), %eax
jge 0xa9ad
movslq 0xa8(%rsp), %rsi
leaq 0xe0(%rsp), %rdi
movq %rdi, 0x38(%rsp)
callq 0x4bf0
movq %rax, %rdi
callq 0x12270
movq 0x38(%rsp), %rdi
movq %rax, 0xa0(%rsp)
movslq 0xa8(%rsp), %rsi
callq 0x4bf0
movq %rax, %rdi
callq 0x122e0
movq %rax, 0x98(%rsp)
movq 0xa0(%rsp), %rdi
movq 0x98(%rsp), %rsi
callq 0x12530
jmp 0xa995
jmp 0xa997
movl 0xa8(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xa8(%rsp)
jmp 0xa91e
leaq 0x1da19(%rip), %rsi     # 0x283cd
leaq 0x148(%rsp), %rdi
callq 0x32c0
movq %rax, 0x30(%rsp)
jmp 0xa9c8
movq 0x30(%rsp), %rdi
movq 0x2a5f4(%rip), %rsi     # 0x34fc8
callq 0x3300
jmp 0xa9db
movq 0x80(%rsp), %rax
movl 0xc(%rax), %esi
leaq 0x148(%rsp), %rdi
callq 0x34d0
movq %rax, 0x28(%rsp)
jmp 0xa9fa
movq 0x28(%rsp), %rdi
movq 0x2a5c2(%rip), %rsi     # 0x34fc8
callq 0x3300
jmp 0xaa0d
movl $0x0, 0x94(%rsp)
movq 0x80(%rsp), %rcx
movl 0x94(%rsp), %eax
cmpl 0xc(%rcx), %eax
jge 0xab4c
movl 0x94(%rsp), %esi
leaq 0x148(%rsp), %rdi
callq 0x34d0
movq %rax, 0x20(%rsp)
jmp 0xaa4b
movq 0x20(%rsp), %rdi
leaq 0x1d955(%rip), %rsi     # 0x283ac
callq 0x32c0
jmp 0xaa5e
movl $0x0, 0x90(%rsp)
movslq 0x90(%rsp), %rax
movq %rax, 0x18(%rsp)
movslq 0x94(%rsp), %rsi
leaq 0xe0(%rsp), %rdi
callq 0x4bf0
movq %rax, %rdi
callq 0x4c10
movq %rax, %rcx
movq 0x18(%rsp), %rax
cmpq %rcx, %rax
jae 0xab06
movslq 0x94(%rsp), %rsi
leaq 0xe0(%rsp), %rdi
callq 0x4bf0
movq %rax, %rdi
movslq 0x90(%rsp), %rsi
callq 0x12960
movl (%rax), %esi
leaq 0x148(%rsp), %rdi
callq 0x34d0
movq %rax, 0x10(%rsp)
jmp 0xaadb
movq 0x10(%rsp), %rdi
leaq 0x1da54(%rip), %rsi     # 0x2853b
callq 0x32c0
jmp 0xaaee
jmp 0xaaf0
movl 0x90(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x90(%rsp)
jmp 0xaa69
leaq 0x1da42(%rip), %rsi     # 0x2854f
leaq 0x148(%rsp), %rdi
callq 0x32c0
movq %rax, 0x8(%rsp)
jmp 0xab21
movq 0x8(%rsp), %rdi
movq 0x2a49b(%rip), %rsi     # 0x34fc8
callq 0x3300
jmp 0xab34
jmp 0xab36
movl 0x94(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x94(%rsp)
jmp 0xaa18
leaq 0x148(%rsp), %rdi
callq 0x3400
jmp 0xab5b
leaq 0xe0(%rsp), %rdi
callq 0x11480
leaq 0x148(%rsp), %rdi
callq 0x3420
addq $0x358, %rsp            # imm = 0x358
retq
leaq 0x148(%rsp), %rdi
callq 0x3420
movq 0x120(%rsp), %rdi
callq 0x34e0
nopw (%rax,%rax)