// File: /workspace/github_c_makefile_star2_O3/pwelke[P]GraphMiningTools/minhashing.c
// Function: fullEmbeddingProjectionApproximationLocalEasy
int* fullEmbeddingProjectionApproximationLocalEasy(struct Graph* g, struct EvaluationPlan p, int* projection, int projectionSize, int nLocalTrees, struct GraphPool* gp, struct ShallowGraphPool* sgp) {

	int nEvaluations = 0;
	cleanEvaluationPlan(p);

	struct BlockTree blockTree = getBlockTreeT(g, sgp);
	struct SpanningtreeTree sptTree = getSampledSpanningtreeTree(blockTree, nLocalTrees, 1, gp, sgp);

	for (int i=0; i<projectionSize; ++i) {
		// if we don't know the value we need to compute it.
		int currentGraphNumber = projection[i];
		if (!embeddingValueKnown(p.poset->vertices[currentGraphNumber])) {
			// evaluate the embedding operator
			struct Graph* pattern = (struct Graph*)(p.poset->vertices[currentGraphNumber]->label);
			char match = subtreeCheckForSpanningtreeTree(&sptTree, pattern, gp);
			wipeCharacteristicsForLocalEasy(sptTree);
			++nEvaluations;
			updateEvaluationPlan(p, currentGraphNumber, match);
		}
	}

	dumpSpanningtreeTree(sptTree, gp);

	int* approximateEmbedding = malloc((p.poset->n - 1) * sizeof(int));
	if (!approximateEmbedding) {
		fprintf(stderr, "Could not allocate memory for sketch. This is a bad thing.\n");
		return NULL;
	}

	for (int i=1; i<p.poset->n; ++i) {
		approximateEmbedding[i-1] = p.poset->vertices[i]->visited; // init sketch values to 'infty'
	}

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

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movq %r9, %r13
movq %r8, 0x40(%rsp)
movl %ecx, %r14d
movl %edx, %ebx
movq %rsi, %r15
movq %rdi, %rsi
leaq 0xf0(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x38(%rsp)
movslq (%rax), %rax
testq %rax, %rax
jle 0x15be4
leaq 0xf0(%rsp), %rcx
movq 0x8(%rcx), %rdx
movq 0x38(%rsp), %rcx
movq 0x10(%rcx), %rcx
movq 0x10(%rdx), %rdx
xorl %edi, %edi
xorl %r8d, %r8d
movq (%rcx,%r8,8), %r9
movl %edi, 0x1c(%r9)
movq (%rdx,%r8,8), %r9
movl %edi, 0x1c(%r9)
incq %r8
cmpq %r8, %rax
jne 0x15bcc
leaq 0x90(%rsp), %rbp
movq %rbp, %rdi
movq %r13, %rdx
callq 0xe7b8
movq 0x20(%rbp), %rax
movq %rax, 0x20(%rsp)
movups (%rbp), %xmm0
movups 0x10(%rbp), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
leaq 0x58(%rsp), %rdi
movl %r14d, %esi
movl $0x1, %edx
movq 0x40(%rsp), %rcx
movq %r13, %r8
callq 0xefc8
xorl %ebp, %ebp
testl %ebx, %ebx
movq 0x38(%rsp), %r13
jle 0x15d35
movl %ebx, %r14d
leaq 0xf0(%rsp), %rax
movq (%rax), %rcx
movq %rcx, 0x48(%rsp)
movq 0x8(%rax), %rax
movq %rax, 0x50(%rsp)
xorl %r12d, %r12d
xorl %ebp, %ebp
movslq (%r15,%r12,4), %rbx
movq 0x10(%r13), %rax
movq (%rax,%rbx,8), %rax
cmpl $0x0, 0x1c(%rax)
jne 0x15d29
movq (%rax), %rsi
leaq 0x58(%rsp), %rdi
movq 0x40(%rsp), %rdx
callq 0xfa92
movl %eax, %r13d
movq 0x88(%rsp), %rax
movq %rax, 0x30(%rsp)
movups 0x58(%rsp), %xmm0
movups 0x68(%rsp), %xmm1
movups 0x78(%rsp), %xmm2
movups %xmm2, 0x20(%rsp)
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
callq 0xf3f1
incl %ebp
testb %r13b, %r13b
je 0x15cf1
movq 0x50(%rsp), %rax
movq 0x10(%rax), %rax
movq (%rax,%rbx,8), %rdi
leaq 0xf0(%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 0x15d24
movq 0x48(%rsp), %rax
movq 0x10(%rax), %rax
movq (%rax,%rbx,8), %rdi
leaq 0xf0(%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
movq 0x38(%rsp), %r13
incq %r12
cmpq %r12, %r14
jne 0x15c5b
movq 0x88(%rsp), %rax
movq %rax, 0x30(%rsp)
movups 0x58(%rsp), %xmm0
movups 0x68(%rsp), %xmm1
movups 0x78(%rsp), %xmm2
movups %xmm2, 0x20(%rsp)
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
movq 0x40(%rsp), %rdi
callq 0xf470
movslq (%r13), %r15
leaq -0x4(,%r15,4), %rdi
callq 0x1190
movq %rax, %r14
testq %rax, %rax
jne 0x15d89
callq 0x1f21
jmp 0x15d99
movq %r14, %rdi
movl %r15d, %esi
movq %r13, %rdx
movl %ebp, %ecx
callq 0x1edf
movq %r14, %rax
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq