// File: /workspace/github_cpp_makefile_star2_O2/datourat[P]IP-label-for-graph-reachability/Graph.cpp
// Function: Graph::ComputeLayerLabel()
void Graph::ComputeLayerLabel(){
	int i, k;
	int u,v;
	vector<int> indegreeRecord(vsize);
	uint16_t layer=1;
	int vectorsize, tmpsize;

	TopoOrder.resize(vsize);
	vector<uint16_t>(vsize).swap(layerdown);

	k=0;
	for(i=0; i<vsize; i++){
		indegreeRecord[i]=vl[i].indegree;
		if(indegreeRecord[i]==0){
			TopoOrder[k]=i;
			layerdown[i]=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){
					TopoOrder[k]=v;
					layerdown[v]=layer;
					k++;
				}
			}
		}

		if(vectorsize!=k){
			vectorsize=k;
			flag=true;
		}
	}

	uint16_t tmp;
	vector<uint16_t>(vsize).swap(layerup);
	for(int i=vsize-1; i>=0; i--){
		u=TopoOrder[i];
		tmp=0;
		for(vector<int>::iterator it=graph[u].outList.begin(); it!=graph[u].outList.end(); it++){
			if( layerup[*it] > tmp){
				tmp = layerup[*it];
			}
		}
		layerup[u]=tmp+1;
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdi, %rbx
movslq 0xc(%rdi), %rsi
leaq 0x30(%rsp), %rdi
leaq 0x10(%rsp), %rdx
callq 0x9a92
leaq 0x60(%rbx), %rdi
movslq 0xc(%rbx), %rsi
callq 0x9ae4
movslq 0xc(%rbx), %rsi
leaq 0x10(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0x9b16
leaq 0x10(%rsp), %rdi
movq 0x10(%rdi), %rax
movups 0xc0(%rbx), %xmm0
movq 0xd0(%rbx), %rcx
movq %rcx, 0x10(%rdi)
movaps (%rdi), %xmm1
movaps %xmm0, (%rdi)
movups %xmm1, 0xc0(%rbx)
movq %rax, 0xd0(%rbx)
callq 0xa59c
movq 0x30(%rsp), %rcx
movq 0x30(%rbx), %rdx
movq 0x60(%rbx), %rsi
movq 0xc0(%rbx), %rdi
addq $0x8, %rdx
xorl %r8d, %r8d
xorl %eax, %eax
movslq 0xc(%rbx), %r9
cmpq %r9, %r8
jge 0x5c88
movl (%rdx), %r9d
movl %r9d, (%rcx,%r8,4)
testl %r9d, %r9d
jne 0x5c7f
cltq
movl %r8d, (%rsi,%rax,4)
movw $0x1, (%rdi,%r8,2)
incl %eax
incq %r8
addq $0x10, %rdx
jmp 0x5c5b
movb $0x1, %dil
movw $0x1, %cx
xorl %edx, %edx
xorl %esi, %esi
testb $0x1, %dil
je 0x5d1e
incl %ecx
movq 0x48(%rbx), %rdi
movq 0x60(%rbx), %r8
movslq %esi, %rsi
movslq %eax, %r10
movl %eax, %r9d
cmpq %r10, %rsi
jge 0x5d0f
movslq (%r8,%rsi,4), %r11
imulq $0x30, %r11, %r14
movq 0x18(%rdi,%r14), %r11
movq 0x20(%rdi,%r14), %r14
subq %r11, %r14
shrq $0x2, %r14
movq 0x30(%rsp), %r15
movq 0xc0(%rbx), %r12
testl %r14d, %r14d
cmovlel %edx, %r14d
xorl %r13d, %r13d
cmpq %r13, %r14
je 0x5d0a
movl (%r11,%r13,4), %ebp
movslq %ebp, %rbp
decl (%r15,%rbp,4)
jne 0x5d05
movslq %r9d, %r9
movl %ebp, (%r8,%r9,4)
movw %cx, (%r12,%rbp,2)
incl %r9d
incq %r13
jmp 0x5ce4
incq %rsi
jmp 0x5cb0
cmpl %r9d, %eax
setne %dil
movl %r9d, %eax
jmp 0x5c93
movslq 0xc(%rbx), %rsi
leaq 0x10(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0x9b16
leaq 0x10(%rsp), %rdi
movq 0x10(%rdi), %rax
movups 0xd8(%rbx), %xmm0
movq 0xe8(%rbx), %rcx
movq %rcx, 0x10(%rdi)
movaps (%rdi), %xmm1
movaps %xmm0, (%rdi)
movups %xmm1, 0xd8(%rbx)
movq %rax, 0xe8(%rbx)
callq 0xa59c
movl 0xc(%rbx), %eax
movq 0x60(%rbx), %rcx
movq 0x48(%rbx), %rdx
movq 0xd8(%rbx), %rsi
testl %eax, %eax
jle 0x5dc2
decq %rax
movslq (%rcx,%rax,4), %rdi
imulq $0x30, %rdi, %r9
movq 0x18(%rdx,%r9), %r8
movq 0x20(%rdx,%r9), %r9
movq 0xd8(%rbx), %r10
xorl %r11d, %r11d
cmpq %r9, %r8
je 0x5db8
movslq (%r8), %r14
movzwl (%r10,%r14,2), %ebp
cmpw %r11w, %bp
cmovbel %r11d, %ebp
addq $0x4, %r8
movl %ebp, %r11d
jmp 0x5d9a
incl %r11d
movw %r11w, (%rsi,%rdi,2)
jmp 0x5d77
leaq 0x30(%rsp), %rdi
callq 0xa406
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x5ddf
jmp 0x5ddf
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0xa406
movq %rbx, %rdi
callq 0x3430