// File: /workspace/github_c_makefile_star2_O3/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, 0x40(%rsp)
movq %r8, 0x60(%rsp)
movq %rcx, 0x58(%rsp)
movq %rdx, 0x50(%rsp)
movq %rsi, 0x48(%rsp)
movq %rdi, 0x38(%rsp)
movq 0x128(%rsp), %r14
leaq 0xd0(%rsp), %rbx
movq $0x0, (%rbx)
movq %rbx, %rdi
callq 0x10e84
movl %eax, 0x2c(%rsp)
movslq %eax, %rbp
imulq $0x38, %rbp, %rdi
callq 0x1190
movq %rax, 0x30(%rsp)
movq (%rbx), %r12
testl %ebp, %ebp
je 0x12230
xorl %r15d, %r15d
leaq 0x70(%rsp), %rbx
movq 0x30(%rsp), %r13
movq (%r12,%r15,8), %rsi
leaq 0xa8(%rsp), %rdi
movq %r14, %rdx
callq 0xe7b8
movq 0xc8(%rsp), %rax
movq %rax, 0x20(%rsp)
movups 0xa8(%rsp), %xmm0
movups 0xb8(%rsp), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
movq %rbx, %rdi
movq 0x120(%rsp), %rsi
movq %r14, %rdx
callq 0xf24e
movq 0xa0(%rsp), %rax
movq %rax, 0x30(%r13)
movups 0x70(%rsp), %xmm0
movups 0x80(%rsp), %xmm1
movups 0x90(%rsp), %xmm2
movups %xmm2, 0x20(%r13)
movups %xmm1, 0x10(%r13)
movups %xmm0, (%r13)
incq %r15
addq $0x38, %r13
cmpq %r15, %rbp
jne 0x121a3
movq 0x120(%rsp), %r15
movq %r15, (%rsp)
leaq 0x70(%rsp), %rcx
leaq 0xa8(%rsp), %rbx
movq %r12, %rdi
movl 0x2c(%rsp), %ebp
movl %ebp, %esi
movq 0x38(%rsp), %rdx
movq %rbx, %r8
movq 0x118(%rsp), %r9
callq 0x116e8
leaq 0x68(%rsp), %rsi
movq $0x0, (%rsi)
movq (%rbx), %r13
movq %r13, %rdi
movq %r15, %rdx
movq %r14, %rcx
callq 0x11329
movq %rax, %rbx
movq %r15, %rdi
movq %r13, %rsi
callq 0x1b546
movq %r12, %rdi
callq 0x1030
leaq 0x70(%rsp), %rax
movq (%rax), %r12
movq 0x30(%rsp), %r13
movq %r13, %rdi
movl %ebp, %esi
movq %r12, %rdx
movq %r15, %rcx
callq 0x12335
movq %rax, %r15
movq %r12, %rdi
movq 0x110(%rsp), %rsi
movq %r14, %rdx
callq 0x1b764
movq %r15, %rdi
movq 0x40(%rsp), %rsi
callq 0x1cdf7
movl $0x28, %edi
callq 0x1190
movl %ebp, 0x20(%rax)
movq %rbx, 0x10(%rax)
leaq 0x68(%rsp), %rcx
movq (%rcx), %rcx
movq %rcx, 0x18(%rax)
movq %r12, 0x8(%rax)
movq %r13, (%rax)
movq 0x48(%rsp), %rcx
movq %r12, (%rcx)
movq 0x50(%rsp), %rcx
movq %r15, (%rcx)
movq 0x58(%rsp), %rcx
movq %rbx, (%rcx)
movq 0x60(%rsp), %rcx
movq %rax, (%rcx)
movl $0x1, %eax
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq