// File: datourat[P]IP-label-for-graph-reachability/Graph.cpp
// Function: Graph::RandomDAGGenerator(int, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
void Graph::RandomDAGGenerator(int n, int m, const string& filename){
	int i=0;
	int u, v;

	vsize = n;
	vl = VertexList(n, Vertex());
	graph = GRA(n, In_OutList());

	set< pair<int, int> > tmpset;

	for(int i=0; i<m; i++){
		u=Rand64()%vsize;
		v=Rand64()%vsize;

		if(u==v){
			i--;
			continue;
		}
		if(u>v)
			swap(u, v);

		if(tmpset.find(make_pair(u, v))==tmpset.end()){
			addEdge(u,v);
			tmpset.insert(make_pair(u, v));
		}
		else{
			i--;
			continue;
		}
	}

	int count=0;
	for(int u=0; u<vsize; u++){
		sort(graph[u].outList.begin(), graph[u].outList.end());
		count+=graph[u].outList.size();
		for(int j=0; j+1<graph[u].outList.size(); j++){
			if(graph[u].outList[j]==graph[u].outList[j+1]){
				cout << "redundant edges" << endl;
				quit();
			}
		}
	}

	cout << "Number of edges: " << count << endl;

	ofstream output(filename.c_str());
	writeGraph(output);
	output.close();
}

// Assembly:
subq $0x3f8, %rsp            # imm = 0x3F8
movq %rdi, 0x3f0(%rsp)
movl %esi, 0x3ec(%rsp)
movl %edx, 0x3e8(%rsp)
movq %rcx, 0x3e0(%rsp)
movq 0x3f0(%rsp), %rax
movq %rax, 0x90(%rsp)
movl $0x0, 0x3dc(%rsp)
movl 0x3ec(%rsp), %ecx
movl %ecx, 0xc(%rax)
movslq 0x3ec(%rsp), %rax
movq %rax, 0x98(%rsp)
leaq 0x3a8(%rsp), %rdi
movq %rdi, 0xa0(%rsp)
callq 0x11c60
leaq 0x3a7(%rsp), %rdi
movq %rdi, 0xa8(%rsp)
callq 0x112e0
movq 0x98(%rsp), %rsi
movq 0xa0(%rsp), %rdx
movq 0xa8(%rsp), %rcx
leaq 0x3b8(%rsp), %rdi
callq 0x11c90
jmp 0x789b
movq 0x90(%rsp), %rdi
addq $0x30, %rdi
leaq 0x3b8(%rsp), %rsi
movq %rsi, 0x70(%rsp)
callq 0x11240
movq 0x70(%rsp), %rdi
callq 0x11280
leaq 0x3a7(%rsp), %rdi
callq 0x11370
movslq 0x3ec(%rsp), %rax
movq %rax, 0x78(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x360(%rsp)
movaps %xmm0, 0x350(%rsp)
movaps %xmm0, 0x340(%rsp)
leaq 0x340(%rsp), %rdi
movq %rdi, 0x80(%rsp)
callq 0x11380
leaq 0x33f(%rsp), %rdi
movq %rdi, 0x88(%rsp)
callq 0x113b0
movq 0x78(%rsp), %rsi
movq 0x80(%rsp), %rdx
movq 0x88(%rsp), %rcx
leaq 0x378(%rsp), %rdi
callq 0x113c0
jmp 0x7946
movq 0x90(%rsp), %rdi
addq $0x48, %rdi
leaq 0x378(%rsp), %rsi
callq 0x111a0
leaq 0x378(%rsp), %rdi
callq 0x111e0
leaq 0x33f(%rsp), %rdi
callq 0x11440
leaq 0x340(%rsp), %rdi
callq 0x11450
leaq 0x308(%rsp), %rdi
callq 0x127d0
movl $0x0, 0x304(%rsp)
movl 0x304(%rsp), %eax
cmpl 0x3e8(%rsp), %eax
jge 0x7bf9
callq 0x127e0
movq %rax, 0x68(%rsp)
jmp 0x79be
movq 0x68(%rsp), %rax
movq 0x90(%rsp), %rcx
movslq 0xc(%rcx), %rcx
xorl %edx, %edx
divq %rcx
movl %edx, %eax
movl %eax, 0x3d8(%rsp)
callq 0x127e0
movq %rax, 0x60(%rsp)
jmp 0x79e9
movq 0x60(%rsp), %rax
movq 0x90(%rsp), %rcx
movslq 0xc(%rcx), %rcx
xorl %edx, %edx
divq %rcx
movl %edx, %eax
movl %eax, 0x3d4(%rsp)
movl 0x3d8(%rsp), %eax
cmpl 0x3d4(%rsp), %eax
jne 0x7aa4
movl 0x304(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x304(%rsp)
jmp 0x7be3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x398(%rsp)
movl %eax, 0x394(%rsp)
leaq 0x3a7(%rsp), %rdi
callq 0x11370
jmp 0x7ed7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x398(%rsp)
movl %eax, 0x394(%rsp)
leaq 0x33f(%rsp), %rdi
callq 0x11440
leaq 0x340(%rsp), %rdi
callq 0x11450
jmp 0x7ed7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x398(%rsp)
movl %eax, 0x394(%rsp)
jmp 0x7eca
movl 0x3d8(%rsp), %eax
cmpl 0x3d4(%rsp), %eax
jle 0x7ac9
leaq 0x3d8(%rsp), %rdi
leaq 0x3d4(%rsp), %rsi
callq 0x12810
leaq 0x3d8(%rsp), %rdi
leaq 0x3d4(%rsp), %rsi
callq 0x128a0
movq %rax, 0x58(%rsp)
jmp 0x7ae5
movq 0x58(%rsp), %rax
movq %rax, 0x2f0(%rsp)
leaq 0x308(%rsp), %rdi
leaq 0x2f0(%rsp), %rsi
callq 0x12860
movq %rax, 0x50(%rsp)
jmp 0x7b0e
movq 0x50(%rsp), %rax
movq %rax, 0x2f8(%rsp)
leaq 0x308(%rsp), %rdi
callq 0x128d0
movq %rax, 0x2e8(%rsp)
leaq 0x2f8(%rsp), %rdi
leaq 0x2e8(%rsp), %rsi
callq 0x12840
testb $0x1, %al
jne 0x7b4e
jmp 0x7bce
movq 0x90(%rsp), %rdi
movl 0x3d8(%rsp), %esi
movl 0x3d4(%rsp), %edx
callq 0x61a0
jmp 0x7b6b
leaq 0x3d8(%rsp), %rdi
leaq 0x3d4(%rsp), %rsi
callq 0x128a0
movq %rax, 0x48(%rsp)
jmp 0x7b87
movq 0x48(%rsp), %rax
movq %rax, 0x2e0(%rsp)
leaq 0x308(%rsp), %rdi
leaq 0x2e0(%rsp), %rsi
callq 0x12900
movb %dl, 0x3f(%rsp)
movq %rax, 0x40(%rsp)
jmp 0x7bb4
movb 0x3f(%rsp), %al
movq 0x40(%rsp), %rcx
movq %rcx, 0x2d0(%rsp)
movb %al, 0x2d8(%rsp)
jmp 0x7be1
movl 0x304(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x304(%rsp)
jmp 0x7be3
jmp 0x7be3
movl 0x304(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x304(%rsp)
jmp 0x799e
movl $0x0, 0x2cc(%rsp)
movl $0x0, 0x2c8(%rsp)
movq 0x90(%rsp), %rcx
movl 0x2c8(%rsp), %eax
cmpl 0xc(%rcx), %eax
jge 0x7df8
movq 0x90(%rsp), %rdi
addq $0x48, %rdi
movq %rdi, 0x30(%rsp)
movslq 0x2c8(%rsp), %rsi
callq 0x11d60
movq %rax, %rdi
addq $0x18, %rdi
callq 0x12270
movq 0x30(%rsp), %rdi
movq %rax, 0x2c0(%rsp)
movslq 0x2c8(%rsp), %rsi
callq 0x11d60
movq %rax, %rdi
addq $0x18, %rdi
callq 0x122e0
movq %rax, 0x2b8(%rsp)
movq 0x2c0(%rsp), %rdi
movq 0x2b8(%rsp), %rsi
callq 0x12530
jmp 0x7c96
movq 0x90(%rsp), %rdi
addq $0x48, %rdi
movslq 0x2c8(%rsp), %rsi
callq 0x11d60
movq %rax, %rdi
addq $0x18, %rdi
callq 0x4c10
movq %rax, %rcx
movslq 0x2cc(%rsp), %rax
addq %rcx, %rax
movl %eax, 0x2cc(%rsp)
movl $0x0, 0x2b4(%rsp)
movq 0x90(%rsp), %rdi
movl 0x2b4(%rsp), %eax
addl $0x1, %eax
cltq
movq %rax, 0x28(%rsp)
addq $0x48, %rdi
movslq 0x2c8(%rsp), %rsi
callq 0x11d60
movq %rax, %rdi
addq $0x18, %rdi
callq 0x4c10
movq %rax, %rcx
movq 0x28(%rsp), %rax
cmpq %rcx, %rax
jae 0x7de0
movq 0x90(%rsp), %rdi
addq $0x48, %rdi
movslq 0x2c8(%rsp), %rsi
callq 0x11d60
movq %rax, %rdi
addq $0x18, %rdi
movslq 0x2b4(%rsp), %rsi
callq 0x12960
movq 0x90(%rsp), %rdi
movl (%rax), %eax
movl %eax, 0x24(%rsp)
addq $0x48, %rdi
movslq 0x2c8(%rsp), %rsi
callq 0x11d60
movq %rax, %rdi
addq $0x18, %rdi
movl 0x2b4(%rsp), %eax
addl $0x1, %eax
movslq %eax, %rsi
callq 0x12960
movq %rax, %rcx
movl 0x24(%rsp), %eax
cmpl (%rcx), %eax
jne 0x7dc8
movq 0x2d23f(%rip), %rdi     # 0x34fd8
leaq 0x20686(%rip), %rsi     # 0x28426
callq 0x32c0
movq %rax, 0x18(%rsp)
jmp 0x7dac
movq 0x18(%rsp), %rdi
movq 0x2d210(%rip), %rsi     # 0x34fc8
callq 0x3300
jmp 0x7dbf
callq 0x4da0
jmp 0x7dc6
jmp 0x7dc8
jmp 0x7dca
movl 0x2b4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x2b4(%rsp)
jmp 0x7cdb
jmp 0x7de2
movl 0x2c8(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x2c8(%rsp)
jmp 0x7c0f
movq 0x2d1d9(%rip), %rdi     # 0x34fd8
leaq 0x20630(%rip), %rsi     # 0x28436
callq 0x32c0
movq %rax, 0x10(%rsp)
jmp 0x7e12
movq 0x10(%rsp), %rdi
movl 0x2cc(%rsp), %esi
callq 0x34d0
movq %rax, 0x8(%rsp)
jmp 0x7e2a
movq 0x8(%rsp), %rdi
movq 0x2d192(%rip), %rsi     # 0x34fc8
callq 0x3300
jmp 0x7e3d
movq 0x3e0(%rsp), %rdi
callq 0x3120
movq %rax, %rsi
leaq 0xb0(%rsp), %rdi
movl $0x10, %edx
callq 0x3320
jmp 0x7e61
movq 0x90(%rsp), %rdi
leaq 0xb0(%rsp), %rsi
callq 0x69e0
jmp 0x7e78
leaq 0xb0(%rsp), %rdi
callq 0x3400
jmp 0x7e87
leaq 0xb0(%rsp), %rdi
callq 0x3420
leaq 0x308(%rsp), %rdi
callq 0x12980
addq $0x3f8, %rsp            # imm = 0x3F8
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x398(%rsp)
movl %eax, 0x394(%rsp)
leaq 0xb0(%rsp), %rdi
callq 0x3420
leaq 0x308(%rsp), %rdi
callq 0x12980
movq 0x398(%rsp), %rdi
callq 0x34e0
nopw %cs:(%rax,%rax)