// File: /workspace/github_c_makefile_star2_O0/pwelke[P]GraphMiningTools/cpk.c
// Function: CyclicPatternKernel_onlyTrees
int CyclicPatternKernel_onlyTrees(struct Graph *g, struct ShallowGraphPool *sgp, struct GraphPool *gp,
		struct Vertex* globalPatternSet, struct compInfo** results, int* resSize) {
	struct Graph* tmp;
	struct Graph* idx;
	int pos = 0;
	int i;

	/* find biconnected Components */
	struct ShallowGraph* h = listBiconnectedComponents(g, sgp);
	struct Graph* forest = partitionIntoForestAndCycles(h, g, gp, sgp);
	/* TODO refactor */
	struct Graph* biconnectedComponents = forest->next;

	/* list tree patterns */
	struct ShallowGraph* treePatterns = getTreePatterns(forest, sgp);

	/* create search tree structure */
	struct Vertex* treePatternSearchTree = buildSearchTree(treePatterns, gp, sgp);
	int numTrees = treePatternSearchTree->number;

	if (numTrees > *resSize) {
		if (*results) {
			free(*results);
		}

		*results = getResultVector(numTrees);
		*resSize = numTrees;
	}

	/* add elements to global search trees to obtain mapping from strings to integers */
	mergeSearchTrees(globalPatternSet, treePatternSearchTree, 1, *results, &pos, globalPatternSet, 0, gp);

	/* sort the output elements by increasing id */
	qsort(*results, pos, sizeof(struct compInfo), &compInfoComparison);

	/* "all" output the feature vector for the current graph in the format specified
	 * by SVMlight g->activity is assumed to be either 0, 1 or -1 to be compliant with
	 * the specs of SVMlight.
	 */

	/* print the id and label of the graph */
	printf("%i", g->activity);

	/* print key:value pairs */
	for (i=0; i<pos; ++i) {
		printf(" %i:%i", (*results)[i].id, (*results)[i].count);
	}
	printf("\n");

	/* garbage collection */

	/* dump biconnected components list */
	for (idx=biconnectedComponents; idx; idx=tmp) {
		tmp = idx->next;
		dumpGraph(gp, idx);
	}

	dumpSearchTree(gp, treePatternSearchTree);
	dumpGraph(gp, forest);

	return 0;
}

// Assembly:
subq $0x88, %rsp
movq %rdi, 0x80(%rsp)
movq %rsi, 0x78(%rsp)
movq %rdx, 0x70(%rsp)
movq %rcx, 0x68(%rsp)
movq %r8, 0x60(%rsp)
movq %r9, 0x58(%rsp)
movl $0x0, 0x44(%rsp)
movq 0x80(%rsp), %rdi
movq 0x78(%rsp), %rsi
callq 0x10700
movq %rax, 0x38(%rsp)
movq 0x38(%rsp), %rdi
movq 0x80(%rsp), %rsi
movq 0x70(%rsp), %rdx
movq 0x78(%rsp), %rcx
callq 0x10d30
movq %rax, 0x30(%rsp)
movq 0x30(%rsp), %rax
movq 0x18(%rax), %rax
movq %rax, 0x28(%rsp)
movq 0x30(%rsp), %rdi
movq 0x78(%rsp), %rsi
callq 0x9c40
movq %rax, 0x20(%rsp)
movq 0x20(%rsp), %rdi
movq 0x70(%rsp), %rsi
movq 0x78(%rsp), %rdx
callq 0x2d520
movq %rax, 0x18(%rsp)
movq 0x18(%rsp), %rax
movl 0x18(%rax), %eax
movl %eax, 0x14(%rsp)
movl 0x14(%rsp), %eax
movq 0x58(%rsp), %rcx
cmpl (%rcx), %eax
jle 0x6113
movq 0x60(%rsp), %rax
cmpq $0x0, (%rax)
je 0x60f4
movq 0x60(%rsp), %rax
movq (%rax), %rdi
callq 0x1030
movl 0x14(%rsp), %edi
callq 0x2c430
movq %rax, %rcx
movq 0x60(%rsp), %rax
movq %rcx, (%rax)
movl 0x14(%rsp), %ecx
movq 0x58(%rsp), %rax
movl %ecx, (%rax)
movq 0x68(%rsp), %rdi
movq 0x18(%rsp), %rsi
movq 0x60(%rsp), %rax
movq (%rax), %rcx
movq 0x68(%rsp), %r9
movq 0x70(%rsp), %rax
movl $0x1, %edx
leaq 0x44(%rsp), %r8
xorl %r10d, %r10d
movl $0x0, (%rsp)
movq %rax, 0x8(%rsp)
callq 0x2c650
movq 0x60(%rsp), %rax
movq (%rax), %rdi
movslq 0x44(%rsp), %rsi
movl $0xc, %edx
leaq 0x262ea(%rip), %rcx     # 0x2c450
callq 0x1060
movq 0x80(%rsp), %rax
movl 0xc(%rax), %esi
leaq 0x30477(%rip), %rdi     # 0x365f4
movb $0x0, %al
callq 0x1090
movl $0x0, 0x40(%rsp)
movl 0x40(%rsp), %eax
cmpl 0x44(%rsp), %eax
jge 0x61de
movq 0x60(%rsp), %rax
movq (%rax), %rax
movslq 0x40(%rsp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %esi
movq 0x60(%rsp), %rax
movq (%rax), %rax
movslq 0x40(%rsp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movl 0x4(%rax), %edx
leaq 0x2ef66(%rip), %rdi     # 0x35130
movb $0x0, %al
callq 0x1090
movl 0x40(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x40(%rsp)
jmp 0x618c
leaq 0x2eed0(%rip), %rdi     # 0x350b5
movb $0x0, %al
callq 0x1090
movq 0x28(%rsp), %rax
movq %rax, 0x48(%rsp)
cmpq $0x0, 0x48(%rsp)
je 0x6227
movq 0x48(%rsp), %rax
movq 0x18(%rax), %rax
movq %rax, 0x50(%rsp)
movq 0x70(%rsp), %rdi
movq 0x48(%rsp), %rsi
callq 0x1fb30
movq 0x50(%rsp), %rax
movq %rax, 0x48(%rsp)
jmp 0x61f6
movq 0x70(%rsp), %rdi
movq 0x18(%rsp), %rsi
callq 0x2d3c0
movq 0x70(%rsp), %rdi
movq 0x30(%rsp), %rsi
callq 0x1fb30
xorl %eax, %eax
addq $0x88, %rsp
retq
nop