// File: /workspace/github_c_makefile_star2_O0/pwelke[P]GraphMiningTools/lwmr_miningAndExtension.c
// Function: DFSStrategyRooted
void DFSStrategyRooted(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 dontUseApriori = 0;

	// init an array of searchtrees, one for each level
	// this should speed up the alg but will increase memory consumption in the long run
	struct Vertex** levelSearchTrees = malloc(maxPatternSize * sizeof(struct Vertex*));
	for (size_t i=0; i<maxPatternSize; ++i) {
		if (i != startPatternSize - 1) {
			levelSearchTrees[i] = getVertex(gp->vertexPool);
		} else {
			levelSearchTrees[i] = initialFrequentPatterns;
		}
	}

	// the frontier of candidate patterns
	struct SupportSet* candidateSupportSetStack = supportSets;
	size_t patternID = initialFrequentPatterns->lowPoint;

	while (candidateSupportSetStack) {

		// support set of current pattern, pattern, and pattern size
		struct SupportSet* currentPatternSupport = popSupportSet(&candidateSupportSetStack);
		struct Graph *currentPattern = currentPatternSupport->first->data.h;
		size_t currentPatternSize = currentPattern->n;

		// we extend all patterns that have at most maxPatternSize - 1 vertices
		if (currentPatternSize < maxPatternSize) {

			// logging
			fprintf(logStream, "Processing pattern %i with %zu vertices:\n", currentPattern->number, currentPatternSize);
			fflush(logStream);

			// extend current pattern and check frequencies
			struct Vertex* newFrequentPatternSearchTree = getVertex(gp->vertexPool);
			offsetSearchTreeIds(newFrequentPatternSearchTree, patternID);
			// TODO add infrequent patterns to some other search tree and output.
			struct SupportSet *newSupportSets = _getNextLevelRooted(currentPatternSupport, levelSearchTrees[currentPatternSize - 1], levelSearchTrees[currentPatternSize], threshold, extensionEdges, embeddingOperator, importance, dontUseApriori, &newFrequentPatternSearchTree, logStream, gp, sgp);
			patternID = newFrequentPatternSearchTree->lowPoint;

			// print frequent patterns
			printStringsInSearchTree(newFrequentPatternSearchTree, patternStream, sgp);
			fflush(patternStream);
			printSupportSetsSparse(newSupportSets, featureStream);
			fflush(featureStream);

			// add patterns to frequent pattern list and support sets to frontier
			mergeSearchTrees(levelSearchTrees[currentPatternSize], 
							 newFrequentPatternSearchTree, 
							 1, 
							 NULL, // &searchTreeHelper, don't need results here 
							 0, // &searchTreePosition, don't need results here
							 levelSearchTrees[currentPatternSize], 
							 0, 
							 gp);
			dumpSearchTree(gp, newFrequentPatternSearchTree);
			candidateSupportSetStack = appendSupportSets(newSupportSets, candidateSupportSetStack);
		} else {
			// dump support of the pattern, as this is not done by the extension
			dumpSupportSetCopy(currentPatternSupport);
			dumpGraph(gp, currentPattern);
		}
		if (currentPatternSize == 1) {
			// dumpSupportSet(currentPatternSupport);
			dumpGraph(gp, currentPattern);
		}
	}

	// garbage collection: TODO
	for (size_t i = 0; i < maxPatternSize; ++i) {
		if (i != startPatternSize - 1) {
			dumpSearchTree(gp, levelSearchTrees[i]);
		}
	}
	free(levelSearchTrees);
}

