// File: /workspace/github_c_makefile_star2_O2/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 $0x48, %rsp
movq %rdx, 0x40(%rsp)
movl %esi, 0x34(%rsp)
movq %rdi, 0x38(%rsp)
movq 0xa8(%rsp), %r14
leaq (,%r14,4), %rdi
callq 0x1180
movq %rax, %rbx
testq %rax, %rax
jne 0x123ff
movq 0x17c13(%rip), %rax     # 0x29ff8
movq (%rax), %rcx
leaq 0xb7d7(%rip), %rdi      # 0x1dbc6
pushq $0x3b
popq %rsi
pushq $0x1
popq %rdx
callq 0x1210
jmp 0x12508
leaq 0x80(%rsp), %rax
movq (%rax), %rbp
movq 0x8(%rax), %rax
movl (%rbp), %ecx
xorl %edx, %edx
testl %ecx, %ecx
cmovlel %edx, %ecx
cmpq %rdx, %rcx
je 0x1243a
movq 0x10(%rbp), %rsi
movq (%rsi,%rdx,8), %rsi
andl $0x0, 0x1c(%rsi)
movq 0x10(%rax), %rsi
movq (%rsi,%rdx,8), %rsi
andl $0x0, 0x1c(%rsi)
incq %rdx
jmp 0x12418
xorl %eax, %eax
cmpq %rax, %r14
je 0x1244a
orl $-0x1, (%rbx,%rax,4)
incq %rax
jmp 0x1243c
leaq 0x80(%rsp), %rax
movq 0x20(%rax), %r15
movq 0x10(%rax), %r14
movq 0x18(%rax), %r12
addq $0x8, %r14
movl $0x0, 0x30(%rsp)
subq $0x1, %r15
jb 0x124ec
movq (%r14), %rax
cmpl $-0x1, (%rbx,%rax,4)
je 0x1247f
addq $0x10, %r14
jmp 0x1246a
movq -0x8(%r14), %rcx
movq (%r12,%rax,8), %rdx
movslq (%rdx,%rcx,4), %r13
movq 0x10(%rbp), %rdx
movq (%rdx,%r13,8), %rdx
movl 0x1c(%rdx), %esi
testl %esi, %esi
je 0x124a4
cmpl $0x1, %esi
jne 0x12479
movl %ecx, (%rbx,%rax,4)
jmp 0x12479
movq (%rdx), %rsi
movq 0x38(%rsp), %rdi
movl 0x34(%rsp), %edx
movq 0x40(%rsp), %rcx
callq 0x74f2
incl 0x30(%rsp)
leaq 0x80(%rsp), %rcx
movups (%rcx), %xmm0
movups 0x10(%rcx), %xmm1
movups 0x20(%rcx), %xmm2
movups %xmm2, 0x20(%rsp)
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
movsbl %al, %esi
movl %r13d, %edi
callq 0x120b2
jmp 0x12479
movq 0x17b05(%rip), %rax     # 0x29ff8
movq (%rax), %rdi
leaq 0xab39(%rip), %rsi      # 0x1d036
movl 0x30(%rsp), %edx
xorl %eax, %eax
callq 0x1150
movq %rbx, %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq