// File: /workspace/github_c_makefile_star2_O2/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xc8, %rsp
movsd %xmm0, 0x98(%rsp)
movq %r9, 0x88(%rsp)
movq %r8, %r14
movq %rdx, 0x70(%rsp)
movq %rsi, 0x80(%rsp)
movq %rdi, %r15
movq 0x120(%rsp), %r13
movq %rcx, %rdi
movq %r13, %rsi
callq 0x18e1c
movq %rax, %r12
incq %r15
cmpq 0x80(%rsp), %r15
ja 0x10308
cmpl $0x0, 0x18(%r12)
jle 0x10308
movq $0x0, 0x40(%rsp)
movq 0x118(%rsp), %rbx
movq %rbx, %rdi
leaq 0xda92(%rip), %rsi      # 0x1d94d
movq %r15, 0x60(%rsp)
movq %r15, %rdx
xorl %eax, %eax
callq 0x1150
movq %rbx, %rdi
callq 0x1190
movq 0x10(%r13), %rdi
callq 0x114a5
movq %r12, 0x78(%rsp)
movl 0x20(%r12), %esi
movq %rax, 0x58(%rsp)
movq %rax, %rdi
callq 0x18943
movq 0x10(%r13), %rdi
callq 0x114a5
movq %rax, %r12
movq $0x0, 0x48(%rsp)
movq %r14, 0x68(%rsp)
movl $0x0, 0x38(%rsp)
movl $0x0, 0x3c(%rsp)
movl $0x0, 0x30(%rsp)
xorl %ebp, %ebp
testq %r14, %r14
je 0x1007c
movq %r14, 0x90(%rsp)
movq (%r14), %rax
movq 0x10(%rax), %rdi
movq %rdi, 0x50(%rsp)
movq 0x88(%rsp), %rsi
movq %r13, %rdx
movq 0x128(%rsp), %rcx
callq 0x1ac50
movq %rax, 0xa0(%rsp)
leaq 0xa0(%rsp), %rdi
callq 0x6404
movq %rax, %r14
testq %r14, %r14
je 0x1006b
movq %r14, %rdi
movq 0x128(%rsp), %r15
movq %r15, %rsi
callq 0x579f
movl 0x28(%r12), %ebx
movq %r12, %rdi
movq %rax, %rsi
movq %r13, %rdx
movq %r15, %rcx
callq 0x186c6
cmpl 0x28(%r12), %ebx
je 0x1001f
incl 0x30(%rsp)
movq %r14, %rdi
movq 0x78(%rsp), %rsi
movq %r13, %rdx
movq %r15, %rcx
callq 0x1ad7f
testq %rax, %rax
je 0x10017
movq %rax, %r13
incl 0x3c(%rsp)
movq 0x50(%rsp), %rax
movl 0x8(%rax), %edx
movq %r13, %rdi
movq 0x68(%rsp), %rsi
callq 0xfdec
movq %rax, %rbx
movq %r13, %rdi
callq 0x772d
movq 0x70(%rsp), %rax
cmpq %rax, 0x18(%rbx)
jae 0x10041
movq 0x120(%rsp), %r13
movq %r13, %rdi
movq %r14, %rsi
callq 0x1166e
movq %rbx, %rdi
callq 0x1a402
jmp 0x1002a
movq 0x120(%rsp), %r13
movq %r13, %rdi
movq %r14, %rsi
callq 0x1166e
leaq 0xa0(%rsp), %rdi
callq 0x6404
movq %rax, %r14
incl %ebp
jmp 0xff73
incl 0x38(%rsp)
movq 0x48(%rsp), %rax
movq %rax, 0x18(%r14)
movq 0x40(%rsp), %rax
movq %rax, 0x10(%rbx)
movq %rbx, 0x40(%rsp)
movq %r14, 0x48(%rsp)
movq 0x120(%rsp), %r13
jmp 0x1002a
movq 0x90(%rsp), %r14
movq 0x10(%r14), %r14
jmp 0xff26
movq %r13, %rdi
movq %r12, %rsi
callq 0x18dcd
movq 0x118(%rsp), %rdi
leaq 0xd8f6(%rip), %rsi      # 0x1d98c
movl %ebp, %edx
movl 0x30(%rsp), %ecx
movl 0x3c(%rsp), %r8d
movl 0x38(%rsp), %r9d
xorl %eax, %eax
callq 0x1150
movq 0x48(%rsp), %r14
movq 0x40(%rsp), %rbx
xorl %r12d, %r12d
movq $0x0, 0x30(%rsp)
movq 0x128(%rsp), %rbp
testq %rbx, %rbx
je 0x101dc
xorl %eax, %eax
callq 0x1a3dc
movq %rax, %r15
movq %rbx, %r13
movq (%r13), %r13
testq %r13, %r13
je 0x1018a
movq 0x20(%r13), %rax
movq %rax, 0x20(%rsp)
movups (%r13), %xmm0
movups 0x10(%r13), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
leaq 0xa0(%rsp), %rdi
movq %r14, %rsi
movsd 0x98(%rsp), %xmm0
movq 0x120(%rsp), %rdx
movq %rbp, %rcx
callq *0x100(%rsp)
cmpl $0x0, 0xc0(%rsp)
je 0x1016a
movq 0xc0(%rsp), %rax
movq %rax, 0x20(%rsp)
movups 0xa0(%rsp), %xmm0
movups 0xb0(%rsp), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
movq %r15, %rdi
callq 0x1a223
jmp 0x10181
movq 0xa8(%rsp), %rax
movq 0xb8(%rsp), %rdi
movl (%rax), %esi
callq 0x133ca
addq $0x28, %r13
jmp 0x100e1
movq 0x18(%r15), %rax
cmpq 0x70(%rsp), %rax
jae 0x101ac
andl $0x0, 0xc(%r14)
movq %r15, %rdi
callq 0x1a448
movq 0x120(%rsp), %r13
jmp 0x101cf
movl %eax, 0xc(%r14)
testq %r12, %r12
movq 0x120(%rsp), %r13
je 0x101c7
movq %r15, 0x10(%r12)
movq %r15, %r12
jmp 0x101cf
movq %r15, %r12
movq %r15, 0x30(%rsp)
movq 0x18(%r14), %r14
movq 0x10(%rbx), %rbx
jmp 0x100cb
movq 0x68(%rsp), %r14
movq 0x60(%rsp), %r15
movq 0x48(%rsp), %r12
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x10203
movq 0x10(%rdi), %rbx
callq 0x1a402
movq %rbx, %rdi
jmp 0x101f0
xorl %ebp, %ebp
testq %r12, %r12
je 0x1027b
movq 0x18(%r12), %rbx
andq $0x0, 0x18(%r12)
cmpl $0x0, 0xc(%r12)
jne 0x1022d
movq %r13, %rdi
movq %r12, %rsi
callq 0x1166e
movq %rbx, %r12
jmp 0x10205
incl %ebp
movl %ebp, 0x50(%rsp)
movq %r12, %rdi
movq %r12, %r15
movq 0x128(%rsp), %r12
movq %r12, %rsi
callq 0x579f
movl 0xc(%r15), %ecx
movl %ecx, 0x28(%rax)
movq 0x58(%rsp), %rbp
movq %rbp, %rdi
movq %rax, %rsi
movq %r13, %rdx
movq %r12, %rcx
callq 0x1871e
movl 0x20(%rbp), %eax
movl 0x50(%rsp), %ebp
movl %eax, 0x8(%r15)
movq 0x60(%rsp), %r15
movq %rbx, %r12
jmp 0x10205
movq 0x118(%rsp), %rdi
leaq 0xd6eb(%rip), %rsi      # 0x1d975
movl %ebp, %edx
xorl %eax, %eax
callq 0x1150
movq 0x58(%rsp), %r12
movq %r12, %rdi
movq 0x110(%rsp), %rbx
movq %rbx, %rsi
movq 0x128(%rsp), %rdx
callq 0x18fd2
movq %rbx, %rdi
callq 0x1190
movq 0x30(%rsp), %rdi
movq 0x108(%rsp), %rbx
movq %rbx, %rsi
callq 0x1a3b4
movq %rbx, %rdi
callq 0x1190
movq %r13, %rdi
movq 0x78(%rsp), %rsi
callq 0x18dcd
testq %r14, %r14
je 0x102fe
movq 0x10(%r14), %rbx
movq %r14, %rdi
movq %r13, %rsi
callq 0x1a4cd
movq %rbx, %r14
jmp 0x102e5
movq 0x30(%rsp), %r14
jmp 0xfe83
movq %r13, %rdi
movq %r12, %rsi
callq 0x18dcd
testq %r14, %r14
je 0x1032c
movq 0x10(%r14), %rbx
movq %r14, %rdi
movq %r13, %rsi
callq 0x1a4cd
movq %rbx, %r14
jmp 0x10313
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop