// File: /workspace/github_c_makefile_star2_O0/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:
subq $0x68, %rsp
movq %rdi, 0x60(%rsp)
movl %esi, 0x5c(%rsp)
movq %rdx, 0x50(%rsp)
movq %rcx, 0x48(%rsp)
movq %r8, 0x40(%rsp)
movslq 0x5c(%rsp), %rdi
shlq $0x2, %rdi
callq 0x1170
movq %rax, 0x38(%rsp)
movslq 0x5c(%rsp), %rdi
shlq $0x3, %rdi
callq 0x1170
movq %rax, 0x30(%rsp)
movl $0x0, 0x2c(%rsp)
movl 0x2c(%rsp), %eax
cmpl 0x5c(%rsp), %eax
jge 0x15bc4
movq 0x38(%rsp), %rax
movslq 0x2c(%rsp), %rcx
movl $0xffffffff, (%rax,%rcx,4) # imm = 0xFFFFFFFF
movq 0x30(%rsp), %rax
movslq 0x2c(%rsp), %rcx
movq $0x1, (%rax,%rcx,8)
movl 0x2c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x2c(%rsp)
jmp 0x15b8a
movl $0x0, 0x28(%rsp)
movq 0x60(%rsp), %rax
movq %rax, 0x20(%rsp)
cmpq $0x0, 0x20(%rsp)
je 0x15d73
movq 0x20(%rsp), %rax
cmpl $0x1, 0x10(%rax)
jg 0x15bf2
jmp 0x15d60
movq 0x20(%rsp), %rdi
movq 0x48(%rsp), %rsi
callq 0xb1e0
movq %rax, 0x18(%rsp)
movq 0x18(%rsp), %rdi
movq 0x50(%rsp), %rsi
movq 0x40(%rsp), %rdx
movq 0x48(%rsp), %rcx
callq 0x136a0
movq %rax, 0x10(%rsp)
movq 0x48(%rsp), %rdi
movq 0x18(%rsp), %rsi
callq 0x1fb30
movq 0x20(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x8(%rsp)
cmpq $0x0, 0x8(%rsp)
je 0x15d55
movq 0x38(%rsp), %rax
movq 0x8(%rsp), %rcx
movq 0x10(%rcx), %rcx
movslq 0x18(%rcx), %rcx
movl (%rax,%rcx,4), %eax
cmpl 0x28(%rsp), %eax
jge 0x15cc6
movl 0x28(%rsp), %edx
movq 0x38(%rsp), %rax
movq 0x8(%rsp), %rcx
movq 0x10(%rcx), %rcx
movslq 0x18(%rcx), %rcx
movl %edx, (%rax,%rcx,4)
cmpq $-0x1, 0x10(%rsp)
je 0x15caa
movq 0x10(%rsp), %rdx
movq 0x30(%rsp), %rax
movq 0x8(%rsp), %rcx
movq 0x10(%rcx), %rcx
movslq 0x18(%rcx), %rcx
imulq (%rax,%rcx,8), %rdx
movq %rdx, (%rax,%rcx,8)
jmp 0x15cc4
movq 0x30(%rsp), %rax
movq 0x8(%rsp), %rcx
movq 0x10(%rcx), %rcx
movslq 0x18(%rcx), %rcx
movq $0x0, (%rax,%rcx,8)
jmp 0x15cc6
movq 0x38(%rsp), %rax
movq 0x8(%rsp), %rcx
movq 0x18(%rcx), %rcx
movslq 0x18(%rcx), %rcx
movl (%rax,%rcx,4), %eax
cmpl 0x28(%rsp), %eax
jge 0x15d40
movl 0x28(%rsp), %edx
movq 0x38(%rsp), %rax
movq 0x8(%rsp), %rcx
movq 0x18(%rcx), %rcx
movslq 0x18(%rcx), %rcx
movl %edx, (%rax,%rcx,4)
cmpq $-0x1, 0x10(%rsp)
je 0x15d24
movq 0x10(%rsp), %rdx
movq 0x30(%rsp), %rax
movq 0x8(%rsp), %rcx
movq 0x18(%rcx), %rcx
movslq 0x18(%rcx), %rcx
imulq (%rax,%rcx,8), %rdx
movq %rdx, (%rax,%rcx,8)
jmp 0x15d3e
movq 0x30(%rsp), %rax
movq 0x8(%rsp), %rcx
movq 0x18(%rcx), %rcx
movslq 0x18(%rcx), %rcx
movq $0x0, (%rax,%rcx,8)
jmp 0x15d40
jmp 0x15d42
movq 0x8(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x8(%rsp)
jmp 0x15c40
movl 0x28(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x28(%rsp)
movq 0x20(%rsp), %rax
movq 0x18(%rax), %rax
movq %rax, 0x20(%rsp)
jmp 0x15bd6
movq 0x38(%rsp), %rdi
callq 0x1030
movq 0x30(%rsp), %rax
addq $0x68, %rsp
retq
nopw (%rax,%rax)