// File: /workspace/github_c_makefile_star2_O2/pwelke[P]GraphMiningTools/opk.c
// Function: outerplanarKernel
void outerplanarKernel(struct Graph *g, int depth, struct ShallowGraphPool *sgp, struct GraphPool *gp,
		char outputOptions, struct Vertex* globalTreeSet, struct compInfo** results, int* resSize) {

	struct ShallowGraph* biconnectedComponents = listBiconnectedComponents(g, sgp);
	struct BBTree* bbTree = createBlockAndBridgeTree(biconnectedComponents, g, gp, sgp);

	/* if the depth of dfs is not set to a constant, it will be n */
	if (depth == -1) {
		depth = g->n;
	}

	if (bbTree) {

		/* start a tree kernel on both bridge and block vertices */
		struct ShallowGraph* trees1 = bfsSubtreeEnumeration(bbTree->tree, depth, sgp);
		struct Vertex* searchTree = buildSearchTree(trees1, gp, sgp);

		int pos = 0;

		if (bbTree->blocks) {
			struct ShallowGraph* trees2 = bfsSubtreeEnumeration(bbTree->blocks, depth, sgp);
			struct Vertex* tmpSearchTree = buildSearchTree(trees2, gp, sgp);

			/* adjust storage size if necessary */
			if (searchTree->number + tmpSearchTree->number > *resSize) {
				if (*results) {
					free(*results);
				}
				*results = getResultVector(searchTree->number + tmpSearchTree->number);
				*resSize = searchTree->number + tmpSearchTree->number;
			}
			shallowMergeSearchTrees(searchTree, tmpSearchTree, 1, *results, &pos, searchTree, 0, gp);

			/* garbage collection */
			dumpSearchTree(gp, tmpSearchTree);

		}



		/* adjust storage size if necessary */
		if (searchTree->number > *resSize) {
			if (*results) {
				free(*results);
			}
			*results = getResultVector(searchTree->number);
			*resSize = searchTree->number;
		}



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


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

		/* output options */
		switch (outputOptions) {
		int i;
		int n;

		case 'a':
			/* "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");
			break;
		case 'o':
			printf("%i %i\n", g->number, (bbTree) ? 1 : 0);
			break;
		case 'c':
			/* returns the number of cycles found in the graph */
			if (searchTree)
				printf("%i %i\n", g->number, searchTree->number / 2);
			else
				printf("%i 0\n", g->number);
			break;
		case 'v':
			/* returns the number of vertices in the graph */
			printf("%i %i\n", g->number, g->n);
			break;
		case 'e':
			/* returns the number of edges in the graph */
			printf("%i %i\n", g->number, g->m);
			break;
		case 'b':
			/* returns the number of vertices in the bbtree */
			n = 0;
			if (bbTree) {
				if (bbTree->blocks) {
					n += bbTree->blocks->n;
				}
				if (bbTree->tree) {
					for (i=0; i<bbTree->tree->n; ++i) {
						if (bbTree->tree->vertices[i]) {
							++n;
						}
					}
				}
			} else {
				n = -1;
			}
			printf("%i %i\n", g->number, n);
			break;
		case 'd':
			printf("%i", g->number);
			if (bbTree->blocks) {
				for (i=0; i<bbTree->blocks->n; ++i) {
					struct Graph* tmpGraph = shallowGraphToGraph(bbTree->blockComponents[i], gp);
					printf(" %i", tmpGraph->m - tmpGraph->n);
					dumpGraph(gp, tmpGraph);
				}
			} else {
				printf(" -1");
			}
			printf("\n");
			break;
		}


		/* prelim garbage collection */
		dumpSearchTree(gp, searchTree);
		dumpBBTree(gp, sgp, bbTree);
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %r9, 0x20(%rsp)
movl %r8d, %ebp
movq %rcx, %r14
movq %rdx, %r13
movl %esi, %r12d
movq %rdi, %rbx
movq %rdx, %rsi
callq 0x8ccd
movq %rax, %rdi
movq %rbx, %rsi
movq %r14, %rdx
movq %r13, %rcx
callq 0x144be
movq %rax, %r15
cmpl $-0x1, %r12d
jne 0x136ff
movl (%rbx), %r12d
testq %r15, %r15
je 0x139f5
movq %rbx, 0x10(%rsp)
movl %ebp, 0xc(%rsp)
movq 0x68(%rsp), %rbx
movq 0x60(%rsp), %rbp
movq (%r15), %rdi
movl %r12d, %esi
movq %r13, %rdx
callq 0x1b29e
movq %rax, %rdi
movq %r14, %rsi
movq %r13, %rdx
callq 0x18e94
andl $0x0, 0x8(%rsp)
movq %rax, %rsi
movq 0x8(%r15), %rdi
testq %rdi, %rdi
movq %rax, (%rsp)
je 0x137ef
movl %r12d, %esi
movq %r13, %rdx
callq 0x1b29e
movq %rax, %rdi
movq %r14, %rsi
movq %r13, 0x18(%rsp)
movq %r13, %rdx
callq 0x18e94
movq (%rsp), %rdi
movq %rax, %r12
movl 0x18(%rax), %eax
addl 0x18(%rdi), %eax
movq (%rbp), %rcx
cmpl (%rbx), %eax
jle 0x137b6
movq %rcx, %rdi
callq 0x1030
movl 0x18(%r12), %edi
movq (%rsp), %rax
addl 0x18(%rax), %edi
callq 0x18655
movq (%rsp), %rdi
movq %rax, %rcx
movq %rax, (%rbp)
movl 0x18(%r12), %eax
addl 0x18(%rdi), %eax
movq %rbx, %r13
movl %eax, (%rbx)
jmp 0x137b9
movq %rbx, %r13
pushq $0x1
popq %rdx
leaq 0x8(%rsp), %r8
movq %r12, %rsi
movq (%rsp), %r9
pushq %r14
pushq $0x0
callq 0x18c73
popq %rax
popq %rcx
movq %r14, %rdi
movq %r12, %rsi
callq 0x18dcd
movq (%rsp), %rsi
movq 0x60(%rsp), %rbp
movq %r13, %rbx
movq 0x18(%rsp), %r13
movl 0x18(%rsi), %eax
movq (%rbp), %rcx
cmpl (%rbx), %eax
jle 0x1381e
movq %rcx, %rdi
callq 0x1030
movq (%rsp), %rax
movl 0x18(%rax), %edi
callq 0x18655
movq (%rsp), %rsi
movq %rax, %rcx
movq %rax, (%rbp)
movl 0x18(%rsi), %eax
movl %eax, (%rbx)
movq 0x10(%rsp), %rbx
leaq 0x8(%rsp), %r12
andl $0x0, (%r12)
pushq $0x1
popq %rdx
movq 0x20(%rsp), %rdi
movq %r12, %r8
movq %rdi, %r9
pushq %r14
pushq $0x0
callq 0x1877e
popq %rax
popq %rcx
movq (%rbp), %rdi
movslq (%r12), %rsi
leaq 0x4e0c(%rip), %rcx      # 0x18661
pushq $0xc
popq %rdx
callq 0x1080
movsbl 0xc(%rsp), %ecx
leal -0x61(%rcx), %eax
cmpl $0xe, %eax
ja 0x138d0
leaq 0xa417(%rip), %rcx      # 0x1dc88
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %rbx, %rax
movq %r13, %rbx
movl 0xc(%rax), %esi
leaq 0xacc0(%rip), %rdi      # 0x1e54a
xorl %eax, %eax
callq 0x10b0
pushq $0x4
popq %r13
leaq 0x983c(%rip), %r12      # 0x1d0d8
xorl %ebp, %ebp
movslq 0x8(%rsp), %rax
cmpq %rax, %rbp
jge 0x13994
movq 0x60(%rsp), %rax
movq (%rax), %rax
movl -0x4(%rax,%r13), %esi
movl (%rax,%r13), %edx
movq %r12, %rdi
xorl %eax, %eax
callq 0x10b0
incq %rbp
addq $0xc, %r13
jmp 0x1389e
cmpl $0x76, %ecx
jne 0x139db
movl (%rbx), %edx
jmp 0x139ca
movl 0x8(%rbx), %esi
movq (%rsp), %rax
movl 0x18(%rax), %eax
pushq $0x2
popq %rcx
cltd
idivl %ecx
leaq 0xa6c4(%rip), %rdi      # 0x1dfbb
movl %eax, %edx
jmp 0x139d4
movl 0x8(%rbx), %esi
leaq 0xa6b3(%rip), %rdi      # 0x1dfbb
pushq $0x1
popq %rdx
jmp 0x139d4
movl 0x8(%rbx), %esi
leaq 0xac30(%rip), %rdi      # 0x1e54a
xorl %eax, %eax
callq 0x10b0
movq 0x8(%r15), %rax
movq %r13, %rbx
testq %rax, %rax
je 0x13986
leaq 0xac15(%rip), %r12      # 0x1e549
xorl %ebp, %ebp
movslq (%rax), %rax
cmpq %rax, %rbp
jge 0x13994
movq 0x10(%r15), %rax
movq (%rax,%rbp,8), %rdi
movq %r14, %rsi
callq 0x5fe8
movq %rax, %r13
movl 0x4(%rax), %esi
subl (%rax), %esi
movq %r12, %rdi
xorl %eax, %eax
callq 0x10b0
movq %r14, %rdi
movq %r13, %rsi
callq 0x1166e
incq %rbp
movq 0x8(%r15), %rax
jmp 0x13936
movq 0x8(%r15), %rax
testq %rax, %rax
je 0x139a1
movl (%rax), %edx
jmp 0x139a3
movl 0x4(%rbx), %edx
jmp 0x139ca
leaq 0xa373(%rip), %rdi      # 0x1dd00
xorl %eax, %eax
callq 0x10b0
pushq $0xa
popq %rdi
callq 0x1040
movq %rbx, %r13
jmp 0x139db
xorl %edx, %edx
movq (%r15), %rax
testq %rax, %rax
je 0x139ca
movl (%rax), %ecx
xorl %esi, %esi
testl %ecx, %ecx
cmovlel %esi, %ecx
cmpq %rsi, %rcx
je 0x139ca
movq 0x10(%rax), %rdi
cmpq $0x1, (%rdi,%rsi,8)
sbbl $-0x1, %edx
incq %rsi
jmp 0x139b4
movl 0x8(%rbx), %esi
leaq 0xa5e7(%rip), %rdi      # 0x1dfbb
xorl %eax, %eax
callq 0x10b0
movq %r14, %rdi
movq (%rsp), %rsi
callq 0x18dcd
movq %r14, %rdi
movq %r13, %rsi
movq %r15, %rdx
callq 0x143d1
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq