// File: /workspace/github_c_makefile_star2_O2/pwelke[P]GraphMiningTools/listSpanningTrees.c
// Function: _recCount
long int __recCount(long int d, struct Graph* graph, struct Graph* partialTree, int* components, int n, struct ShallowGraphPool* sgp, struct GraphPool* gp) {
	struct ShallowGraph* B;

	struct ShallowGraph* graphEdges = __getGraphAndNonGraphEdges(partialTree, getGraphEdges(graph, sgp), sgp);
	struct ShallowGraph* rest = graphEdges->next;

	if (rest->m == 0) {
		/* garbage collection */
		dumpShallowGraphCycle(sgp, graphEdges);
		return 1;
	}

	/* get edge that will be included and excluded in this __recursive step */
	struct VertexList* e = popEdge(rest);

	/* add e to partialTree (already contained in graph) to find spanning trees containing e */
	addEdgeBetweenVertices(e->startPoint->number, e->endPoint->number, e->label, partialTree, gp);

	/* S1 */
	/* let B be the set of all edges (in graph) joining edges already connected in partialTree */
	B = __selectB(partialTree, rest, components, n, sgp);

	/* ensures, that adding an edge of graph to partialTree results in a tree in the __recursive call */
	deleteEdges(graph, B, gp);

	long int result1 = __recCount(d, graph, partialTree, components, n, sgp, gp);

	/* add edges to graph again */
	addEdges(graph, B, gp);

	/* preliminary garbage collection */
	dumpShallowGraphCycle(sgp, B);

	/* at this point, graph and partialTree are as at the start of this call.
	If there are already too many spanning Trees found (indicated by return value -1)
	return at this point and prune the second __recursive call */
	if ((result1 == -1) || (result1 > d)) {
		/* garbage collection */
		dumpVertexList(sgp->listPool, e);
		dumpShallowGraphCycle(sgp, graphEdges);
		return -1;
	}

	/* delete e from partialTree and graph to find spanning trees not containing e */
	deleteEdgeBetweenVertices(graph, e, gp);
	deleteEdgeBetweenVertices(partialTree, e, gp);

	/* S2 */
	struct ShallowGraph* bridges = __getNonTreeBridges(graph, partialTree, sgp);

	addEdges(partialTree, bridges, gp);
	long int result2 = __recCount(d, graph, partialTree, components, n, sgp, gp);
	deleteEdges(partialTree, bridges, gp);

	/* At the end, spanningTree and graph need to be same as in the beginning. */
	addEdgeBetweenVertices(e->startPoint->number, e->endPoint->number, e->label, graph, gp);

	/* garbage collection */
	dumpVertexList(sgp->listPool, e);
	dumpShallowGraphCycle(sgp, bridges);
	dumpShallowGraphCycle(sgp, graphEdges);

	if ((result2 == -1) || (result2 > d)) {
		/* if there were too many spanning trees in the second __recursion... */ 
		return -1;
	} else {
		/* avoid overflow */
		if ((result1 > LONG_MAX / 2) || (result2 > LONG_MAX / 2)) {
			return -1;
		} else {
			return result1 + result2;
		}
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %r9, %rbx
movl %r8d, %r15d
movq %rcx, 0x28(%rsp)
movq %rdx, %r13
movq %rsi, %r12
movq %rdi, 0x10(%rsp)
movq %rsi, %rdi
movq %r9, %rsi
callq 0x6172
movq %r13, %rdi
movq %rax, %rsi
movq %rbx, %rdx
callq 0x9cfe
movq 0x18(%rax), %r14
cmpl $0x0, 0x10(%r14)
je 0xa57f
movq %rax, 0x20(%rsp)
movl %r15d, 0xc(%rsp)
movq 0x70(%rsp), %rbp
movq %r14, %rdi
callq 0x65fe
movq (%rax), %rdx
movq 0x10(%rax), %rcx
movl 0x18(%rcx), %edi
movq %rax, 0x18(%rsp)
movq 0x18(%rax), %rax
movl 0x18(%rax), %esi
movq %r13, %rcx
movq %rbp, %r8
callq 0x6200
movq %r13, %rdi
movq %r14, %rsi
movq 0x28(%rsp), %rbp
movq %rbp, %rdx
movl %r15d, %ecx
movq %rbx, %r8
callq 0x9c20
movq %rax, %r14
movq %r12, %rdi
movq %rax, %rsi
movq 0x70(%rsp), %r15
movq %r15, %rdx
callq 0x5d7c
movq %r15, (%rsp)
movq 0x10(%rsp), %r15
movq %r15, %rdi
movq %r12, %rsi
movq %r13, %rdx
movq %rbp, %rcx
movl 0xc(%rsp), %r8d
movq %rbx, %r9
callq 0xa45b
movq %rax, %rbp
movq %r12, %rdi
movq %r14, %rsi
movq 0x70(%rsp), %rdx
callq 0x6274
movq %rbx, %rdi
movq %r14, %rsi
callq 0x11888
cmpq $-0x1, %rbp
setne %al
cmpq %r15, %rbp
setle %cl
testb %cl, %al
jne 0xa591
movq 0x10(%rbx), %rdi
movq 0x18(%rsp), %rsi
callq 0x11364
movq %rbx, %rdi
movq 0x20(%rsp), %rsi
callq 0x11888
jmp 0xa666
movq %rbx, %rdi
movq %rax, %rsi
callq 0x11888
pushq $0x1
jmp 0xa668
movq %rbp, 0x30(%rsp)
movq %r12, %rdi
movq 0x18(%rsp), %rbp
movq %rbp, %rsi
movq 0x70(%rsp), %r15
movq %r15, %rdx
callq 0x5d1f
movq %r13, %rdi
movq %rbp, %rsi
movq %r15, %rdx
callq 0x5d1f
movq %r12, %rdi
movq %r13, %rsi
movq %rbx, %rdx
callq 0x9da2
movq %rax, %r14
movq %r13, %rdi
movq %rax, %rsi
movq %r15, %rdx
callq 0x6274
movq %r15, (%rsp)
movq 0x10(%rsp), %rdi
movq %r12, %rsi
movq %r13, %rdx
movq 0x28(%rsp), %rcx
movl 0xc(%rsp), %r8d
movq %rbx, %r9
callq 0xa45b
movq %rax, %r15
movq %r13, %rdi
movq %r14, %rsi
movq 0x70(%rsp), %r13
movq %r13, %rdx
callq 0x5d7c
movq (%rbp), %rdx
movq 0x10(%rbp), %rax
movl 0x18(%rax), %edi
movq 0x18(%rbp), %rax
movl 0x18(%rax), %esi
movq %r12, %rcx
movq %r13, %r8
callq 0x6200
movq 0x10(%rbx), %rdi
movq %rbp, %rsi
callq 0x11364
movq %rbx, %rdi
movq %r14, %rsi
callq 0x11888
movq %rbx, %rdi
movq 0x20(%rsp), %rsi
callq 0x11888
cmpq $-0x1, %r15
sete %al
cmpq 0x10(%rsp), %r15
setg %cl
orb %al, %cl
je 0xa678
pushq $-0x1
popq %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x30(%rsp), %rsi
leaq (%r15,%rsi), %rax
movabsq $0x3fffffffffffffff, %rcx # imm = 0x3FFFFFFFFFFFFFFF
cmpq %rcx, %r15
pushq $-0x1
popq %rdx
cmovgq %rdx, %rax
cmpq %rcx, %rsi
cmovgq %rdx, %rax
jmp 0xa669