// File: /workspace/github_c_makefile_star2_O1/pwelke[P]GraphMiningTools/subtreeIsomorphismSampling.c
// Function: recursiveSubtreeIsomorphismSamplerWithMatching
static char recursiveSubtreeIsomorphismSamplerWithMatching(struct Vertex* parent, struct Graph* g, struct GraphPool* gp) {

	// base case: if parent is a leaf and its only neighbor is already assigned to a vertex in g, we are done
	if (isLeaf(parent) && parent->neighborhood->endPoint->visited) { return 1; }

	struct Vertex* parentImage = g->vertices[parent->visited - 1];
	struct Graph* B = makeBipartiteInstanceFromVertices(parent, parentImage, gp);
	int sizeOfMatching = bipartiteMatchingEvenMoreDirty(B);
	int nNeighbors = B->number;

	// is there a matching here covering all unmatched neighbors of parent?
	// if not, there is no subgraph iso here
	if (sizeOfMatching != nNeighbors) {
		dumpGraph(gp, B);
		return 0;
	}

	// mark all matched neighbors of currentImage as ->visited
	for (int i=0; i<nNeighbors; ++i) {
		// find match
		for (struct VertexList* e=B->vertices[i]->neighborhood; e!=NULL; e=e->next) {
			if (e->flag == 1) {
				// mark embedding vertex as mapped to current vertex
				((struct VertexList*)B->vertices[i]->label)->endPoint->visited = e->endPoint->lowPoint + 1;
				g->vertices[e->endPoint->lowPoint]->visited = 1;
				break;
			}
		}
	}

	// recurse to the matched vertices
	for (int i=0; i<nNeighbors; ++i) {
		for (struct VertexList* e=B->vertices[i]->neighborhood; e!=NULL; e=e->next) {
			if (e->flag == 1) {
				struct Vertex* newChild = ((struct VertexList*)e->startPoint->label)->endPoint;
				char embeddingWorked = recursiveSubtreeIsomorphismSamplerWithMatching(newChild, g, gp);
				if (embeddingWorked) {
					// we are done with this neighbor of parent
					break;
				} else {
					// there is no subtree iso here
					dumpGraph(gp, B);
					return 0;
				}
			}
		}
	}

	dumpGraph(gp, B);
	// so far, we have been successful
	return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdx, (%rsp)
movq %rsi, %rbx
movq %rdi, %r15
callq 0x7c33
testb %al, %al
je 0x1c4c2
movq 0x8(%r15), %rax
movq 0x18(%rax), %rax
movb $0x1, %bpl
cmpl $0x0, 0x1c(%rax)
jne 0x1c715
movq %rbx, 0x10(%rsp)
movq 0x10(%rbx), %rax
movslq 0x1c(%r15), %rcx
movq -0x8(%rax,%rcx,8), %r13
movq %r15, %rdi
callq 0x7c22
movl %eax, %ebp
movq %r15, %rdi
movl %eax, %esi
callq 0x1be64
movq %rax, %r12
movq %r13, %rdi
callq 0x7c22
movl %eax, %ebx
movq %r13, %rdi
movl %eax, %esi
callq 0x1be64
movq %rax, %r13
leal (%rbx,%rbp), %edi
movq (%rsp), %rsi
callq 0x8565
movq %rax, %r15
testl %ebp, %ebp
jle 0x1c54b
movl %ebp, %eax
xorl %ecx, %ecx
xorl %r14d, %r14d
movq (%r12,%rcx,8), %rdx
movq 0x18(%rdx), %rsi
cmpl $0x0, 0x1c(%rsi)
jne 0x1c541
movl 0x18(%rsi), %esi
movq 0x10(%r15), %rdi
movslq %r14d, %r14
movq (%rdi,%r14,8), %rdi
movl %esi, 0x20(%rdi)
movq %rdx, (%rdi)
incl %r14d
incq %rcx
cmpq %rcx, %rax
jne 0x1c51c
jmp 0x1c54e
xorl %r14d, %r14d
leal -0x1(%rbp), %eax
cmpl %eax, %r14d
jne 0x1c57c
movl %r14d, 0x8(%r15)
movslq (%r15), %rax
leaq -0x1(%rax), %rcx
movl %ecx, (%r15)
movq (%rsp), %rcx
movq 0x10(%rcx), %rdi
movq 0x10(%r15), %rcx
movq -0x8(%rcx,%rax,8), %rsi
callq 0x14628
jmp 0x1c583
movl %ebp, 0x8(%r15)
movl %ebp, %r14d
testl %ebx, %ebx
jle 0x1c5b5
movslq %r14d, %rax
movl %ebx, %ecx
shlq $0x3, %rax
addq 0x10(%r15), %rax
xorl %edx, %edx
movq (%r13,%rdx,8), %rsi
movq 0x18(%rsi), %rdi
movl 0x18(%rdi), %edi
movq (%rax,%rdx,8), %r8
movl %edi, 0x20(%r8)
movq %rsi, (%r8)
incq %rdx
cmpq %rdx, %rcx
jne 0x1c596
movq %r12, %rdi
callq 0x1030
movq %r13, %rdi
callq 0x1030
testl %r14d, %r14d
jle 0x1c659
movl %r14d, %eax
movq %rax, 0x8(%rsp)
xorl %r13d, %r13d
cmpl (%r15), %r14d
jge 0x1c64f
movq 0x10(%r15), %rax
movq (%rax,%r13,8), %rax
movq (%rax), %rbp
movq 0x8(%rsp), %r12
movq 0x10(%r15), %rax
movq (%rax,%r12,8), %rax
movq (%rax), %rbx
movq 0x18(%rbx), %rax
cmpl $0x0, 0x1c(%rax)
jne 0x1c647
movq (%rbp), %rdi
movq (%rbx), %rsi
callq 0x1bc18
testl %eax, %eax
jne 0x1c647
movq 0x18(%rbp), %rax
movq (%rax), %rdi
movq 0x18(%rbx), %rax
movq (%rax), %rsi
callq 0x1bc18
testl %eax, %eax
jne 0x1c647
movq 0x10(%r15), %rax
movq (%rax,%r13,8), %rdi
movq (%rax,%r12,8), %rsi
movq (%rsp), %rax
movq 0x18(%rax), %rdx
callq 0x344f
incl 0x4(%r15)
incq %r12
cmpl %r12d, (%r15)
jg 0x1c5ee
incq %r13
cmpq 0x8(%rsp), %r13
jne 0x1c5d9
movq %r15, %rdi
callq 0x373e
movl 0x8(%r15), %r14d
cmpl %r14d, %eax
jne 0x1c707
testl %r14d, %r14d
movq 0x10(%rsp), %r12
jle 0x1c6c1
movq 0x10(%r15), %rax
xorl %ecx, %ecx
movq (%rax,%rcx,8), %rdx
movq %rdx, %rsi
movq 0x8(%rsi), %rsi
testq %rsi, %rsi
je 0x1c6b9
cmpl $0x1, 0x24(%rsi)
jne 0x1c685
movq 0x18(%rsi), %rsi
movslq 0x20(%rsi), %rsi
leal 0x1(%rsi), %edi
movq (%rdx), %rdx
movq 0x18(%rdx), %rdx
movl %edi, 0x1c(%rdx)
movq 0x10(%r12), %rdx
movq (%rdx,%rsi,8), %rdx
movl $0x1, 0x1c(%rdx)
incq %rcx
cmpq %r14, %rcx
jne 0x1c67e
movb $0x1, %bpl
testl %r14d, %r14d
jle 0x1c709
xorl %ebx, %ebx
movq 0x10(%r15), %rax
movq (%rax,%rbx,8), %rax
movq 0x8(%rax), %rax
testq %rax, %rax
je 0x1c6fd
cmpl $0x1, 0x24(%rax)
jne 0x1c6d3
movq 0x10(%rax), %rax
movq (%rax), %rax
movq 0x18(%rax), %rdi
movq %r12, %rsi
movq (%rsp), %rdx
callq 0x1c48c
testb %al, %al
je 0x1c707
incq %rbx
cmpq %r14, %rbx
jne 0x1c6cb
jmp 0x1c709
xorl %ebp, %ebp
movq (%rsp), %rdi
movq %r15, %rsi
callq 0x14832
movl %ebp, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq