// File: /workspace/github_cpp_makefile_star2_O2/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 $0x248, %rsp            # imm = 0x248
movq %rcx, 0x8(%rsp)
movq %rdi, %rbx
movl %esi, 0xc(%rdi)
leaq 0x10(%rsp), %rax
andw $0x0, (%rax)
movl %edx, 0x4(%rsp)
andl $0x0, 0xc(%rax)
movslq %esi, %r14
andq $0x0, 0x4(%rax)
leaq 0x40(%rsp), %r15
leaq 0x3(%rsp), %rcx
movq %r15, %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0x97be
leaq 0x30(%rbx), %rdi
movq %r15, %rsi
callq 0xa5fc
movq %r15, %rdi
callq 0xa4e4
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%r15)
movaps %xmm0, 0x10(%r15)
movaps %xmm0, (%r15)
leaq 0x10(%rsp), %rdi
leaq 0x40(%rsp), %rdx
leaq 0x3(%rsp), %rcx
movq %r14, %rsi
callq 0x956a
leaq 0x48(%rbx), %r15
leaq 0x10(%rsp), %r14
movq %r15, %rdi
movq %r14, %rsi
callq 0xa5aa
movq %r14, %rdi
callq 0x94f6
leaq 0x40(%rsp), %rdi
callq 0x95c0
leaq 0x18(%rsp), %rax
andl $0x0, (%rax)
andq $0x0, 0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
andq $0x0, 0x20(%rax)
xorl %ebp, %ebp
cmpl 0x4(%rsp), %ebp
jge 0x590f
callq 0x9a79
movslq 0xc(%rbx), %rcx
xorl %edx, %edx
divq %rcx
movq %rdx, %r13
callq 0x9a79
movslq 0xc(%rbx), %rcx
xorl %edx, %edx
divq %rcx
movq %rdx, %r14
cmpl %r14d, %r13d
je 0x5881
movl %r14d, %r12d
cmovgl %r13d, %r12d
cmovll %r13d, %r14d
movq %r12, %rax
shlq $0x20, %rax
leaq (%r14,%rax), %r13
movq %r13, 0x40(%rsp)
leaq 0x10(%rsp), %rdi
leaq 0x40(%rsp), %rsi
callq 0xb56e
leaq 0x18(%rsp), %rcx
cmpq %rcx, %rax
jne 0x5881
movq %rbx, %rdi
movl %r14d, %esi
movl %r12d, %edx
callq 0x4c60
movq %r13, 0x40(%rsp)
leaq 0x10(%rsp), %rdi
leaq 0x40(%rsp), %rsi
callq 0xb5fe
incl %ebp
jmp 0x5881
xorl %r14d, %r14d
xorl %ebp, %ebp
movslq 0xc(%rbx), %rax
cmpq %rax, %r14
jge 0x59ae
movq (%r15), %rax
imulq $0x30, %r14, %r12
movq 0x18(%rax,%r12), %rdi
movq 0x20(%rax,%r12), %rsi
callq 0xad95
movq (%r15), %rcx
movq 0x18(%rcx,%r12), %rax
movq 0x20(%rcx,%r12), %rcx
movq %rcx, %rdx
subq %rax, %rdx
shrq $0x2, %rdx
addl %edx, %ebp
xorl %edx, %edx
subq %rax, %rcx
sarq $0x2, %rcx
incq %rdx
cmpq %rdx, %rcx
jbe 0x59a6
movl -0x4(%rax,%rdx,4), %esi
leaq 0x1(%rdx), %r13
cmpl (%rax,%rdx,4), %esi
movq %r13, %rdx
jne 0x595c
movq 0xf660(%rip), %rdi      # 0x14fd8
leaq 0x8aa7(%rip), %rsi      # 0xe426
callq 0x3270
movq %rax, %rdi
callq 0x3140
callq 0x41b8
decq %r13
movq (%r15), %rcx
movq 0x18(%rcx,%r12), %rax
movq 0x20(%rcx,%r12), %rcx
movq %r13, %rdx
jmp 0x5952
incq %r14
jmp 0x5914
movq 0xf623(%rip), %rdi      # 0x14fd8
leaq 0x8a7a(%rip), %rsi      # 0xe436
callq 0x3270
movq %rax, %rdi
movl %ebp, %esi
callq 0x3420
movq %rax, %rdi
callq 0x3140
movq 0x8(%rsp), %rax
movq (%rax), %rsi
leaq 0x40(%rsp), %rdi
pushq $0x10
popq %rdx
callq 0x32b0
leaq 0x40(%rsp), %rsi
movq %rbx, %rdi
callq 0x510c
leaq 0x40(%rsp), %rdi
callq 0x3360
leaq 0x40(%rsp), %rdi
callq 0x3380
leaq 0x10(%rsp), %rdi
callq 0xa00c
addq $0x248, %rsp            # imm = 0x248
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x5a4f
jmp 0x5a4f
jmp 0x5a4f
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0x95c0
jmp 0x5a5c
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0x3380
jmp 0x5a52
jmp 0x5a4f
jmp 0x5a4f
jmp 0x5a4f
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0xa00c
movq %rbx, %rdi
callq 0x3430