// File: /workspace/github_c_makefile_star2_O3/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %r9, %r14
movq %r8, %r15
movq %rcx, 0x8(%rsp)
movq %rdx, %rbx
movq %rsi, %r13
movq %rdi, %rbp
movl $0x0, 0x4(%rsp)
callq 0xb23b
movq %rax, %rdi
movq %rbp, %rsi
movq %rbx, %rdx
movq %r13, %rcx
callq 0xb57c
movq 0x18(%rax), %r12
movq %rax, 0x20(%rsp)
movq %rax, %rdi
movq %r13, %rsi
callq 0x77e2
movq %rax, %rdi
movq %rbx, %rsi
movq %r13, %rdx
callq 0x1b614
movl 0x18(%rax), %r13d
movq (%r15), %rcx
movq %r14, 0x18(%rsp)
cmpl (%r14), %r13d
movq %rax, 0x10(%rsp)
jle 0x59f3
testq %rcx, %rcx
je 0x59d8
movq %rcx, %rdi
callq 0x1030
movl %r13d, %edi
callq 0x1ada1
movq %rax, %rcx
movq %rax, (%r15)
movq 0x18(%rsp), %rax
movl %r13d, (%rax)
movq 0x10(%rsp), %rax
movq 0x8(%rsp), %rdi
leaq 0x4(%rsp), %r13
movq %rax, %rsi
movl $0x1, %edx
movq %r13, %r8
movq %rdi, %r9
pushq %rbx
pushq $0x0
callq 0x1aefc
addq $0x10, %rsp
movq (%r15), %rdi
movslq (%r13), %rsi
leaq 0x1538c(%rip), %rcx     # 0x1adb1
movl $0xc, %edx
callq 0x1080
movl 0xc(%rbp), %esi
leaq 0x1bb71(%rip), %rdi     # 0x215aa
xorl %eax, %eax
callq 0x10b0
cmpl $0x0, (%r13)
jle 0x5a7d
movl $0x4, %r13d
leaq 0x1a684(%rip), %r14     # 0x200d8
xorl %ebp, %ebp
movq (%r15), %rax
movl -0x4(%rax,%r13), %esi
movl (%rax,%r13), %edx
movq %r14, %rdi
xorl %eax, %eax
callq 0x10b0
incq %rbp
movslq 0x4(%rsp), %rax
addq $0xc, %r13
cmpq %rax, %rbp
jl 0x5a56
movl $0xa, %edi
callq 0x1040
testq %r12, %r12
je 0x5aa4
movq 0x18(%r12), %r14
movq %rbx, %rdi
movq %r12, %rsi
callq 0x14700
movq %r14, %r12
testq %r14, %r14
jne 0x5a8c
movq %rbx, %rdi
movq 0x10(%rsp), %rsi
callq 0x1b546
movq %rbx, %rdi
movq 0x20(%rsp), %rsi
callq 0x14700
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop