// File: datourat[P]IP-label-for-graph-reachability/Graph.cpp
// Function: Graph::reverseLayerSeparation()
void Graph::reverseLayerSeparation(){


	int i;
	int u,v;
	vector<int> degreezero;
	vector<int> degreezeroNext;
	vector<int> outdegreeRecord(vsize, 0);
	uint16_t layer=1;
	int vectorsize, tmpsize;

	for(i=0; i<vsize; i++){
		outdegreeRecord[i]=vl[i].outdegree;
		if(outdegreeRecord[i]==0){
			degreezero.push_back(i);
			vl[i].layer=layer;
		}
	}

	while(vectorsize=degreezero.size()){
//		output << layer << ":\t" << degreezero.size() << endl;

//		output << layer << "(" << degreezero.size() << ")\t:";

		layer++;
		for(i=0; i<vectorsize; i++){
			u=degreezero[i];
			tmpsize=graph[u].inList.size();
//			output << u << " ";
			for(int j=0;j<tmpsize;j++){
				v=graph[u].inList[j];
				outdegreeRecord[v]--;
				if(outdegreeRecord[v]==0){
					degreezeroNext.push_back(v);
					vl[v].layer=layer;
				}
			}
		}
//		output << endl;
		degreezero=degreezeroNext;
		degreezeroNext.clear();
	}
	
//	output.close();
//	output.close();

}

// Assembly:
subq $0xa8, %rsp
movq %rdi, 0xa0(%rsp)
movq 0xa0(%rsp), %rax
movq %rax, 0x8(%rsp)
leaq 0x78(%rsp), %rdi
callq 0x11160
leaq 0x60(%rsp), %rdi
callq 0x11160
movq 0x8(%rsp), %rax
movslq 0xc(%rax), %rax
movq %rax, 0x10(%rsp)
movl $0x0, 0x44(%rsp)
leaq 0x43(%rsp), %rdi
movq %rdi, 0x18(%rsp)
callq 0x12990
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rcx
leaq 0x48(%rsp), %rdi
leaq 0x44(%rsp), %rdx
callq 0x12bf0
jmp 0x89f0
leaq 0x43(%rsp), %rdi
callq 0x12a20
movw $0x1, 0x32(%rsp)
movl $0x0, 0x9c(%rsp)
movq 0x8(%rsp), %rcx
movl 0x9c(%rsp), %eax
cmpl 0xc(%rcx), %eax
jge 0x8afd
movq 0x8(%rsp), %rdi
addq $0x30, %rdi
movslq 0x9c(%rsp), %rsi
callq 0x11d40
movl 0xc(%rax), %eax
movl %eax, 0x4(%rsp)
movslq 0x9c(%rsp), %rsi
leaq 0x48(%rsp), %rdi
callq 0x12960
movl 0x4(%rsp), %ecx
movl %ecx, (%rax)
movslq 0x9c(%rsp), %rsi
leaq 0x48(%rsp), %rdi
callq 0x12960
cmpl $0x0, (%rax)
jne 0x8ae5
leaq 0x78(%rsp), %rdi
leaq 0x9c(%rsp), %rsi
callq 0x12660
jmp 0x8a81
movq 0x8(%rsp), %rdi
movw 0x32(%rsp), %ax
movw %ax, 0x2(%rsp)
addq $0x30, %rdi
movslq 0x9c(%rsp), %rsi
callq 0x11d40
movw 0x2(%rsp), %cx
movw %cx, (%rax)
jmp 0x8ae5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x38(%rsp)
movl %eax, 0x34(%rsp)
leaq 0x43(%rsp), %rdi
callq 0x12a20
jmp 0x8c99
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x38(%rsp)
movl %eax, 0x34(%rsp)
leaq 0x48(%rsp), %rdi
callq 0x115a0
jmp 0x8c99
jmp 0x8ae7
movl 0x9c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x9c(%rsp)
jmp 0x8a0c
jmp 0x8aff
leaq 0x78(%rsp), %rdi
callq 0x4c10
movl %eax, 0x2c(%rsp)
cmpl $0x0, %eax
je 0x8c73
movw 0x32(%rsp), %ax
addw $0x1, %ax
movw %ax, 0x32(%rsp)
movl $0x0, 0x9c(%rsp)
movl 0x9c(%rsp), %eax
cmpl 0x2c(%rsp), %eax
jge 0x8c53
movslq 0x9c(%rsp), %rsi
leaq 0x78(%rsp), %rdi
callq 0x12960
movq 0x8(%rsp), %rdi
movl (%rax), %eax
movl %eax, 0x98(%rsp)
addq $0x48, %rdi
movslq 0x98(%rsp), %rsi
callq 0x11d60
movq %rax, %rdi
callq 0x4c10
movl %eax, 0x28(%rsp)
movl $0x0, 0x24(%rsp)
movl 0x24(%rsp), %eax
cmpl 0x28(%rsp), %eax
jge 0x8c3b
movq 0x8(%rsp), %rdi
addq $0x48, %rdi
movslq 0x98(%rsp), %rsi
callq 0x11d60
movq %rax, %rdi
movslq 0x24(%rsp), %rsi
callq 0x12960
movl (%rax), %eax
movl %eax, 0x94(%rsp)
movslq 0x94(%rsp), %rsi
leaq 0x48(%rsp), %rdi
callq 0x12960
movl (%rax), %ecx
addl $-0x1, %ecx
movl %ecx, (%rax)
movslq 0x94(%rsp), %rsi
leaq 0x48(%rsp), %rdi
callq 0x12960
cmpl $0x0, (%rax)
jne 0x8c29
leaq 0x60(%rsp), %rdi
leaq 0x94(%rsp), %rsi
callq 0x12660
jmp 0x8c03
movq 0x8(%rsp), %rdi
movw 0x32(%rsp), %ax
movw %ax, (%rsp)
addq $0x30, %rdi
movslq 0x94(%rsp), %rsi
callq 0x11d40
movw (%rsp), %cx
movw %cx, (%rax)
jmp 0x8c2b
movl 0x24(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x24(%rsp)
jmp 0x8b85
jmp 0x8c3d
movl 0x9c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x9c(%rsp)
jmp 0x8b2f
leaq 0x78(%rsp), %rdi
leaq 0x60(%rsp), %rsi
callq 0x11fb0
jmp 0x8c64
leaq 0x60(%rsp), %rdi
callq 0x11be0
jmp 0x8aff
leaq 0x48(%rsp), %rdi
callq 0x115a0
leaq 0x60(%rsp), %rdi
callq 0x115a0
leaq 0x78(%rsp), %rdi
callq 0x115a0
addq $0xa8, %rsp
retq
leaq 0x60(%rsp), %rdi
callq 0x115a0
leaq 0x78(%rsp), %rdi
callq 0x115a0
movq 0x38(%rsp), %rdi
callq 0x34e0
nopw (%rax,%rax)