// File: /workspace/github_cpp_makefile_star2_O1/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 0xc488
leaq 0x60(%rbx), %rdi
movslq 0xc(%rbx), %rsi
callq 0xc512
movslq 0xc(%rbx), %rsi
leaq 0x10(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0xc544
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 0x6dac
callq 0x3260
xorl %eax, %eax
cmpl $0x0, 0xc(%rbx)
movl $0x0, %ecx
jle 0x6e02
movq 0x30(%rsp), %rdx
movq 0x30(%rbx), %rsi
movq 0x60(%rbx), %rdi
movq 0xc0(%rbx), %r8
addq $0x8, %rsi
xorl %r9d, %r9d
xorl %ecx, %ecx
movl (%rsi), %r10d
movl %r10d, (%rdx,%r9,4)
testl %r10d, %r10d
jne 0x6df2
movslq %ecx, %rcx
movl %r9d, (%rdi,%rcx,4)
movw $0x1, (%r8,%r9,2)
incl %ecx
incq %r9
movslq 0xc(%rbx), %r10
addq $0x10, %rsi
cmpq %r10, %r9
jl 0x6dd6
movq 0x48(%rbx), %rdx
movq 0x60(%rbx), %rsi
movw $0x1, %di
incl %edi
cmpl %ecx, %eax
jge 0x6e82
movq 0x30(%rsp), %r9
cltq
movslq %ecx, %r10
movl %ecx, %r8d
movslq (%rsi,%rax,4), %r11
leaq (%r11,%r11,2), %r14
shlq $0x4, %r14
movq 0x18(%rdx,%r14), %r11
movq 0x20(%rdx,%r14), %r14
subq %r11, %r14
shrq $0x2, %r14
testl %r14d, %r14d
jle 0x6e78
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 0x6e70
movslq %r8d, %r8
movl %r13d, (%rsi,%r8,4)
movw %di, (%r15,%r13,2)
incl %r8d
incq %r12
cmpq %r12, %r14
jne 0x6e54
incq %rax
cmpq %r10, %rax
jne 0x6e21
jmp 0x6e85
movl %ecx, %r8d
cmpl %r8d, %ecx
movl %r8d, %ecx
jne 0x6e0e
movslq 0xc(%rbx), %rsi
leaq 0x10(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0xc544
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 0x6eda
callq 0x3260
movslq 0xc(%rbx), %rax
testq %rax, %rax
jle 0x6f49
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 0x6f32
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 0x6f11
incl %r8d
jmp 0x6f37
movw $0x1, %r8w
leaq -0x1(%rax), %r9
movw %r8w, (%rsi,%rdi,2)
cmpq $0x1, %rax
movq %r9, %rax
jg 0x6ef2
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x6f58
callq 0x3260
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x6f6b
jmp 0x6f6b
movq %rax, %rbx
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x6f7d
callq 0x3260
movq %rbx, %rdi
callq 0x3460
nop