// File: /workspace/github_c_makefile_star2_O2/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 %rsi, %r14
movq %rdi, %r9
movq (%rsi), %rax
movq %rax, 0x20(%rsp)
movq %rdx, %rbp
movq (%rbp), %rbp
testq %rbp, %rbp
je 0x1b5ca
movq 0x10(%rbp), %rax
movq %r14, %rdi
movq (%rdi), %rdi
testq %rdi, %rdi
je 0x1b4b3
movq 0x10(%rdi), %r8
cmpq %r8, %rax
je 0x1b498
movq 0x18(%rdi), %rsi
jmp 0x1b4a2
movq 0x18(%rdi), %rsi
cmpq %rsi, 0x18(%rbp)
je 0x1b4e8
cmpq %rsi, %rax
jne 0x1b4ad
cmpq %r8, 0x18(%rbp)
je 0x1b4e8
addq $0x8, %rdi
jmp 0x1b481
movslq 0x18(%rax), %r12
movq 0x18(%rbp), %rax
movslq 0x18(%rax), %r13
cmpl $0x0, 0x4(%r9)
movq 0x10(%r9), %rax
movq (%rax,%r12,8), %r15
je 0x1b4f1
cmpq $0x0, 0x8(%r15)
sete %sil
movq (%rax,%r13,8), %rax
cmpq $0x0, 0x8(%rax)
sete %al
cmpb %al, %sil
jne 0x1b4f1
addq $0x8, %rbp
jmp 0x1b46d
movq 0x10(%rbx), %rsi
movq %rbp, %rdi
movq %rcx, (%rsp)
movq %rdx, 0x8(%rsp)
movq %r9, 0x10(%rsp)
callq 0x5a28
movq %r15, %rdi
movq %rax, %rsi
callq 0x5b2c
movq 0x10(%rsp), %r15
movq 0x10(%r15), %rax
movq (%rax,%r13,8), %rax
movq %rax, 0x18(%rsp)
movq 0x10(%rbx), %rsi
movq %rbp, %rdi
callq 0x5a44
movq 0x18(%rsp), %rdi
movq %rax, %rsi
callq 0x5b2c
incl 0x4(%r15)
movq (%rsp), %rcx
incl (%rcx)
movq %r15, %rdi
movq %r14, %rsi
movq 0x8(%rsp), %rdx
movq %rbx, %r8
callq 0x1b44b
movq 0x10(%r15), %rax
movq (%rax,%r12,8), %rax
movq 0x8(%rax), %rsi
movq 0x8(%rsi), %rcx
movq %rcx, 0x8(%rax)
movq 0x10(%rbx), %rdi
callq 0x11364
movq 0x10(%r15), %rax
movq (%rax,%r13,8), %rax
movq 0x8(%rax), %rsi
movq 0x8(%rsi), %rcx
movq %rcx, 0x8(%rax)
movq 0x10(%rbx), %rdi
callq 0x11364
decl 0x4(%r15)
movq 0x10(%rbx), %rsi
movq %rbp, %rdi
callq 0x5a28
movq %r14, %rdi
movq %rax, %rsi
callq 0x61e7
movq %r15, %rdi
movq %r14, %rsi
movq 0x8(%rsp), %rdx
movq (%rsp), %rcx
movq %rbx, %r8
callq 0x1b44b
movq 0x20(%rsp), %r12
cmpq %r12, (%r14)
je 0x1b5ed
movq 0x10(%rbx), %r15
movq %r14, %rdi
callq 0x65fe
movq %r15, %rdi
movq %rax, %rsi
callq 0x11364
jmp 0x1b5cf
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq