// File: /workspace/github_c_makefile_star2_O1/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, 0x30(%rsp)
movq %rdx, 0x68(%rsp)
movq %rsi, %rbx
movq %rdi, %r14
movq 0x120(%rsp), %r15
movq %rcx, %rdi
movq %r15, %rsi
callq 0x1b696
movq %r14, %rdx
movq %rax, %r13
incq %rdx
movq %rbx, 0x70(%rsp)
cmpq %rbx, %rdx
ja 0x13190
movq 0x128(%rsp), %r12
movq 0x30(%rsp), %rbp
cmpl $0x0, 0x18(%r13)
jle 0x1318b
movq 0x118(%rsp), %rbx
movq %rbx, %rdi
leaq 0xdc95(%rip), %rsi      # 0x20982
movq %rdx, 0x80(%rsp)
xorl %eax, %eax
callq 0x1160
movq %rbx, %rdi
callq 0x11a0
movq 0x10(%r15), %rdi
callq 0x145b2
movq %r13, 0x58(%rsp)
movl 0x20(%r13), %esi
movq %rax, 0x78(%rsp)
movq %rax, %rdi
callq 0x1b1ae
movq 0x10(%r15), %rdi
callq 0x145b2
movq %rax, %r13
testq %rbp, %rbp
movq %rbp, 0x60(%rsp)
je 0x12ed7
movq %rbp, %rax
movq $0x0, 0x40(%rsp)
movq $0x0, 0x38(%rsp)
xorl %ebp, %ebp
movl $0x0, 0x48(%rsp)
movl $0x0, 0x4c(%rsp)
movq $0x0, 0x50(%rsp)
leaq 0xa0(%rsp), %r14
movq %rax, 0x90(%rsp)
movq (%rax), %rax
movq 0x10(%rax), %rdi
movq %rdi, 0x30(%rsp)
movq 0x88(%rsp), %rsi
movq %r15, %rdx
movq %r12, %rcx
callq 0x1d8e5
movq %rax, 0xa0(%rsp)
movq %r14, %rdi
callq 0x864a
movq %rax, %r12
testq %rax, %rax
je 0x12eb8
movq %r12, %rdi
movq 0x128(%rsp), %r14
movq %r14, %rsi
callq 0x78fc
movl 0x28(%r13), %ebx
movq %r13, %rdi
movq %rax, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x1af0f
cmpl 0x28(%r13), %ebx
jne 0x12dea
xorl %ebx, %ebx
jmp 0x12e04
incl 0x48(%rsp)
movq %r12, %rdi
movq 0x58(%rsp), %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x1da2d
movq %rax, %rbx
testq %rbx, %rbx
leaq 0xa0(%rsp), %r14
je 0x12e5a
incl 0x4c(%rsp)
movq 0x30(%rsp), %rax
movl 0x8(%rax), %edx
movq %rbx, %rdi
movq 0x60(%rsp), %rsi
callq 0x12c18
movq %rax, %r15
movq %rbx, %rdi
callq 0x9b14
movq 0x68(%rsp), %rax
cmpq %rax, 0x18(%r15)
jae 0x12e71
movq 0x120(%rsp), %rdi
movq %r12, %rsi
callq 0x14832
movq %r15, %rdi
callq 0x1cfb1
jmp 0x12e65
movq %r15, %rdi
movq %r12, %rsi
callq 0x14832
movq 0x40(%rsp), %r15
movq 0x38(%rsp), %r12
jmp 0x12e90
movq 0x50(%rsp), %rax
incl %eax
movq %rax, 0x50(%rsp)
movq 0x38(%rsp), %rax
movq %rax, 0x18(%r12)
movq 0x40(%rsp), %rax
movq %rax, 0x10(%r15)
movq %r14, %rdi
callq 0x864a
movq %r12, 0x38(%rsp)
incl %ebp
movq %r15, 0x40(%rsp)
movq %rax, %r12
testq %rax, %rax
movq 0x120(%rsp), %r15
jne 0x12db8
movq 0x90(%rsp), %rax
movq 0x10(%rax), %rax
testq %rax, %rax
movq 0x128(%rsp), %r12
jne 0x12d75
jmp 0x12f0c
movq $0x0, 0x50(%rsp)
movq $0x0, 0x40(%rsp)
movq $0x0, 0x38(%rsp)
movl $0x0, 0x4c(%rsp)
movl $0x0, 0x48(%rsp)
xorl %ebp, %ebp
leaq 0xa0(%rsp), %r14
movq %r15, %rdi
movq %r13, %rsi
callq 0x1b644
movq 0x118(%rsp), %rdi
leaq 0xda9b(%rip), %rsi      # 0x209c1
movl %ebp, %edx
movl 0x48(%rsp), %ecx
movl 0x4c(%rsp), %r8d
movq 0x50(%rsp), %r9
xorl %eax, %eax
callq 0x1160
movq 0x40(%rsp), %rbx
testq %rbx, %rbx
je 0x13057
movq $0x0, 0x30(%rsp)
xorl %r13d, %r13d
movq 0x38(%rsp), %r15
xorl %eax, %eax
callq 0x1cf87
movq %rax, %r12
movq (%rbx), %rbp
testq %rbp, %rbp
je 0x1300c
movq 0x20(%rbp), %rax
movq %rax, 0x20(%rsp)
movups (%rbp), %xmm0
movups 0x10(%rbp), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
movq %r14, %rdi
movq %r15, %rsi
movsd 0x98(%rsp), %xmm0
movq 0x120(%rsp), %rdx
movq 0x128(%rsp), %rcx
callq *0x100(%rsp)
cmpl $0x0, 0xc0(%rsp)
je 0x12fec
movq 0xc0(%rsp), %rax
movq %rax, 0x20(%rsp)
movups 0xa0(%rsp), %xmm0
movups 0xb0(%rsp), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
movq %r12, %rdi
callq 0x1cd7a
jmp 0x13003
movq 0xa8(%rsp), %rax
movq 0xb8(%rsp), %rdi
movl (%rax), %esi
callq 0x1631f
movq 0x28(%rbp), %rbp
jmp 0x12f69
movq 0x18(%r12), %rax
cmpq 0x68(%rsp), %rax
jae 0x1302a
movl $0x0, 0xc(%r15)
movq %r12, %rdi
callq 0x1cff7
jmp 0x13044
movl %eax, 0xc(%r15)
testq %r13, %r13
je 0x1303c
movq %r12, 0x10(%r13)
movq %r12, %r13
jmp 0x13044
movq %r12, %r13
movq %r12, 0x30(%rsp)
movq 0x18(%r15), %r15
movq 0x10(%rbx), %rbx
testq %rbx, %rbx
jne 0x12f5c
jmp 0x13060
movq $0x0, 0x30(%rsp)
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x1307b
movq 0x10(%rdi), %rbx
callq 0x1cfb1
movq %rbx, %rdi
testq %rbx, %rbx
jne 0x1306a
movq 0x38(%rsp), %r14
testq %r14, %r14
movq 0x120(%rsp), %r15
movq 0x128(%rsp), %r12
movq 0x78(%rsp), %r13
je 0x130f3
xorl %ebp, %ebp
movq 0x18(%r14), %rbx
movq $0x0, 0x18(%r14)
cmpl $0x0, 0xc(%r14)
je 0x130de
incl %ebp
movq %r14, %rdi
movq %r12, %rsi
callq 0x78fc
movl 0xc(%r14), %ecx
movl %ecx, 0x28(%rax)
movq %r13, %rdi
movq %rax, %rsi
movq %r15, %rdx
movq %r12, %rcx
callq 0x1af75
movl 0x20(%r13), %eax
movl %eax, 0x8(%r14)
jmp 0x130e9
movq %r15, %rdi
movq %r14, %rsi
callq 0x14832
movq %rbx, %r14
testq %rbx, %rbx
jne 0x1309c
jmp 0x130f5
xorl %ebp, %ebp
movq 0x118(%rsp), %rdi
leaq 0xd8a6(%rip), %rsi      # 0x209aa
movl %ebp, %edx
xorl %eax, %eax
callq 0x1160
movq %r13, %rdi
movq 0x110(%rsp), %rbx
movq %rbx, %rsi
movq %r12, %rdx
callq 0x1b857
movq %rbx, %rdi
callq 0x11a0
movq 0x30(%rsp), %rdi
movq 0x108(%rsp), %rbx
movq %rbx, %rsi
callq 0x1cf5c
movq %rbx, %rdi
callq 0x11a0
movq %r15, %rdi
movq 0x58(%rsp), %rsi
callq 0x1b644
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0x13173
movq 0x10(%rdi), %rbx
movq %r15, %rsi
callq 0x1d07c
movq %rbx, %rdi
testq %rbx, %rbx
jne 0x1315f
movq 0x80(%rsp), %rdx
incq %rdx
cmpq 0x70(%rsp), %rdx
jbe 0x12ccb
jmp 0x13190
movq %rbp, 0x30(%rsp)
movq %r15, %rdi
movq %r13, %rsi
callq 0x1b644
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x131b9
movq 0x10(%rdi), %rbx
movq %r15, %rsi
callq 0x1d07c
movq %rbx, %rdi
testq %rbx, %rbx
jne 0x131a5
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop