// File: /workspace/github_c_makefile_star2_O0/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:
subq $0x88, %rsp
movq 0x90(%rsp), %rax
movq %rdi, 0x78(%rsp)
movq %rsi, 0x70(%rsp)
movq %rdx, 0x68(%rsp)
movq %rcx, 0x60(%rsp)
movl %r8d, 0x5c(%rsp)
movq %r9, 0x50(%rsp)
movq 0x68(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0x70(%rsp), %rdi
movq 0x50(%rsp), %rsi
callq 0xb530
movq 0x10(%rsp), %rdi
movq %rax, %rsi
movq 0x50(%rsp), %rdx
callq 0x12830
movq %rax, 0x40(%rsp)
movq 0x40(%rsp), %rax
movq 0x18(%rax), %rax
movq %rax, 0x38(%rsp)
movq 0x38(%rsp), %rax
cmpl $0x0, 0x10(%rax)
jne 0x133f6
movq 0x50(%rsp), %rdi
movq 0x40(%rsp), %rsi
callq 0x20000
movq $0x1, 0x80(%rsp)
jmp 0x13681
movq 0x38(%rsp), %rdi
callq 0xbef0
movq %rax, 0x30(%rsp)
movq 0x30(%rsp), %rax
movq 0x10(%rax), %rax
movl 0x18(%rax), %edi
movq 0x30(%rsp), %rax
movq 0x18(%rax), %rax
movl 0x18(%rax), %esi
movq 0x30(%rsp), %rax
movq (%rax), %rdx
movq 0x68(%rsp), %rcx
movq 0x90(%rsp), %r8
callq 0xb670
movq 0x68(%rsp), %rdi
movq 0x38(%rsp), %rsi
movq 0x60(%rsp), %rdx
movl 0x5c(%rsp), %ecx
movq 0x50(%rsp), %r8
callq 0x12660
movq %rax, 0x48(%rsp)
movq 0x70(%rsp), %rdi
movq 0x48(%rsp), %rsi
movq 0x90(%rsp), %rdx
callq 0xac50
movq 0x78(%rsp), %rdi
movq 0x70(%rsp), %rsi
movq 0x68(%rsp), %rdx
movq 0x60(%rsp), %rcx
movl 0x5c(%rsp), %r8d
movq 0x50(%rsp), %r9
movq 0x90(%rsp), %rax
movq %rax, (%rsp)
callq 0x13360
movq %rax, 0x28(%rsp)
movq 0x70(%rsp), %rdi
movq 0x48(%rsp), %rsi
movq 0x90(%rsp), %rdx
callq 0xb750
movq 0x50(%rsp), %rdi
movq 0x48(%rsp), %rsi
callq 0x20000
cmpq $-0x1, 0x28(%rsp)
je 0x134de
movq 0x28(%rsp), %rax
cmpq 0x78(%rsp), %rax
jle 0x13511
movq 0x50(%rsp), %rax
movq 0x10(%rax), %rdi
movq 0x30(%rsp), %rsi
callq 0x1f410
movq 0x50(%rsp), %rdi
movq 0x40(%rsp), %rsi
callq 0x20000
movq $-0x1, 0x80(%rsp)
jmp 0x13681
movq 0x70(%rsp), %rdi
movq 0x30(%rsp), %rsi
movq 0x90(%rsp), %rdx
callq 0xaba0
movq 0x68(%rsp), %rdi
movq 0x30(%rsp), %rsi
movq 0x90(%rsp), %rdx
callq 0xaba0
movq 0x70(%rsp), %rdi
movq 0x68(%rsp), %rsi
movq 0x50(%rsp), %rdx
callq 0x12960
movq %rax, 0x20(%rsp)
movq 0x68(%rsp), %rdi
movq 0x20(%rsp), %rsi
movq 0x90(%rsp), %rdx
callq 0xb750
movq 0x78(%rsp), %rdi
movq 0x70(%rsp), %rsi
movq 0x68(%rsp), %rdx
movq 0x60(%rsp), %rcx
movl 0x5c(%rsp), %r8d
movq 0x50(%rsp), %r9
movq 0x90(%rsp), %rax
movq %rax, (%rsp)
callq 0x13360
movq %rax, 0x18(%rsp)
movq 0x68(%rsp), %rdi
movq 0x20(%rsp), %rsi
movq 0x90(%rsp), %rdx
callq 0xac50
movq 0x30(%rsp), %rax
movq 0x10(%rax), %rax
movl 0x18(%rax), %edi
movq 0x30(%rsp), %rax
movq 0x18(%rax), %rax
movl 0x18(%rax), %esi
movq 0x30(%rsp), %rax
movq (%rax), %rdx
movq 0x70(%rsp), %rcx
movq 0x90(%rsp), %r8
callq 0xb670
movq 0x50(%rsp), %rax
movq 0x10(%rax), %rdi
movq 0x30(%rsp), %rsi
callq 0x1f410
movq 0x50(%rsp), %rdi
movq 0x20(%rsp), %rsi
callq 0x20000
movq 0x50(%rsp), %rdi
movq 0x40(%rsp), %rsi
callq 0x20000
cmpq $-0x1, 0x18(%rsp)
je 0x13631
movq 0x18(%rsp), %rax
cmpq 0x78(%rsp), %rax
jle 0x1363f
movq $-0x1, 0x80(%rsp)
jmp 0x13681
movabsq $0x3fffffffffffffff, %rax # imm = 0x3FFFFFFFFFFFFFFF
cmpq %rax, 0x28(%rsp)
jg 0x13661
movabsq $0x3fffffffffffffff, %rax # imm = 0x3FFFFFFFFFFFFFFF
cmpq %rax, 0x18(%rsp)
jle 0x1366f
movq $-0x1, 0x80(%rsp)
jmp 0x13681
movq 0x28(%rsp), %rax
addq 0x18(%rsp), %rax
movq %rax, 0x80(%rsp)
movq 0x80(%rsp), %rax
addq $0x88, %rsp
retq
nopw %cs:(%rax,%rax)