// File: /workspace/github_c_makefile_star2_O3/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 0x7c5f
testb %al, %al
je 0x1c37a
movq 0x8(%r15), %rax
movq 0x18(%rax), %rcx
movb $0x1, %al
cmpl $0x0, 0x1c(%rcx)
jne 0x1c5e6
movq %rbx, 0x10(%rsp)
movq 0x10(%rbx), %rax
movslq 0x1c(%r15), %rcx
movq -0x8(%rax,%rcx,8), %r13
movq %r15, %rdi
callq 0x7c4e
movl %eax, %ebp
movq %r15, %rdi
movl %eax, %esi
callq 0x1bd78
movq %rax, %r12
movq %r13, %rdi
callq 0x7c4e
movl %eax, %ebx
movq %r13, %rdi
movl %eax, %esi
callq 0x1bd78
movq %rax, %r13
leal (%rbx,%rbp), %edi
movq (%rsp), %rsi
callq 0x85e3
movq %rax, %r15
testl %ebp, %ebp
jle 0x1c403
movl %ebp, %eax
xorl %ecx, %ecx
xorl %r14d, %r14d
movq (%r12,%rcx,8), %rdx
movq 0x18(%rdx), %rsi
cmpl $0x0, 0x1c(%rsi)
jne 0x1c3f9
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 0x1c3d4
jmp 0x1c406
xorl %r14d, %r14d
leal -0x1(%rbp), %eax
cmpl %eax, %r14d
jne 0x1c434
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 0x144f0
jmp 0x1c43b
movl %ebp, 0x8(%r15)
movl %ebp, %r14d
testl %ebx, %ebx
jle 0x1c46d
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 0x1c44e
movq %r12, %rdi
callq 0x1030
movq %r13, %rdi
callq 0x1030
testl %r14d, %r14d
jle 0x1c51b
movl %r14d, %eax
movq %rax, 0x8(%rsp)
movl (%r15), %eax
xorl %r13d, %r13d
cmpl %eax, %r14d
jge 0x1c50d
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 0x1c502
movq (%rbp), %rdi
movq (%rbx), %rsi
callq 0x1bb34
testl %eax, %eax
jne 0x1c502
movq 0x18(%rbp), %rax
movq (%rax), %rdi
movq 0x18(%rbx), %rax
movq (%rax), %rsi
callq 0x1bb34
testl %eax, %eax
jne 0x1c502
movq 0x10(%r15), %rax
movq (%rax,%r13,8), %rdi
movq (%rax,%r12,8), %rsi
movq (%rsp), %rax
movq 0x18(%rax), %rdx
callq 0x3468
incl 0x4(%r15)
incq %r12
movl (%r15), %eax
cmpl %r12d, %eax
jg 0x1c4a9
incq %r13
cmpq 0x8(%rsp), %r13
jne 0x1c494
movq %r15, %rdi
callq 0x3762
cmpl 0x8(%r15), %eax
jne 0x1c5d8
testl %eax, %eax
movq 0x10(%rsp), %r12
jle 0x1c5c8
movq 0x10(%r15), %rcx
movl %eax, %r14d
xorl %edx, %edx
movq (%rcx,%rdx,8), %rsi
movq %rsi, %rdi
movq 0x8(%rdi), %rdi
testq %rdi, %rdi
je 0x1c580
cmpl $0x1, 0x24(%rdi)
jne 0x1c54a
movq 0x18(%rdi), %rdi
movslq 0x20(%rdi), %rdi
leal 0x1(%rdi), %r8d
movq (%rsi), %rsi
movq 0x18(%rsi), %rsi
movl %r8d, 0x1c(%rsi)
movq 0x10(%r12), %rsi
movq (%rsi,%rdi,8), %rsi
movl $0x1, 0x1c(%rsi)
incq %rdx
cmpq %r14, %rdx
jne 0x1c543
testl %eax, %eax
jle 0x1c5c8
xorl %ebx, %ebx
movq 0x10(%r15), %rax
movq (%rax,%rbx,8), %rax
movq 0x8(%rax), %rax
testq %rax, %rax
je 0x1c5c0
cmpl $0x1, 0x24(%rax)
jne 0x1c596
movq 0x10(%rax), %rax
movq (%rax), %rax
movq 0x18(%rax), %rdi
movq %r12, %rsi
movq (%rsp), %rdx
callq 0x1c345
testb %al, %al
je 0x1c5d8
incq %rbx
cmpq %r14, %rbx
jne 0x1c58e
movq (%rsp), %rdi
movq %r15, %rsi
callq 0x14700
movb $0x1, %al
jmp 0x1c5e6
movq (%rsp), %rdi
movq %r15, %rsi
callq 0x14700
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq