// File: /workspace/github_c_makefile_star2_O0/pwelke[P]GraphMiningTools/lwmr_miningAndExtension.c
// Function: BFSStrategyRooted
void BFSStrategyRooted(size_t startPatternSize,
					  size_t maxPatternSize,
		              size_t threshold,
					  struct Vertex* initialFrequentPatterns,
					  struct SupportSet* supportSets,
					  struct ShallowGraph* extensionEdges,
					  // embedding operator function pointer,
					  struct SubtreeIsoDataStore (*embeddingOperator)(struct SubtreeIsoDataStore, struct Graph*, double, struct GraphPool*, struct ShallowGraphPool*),
					  double importance,
					  FILE* featureStream,
					  FILE* patternStream,
					  FILE* logStream,
					  struct GraphPool* gp,
					  struct ShallowGraphPool* sgp) {

	const char useAprioriPruning = 1;

	// levelwise search for patterns with more than one vertex:
	struct Vertex* previousLevelSearchTree = shallowCopySearchTree(initialFrequentPatterns, gp);
	struct SupportSet* previousLevelSupportSets = supportSets;
	struct Vertex* currentLevelSearchTree = previousLevelSearchTree; // initialization for garbage collection in case of maxPatternSize == 1
	struct SupportSet* currentLevelSupportSets = previousLevelSupportSets; // initialization for garbage collection in case of maxPatternSize == 1

	for (size_t p=startPatternSize+1; (p<=maxPatternSize) && (previousLevelSearchTree->number>0); ++p) {
		fprintf(logStream, "Processing patterns with %zu vertices:\n", p); fflush(logStream);
		currentLevelSearchTree = getVertex(gp->vertexPool);
		offsetSearchTreeIds(currentLevelSearchTree, previousLevelSearchTree->lowPoint);

		currentLevelSupportSets = _getNextLevelRooted(previousLevelSupportSets, previousLevelSearchTree, NULL, threshold, extensionEdges, embeddingOperator, importance, useAprioriPruning, &currentLevelSearchTree, logStream, gp, sgp);

		printStringsInSearchTree(currentLevelSearchTree, patternStream, sgp);
		fflush(patternStream);
		printSupportSetsSparse(currentLevelSupportSets, featureStream);
		fflush(featureStream);

		// garbage collection:
		// what is now all previousLevel... data structures will not be used at all in the next iteration
		dumpSearchTree(gp, previousLevelSearchTree);
		while (previousLevelSupportSets) {
			struct SupportSet* tmp = previousLevelSupportSets->next;
			// ...hence, we also dump the pattern graphs completely, which we can't do in a DFS mining approach.
			dumpSupportSetWithPattern(previousLevelSupportSets, gp);
			previousLevelSupportSets = tmp;
		}

		// previous level = current level
		previousLevelSearchTree = currentLevelSearchTree;
		previousLevelSupportSets = currentLevelSupportSets;
	}

	// garbage collection
	dumpSearchTree(gp, previousLevelSearchTree);

	while (previousLevelSupportSets) {
		struct SupportSet* tmp = previousLevelSupportSets->next;
		// we also dump the pattern graphs completely, which we can't do in a DFS mining approach.
		dumpSupportSetWithPattern(previousLevelSupportSets, gp);
		previousLevelSupportSets = tmp;
	}
}

// Assembly:
pushq %rbx
subq $0xb0, %rsp
movq 0xe8(%rsp), %rax
movq 0xe0(%rsp), %rax
movq 0xd8(%rsp), %rax
movq 0xd0(%rsp), %rax
movq 0xc8(%rsp), %rax
movq 0xc0(%rsp), %rax
movq %rdi, 0xa8(%rsp)
movq %rsi, 0xa0(%rsp)
movq %rdx, 0x98(%rsp)
movq %rcx, 0x90(%rsp)
movq %r8, 0x88(%rsp)
movq %r9, 0x80(%rsp)
movsd %xmm0, 0x78(%rsp)
movb $0x1, 0x77(%rsp)
movq 0x90(%rsp), %rdi
movq 0xe0(%rsp), %rsi
callq 0x2d440
movq %rax, 0x68(%rsp)
movq 0x88(%rsp), %rax
movq %rax, 0x60(%rsp)
movq 0x68(%rsp), %rax
movq %rax, 0x58(%rsp)
movq 0x60(%rsp), %rax
movq %rax, 0x50(%rsp)
movq 0xa8(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x48(%rsp)
movq 0x48(%rsp), %rcx
xorl %eax, %eax
cmpq 0xa0(%rsp), %rcx
movb %al, 0x37(%rsp)
ja 0x1e274
movq 0x68(%rsp), %rax
cmpl $0x0, 0x18(%rax)
setg %al
movb %al, 0x37(%rsp)
movb 0x37(%rsp), %al
testb $0x1, %al
jne 0x1e281
jmp 0x1e3f0
movq 0xd8(%rsp), %rdi
movq 0x48(%rsp), %rdx
leaq 0x17705(%rip), %rsi     # 0x3599a
movb $0x0, %al
callq 0x1140
movq 0xd8(%rsp), %rdi
callq 0x1180
movq 0xe0(%rsp), %rax
movq 0x10(%rax), %rdi
callq 0x1f6a0
movq %rax, 0x58(%rsp)
movq 0x58(%rsp), %rdi
movq 0x68(%rsp), %rax
movl 0x20(%rax), %esi
callq 0x2c9e0
movq 0x60(%rsp), %rdi
movq 0x68(%rsp), %rsi
movq 0x98(%rsp), %rcx
movq 0x80(%rsp), %r8
movq 0xc0(%rsp), %r9
movsd 0x78(%rsp), %xmm0
movq 0xd8(%rsp), %r11
movq 0xe0(%rsp), %r10
movq 0xe8(%rsp), %rax
xorl %edx, %edx
leaq 0x58(%rsp), %rbx
movl $0x1, (%rsp)
movq %rbx, 0x8(%rsp)
movq %r11, 0x10(%rsp)
movq %r10, 0x18(%rsp)
movq %rax, 0x20(%rsp)
callq 0x1e440
movq %rax, 0x50(%rsp)
movq 0x58(%rsp), %rdi
movq 0xd0(%rsp), %rsi
movq 0xe8(%rsp), %rdx
callq 0x2d770
movq 0xd0(%rsp), %rdi
callq 0x1180
movq 0x50(%rsp), %rdi
movq 0xc8(%rsp), %rsi
callq 0x2fce0
movq 0xc8(%rsp), %rdi
callq 0x1180
movq 0xe0(%rsp), %rdi
movq 0x68(%rsp), %rsi
callq 0x2d3c0
cmpq $0x0, 0x60(%rsp)
je 0x1e3c9
movq 0x60(%rsp), %rax
movq 0x10(%rax), %rax
movq %rax, 0x40(%rsp)
movq 0x60(%rsp), %rdi
movq 0xe0(%rsp), %rsi
callq 0x2fed0
movq 0x40(%rsp), %rax
movq %rax, 0x60(%rsp)
jmp 0x1e395
movq 0x58(%rsp), %rax
movq %rax, 0x68(%rsp)
movq 0x50(%rsp), %rax
movq %rax, 0x60(%rsp)
movq 0x48(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x48(%rsp)
jmp 0x1e24f
movq 0xe0(%rsp), %rdi
movq 0x68(%rsp), %rsi
callq 0x2d3c0
cmpq $0x0, 0x60(%rsp)
je 0x1e436
movq 0x60(%rsp), %rax
movq 0x10(%rax), %rax
movq %rax, 0x38(%rsp)
movq 0x60(%rsp), %rdi
movq 0xe0(%rsp), %rsi
callq 0x2fed0
movq 0x38(%rsp), %rax
movq %rax, 0x60(%rsp)
jmp 0x1e402
addq $0xb0, %rsp
popq %rbx
retq
nop