// File: /workspace/github_c_makefile_star2_O0/pwelke[P]GraphMiningTools/localEasySubtreeIsomorphism.c
// Function: getSampledSpanningtreeTree
struct SpanningtreeTree getSampledSpanningtreeTree(struct BlockTree blockTree, int spanningTreesPerBlock, char removeDuplicates, struct GraphPool* gp, struct ShallowGraphPool* sgp) {
	struct SpanningtreeTree sptTree = {0,0,0,0,0,0,0};
	sptTree.g = blockTree.g;
	sptTree.nRoots = blockTree.nRoots;
	sptTree.roots = blockTree.roots;
	sptTree.parents = blockTree.parents;
	sptTree.localSpanningTrees = malloc(sptTree.nRoots * sizeof(struct Graph*));
	sptTree.localPostorders = malloc(sptTree.nRoots * sizeof(struct PostorderList*));

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

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

			/* Duplicate spanning trees are 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. */
			if (removeDuplicates) {
				shallowSpanningtrees = filterDuplicateSpanningTrees(shallowSpanningtrees, sgp);
			}
		} else {
			// if the mergedGraph is a tree, we use it directly
			shallowSpanningtrees = getGraphEdges(mergedGraph, sgp);
		}
		sptTree.localSpanningTrees[v] = spanningTreeConverter(shallowSpanningtrees, mergedGraph, gp, sgp);

		sptTree.localPostorders[v] = NULL;
		struct PostorderList* tail = NULL;
		for (struct Graph* localSpanningTree=sptTree.localSpanningTrees[v]; localSpanningTree!=NULL; localSpanningTree=localSpanningTree->next) {
			struct PostorderList* tmp = __getPOL();
			tmp->postorder = getPostorder(localSpanningTree, 0);
			if (sptTree.localPostorders[v] == NULL) {
				sptTree.localPostorders[v] = tail = tmp;
			} else {
				// append at the end of the list
				tail->next = tmp;
				tail = tmp;
			}
		}

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

	initCharacteristicsArrayForLocalEasy(&sptTree);

	//garbage collection
	free(blockTree.vRootedBlocks);

	return sptTree;
}

// Assembly:
subq $0x78, %rsp
movq %rdi, 0x10(%rsp)
movb %dl, %al
movq %rdi, %rdx
movq %rdx, (%rsp)
leaq 0x80(%rsp), %rdx
movq %rdx, 0x8(%rsp)
movl %esi, 0x74(%rsp)
movb %al, 0x73(%rsp)
movq %rcx, 0x68(%rsp)
movq %r8, 0x60(%rsp)
xorl %esi, %esi
movl $0x38, %edx
callq 0x10b0
movq 0x8(%rsp), %rax
movq 0x10(%rsp), %rdi
movq (%rax), %rcx
movq %rcx, (%rdi)
movl 0x20(%rax), %ecx
movl %ecx, 0x30(%rdi)
movq 0x8(%rax), %rcx
movq %rcx, 0x8(%rdi)
movq 0x10(%rax), %rax
movq %rax, 0x10(%rdi)
movslq 0x30(%rdi), %rdi
shlq $0x3, %rdi
callq 0x1170
movq 0x10(%rsp), %rdi
movq %rax, 0x18(%rdi)
movslq 0x30(%rdi), %rdi
shlq $0x3, %rdi
callq 0x1170
movq 0x10(%rsp), %rdi
movq %rax, 0x28(%rdi)
movl $0x0, 0x5c(%rsp)
movq 0x10(%rsp), %rcx
movl 0x5c(%rsp), %eax
cmpl 0x30(%rcx), %eax
jge 0x1722e
movq 0x8(%rsp), %rax
movq 0x18(%rax), %rax
movslq 0x5c(%rsp), %rcx
movq (%rax,%rcx,8), %rdi
movq 0x60(%rsp), %rsi
callq 0x17250
movq %rax, 0x50(%rsp)
movq 0x50(%rsp), %rdi
movq 0x68(%rsp), %rsi
callq 0x16470
movq %rax, 0x48(%rsp)
movq $0x0, 0x40(%rsp)
movq 0x48(%rsp), %rax
movl 0x4(%rax), %eax
movq 0x48(%rsp), %rcx
movl (%rcx), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
je 0x17105
movl $0x0, 0x3c(%rsp)
movl 0x3c(%rsp), %eax
cmpl 0x74(%rsp), %eax
jge 0x170e8
movq 0x48(%rsp), %rdi
movq 0x60(%rsp), %rsi
callq 0x32f00
movq %rax, 0x30(%rsp)
movq 0x40(%rsp), %rcx
movq 0x30(%rsp), %rax
movq %rcx, 0x18(%rax)
movq 0x30(%rsp), %rax
movq %rax, 0x40(%rsp)
movl 0x3c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x3c(%rsp)
jmp 0x170a5
cmpb $0x0, 0x73(%rsp)
je 0x17103
movq 0x40(%rsp), %rdi
movq 0x60(%rsp), %rsi
callq 0x16c90
movq %rax, 0x40(%rsp)
jmp 0x17119
movq 0x48(%rsp), %rdi
movq 0x60(%rsp), %rsi
callq 0xb530
movq %rax, 0x40(%rsp)
movq 0x40(%rsp), %rdi
movq 0x48(%rsp), %rsi
movq 0x68(%rsp), %rdx
movq 0x60(%rsp), %rcx
callq 0x166e0
movq %rax, %rsi
movq 0x10(%rsp), %rax
movq 0x18(%rax), %rcx
movslq 0x5c(%rsp), %rdx
movq %rsi, (%rcx,%rdx,8)
movq 0x28(%rax), %rcx
movslq 0x5c(%rsp), %rdx
movq $0x0, (%rcx,%rdx,8)
movq $0x0, 0x28(%rsp)
movq 0x18(%rax), %rax
movslq 0x5c(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, 0x20(%rsp)
cmpq $0x0, 0x20(%rsp)
je 0x17200
callq 0x197e0
movq %rax, 0x18(%rsp)
movq 0x20(%rsp), %rdi
xorl %esi, %esi
callq 0x2df00
movq %rax, %rdx
movq 0x10(%rsp), %rax
movq 0x18(%rsp), %rcx
movq %rdx, (%rcx)
movq 0x28(%rax), %rax
movslq 0x5c(%rsp), %rcx
cmpq $0x0, (%rax,%rcx,8)
jne 0x171d3
movq 0x10(%rsp), %rax
movq 0x18(%rsp), %rdx
movq %rdx, 0x28(%rsp)
movq 0x28(%rax), %rax
movslq 0x5c(%rsp), %rcx
movq %rdx, (%rax,%rcx,8)
jmp 0x171eb
movq 0x18(%rsp), %rcx
movq 0x28(%rsp), %rax
movq %rcx, 0x8(%rax)
movq 0x18(%rsp), %rax
movq %rax, 0x28(%rsp)
jmp 0x171ed
movq 0x20(%rsp), %rax
movq 0x18(%rax), %rax
movq %rax, 0x20(%rsp)
jmp 0x17173
movq 0x60(%rsp), %rdi
movq 0x50(%rsp), %rsi
callq 0x1ff70
movq 0x68(%rsp), %rdi
movq 0x48(%rsp), %rsi
callq 0x1fb30
movl 0x5c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x5c(%rsp)
jmp 0x17037
movq 0x10(%rsp), %rdi
callq 0x16850
movq 0x8(%rsp), %rax
movq 0x18(%rax), %rdi
callq 0x1030
movq (%rsp), %rax
addq $0x78, %rsp
retq
nop