// File: /workspace/github_c_makefile_star2_O1/pwelke[P]GraphMiningTools/treeKernels.c
// Function: recSubtreeEnum
void recSubtreeEnum(struct Graph* current, struct ShallowGraph* forbiddenEdges, struct ShallowGraph* allEdges, int* number, struct ShallowGraphPool* sgp) {
	struct VertexList* e;
	struct VertexList* startOfForbidden = forbiddenEdges->edges;

	for (e=allEdges->edges; e; e=e->next) {

		/* check if e is in forbiddenEdges */
		struct VertexList* idx;
		char allowed = 1;
		for (idx=forbiddenEdges->edges; idx; idx=idx->next) {
			/* if edge is forbidden */
			if (((e->startPoint == idx->startPoint) && (e->endPoint == idx->endPoint))
					|| ((e->startPoint == idx->endPoint) && (e->endPoint == idx->startPoint))) {
				allowed = 0;
				break;
			}
		}

		/* if its not, list current + e and continue recursively */
		if (allowed) {

			int v = e->startPoint->number;
			int w = e->endPoint->number;

			/* if adding e produces a tree, list that tree and continue recursively
			 * this assumes, that t is a tree */
			if ((current->m == 0)
					|| ((current->vertices[v]->neighborhood != NULL) && (current->vertices[w]->neighborhood == NULL))
					|| ((current->vertices[w]->neighborhood != NULL) && (current->vertices[v]->neighborhood == NULL))) {
				struct VertexList* tmp;

				addEdge(current->vertices[v], shallowCopyEdge(e, sgp->listPool));
				addEdge(current->vertices[w], inverseEdge(e, sgp->listPool));

				++current->m;

				/* here, output is produced */
				++(*number);

				/* recursive call for (T + e, F) */
				recSubtreeEnum(current, forbiddenEdges, allEdges, number, sgp);

				/* remove edge from current, add it to forbidden list */
				tmp = current->vertices[v]->neighborhood;
				current->vertices[v]->neighborhood = tmp->next;
				dumpVertexList(sgp->listPool, tmp);

				tmp = current->vertices[w]->neighborhood;
				current->vertices[w]->neighborhood = tmp->next;
				dumpVertexList(sgp->listPool, tmp);

				--current->m;

				pushEdge(forbiddenEdges, shallowCopyEdge(e, sgp->listPool));

				recSubtreeEnum(current, forbiddenEdges, allEdges, number, sgp);

				break;

			}
		}
	}

	/* reallow all edges that were forbidden in the current recursion */
	for (e=forbiddenEdges->edges; e!=startOfForbidden; e=forbiddenEdges->edges) {
		dumpVertexList(sgp->listPool, popEdge(forbiddenEdges));
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %r8, %rbx
movq %rcx, 0x18(%rsp)
movq %rsi, %r14
movq (%rsi), %rax
movq %rax, 0x10(%rsp)
movq %rdx, 0x8(%rsp)
movq (%rdx), %rbp
testq %rbp, %rbp
je 0x1e336
movq %rdi, %r13
movq (%r14), %rax
testq %rax, %rax
je 0x1e1f3
movq 0x10(%rbp), %rcx
movq 0x10(%rax), %rdx
cmpq %rdx, %rcx
jne 0x1e1da
movq 0x18(%rbp), %rsi
cmpq 0x18(%rax), %rsi
je 0x1e323
cmpq 0x18(%rax), %rcx
jne 0x1e1ea
cmpq %rdx, 0x18(%rbp)
je 0x1e323
movq 0x8(%rax), %rax
testq %rax, %rax
jne 0x1e1c3
movq 0x10(%rbp), %rax
movq 0x18(%rbp), %rcx
movslq 0x18(%rax), %rdi
movslq 0x18(%rcx), %r15
cmpl $0x0, 0x4(%r13)
je 0x1e242
movq 0x10(%r13), %rdx
movq (%rdx,%rdi,8), %rax
movq 0x8(%rax), %rsi
testq %rsi, %rsi
je 0x1e226
movq (%rdx,%r15,8), %rax
cmpq $0x0, 0x8(%rax)
je 0x1e242
xorl %eax, %eax
movb $0x1, %cl
testq %rsi, %rsi
jne 0x1e31f
movq (%rdx,%r15,8), %rdx
cmpq $0x0, 0x8(%rdx)
je 0x1e31f
movq 0x10(%r13), %rax
movq (%rax,%rdi,8), %r12
movq 0x10(%rbx), %rsi
movq %rdi, 0x20(%rsp)
movq %rbp, %rdi
callq 0x7bc0
movq %r12, %rdi
movq %rax, %rsi
callq 0x7cd0
movq 0x10(%r13), %rax
movq (%rax,%r15,8), %r12
movq 0x10(%rbx), %rsi
movq %rbp, %rdi
callq 0x7bdc
movq %r12, %rdi
movq %rax, %rsi
callq 0x7cd0
incl 0x4(%r13)
movq 0x18(%rsp), %r12
incl (%r12)
movq %r13, %rdi
movq %r14, %rsi
movq 0x8(%rsp), %rdx
movq %r12, %rcx
movq %rbx, %r8
callq 0x1e182
movq 0x10(%r13), %rax
movq 0x20(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movq 0x8(%rax), %rsi
movq 0x8(%rsi), %rcx
movq %rcx, 0x8(%rax)
movq 0x10(%rbx), %rdi
callq 0x1438e
movq 0x10(%r13), %rax
movq (%rax,%r15,8), %rax
movq 0x8(%rax), %rsi
movq 0x8(%rsi), %rcx
movq %rcx, 0x8(%rax)
movq 0x10(%rbx), %rdi
callq 0x1438e
decl 0x4(%r13)
movq 0x10(%rbx), %rsi
movq %rbp, %rdi
callq 0x7bc0
movq %r14, %rdi
movq %rax, %rsi
callq 0x840c
movq %r13, %rdi
movq %r14, %rsi
movq 0x8(%rsp), %rdx
movq %r12, %rcx
movq %rbx, %r8
callq 0x1e182
movl $0x2, %eax
xorl %ecx, %ecx
testb %cl, %cl
je 0x1e325
xorl %eax, %eax
testl %eax, %eax
jne 0x1e336
movq 0x8(%rbp), %rbp
testq %rbp, %rbp
jne 0x1e1b7
movq 0x10(%rsp), %r12
cmpq %r12, (%r14)
je 0x1e359
movq 0x10(%rbx), %r15
movq %r14, %rdi
callq 0x8891
movq %r15, %rdi
movq %rax, %rsi
callq 0x1438e
jmp 0x1e33b
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq