// File: /workspace/github_cpp_makefile_star2_O3/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 0xc3d2
leaq 0x60(%rbx), %rdi
movslq 0xc(%rbx), %rsi
callq 0xc45e
movslq 0xc(%rbx), %rsi
leaq 0x10(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0xc490
movq 0x20(%rsp), %rax
movq 0xc0(%rbx), %rdi
movups 0xc8(%rbx), %xmm0
movaps 0x10(%rsp), %xmm1
movq %rdi, 0x10(%rsp)
movups %xmm0, 0x18(%rsp)
movups %xmm1, 0xc0(%rbx)
movq %rax, 0xd0(%rbx)
testq %rdi, %rdi
je 0x6d82
callq 0x3260
xorl %edi, %edi
cmpl $0x0, 0xc(%rbx)
movl $0x0, %eax
jle 0x6dd7
movq 0x30(%rsp), %rcx
movq 0x30(%rbx), %rdx
movq 0x60(%rbx), %rsi
movq 0xc0(%rbx), %r8
addq $0x8, %rdx
xorl %r9d, %r9d
xorl %eax, %eax
movl (%rdx), %r10d
movl %r10d, (%rcx,%r9,4)
testl %r10d, %r10d
jne 0x6dc7
cltq
movl %r9d, (%rsi,%rax,4)
movw $0x1, (%r8,%r9,2)
incl %eax
incq %r9
movslq 0xc(%rbx), %r10
addq $0x10, %rdx
cmpq %r10, %r9
jl 0x6dac
movq 0x48(%rbx), %rcx
movq 0x60(%rbx), %rdx
movw $0x1, %si
incl %esi
cmpl %eax, %edi
jge 0x6e5a
movq 0x30(%rsp), %r9
movslq %edi, %rdi
movslq %eax, %r10
movl %eax, %r8d
movslq (%rdx,%rdi,4), %r11
leaq (%r11,%r11,2), %r14
shlq $0x4, %r14
movq 0x18(%rcx,%r14), %r11
movq 0x20(%rcx,%r14), %r14
subq %r11, %r14
shrq $0x2, %r14
testl %r14d, %r14d
jle 0x6e4e
movq 0xc0(%rbx), %r15
andl $0x7fffffff, %r14d      # imm = 0x7FFFFFFF
xorl %r12d, %r12d
movl (%r11,%r12,4), %ebp
movslq %ebp, %r13
decl (%r9,%r13,4)
jne 0x6e46
movslq %r8d, %r8
movl %r13d, (%rdx,%r8,4)
movw %si, (%r15,%r13,2)
incl %r8d
incq %r12
cmpq %r12, %r14
jne 0x6e2a
incq %rdi
cmpq %r10, %rdi
jne 0x6df7
movl %eax, %edi
jmp 0x6e5d
movl %eax, %r8d
cmpl %r8d, %eax
movl %r8d, %eax
jne 0x6de3
movslq 0xc(%rbx), %rsi
leaq 0x10(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0xc490
movq 0x20(%rsp), %rax
movq 0xd8(%rbx), %rdi
movups 0xe0(%rbx), %xmm0
movaps 0x10(%rsp), %xmm1
movq %rdi, 0x10(%rsp)
movups %xmm0, 0x18(%rsp)
movups %xmm1, 0xd8(%rbx)
movq %rax, 0xe8(%rbx)
testq %rdi, %rdi
je 0x6eb6
callq 0x3260
movslq 0xc(%rbx), %rax
testq %rax, %rax
jle 0x6f25
movq 0x48(%rbx), %rcx
movq 0x60(%rbx), %rdx
movq 0xd8(%rbx), %rsi
movslq -0x4(%rdx,%rax,4), %rdi
leaq (%rdi,%rdi,2), %r8
shlq $0x4, %r8
movq 0x18(%rcx,%r8), %r9
movq 0x20(%rcx,%r8), %r10
cmpq %r10, %r9
je 0x6f0e
xorl %r8d, %r8d
movslq (%r9), %r11
movzwl (%rsi,%r11,2), %r11d
cmpw %r8w, %r11w
cmovbel %r8d, %r11d
movl %r11d, %r8d
addq $0x4, %r9
cmpq %r10, %r9
jne 0x6eed
incl %r8d
jmp 0x6f13
movw $0x1, %r8w
leaq -0x1(%rax), %r9
movw %r8w, (%rsi,%rdi,2)
cmpq $0x1, %rax
movq %r9, %rax
jg 0x6ece
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x6f34
callq 0x3260
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x6f47
jmp 0x6f47
movq %rax, %rbx
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x6f59
callq 0x3260
movq %rbx, %rdi
callq 0x3460
nop