// File: /workspace/github_c_makefile_star2_O0/pwelke[P]GraphMiningTools/localEasySubtreeIsomorphism.c
// Function: getNumberOfNonisomorphicSpanningTreesObtainedByLocalEasySampling
int getNumberOfNonisomorphicSpanningTreesObtainedByLocalEasySampling(struct Graph* g, int k, struct GraphPool* gp, struct ShallowGraphPool* sgp) {

	struct BlockTree blockTree = getBlockTreeT(g, sgp);
	int numberOfNonisomorphicSpanningForestComponents = 0;

	struct ShallowGraph** localSpanningTrees = malloc(blockTree.nRoots * sizeof(struct Graph*));

	for (int v=0; v<blockTree.nRoots; ++v) {
		struct ShallowGraph* mergedEdges = mergeShallowGraphs(blockTree.vRootedBlocks[v], sgp);
		struct Graph* mergedGraph = blockConverterKeepIDs(mergedEdges, gp);

		struct ShallowGraph* shallowSpanningtrees = NULL;
		if (mergedGraph->m != mergedGraph->n-1) {
			// sample spanning trees according to parameter
			for (int i=0; i<k; ++i) {
				struct ShallowGraph* spt = randomSpanningTreeAsShallowGraph(mergedGraph, sgp);
				spt->next = shallowSpanningtrees;
				shallowSpanningtrees = spt;
			}

			/* Duplicate spanning trees are NOT filtered here.
			 * In contrast to normal spanning tree sampling, here we can only filter identical trees (seen as edge sets)
			 * and not trees up to isomorphism, as two isomorphic but different local spanning trees might result in different
			 * (and hence possibly nonisomorphic) global spanning trees, when combined. */
//			shallowSpanningtrees = filterDuplicateSpanningTrees(shallowSpanningtrees, sgp);

		} else {
			// if the mergedGraph is a tree, we use it directly
			shallowSpanningtrees = getGraphEdges(mergedGraph, sgp);
		}

		// make the shallowgraphs be subgraphs of g, not of mergedGraph
		rebaseShallowGraphsOnLowPoints(shallowSpanningtrees, g);

		localSpanningTrees[v] = shallowSpanningtrees;

		// garbage collection
		dumpShallowGraph(sgp, mergedEdges);
		dumpGraph(gp, mergedGraph);

	}

	struct Vertex* searchTree = getVertex(gp->vertexPool);

	struct ShallowGraph* combinations = spanningTreeCombinations(localSpanningTrees, 0, blockTree.nRoots, sgp);
	for (struct ShallowGraph* combination=popShallowGraph(&combinations); combination!=NULL; combination=popShallowGraph(&combinations)) {
		struct Graph* spForest = shallowGraphToGraph(combination, gp);
		addToSearchTree(searchTree, runForEachConnectedComponent(&xcanonicalStringOfTree, spForest, 0, 0, 0, gp, sgp), gp, sgp);
		dumpGraph(gp, spForest);
		dumpShallowGraph(sgp, combination);
	}

	numberOfNonisomorphicSpanningForestComponents = searchTree->d;

	//garbage collection
	dumpSearchTree(gp, searchTree);
	for (int v=0; v<blockTree.nRoots; ++v) {
		dumpShallowGraphCycle(sgp, localSpanningTrees[v]);
	}
	free(localSpanningTrees);
	free(blockTree.parents);
	free(blockTree.roots);
	free(blockTree.vRootedBlocks);

	return numberOfNonisomorphicSpanningForestComponents;
}

