// File: /workspace/github_c_makefile_star2_O1/pwelke[P]GraphMiningTools/localEasiness.c
// Function: computeLocalEasinessExactly
long int* computeLocalEasinessExactly(struct ShallowGraph* biconnectedComponents, int n, long int maxBound, struct GraphPool* gp, struct ShallowGraphPool* sgp) {

	/* store for each vertex if the current bic.comp was already counted */
	int* occurrences = malloc(n * sizeof(int));
	/* store the cycle degrees of each vertex in g */
	long int* easiness = malloc(n * sizeof(long int));

	for (int v=0; v<n; ++v) {
		occurrences[v] = -1;
		easiness[v] = 1;
	}

	int compNumber = 0;
	for (struct ShallowGraph* comp = biconnectedComponents; comp!=NULL; comp=comp->next) {
		// if component is a bridge or singleton (I guess the latter cannot happen), then we do not need to process
		// spanning trees, as there is only one. This would not change the easiness of the contained vertices.
		if (comp->m <= 1) {
			continue;
		}

		// count spanning trees in component. This breaks and returns -1 if there are more than maxBound
		struct Graph* component = shallowGraphToGraph(comp, gp);
		long int nSpanningTrees = countSpanningTrees(component, maxBound, sgp, gp);
		dumpGraph(gp, component);

		for (struct VertexList* e=comp->edges; e!=NULL; e=e->next) {
			if (occurrences[e->startPoint->number] < compNumber) {
				occurrences[e->startPoint->number] = compNumber;
				if (nSpanningTrees != -1) {
					easiness[e->startPoint->number] *= nSpanningTrees;
				} else {
					easiness[e->startPoint->number] = 0;
				}
			}
			if (occurrences[e->endPoint->number] < compNumber) {
				occurrences[e->endPoint->number] = compNumber;
				if (nSpanningTrees != -1) {
					easiness[e->endPoint->number] *= nSpanningTrees;
				} else {
					easiness[e->endPoint->number] = 0;
				}
			}
		}
		++compNumber;
	}

	free(occurrences);
	return easiness;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %r8, 0x18(%rsp)
movq %rcx, 0x10(%rsp)
movq %rdx, 0x8(%rsp)
movl %esi, %ebx
movq %rdi, %r15
movslq %esi, %r14
leaq (,%r14,4), %rdi
callq 0x1190
movq %rax, %r13
leaq (,%r14,8), %rdi
callq 0x1190
movq %rax, %rbp
testl %r14d, %r14d
jle 0xe637
movl %ebx, %r14d
leaq (,%r14,4), %rdx
movq %r13, %rdi
movl $0xff, %esi
callq 0x10d0
incl %ebx
decq %r14
movq %r14, %xmm0
pshufd $0x44, %xmm0, %xmm0     # xmm0 = xmm0[0,1,0,1]
shrl %ebx
shlq $0x4, %rbx
movdqa 0x12251(%rip), %xmm1    # 0x20810
xorl %eax, %eax
movdqa 0x12257(%rip), %xmm2    # 0x20820
pxor %xmm2, %xmm0
pcmpeqd %xmm3, %xmm3
movdqa 0x12257(%rip), %xmm4    # 0x20830
movdqa %xmm1, %xmm5
pxor %xmm2, %xmm5
movdqa %xmm5, %xmm6
pcmpgtd %xmm0, %xmm6
pcmpeqd %xmm0, %xmm5
pshufd $0xf5, %xmm5, %xmm7     # xmm7 = xmm5[1,1,3,3]
pand %xmm6, %xmm7
pshufd $0xf5, %xmm6, %xmm5     # xmm5 = xmm6[1,1,3,3]
por %xmm7, %xmm5
movd %xmm5, %ecx
notl %ecx
testb $0x1, %cl
je 0xe613
movq $0x1, (%rbp,%rax)
pxor %xmm3, %xmm5
pextrw $0x4, %xmm5, %ecx
testb $0x1, %cl
je 0xe62a
movq $0x1, 0x8(%rbp,%rax)
paddq %xmm4, %xmm1
addq $0x10, %rax
cmpq %rax, %rbx
jne 0xe5d9
testq %r15, %r15
je 0xe704
xorl %r14d, %r14d
movq 0x10(%rsp), %r12
cmpl $0x2, 0x10(%r15)
jl 0xe6f7
movq %r15, %rdi
movq %r12, %rsi
callq 0x81e0
movq %r15, 0x20(%rsp)
movq %rax, %r15
movq %rax, %rdi
movq 0x8(%rsp), %rsi
movq 0x18(%rsp), %rdx
movq %r12, %rcx
callq 0xcd86
movq %rax, %rbx
movq %r12, %rdi
movq %r15, %rsi
movq 0x20(%rsp), %r15
callq 0x14832
movq (%r15), %rax
testq %rax, %rax
je 0xe6f4
movq 0x10(%rax), %rcx
movslq 0x18(%rcx), %rcx
cmpl %r14d, (%r13,%rcx,4)
jge 0xe6c2
movl %r14d, (%r13,%rcx,4)
cmpq $-0x1, %rbx
je 0xe6bb
movq (%rbp,%rcx,8), %rdx
imulq %rbx, %rdx
jmp 0xe6bd
xorl %edx, %edx
movq %rdx, (%rbp,%rcx,8)
movq 0x18(%rax), %rcx
movslq 0x18(%rcx), %rcx
cmpl %r14d, (%r13,%rcx,4)
jge 0xe6ee
movl %r14d, (%r13,%rcx,4)
cmpq $-0x1, %rbx
je 0xe6e7
movq (%rbp,%rcx,8), %rdx
imulq %rbx, %rdx
jmp 0xe6e9
xorl %edx, %edx
movq %rdx, (%rbp,%rcx,8)
movq 0x8(%rax), %rax
jmp 0xe691
incl %r14d
movq 0x18(%r15), %r15
testq %r15, %r15
jne 0xe648
movq %r13, %rdi
callq 0x1030
movq %rbp, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq