// File: /workspace/github_c_makefile_star2_O1/pwelke[P]GraphMiningTools/lwm_initAndCollect.c
// Function: initFrequentTreeMiningForForestDB
size_t initFrequentTreeMiningForForestDB(// 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;
	int nGraphs = getDB(&db);
	int** postorders = getPostorders(db, nGraphs);

	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);

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

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

	// '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 $0x58, %rsp
movq %r9, 0x10(%rsp)
movq %r8, 0x30(%rsp)
movq %rcx, 0x28(%rsp)
movq %rdx, 0x20(%rsp)
movq %rsi, 0x18(%rsp)
movq %rdi, %r12
movq 0xa0(%rsp), %r15
xorl %eax, %eax
leaq 0x50(%rsp), %rbx
movq %rax, (%rbx)
movq %rbx, %rdi
callq 0x10f58
movl %eax, %ebp
movq (%rbx), %rbx
movq %rbx, %rdi
movl %eax, %esi
callq 0x11777
movq %rax, %r14
movq %r15, (%rsp)
leaq 0x40(%rsp), %rcx
leaq 0x48(%rsp), %r13
movq %rbx, %rdi
movl %ebp, %esi
movq %r12, %rdx
movq %r13, %r8
movq 0x98(%rsp), %r9
callq 0x117c5
leaq 0x38(%rsp), %rsi
xorl %eax, %eax
movq %rax, (%rsi)
movq (%r13), %r12
movq %r12, %rdi
movq %r15, %rdx
movq 0xa8(%rsp), %rcx
callq 0x1140a
movq %rax, %r13
movq %r15, %rdi
movq %r12, %rsi
callq 0x1b644
leaq 0x40(%rsp), %rax
movq (%rax), %r12
movq %rbx, %rdi
movq %r14, %rsi
movl %ebp, %edx
movq %r12, %rcx
movq %r15, %r8
callq 0x11ab2
movq %rax, %r15
movq %r12, %rdi
movq 0x90(%rsp), %rsi
movq 0xa8(%rsp), %rdx
callq 0x1b857
movq %r15, %rdi
movq 0x10(%rsp), %rsi
callq 0x1cf5c
movl $0x30, %edi
callq 0x1190
movq %rbx, (%rax)
movq %r14, 0x8(%rax)
movl %ebp, 0x28(%rax)
movq %r13, 0x18(%rax)
leaq 0x38(%rsp), %rcx
movq (%rcx), %rcx
movq %rcx, 0x20(%rax)
movq %r12, 0x10(%rax)
movq 0x18(%rsp), %rcx
movq %r12, (%rcx)
movq 0x20(%rsp), %rcx
movq %r15, (%rcx)
movq 0x28(%rsp), %rcx
movq %r13, (%rcx)
movq 0x30(%rsp), %rcx
movq %rax, (%rcx)
movl $0x1, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq