// File: /workspace/github_c_makefile_star2_O0/pwelke[P]GraphMiningTools/lwm_miningAndExtension.c
// Function: BFSStrategy
void BFSStrategy(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) {

	// 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 = _BFSgetNextLevel(previousLevelSupportSets, previousLevelSearchTree, threshold, extensionEdges, embeddingOperator, importance, &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;
	}

//	madness(currentLevelSupportSets, currentLevelSearchTree, extensionEdges, maxPatternSize, threshold, &previousLevelSupportSets, &previousLevelSearchTree, featureStream, patternStream, logStream, gp, sgp);

	// 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:
subq $0x98, %rsp
movq 0xc8(%rsp), %rax
movq 0xc0(%rsp), %rax
movq 0xb8(%rsp), %rax
movq 0xb0(%rsp), %rax
movq 0xa8(%rsp), %rax
movq 0xa0(%rsp), %rax
movq %rdi, 0x90(%rsp)
movq %rsi, 0x88(%rsp)
movq %rdx, 0x80(%rsp)
movq %rcx, 0x78(%rsp)
movq %r8, 0x70(%rsp)
movq %r9, 0x68(%rsp)
movsd %xmm0, 0x60(%rsp)
movq 0x78(%rsp), %rdi
movq 0xc0(%rsp), %rsi
callq 0x2d440
movq %rax, 0x58(%rsp)
movq 0x70(%rsp), %rax
movq %rax, 0x50(%rsp)
movq 0x58(%rsp), %rax
movq %rax, 0x48(%rsp)
movq 0x50(%rsp), %rax
movq %rax, 0x40(%rsp)
movq 0x90(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x38(%rsp)
movq 0x38(%rsp), %rcx
xorl %eax, %eax
cmpq 0x88(%rsp), %rcx
movb %al, 0x27(%rsp)
ja 0x1cdbf
movq 0x58(%rsp), %rax
cmpl $0x0, 0x18(%rax)
setg %al
movb %al, 0x27(%rsp)
movb 0x27(%rsp), %al
testb $0x1, %al
jne 0x1cdcc
jmp 0x1cf29
movq 0xb8(%rsp), %rdi
movq 0x38(%rsp), %rdx
leaq 0x18bba(%rip), %rsi     # 0x3599a
movb $0x0, %al
callq 0x1140
movq 0xb8(%rsp), %rdi
callq 0x1180
movq 0xc0(%rsp), %rax
movq 0x10(%rax), %rdi
callq 0x1f6a0
movq %rax, 0x48(%rsp)
movq 0x48(%rsp), %rdi
movq 0x58(%rsp), %rax
movl 0x20(%rax), %esi
callq 0x2c9e0
movq 0x50(%rsp), %rdi
movq 0x58(%rsp), %rsi
movq 0x80(%rsp), %rdx
movq 0x68(%rsp), %rcx
movq 0xa0(%rsp), %r8
movsd 0x60(%rsp), %xmm0
movq 0xb8(%rsp), %r11
movq 0xc0(%rsp), %r10
movq 0xc8(%rsp), %rax
leaq 0x48(%rsp), %r9
movq %r11, (%rsp)
movq %r10, 0x8(%rsp)
movq %rax, 0x10(%rsp)
callq 0x1cf80
movq %rax, 0x40(%rsp)
movq 0x48(%rsp), %rdi
movq 0xb0(%rsp), %rsi
movq 0xc8(%rsp), %rdx
callq 0x2d770
movq 0xb0(%rsp), %rdi
callq 0x1180
movq 0x40(%rsp), %rdi
movq 0xa8(%rsp), %rsi
callq 0x2fce0
movq 0xa8(%rsp), %rdi
callq 0x1180
movq 0xc0(%rsp), %rdi
movq 0x58(%rsp), %rsi
callq 0x2d3c0
cmpq $0x0, 0x50(%rsp)
je 0x1cf02
movq 0x50(%rsp), %rax
movq 0x10(%rax), %rax
movq %rax, 0x30(%rsp)
movq 0x50(%rsp), %rdi
movq 0xc0(%rsp), %rsi
callq 0x2fed0
movq 0x30(%rsp), %rax
movq %rax, 0x50(%rsp)
jmp 0x1cece
movq 0x48(%rsp), %rax
movq %rax, 0x58(%rsp)
movq 0x40(%rsp), %rax
movq %rax, 0x50(%rsp)
movq 0x38(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x38(%rsp)
jmp 0x1cd9a
movq 0xc0(%rsp), %rdi
movq 0x58(%rsp), %rsi
callq 0x2d3c0
cmpq $0x0, 0x50(%rsp)
je 0x1cf6f
movq 0x50(%rsp), %rax
movq 0x10(%rax), %rax
movq %rax, 0x28(%rsp)
movq 0x50(%rsp), %rdi
movq 0xc0(%rsp), %rsi
callq 0x2fed0
movq 0x28(%rsp), %rax
movq %rax, 0x50(%rsp)
jmp 0x1cf3b
addq $0x98, %rsp
retq
nopw (%rax,%rax)