// File: /workspace/github_c_makefile_star2_O0/pwelke[P]GraphMiningTools/minhashing.c
// Function: fastMinHashForTrees
int* fastMinHashForTrees(struct Graph* g, struct EvaluationPlan p, 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 = isSubtree(g, currentGraph, gp);
		++nEvaluations;

		updateEvaluationPlan(p, currentGraphNumber, match);
	}

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

// Assembly:
subq $0x98, %rsp
leaq 0xa0(%rsp), %rax
movq %rax, 0x30(%rsp)
movq %rdi, 0x88(%rsp)
movq %rsi, 0x80(%rsp)
movq 0x28(%rax), %rdi
shlq $0x2, %rdi
callq 0x1170
movq %rax, 0x78(%rsp)
cmpq $0x0, 0x78(%rsp)
jne 0x21457
movq 0x1cbc3(%rip), %rax     # 0x3dff8
movq (%rax), %rdi
leaq 0x147d5(%rip), %rsi     # 0x35c14
movb $0x0, %al
callq 0x1140
movq $0x0, 0x90(%rsp)
jmp 0x21629
movq 0x30(%rsp), %rax
movl $0x0, 0x74(%rsp)
movups (%rax), %xmm0
movups 0x10(%rax), %xmm1
movups 0x20(%rax), %xmm2
movq %rsp, %rax
movups %xmm2, 0x20(%rax)
movups %xmm1, 0x10(%rax)
movups %xmm0, (%rax)
callq 0x21020
movq $0x0, 0x68(%rsp)
movq 0x30(%rsp), %rcx
movq 0x68(%rsp), %rax
cmpq 0x28(%rcx), %rax
jae 0x214bc
movq 0x78(%rsp), %rax
movq 0x68(%rsp), %rcx
movl $0xffffffff, (%rax,%rcx,4) # imm = 0xFFFFFFFF
movq 0x68(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x68(%rsp)
jmp 0x2148b
movq $0x0, 0x60(%rsp)
movq 0x30(%rsp), %rcx
movq 0x60(%rsp), %rax
cmpq 0x20(%rcx), %rax
jae 0x21600
movq 0x30(%rsp), %rax
movq 0x10(%rax), %rcx
movq 0x60(%rsp), %rdx
shlq $0x4, %rdx
addq %rdx, %rcx
movq (%rcx), %rdx
movq %rdx, 0x50(%rsp)
movq 0x8(%rcx), %rcx
movq %rcx, 0x58(%rsp)
movq 0x18(%rax), %rax
movq 0x58(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movq 0x50(%rsp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, 0x4c(%rsp)
movq 0x78(%rsp), %rax
movq 0x58(%rsp), %rcx
cmpl $-0x1, (%rax,%rcx,4)
je 0x2152d
jmp 0x215ed
movq 0x30(%rsp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rax
movslq 0x4c(%rsp), %rcx
movq (%rax,%rcx,8), %rax
cmpl $0x0, 0x1c(%rax)
je 0x21579
movq 0x30(%rsp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rax
movslq 0x4c(%rsp), %rcx
movq (%rax,%rcx,8), %rax
cmpl $0x1, 0x1c(%rax)
jne 0x21577
movq 0x50(%rsp), %rax
movl %eax, %edx
movq 0x78(%rsp), %rax
movq 0x58(%rsp), %rcx
movl %edx, (%rax,%rcx,4)
jmp 0x215ed
movq 0x30(%rsp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rax
movslq 0x4c(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movq (%rax), %rax
movq %rax, 0x40(%rsp)
movq 0x88(%rsp), %rdi
movq 0x40(%rsp), %rsi
movq 0x80(%rsp), %rdx
callq 0xfbd0
movq 0x30(%rsp), %rcx
movb %al, 0x3f(%rsp)
movl 0x74(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x74(%rsp)
movl 0x4c(%rsp), %edi
movb 0x3f(%rsp), %al
movups (%rcx), %xmm0
movups 0x10(%rcx), %xmm1
movups 0x20(%rcx), %xmm2
movq %rsp, %rcx
movups %xmm2, 0x20(%rcx)
movups %xmm1, 0x10(%rcx)
movups %xmm0, (%rcx)
movsbl %al, %esi
callq 0x210d0
movq 0x60(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x60(%rsp)
jmp 0x214c5
movq 0x1c9f1(%rip), %rax     # 0x3dff8
movq (%rax), %rdi
movl 0x74(%rsp), %edx
leaq 0x13a21(%rip), %rsi     # 0x35036
movb $0x0, %al
callq 0x1140
movq 0x78(%rsp), %rax
movq %rax, 0x90(%rsp)
movq 0x90(%rsp), %rax
addq $0x98, %rsp
retq
nopl (%rax)