// File: datourat[P]IP-label-for-graph-reachability/Graph.cpp
// Function: Graph::layerSeparation()
void Graph::layerSeparation(){
	int i, k;
	int u,v;
	vector<int> indegreeRecord(vsize);
	uint16_t layer=1;
	int vectorsize, tmpsize;

	TopoOrder.resize(vsize);

	k=0;
	for(i=0; i<vsize; i++){
		indegreeRecord[i]=vl[i].indegree;
		if(indegreeRecord[i]==0){
			TopoOrder[k]=i;
			vl[i].topoID =k;
			vl[i].layer=layer;
			k++;
		}
	}


	bool flag=true;
	i=0;
	vectorsize=k;
	while(flag){
		flag=false;
		layer++;
		for(; i<vectorsize; i++){
			u=TopoOrder[i];
			tmpsize=graph[u].outList.size();
			for(int j=0; j<tmpsize; j++){
				v=graph[u].outList[j];
				indegreeRecord[v]--;
				if(indegreeRecord[v]==0){
					flag=true;
					TopoOrder[k]=v;
					vl[v].topoID=k;
					vl[v].layer=layer;
					k++;
				}
			}
		}
		vectorsize=k;
	}


	if(TopoOrder.size()!=vsize){
		cout << "Topology Order Computation Error" << endl;
		quit();
	}

}

// Assembly:
subq $0x98, %rsp
movq %rdi, 0x90(%rsp)
movq 0x90(%rsp), %rax
movq %rax, 0x28(%rsp)
movslq 0xc(%rax), %rax
movq %rax, 0x30(%rsp)
leaq 0x67(%rsp), %rdi
movq %rdi, 0x38(%rsp)
callq 0x12990
movq 0x30(%rsp), %rsi
movq 0x38(%rsp), %rdx
leaq 0x68(%rsp), %rdi
callq 0x129a0
jmp 0x7f3a
leaq 0x67(%rsp), %rdi
callq 0x12a20
movq 0x28(%rsp), %rax
movw $0x1, 0x52(%rsp)
movq %rax, %rdi
addq $0x60, %rdi
movslq 0xc(%rax), %rsi
callq 0x12a30
jmp 0x7f62
movl $0x0, 0x88(%rsp)
movl $0x0, 0x8c(%rsp)
movq 0x28(%rsp), %rcx
movl 0x8c(%rsp), %eax
cmpl 0xc(%rcx), %eax
jge 0x80b9
movq 0x28(%rsp), %rdi
addq $0x30, %rdi
movslq 0x8c(%rsp), %rsi
callq 0x11d40
movl 0x8(%rax), %eax
movl %eax, 0x24(%rsp)
movslq 0x8c(%rsp), %rsi
leaq 0x68(%rsp), %rdi
callq 0x12960
movl 0x24(%rsp), %ecx
movl %ecx, (%rax)
movslq 0x8c(%rsp), %rsi
leaq 0x68(%rsp), %rdi
callq 0x12960
cmpl $0x0, (%rax)
jne 0x80a1
movq 0x28(%rsp), %rdi
movl 0x8c(%rsp), %eax
movl %eax, 0x18(%rsp)
addq $0x60, %rdi
movslq 0x88(%rsp), %rsi
callq 0x12960
movl 0x18(%rsp), %ecx
movq 0x28(%rsp), %rdi
movl %ecx, (%rax)
movl 0x88(%rsp), %eax
movl %eax, 0x1c(%rsp)
addq $0x30, %rdi
movslq 0x8c(%rsp), %rsi
callq 0x11d40
movl 0x1c(%rsp), %ecx
movq 0x28(%rsp), %rdi
movl %ecx, 0x4(%rax)
movw 0x52(%rsp), %ax
movw %ax, 0x22(%rsp)
addq $0x30, %rdi
movslq 0x8c(%rsp), %rsi
callq 0x11d40
movw 0x22(%rsp), %cx
movw %cx, (%rax)
movl 0x88(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x88(%rsp)
jmp 0x80a1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x58(%rsp)
movl %eax, 0x54(%rsp)
leaq 0x67(%rsp), %rdi
callq 0x12a20
jmp 0x82eb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x58(%rsp)
movl %eax, 0x54(%rsp)
leaq 0x68(%rsp), %rdi
callq 0x115a0
jmp 0x82eb
jmp 0x80a3
movl 0x8c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x8c(%rsp)
jmp 0x7f78
movb $0x1, 0x47(%rsp)
movl $0x0, 0x8c(%rsp)
movl 0x88(%rsp), %eax
movl %eax, 0x4c(%rsp)
testb $0x1, 0x47(%rsp)
je 0x8289
movb $0x0, 0x47(%rsp)
movw 0x52(%rsp), %ax
addw $0x1, %ax
movw %ax, 0x52(%rsp)
movl 0x8c(%rsp), %eax
cmpl 0x4c(%rsp), %eax
jge 0x8279
movq 0x28(%rsp), %rdi
addq $0x60, %rdi
movslq 0x8c(%rsp), %rsi
callq 0x12960
movq 0x28(%rsp), %rdi
movl (%rax), %eax
movl %eax, 0x84(%rsp)
addq $0x48, %rdi
movslq 0x84(%rsp), %rsi
callq 0x11d60
movq %rax, %rdi
addq $0x18, %rdi
callq 0x4c10
movl %eax, 0x48(%rsp)
movl $0x0, 0x40(%rsp)
movl 0x40(%rsp), %eax
cmpl 0x48(%rsp), %eax
jge 0x8261
movq 0x28(%rsp), %rdi
addq $0x48, %rdi
movslq 0x84(%rsp), %rsi
callq 0x11d60
movq %rax, %rdi
addq $0x18, %rdi
movslq 0x40(%rsp), %rsi
callq 0x12960
movl (%rax), %eax
movl %eax, 0x80(%rsp)
movslq 0x80(%rsp), %rsi
leaq 0x68(%rsp), %rdi
callq 0x12960
movl (%rax), %ecx
addl $-0x1, %ecx
movl %ecx, (%rax)
movslq 0x80(%rsp), %rsi
leaq 0x68(%rsp), %rdi
callq 0x12960
cmpl $0x0, (%rax)
jne 0x824f
movq 0x28(%rsp), %rdi
movb $0x1, 0x47(%rsp)
movl 0x80(%rsp), %eax
movl %eax, 0xc(%rsp)
addq $0x60, %rdi
movslq 0x88(%rsp), %rsi
callq 0x12960
movl 0xc(%rsp), %ecx
movq 0x28(%rsp), %rdi
movl %ecx, (%rax)
movl 0x88(%rsp), %eax
movl %eax, 0x10(%rsp)
addq $0x30, %rdi
movslq 0x80(%rsp), %rsi
callq 0x11d40
movl 0x10(%rsp), %ecx
movq 0x28(%rsp), %rdi
movl %ecx, 0x4(%rax)
movw 0x52(%rsp), %ax
movw %ax, 0x16(%rsp)
addq $0x30, %rdi
movslq 0x80(%rsp), %rsi
callq 0x11d40
movw 0x16(%rsp), %cx
movw %cx, (%rax)
movl 0x88(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x88(%rsp)
jmp 0x8251
movl 0x40(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x40(%rsp)
jmp 0x8150
jmp 0x8263
movl 0x8c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x8c(%rsp)
jmp 0x80f2
movl 0x88(%rsp), %eax
movl %eax, 0x4c(%rsp)
jmp 0x80d4
movq 0x28(%rsp), %rdi
addq $0x60, %rdi
callq 0x4c10
movq 0x28(%rsp), %rcx
movslq 0xc(%rcx), %rcx
cmpq %rcx, %rax
je 0x82d9
movq 0x2cd2c(%rip), %rdi     # 0x34fd8
leaq 0x20195(%rip), %rsi     # 0x28448
callq 0x32c0
movq %rax, (%rsp)
jmp 0x82be
movq (%rsp), %rdi
movq 0x2ccff(%rip), %rsi     # 0x34fc8
callq 0x3300
jmp 0x82d0
callq 0x4da0
jmp 0x82d7
jmp 0x82d9
leaq 0x68(%rsp), %rdi
callq 0x115a0
addq $0x98, %rsp
retq
movq 0x58(%rsp), %rdi
callq 0x34e0
nopw %cs:(%rax,%rax)