// File: /workspace/github_cpp_makefile_star2_O1/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x278, %rsp            # imm = 0x278
movq %rcx, 0x10(%rsp)
movl %edx, %ebp
movq %rdi, %rbx
movl %esi, 0xc(%rdi)
movslq %esi, %r15
leaq 0x20(%rsp), %rdx
movw $0x0, (%rdx)
movl $0x0, 0xc(%rdx)
xorl %r12d, %r12d
movq %r12, 0x4(%rdx)
leaq 0x70(%rsp), %r14
leaq 0x50(%rsp), %rcx
movq %r14, %rdi
movq %r15, %rsi
callq 0xc168
movq 0x30(%rbx), %rdi
movaps (%r14), %xmm0
movq 0x10(%r14), %rax
movq %rdi, (%r14)
movups 0x38(%rbx), %xmm1
movups %xmm0, 0x30(%rbx)
movq %rax, 0x40(%rbx)
movups %xmm1, 0x8(%r14)
movq %r12, 0x10(%r14)
xorps %xmm0, %xmm0
movaps %xmm0, (%r14)
testq %rdi, %rdi
je 0x67eb
callq 0x3260
movq 0x70(%rsp), %rdi
testq %rdi, %rdi
je 0x67fa
callq 0x3260
xorps %xmm0, %xmm0
leaq 0x70(%rsp), %rdx
movaps %xmm0, 0x20(%rdx)
movaps %xmm0, 0x10(%rdx)
movaps %xmm0, (%rdx)
leaq 0x50(%rsp), %rdi
leaq 0xf(%rsp), %rcx
movq %r15, %rsi
callq 0xbe70
leaq 0x20(%rsp), %rdi
xorps %xmm0, %xmm0
movaps %xmm0, (%rdi)
movq $0x0, 0x10(%rdi)
movups 0x48(%rbx), %xmm0
movq 0x58(%rbx), %rax
leaq 0x50(%rsp), %r14
movaps (%r14), %xmm1
movups %xmm1, 0x48(%rbx)
movq 0x10(%r14), %rcx
movq %rcx, 0x58(%rbx)
movq 0x10(%rdi), %rcx
movq %rax, 0x10(%rdi)
movaps (%rdi), %xmm1
movaps %xmm0, (%rdi)
movaps %xmm1, (%r14)
movq %rcx, 0x10(%r14)
callq 0xbdc2
movq %r14, %rdi
callq 0xbdc2
movq 0x88(%rsp), %rdi
testq %rdi, %rdi
je 0x6884
callq 0x3260
movq 0x70(%rsp), %rdi
testq %rdi, %rdi
je 0x6893
callq 0x3260
leaq 0x28(%rsp), %rcx
movl $0x0, (%rcx)
xorl %eax, %eax
movq %rax, 0x8(%rcx)
movq %rcx, 0x10(%rcx)
movq %rcx, 0x18(%rcx)
movq %rax, 0x20(%rcx)
testl %ebp, %ebp
jle 0x6966
xorl %r15d, %r15d
callq 0x30a0
movslq %eax, %r14
callq 0x30a0
cltq
shlq $0x1f, %rax
orq %r14, %rax
movslq 0xc(%rbx), %rcx
xorl %edx, %edx
divq %rcx
movq %rdx, %r12
callq 0x30a0
movslq %eax, %r14
callq 0x30a0
cltq
shlq $0x1f, %rax
orq %r14, %rax
movslq 0xc(%rbx), %rcx
xorl %edx, %edx
divq %rcx
movq %rdx, %r14
cmpl %r14d, %r12d
je 0x695d
movl %r14d, %r13d
cmovgl %r12d, %r13d
cmovll %r12d, %r14d
movq %r13, %rax
shlq $0x20, %rax
leaq (%r14,%rax), %r12
movq %r12, 0x70(%rsp)
leaq 0x20(%rsp), %rdi
leaq 0x70(%rsp), %rsi
callq 0xdf00
leaq 0x28(%rsp), %rcx
cmpq %rcx, %rax
jne 0x695d
movq %rbx, %rdi
movl %r14d, %esi
movl %r13d, %edx
callq 0x5770
movq %r12, 0x70(%rsp)
leaq 0x20(%rsp), %rdi
leaq 0x70(%rsp), %rsi
callq 0xdf68
incl %r15d
cmpl %ebp, %r15d
jl 0x68bb
cmpl $0x0, 0xc(%rbx)
movl $0x0, %r13d
jle 0x6a6f
xorl %r15d, %r15d
movq 0xf658(%rip), %r12      # 0x15fd8
xorl %r13d, %r13d
movq %r13, 0x18(%rsp)
movq 0x48(%rbx), %rax
leaq (%r15,%r15,2), %r13
shlq $0x4, %r13
movq 0x18(%rax,%r13), %r14
movq 0x20(%rax,%r13), %rbp
cmpq %rbp, %r14
je 0x69d0
movq %rbp, %rax
subq %r14, %rax
sarq $0x2, %rax
bsrq %rax, %rdx
xorl $0x3f, %edx
addl %edx, %edx
xorq $0x7e, %rdx
movq %r14, %rdi
movq %rbp, %rsi
callq 0xd72f
movq %r14, %rdi
movq %rbp, %rsi
callq 0xd812
movq 0x48(%rbx), %rcx
movq 0x18(%rcx,%r13), %rax
movq 0x20(%rcx,%r13), %r14
subq %rax, %r14
cmpq $0x5, %r14
jb 0x6a53
movl $0x1, %ebp
movl -0x4(%rax,%rbp,4), %ecx
cmpl (%rax,%rbp,4), %ecx
jne 0x6a36
movl $0xf, %edx
movq %r12, %rdi
leaq 0x9a92(%rip), %rsi      # 0x10496
callq 0x32e0
movq (%r12), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x3280
movsbl %al, %esi
movq %r12, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x31d0
callq 0x48f8
incq %rbp
movq 0x48(%rbx), %rcx
movq 0x18(%rcx,%r13), %rax
movq 0x20(%rcx,%r13), %rcx
subq %rax, %rcx
sarq $0x2, %rcx
cmpq %rbp, %rcx
ja 0x69ec
shrq $0x2, %r14
movq 0x18(%rsp), %r13
addl %r14d, %r13d
incq %r15
movslq 0xc(%rbx), %rax
cmpq %rax, %r15
jl 0x6983
movq 0xf562(%rip), %rdi      # 0x15fd8
leaq 0x9a29(%rip), %rsi      # 0x104a6
movl $0x11, %edx
callq 0x32e0
movq 0xf54a(%rip), %rdi      # 0x15fd8
movl %r13d, %esi
callq 0x3440
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x3280
movsbl %al, %esi
movq %r14, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x31d0
movq 0x10(%rsp), %rax
movq (%rax), %rsi
leaq 0x70(%rsp), %rdi
movl $0x10, %edx
callq 0x32c0
leaq 0x70(%rsp), %rsi
movq %rbx, %rdi
callq 0x5e4c
leaq 0x70(%rsp), %rdi
callq 0x3350
movq 0xf4d3(%rip), %rax      # 0x15fc8
movq (%rax), %rcx
movq 0x18(%rax), %rax
leaq 0x78(%rsp), %rdi
movq %rcx, -0x8(%rdi)
movq -0x18(%rcx), %rcx
movq %rax, 0x70(%rsp,%rcx)
callq 0x3220
leaq 0x168(%rsp), %rdi
callq 0x30e0
leaq 0x20(%rsp), %rdi
callq 0xcbe2
addq $0x278, %rsp            # imm = 0x278
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x6b66
movq %rax, %rbx
leaq 0x70(%rsp), %rdi
callq 0xbf04
jmp 0x6b73
movq %rax, %rbx
leaq 0x70(%rsp), %rdi
callq 0x3380
jmp 0x6b69
jmp 0x6b66
jmp 0x6b66
jmp 0x6b66
jmp 0x6b66
jmp 0x6b66
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0xcbe2
movq %rbx, %rdi
callq 0x3460
nop