// Assembly:
pushq %rbx
subq $0xc0, %rsp
movq 0xf8(%rsp), %rax
movq 0xf0(%rsp), %rax
movq 0xe8(%rsp), %rax
movq 0xe0(%rsp), %rax
movq 0xd8(%rsp), %rax
movq 0xd0(%rsp), %rax
movq %rdi, 0xb8(%rsp)
movq %rsi, 0xb0(%rsp)
movq %rdx, 0xa8(%rsp)
movq %rcx, 0xa0(%rsp)
movq %r8, 0x98(%rsp)
movq %r9, 0x90(%rsp)
movsd %xmm0, 0x88(%rsp)
movb $0x0, 0x87(%rsp)
movq 0xb0(%rsp), %rdi
shlq $0x3, %rdi
callq 0x1170
movq %rax, 0x78(%rsp)
movq $0x0, 0x70(%rsp)
movq 0x70(%rsp), %rax
cmpq 0xb0(%rsp), %rax
jae 0x1ea49
movq 0x70(%rsp), %rax
movq 0xb8(%rsp), %rcx
subq $0x1, %rcx
cmpq %rcx, %rax
je 0x1ea21
movq 0xf0(%rsp), %rax
movq 0x10(%rax), %rdi
callq 0x1f6a0
movq %rax, %rdx
movq 0x78(%rsp), %rax
movq 0x70(%rsp), %rcx
movq %rdx, (%rax,%rcx,8)
jmp 0x1ea37
movq 0xa0(%rsp), %rdx
movq 0x78(%rsp), %rax
movq 0x70(%rsp), %rcx
movq %rdx, (%rax,%rcx,8)
jmp 0x1ea39
movq 0x70(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x70(%rsp)
jmp 0x1e9d8
movq 0x98(%rsp), %rax
movq %rax, 0x68(%rsp)
movq 0xa0(%rsp), %rax
movslq 0x20(%rax), %rax
movq %rax, 0x60(%rsp)
cmpq $0x0, 0x68(%rsp)
je 0x1ec94
leaq 0x68(%rsp), %rdi
callq 0x30410
movq %rax, 0x58(%rsp)
movq 0x58(%rsp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rax
movq %rax, 0x50(%rsp)
movq 0x50(%rsp), %rax
movslq (%rax), %rax
movq %rax, 0x48(%rsp)
movq 0x48(%rsp), %rax
cmpq 0xb0(%rsp), %rax
jae 0x1ec59
movq 0xe8(%rsp), %rdi
movq 0x50(%rsp), %rax
movl 0x8(%rax), %edx
movq 0x48(%rsp), %rcx
leaq 0x16f7f(%rip), %rsi     # 0x35a4e
movb $0x0, %al
callq 0x1140
movq 0xe8(%rsp), %rdi
callq 0x1180
movq 0xf0(%rsp), %rax
movq 0x10(%rax), %rdi
callq 0x1f6a0
movq %rax, 0x40(%rsp)
movq 0x40(%rsp), %rdi
movq 0x60(%rsp), %rax
movl %eax, %esi
callq 0x2c9e0
movq 0x58(%rsp), %rdi
movq 0x78(%rsp), %rax
movq 0x48(%rsp), %rcx
subq $0x1, %rcx
movq (%rax,%rcx,8), %rsi
movq 0x78(%rsp), %rax
movq 0x48(%rsp), %rcx
movq (%rax,%rcx,8), %rdx
movq 0xa8(%rsp), %rcx
movq 0x90(%rsp), %r8
movq 0xd0(%rsp), %r9
movsd 0x88(%rsp), %xmm0
movq 0xe8(%rsp), %r11
movq 0xf0(%rsp), %r10
movq 0xf8(%rsp), %rax
xorl %ebx, %ebx
leaq 0x40(%rsp), %rbx
movl $0x0, (%rsp)
movq %rbx, 0x8(%rsp)
movq %r11, 0x10(%rsp)
movq %r10, 0x18(%rsp)
movq %rax, 0x20(%rsp)
callq 0x1e440
movq %rax, 0x38(%rsp)
movq 0x40(%rsp), %rax
movslq 0x20(%rax), %rax
movq %rax, 0x60(%rsp)
movq 0x40(%rsp), %rdi
movq 0xe0(%rsp), %rsi
movq 0xf8(%rsp), %rdx
callq 0x2d770
movq 0xe0(%rsp), %rdi
callq 0x1180
movq 0x38(%rsp), %rdi
movq 0xd8(%rsp), %rsi
callq 0x2fce0
movq 0xd8(%rsp), %rdi
callq 0x1180
movq 0x78(%rsp), %rax
movq 0x48(%rsp), %rcx
movq (%rax,%rcx,8), %rdi
movq 0x40(%rsp), %rsi
movq 0x78(%rsp), %rax
movq 0x48(%rsp), %rcx
movq (%rax,%rcx,8), %r9
movq 0xf0(%rsp), %rax
movl $0x1, %edx
xorl %ecx, %ecx
movl %ecx, %r8d
xorl %ecx, %ecx
movq %r8, %rcx
movl $0x0, (%rsp)
movq %rax, 0x8(%rsp)
callq 0x2c650
movq 0xf0(%rsp), %rdi
movq 0x40(%rsp), %rsi
callq 0x2d3c0
movq 0x38(%rsp), %rdi
movq 0x68(%rsp), %rsi
callq 0x303b0
movq %rax, 0x68(%rsp)
jmp 0x1ec75
movq 0x58(%rsp), %rdi
callq 0x2fd70
movq 0xf0(%rsp), %rdi
movq 0x50(%rsp), %rsi
callq 0x1fb30
cmpq $0x1, 0x48(%rsp)
jne 0x1ec8f
movq 0xf0(%rsp), %rdi
movq 0x50(%rsp), %rsi
callq 0x1fb30
jmp 0x1ea67
movq $0x0, 0x30(%rsp)
movq 0x30(%rsp), %rax
cmpq 0xb0(%rsp), %rax
jae 0x1ecef
movq 0x30(%rsp), %rax
movq 0xb8(%rsp), %rcx
subq $0x1, %rcx
cmpq %rcx, %rax
je 0x1ecdd
movq 0xf0(%rsp), %rdi
movq 0x78(%rsp), %rax
movq 0x30(%rsp), %rcx
movq (%rax,%rcx,8), %rsi
callq 0x2d3c0
jmp 0x1ecdf
movq 0x30(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x30(%rsp)
jmp 0x1ec9d
movq 0x78(%rsp), %rdi
callq 0x1030
addq $0xc0, %rsp
popq %rbx
retq
nopw %cs:(%rax,%rax)