// Assembly:
subq $0xc8, %rsp
movq %rdi, 0xc0(%rsp)
movl %esi, 0xbc(%rsp)
movq %rdx, 0xb0(%rsp)
movq %rcx, 0xa8(%rsp)
movq 0xc0(%rsp), %rsi
movq 0xa8(%rsp), %rdx
leaq 0x80(%rsp), %rdi
callq 0x15fb0
movl $0x0, 0x7c(%rsp)
movslq 0xa0(%rsp), %rdi
shlq $0x3, %rdi
callq 0x1170
movq %rax, 0x70(%rsp)
movl $0x0, 0x6c(%rsp)
movl 0x6c(%rsp), %eax
cmpl 0xa0(%rsp), %eax
jge 0x18946
movq 0x98(%rsp), %rax
movslq 0x6c(%rsp), %rcx
movq (%rax,%rcx,8), %rdi
movq 0xa8(%rsp), %rsi
callq 0x17250
movq %rax, 0x60(%rsp)
movq 0x60(%rsp), %rdi
movq 0xb0(%rsp), %rsi
callq 0x18ae0
movq %rax, 0x58(%rsp)
movq $0x0, 0x50(%rsp)
movq 0x58(%rsp), %rax
movl 0x4(%rax), %eax
movq 0x58(%rsp), %rcx
movl (%rcx), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
je 0x188d6
movl $0x0, 0x4c(%rsp)
movl 0x4c(%rsp), %eax
cmpl 0xbc(%rsp), %eax
jge 0x188d4
movq 0x58(%rsp), %rdi
movq 0xa8(%rsp), %rsi
callq 0x32f00
movq %rax, 0x40(%rsp)
movq 0x50(%rsp), %rcx
movq 0x40(%rsp), %rax
movq %rcx, 0x18(%rax)
movq 0x40(%rsp), %rax
movq %rax, 0x50(%rsp)
movl 0x4c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x4c(%rsp)
jmp 0x1888b
jmp 0x188ed
movq 0x58(%rsp), %rdi
movq 0xa8(%rsp), %rsi
callq 0xb530
movq %rax, 0x50(%rsp)
movq 0x50(%rsp), %rdi
movq 0xc0(%rsp), %rsi
callq 0xbcb0
movq 0x50(%rsp), %rdx
movq 0x70(%rsp), %rax
movslq 0x6c(%rsp), %rcx
movq %rdx, (%rax,%rcx,8)
movq 0xa8(%rsp), %rdi
movq 0x60(%rsp), %rsi
callq 0x1ff70
movq 0xb0(%rsp), %rdi
movq 0x58(%rsp), %rsi
callq 0x1fb30
movl 0x6c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x6c(%rsp)
jmp 0x18819
movq 0xb0(%rsp), %rax
movq 0x10(%rax), %rdi
callq 0x1f6a0
movq %rax, 0x38(%rsp)
movq 0x70(%rsp), %rdi
movl 0xa0(%rsp), %edx
movq 0xa8(%rsp), %rcx
xorl %esi, %esi
callq 0x185b0
movq %rax, 0x30(%rsp)
leaq 0x30(%rsp), %rdi
callq 0x16420
movq %rax, 0x28(%rsp)
cmpq $0x0, 0x28(%rsp)
je 0x18a3a
movq 0x28(%rsp), %rdi
movq 0xb0(%rsp), %rsi
callq 0xb1e0
movq %rax, 0x20(%rsp)
movq 0x38(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0x20(%rsp), %rsi
movq 0xb0(%rsp), %r9
movq 0xa8(%rsp), %rax
leaq 0x3ac(%rip), %rdi       # 0x18d80
xorl %r8d, %r8d
xorl %ecx, %ecx
movl %r8d, %edx
movq %rax, (%rsp)
callq 0x2bad0
movq 0x10(%rsp), %rdi
movq %rax, %rsi
movq 0xb0(%rsp), %rdx
movq 0xa8(%rsp), %rcx
callq 0x2c520
movq 0xb0(%rsp), %rdi
movq 0x20(%rsp), %rsi
callq 0x1fb30
movq 0xa8(%rsp), %rdi
movq 0x28(%rsp), %rsi
callq 0x1ff70
leaq 0x30(%rsp), %rdi
callq 0x16420
movq %rax, 0x28(%rsp)
jmp 0x1898b
movq 0x38(%rsp), %rax
movl 0x28(%rax), %eax
movl %eax, 0x7c(%rsp)
movq 0xb0(%rsp), %rdi
movq 0x38(%rsp), %rsi
callq 0x2d3c0
movl $0x0, 0x1c(%rsp)
movl 0x1c(%rsp), %eax
cmpl 0xa0(%rsp), %eax
jge 0x18a95
movq 0xa8(%rsp), %rdi
movq 0x70(%rsp), %rax
movslq 0x1c(%rsp), %rcx
movq (%rax,%rcx,8), %rsi
callq 0x20000
movl 0x1c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1c(%rsp)
jmp 0x18a60
movq 0x70(%rsp), %rdi
callq 0x1030
movq 0x90(%rsp), %rdi
callq 0x1030
movq 0x88(%rsp), %rdi
callq 0x1030
movq 0x98(%rsp), %rdi
callq 0x1030
movl 0x7c(%rsp), %eax
addq $0xc8, %rsp
retq
nopw %cs:(%rax,%rax)