// File: /workspace/github_c_makefile_star2_O1/pwelke[P]GraphMiningTools/lwm_initAndCollect.c
// Function: initExactLocalEasyForGraphDB
size_t initExactLocalEasyForGraphDB(// input
		size_t threshold,
		double importance,
		// output
		struct Vertex** initialFrequentPatterns,
		struct SupportSet** supportSets,
		struct ShallowGraph** extensionEdgeList,
		void** dataStructures,
		// printing
		FILE* featureStream,
		FILE* patternStream,
		FILE* logStream,
		// pools
		struct GraphPool* gp,
		struct ShallowGraphPool* sgp) {

	(void)importance; // unused

	struct Graph** db = NULL;
	size_t nGraphs = getDB(&db);
	struct SpanningtreeTree* sptTrees = malloc(nGraphs * sizeof(struct SpanningtreeTree));
	for (size_t i=0; i<nGraphs; ++i) {
		struct BlockTree blockTree = getBlockTreeT(db[i], sgp);
		sptTrees[i] = getFullSpanningtreeTree(blockTree, gp, sgp);
	}

	struct Vertex* frequentVertices;
	struct Vertex* frequentEdges;
	getFrequentVerticesAndEdges(db, nGraphs, threshold, &frequentVertices, &frequentEdges, logStream, gp);

	/* convert frequentEdges to ShallowGraph of extension edges */
	struct Graph* extensionEdgesVertexStore = NULL;
	struct ShallowGraph* extensionEdges = edgeSearchTree2ShallowGraph(frequentEdges, &extensionEdgesVertexStore, gp, sgp);
	dumpSearchTree(gp, frequentEdges);
	free(db);

	// levelwise search for patterns with one vertex:
	struct SupportSet* frequentVerticesSupportSets = createSingletonPatternSupportSetsForLocalEasyDB(sptTrees, nGraphs, frequentVertices, gp, sgp);
	printStringsInSearchTree(frequentVertices, patternStream, sgp);
	printSupportSetsSparse(frequentVerticesSupportSets, featureStream);

	// store pointers for final garbage collection
	struct IterativeBfsForLocalEasyDataStructures* x = malloc(sizeof(struct IterativeBfsForLocalEasyDataStructures));
	x->nGraphs = nGraphs;
	x->extensionEdges = extensionEdges;
	x->extensionEdgesVertexStore = extensionEdgesVertexStore;
	x->initialFrequentPatterns = frequentVertices;
	x->sptTrees = sptTrees;

	// 'return'
	*initialFrequentPatterns = frequentVertices;
	*supportSets = frequentVerticesSupportSets;
	*extensionEdgeList = extensionEdges;
	*dataStructures = x;
	return 1; // returned patterns have 1 vertex
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd8, %rsp
movq %r9, 0x48(%rsp)
movq %r8, 0x68(%rsp)
movq %rcx, 0x60(%rsp)
movq %rdx, 0x58(%rsp)
movq %rsi, 0x50(%rsp)
movq %rdi, 0x40(%rsp)
movq 0x128(%rsp), %r14
leaq 0x38(%rsp), %rdi
movq $0x0, (%rdi)
callq 0x10f58
movl %eax, 0x2c(%rsp)
movslq %eax, %rbx
imulq $0x38, %rbx, %rdi
callq 0x1190
movq %rax, 0x30(%rsp)
testl %ebx, %ebx
je 0x12301
movq 0x38(%rsp), %rbp
xorl %r15d, %r15d
leaq 0x78(%rsp), %r12
movq 0x30(%rsp), %r13
movq (%rbp,%r15,8), %rsi
leaq 0xb0(%rsp), %rdi
movq %r14, %rdx
callq 0xe85c
movq 0xd0(%rsp), %rax
movq %rax, 0x20(%rsp)
movups 0xb0(%rsp), %xmm0
movups 0xc0(%rsp), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
movq %r12, %rdi
movq 0x120(%rsp), %rsi
movq %r14, %rdx
callq 0xf2cf
movq 0xa8(%rsp), %rax
movq %rax, 0x30(%r13)
movups 0x78(%rsp), %xmm0
movups 0x88(%rsp), %xmm1
movups 0x98(%rsp), %xmm2
movups %xmm2, 0x20(%r13)
movups %xmm1, 0x10(%r13)
movups %xmm0, (%r13)
incq %r15
addq $0x38, %r13
cmpq %r15, %rbx
jne 0x12273
movq 0x38(%rsp), %rbx
movq 0x120(%rsp), %r15
movq %r15, (%rsp)
leaq 0x78(%rsp), %rcx
leaq 0xb0(%rsp), %r13
movq %rbx, %rdi
movl 0x2c(%rsp), %ebp
movl %ebp, %esi
movq 0x40(%rsp), %rdx
movq %r13, %r8
movq 0x118(%rsp), %r9
callq 0x117c5
leaq 0x70(%rsp), %rsi
movq $0x0, (%rsi)
movq (%r13), %r12
movq %r12, %rdi
movq %r15, %rdx
movq %r14, %rcx
callq 0x1140a
movq %rax, %r13
movq %r15, %rdi
movq %r12, %rsi
callq 0x1b644
movq %rbx, %rdi
callq 0x1030
leaq 0x78(%rsp), %rax
movq (%rax), %rbx
movq 0x30(%rsp), %r12
movq %r12, %rdi
movl %ebp, %esi
movq %rbx, %rdx
movq %r15, %rcx
callq 0x1240c
movq %rax, %r15
movq %rbx, %rdi
movq 0x110(%rsp), %rsi
movq %r14, %rdx
callq 0x1b857
movq %r15, %rdi
movq 0x48(%rsp), %rsi
callq 0x1cf5c
movl $0x28, %edi
callq 0x1190
movl %ebp, 0x20(%rax)
movq %r13, 0x10(%rax)
leaq 0x70(%rsp), %rcx
movq (%rcx), %rcx
movq %rcx, 0x18(%rax)
movq %rbx, 0x8(%rax)
movq %r12, (%rax)
movq 0x50(%rsp), %rcx
movq %rbx, (%rcx)
movq 0x58(%rsp), %rcx
movq %r15, (%rcx)
movq 0x60(%rsp), %rcx
movq %r13, (%rcx)
movq 0x68(%rsp), %rcx
movq %rax, (%rcx)
movl $0x1, %eax
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq