// File: /workspace/github_c_makefile_star2_O2/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, 0x30(%rsp)
movq 0x128(%rsp), %r14
leaq 0xd0(%rsp), %rbx
andq $0x0, (%rbx)
movq %rbx, %rdi
callq 0xe32c
movl %eax, 0x2c(%rsp)
movslq %eax, %rbp
imulq $0x38, %rbp, %rdi
callq 0x1180
movq %rax, %r13
xorl %r15d, %r15d
movq (%rbx), %r12
leaq 0x70(%rsp), %rbx
movq %rax, 0x38(%rsp)
cmpq %r15, %rbp
je 0xf5b9
movq (%r12,%r15,8), %rsi
leaq 0xa8(%rsp), %rdi
movq %r14, %rdx
callq 0xbe98
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 0xc81d
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
jmp 0xf527
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 0x30(%rsp), %rdx
movq %rbx, %r8
movq 0x118(%rsp), %r9
callq 0xeaf9
leaq 0x68(%rsp), %rsi
andq $0x0, (%rsi)
movq (%rbx), %r13
movq %r13, %rdi
movq %r15, %rdx
movq %r14, %rcx
callq 0xe771
movq %rax, %rbx
movq %r15, %rdi
movq %r13, %rsi
callq 0x18dcd
movq %r12, %rdi
callq 0x1030
leaq 0x70(%rsp), %rax
movq (%rax), %r12
movq 0x38(%rsp), %r13
movq %r13, %rdi
movl %ebp, %esi
movq %r12, %rdx
movq %r15, %rcx
callq 0xf6b7
movq %rax, %r15
movq %r12, %rdi
movq 0x110(%rsp), %rsi
movq %r14, %rdx
callq 0x18fd2
movq %r15, %rdi
movq 0x40(%rsp), %rsi
callq 0x1a3b4
pushq $0x28
popq %rdi
callq 0x1180
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)
pushq $0x1
popq %rax
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq