// File: /workspace/github_c_makefile_star2_O3/pwelke[P]GraphMiningTools/minhashing.c
// Function: fastMinHashForAbsImportantTrees
int* fastMinHashForAbsImportantTrees(struct Graph* g, struct EvaluationPlan p, int importance, struct GraphPool* gp) {
	int* sketch = malloc(p.sketchSize * sizeof(int));
	if (!sketch) {
		fprintf(stderr, "Could not allocate memory for sketch. This is a bad thing.\n");
		return NULL;
	}
	int nEvaluations = 0;

	cleanEvaluationPlan(p);

	for (size_t i=0; i<p.sketchSize; ++i) {
		sketch[i] = -1; // init sketch values to 'infty'
	}
	for (size_t i=0; i<p.orderLength; ++i) {
		struct PosPair current = p.order[i];
		int currentGraphNumber = p.shrunkPermutations[current.permutation][current.level];

		// check if we already found level min for the permutation
		if (sketch[current.permutation] != -1) {
			continue;
		}

		// check if we already evaluated the embedding operator for this pattern or found a subpattern that had no match
		if (p.poset->vertices[currentGraphNumber]->visited != 0) {
			// either the pattern with id currentGraphNumber was evaluated positively and we hence have found the
			// min value for the current permutation or we need to continue
			if (p.poset->vertices[currentGraphNumber]->visited == 1) {
				sketch[current.permutation] = current.level;
			}
			continue;
		}

		// evaluate the embedding operator
		struct Graph* currentGraph = (struct Graph*)(p.poset->vertices[currentGraphNumber]->label);
		char match = isImportantSubtreeAbsolute(g, currentGraph, importance, gp);
		++nEvaluations;

		updateEvaluationPlan(p, currentGraphNumber, match);
	}

	fprintf(stderr, "%i\n", nEvaluations);
	return sketch;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rdx, 0x50(%rsp)
movl %esi, 0x34(%rsp)
movq %rdi, 0x48(%rsp)
movq 0xb8(%rsp), %r15
leaq (,%r15,4), %r12
movq %r12, %rdi
callq 0x1190
movq %rax, %rbx
testq %rax, %rax
jne 0x156a4
callq 0x1e4c
jmp 0x15731
leaq 0x90(%rsp), %rax
movq (%rax), %r14
movslq (%r14), %rax
testq %rax, %rax
jle 0x156e7
leaq 0x90(%rsp), %rcx
movq 0x8(%rcx), %rdx
movq 0x10(%r14), %rcx
movq 0x10(%rdx), %rdx
xorl %esi, %esi
xorl %edi, %edi
movq (%rcx,%rdi,8), %r8
movl %esi, 0x1c(%r8)
movq (%rdx,%rdi,8), %r8
movl %esi, 0x1c(%r8)
incq %rdi
cmpq %rdi, %rax
jne 0x156cf
testq %r15, %r15
je 0x156fc
movq %rbx, %rdi
movl $0xff, %esi
movq %r12, %rdx
callq 0x10d0
leaq 0x90(%rsp), %rax
movq 0x20(%rax), %rbp
movl $0x0, 0x30(%rsp)
testq %rbp, %rbp
jne 0x15743
movq 0x178dc(%rip), %rax     # 0x2cff8
movq (%rax), %rdi
leaq 0xa910(%rip), %rsi      # 0x20036
movl 0x30(%rsp), %edx
xorl %eax, %eax
callq 0x1160
movq %rbx, %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x10(%rax), %r15
movq 0x18(%rax), %r13
movq (%rax), %rcx
movq %rcx, 0x38(%rsp)
movq 0x8(%rax), %rax
movq %rax, 0x40(%rsp)
addq $0x8, %r15
movl $0x0, 0x30(%rsp)
movq (%r15), %rax
cmpl $-0x1, (%rbx,%rax,4)
je 0x1577c
addq $0x10, %r15
decq %rbp
jne 0x15768
jmp 0x15715
movq -0x8(%r15), %rcx
movq (%r13,%rax,8), %rdx
movslq (%rdx,%rcx,4), %r12
movq 0x10(%r14), %rdx
movq (%rdx,%r12,8), %rdx
movl 0x1c(%rdx), %esi
testl %esi, %esi
je 0x157a2
cmpl $0x1, %esi
jne 0x15771
movl %ecx, (%rbx,%rax,4)
jmp 0x15771
movq (%rdx), %rsi
movq 0x48(%rsp), %rdi
movl 0x34(%rsp), %edx
movq 0x50(%rsp), %rcx
callq 0x98c6
incl 0x30(%rsp)
testb %al, %al
je 0x157f8
movq 0x40(%rsp), %rax
movq 0x10(%rax), %rax
movq (%rax,%r12,8), %rdi
leaq 0x90(%rsp), %rax
movups (%rax), %xmm0
movups 0x10(%rax), %xmm1
movups 0x20(%rax), %xmm2
movups %xmm2, 0x20(%rsp)
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
callq 0x15312
jmp 0x15771
movq 0x38(%rsp), %rax
movq 0x10(%rax), %rax
movq (%rax,%r12,8), %rdi
leaq 0x90(%rsp), %rax
movups (%rax), %xmm0
movups 0x10(%rax), %xmm1
movups 0x20(%rax), %xmm2
movups %xmm2, 0x20(%rsp)
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
callq 0x1537f
jmp 0x15771