// File: /workspace/github_c_makefile_star2_O1/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, %rbp
movl %r8d, 0x1c(%rsp)
movq %rcx, %r14
movq %rdx, %rbx
movl %esi, %r12d
movq %rdi, %r13
movq %rdx, %rsi
callq 0xb2bf
movq %rax, %rdi
movq %r13, %rsi
movq %r14, %rdx
movq %rbx, %rcx
callq 0x174ea
movq %rax, %r15
cmpl $-0x1, %r12d
jne 0x16670
movl (%r13), %r12d
testq %r15, %r15
je 0x169b2
movq %rbp, 0x20(%rsp)
movq 0x68(%rsp), %rbp
movq (%r15), %rdi
movl %r12d, %esi
movq %rbx, %rdx
callq 0x1df8c
movq %rax, %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x1b712
movq %rax, %rsi
movl $0x0, 0xc(%rsp)
movq 0x8(%r15), %rdi
testq %rdi, %rdi
movq %rax, (%rsp)
je 0x16761
movl %r12d, %esi
movq %rbx, %rdx
callq 0x1df8c
movq %rax, %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x1b712
movq (%rsp), %rdx
movq %rax, %r12
movl 0x18(%rax), %eax
addl 0x18(%rdx), %eax
cmpl (%rbp), %eax
jle 0x16724
movq 0x60(%rsp), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x166fc
callq 0x1030
movq (%rsp), %rdx
movl 0x18(%r12), %edi
addl 0x18(%rdx), %edi
callq 0x1ae92
movq (%rsp), %rdx
movq 0x60(%rsp), %rcx
movq %rax, (%rcx)
movl 0x18(%r12), %eax
addl 0x18(%rdx), %eax
movq 0x68(%rsp), %rcx
movl %eax, (%rcx)
movq 0x60(%rsp), %rax
movq (%rax), %rcx
leaq 0xc(%rsp), %r8
movq %rdx, %rdi
movq %r12, %rsi
movl $0x1, %edx
movq (%rsp), %r9
pushq %r14
pushq $0x0
callq 0x1b4e4
addq $0x10, %rsp
movq %r14, %rdi
movq %r12, %rsi
callq 0x1b644
movq (%rsp), %rsi
movq 0x68(%rsp), %rbp
movq %rbx, 0x10(%rsp)
movl 0x18(%rsi), %eax
cmpl (%rbp), %eax
jle 0x16799
movq 0x60(%rsp), %rbx
movq (%rbx), %rdi
testq %rdi, %rdi
je 0x16784
callq 0x1030
movq (%rsp), %rsi
movl 0x18(%rsi), %edi
callq 0x1ae92
movq (%rsp), %rsi
movq %rax, (%rbx)
movl 0x18(%rsi), %eax
movl %eax, (%rbp)
xorl %eax, %eax
leaq 0xc(%rsp), %r12
movl %eax, (%r12)
movq 0x60(%rsp), %rbx
movq (%rbx), %rcx
movq 0x20(%rsp), %rdi
movl $0x1, %edx
movq %r12, %r8
movq %rdi, %r9
pushq %r14
pushq %rax
callq 0x1afe3
addq $0x10, %rsp
movq (%rbx), %rdi
movslq (%r12), %rsi
leaq 0x46cc(%rip), %rcx      # 0x1aea2
movl $0xc, %edx
callq 0x1080
movsbl 0x1c(%rsp), %ecx
leal -0x61(%rcx), %eax
cmpl $0xe, %eax
ja 0x1686a
leaq 0xa4c8(%rip), %rcx      # 0x20cbc
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
movq 0x10(%rsp), %rbx
jmpq *%rax
movl 0xc(%r13), %esi
leaq 0xad9d(%rip), %rdi      # 0x215aa
xorl %eax, %eax
callq 0x10b0
cmpl $0x0, 0xc(%rsp)
movq 0x60(%rsp), %rbx
jle 0x16856
movl $0x4, %r13d
leaq 0x98ab(%rip), %r12      # 0x200d8
xorl %ebp, %ebp
movq (%rbx), %rax
movl -0x4(%rax,%r13), %esi
movl (%rax,%r13), %edx
movq %r12, %rdi
xorl %eax, %eax
callq 0x10b0
incq %rbp
movslq 0xc(%rsp), %rax
addq $0xc, %r13
cmpq %rax, %rbp
jl 0x1682f
movl $0xa, %edi
callq 0x1040
movq 0x10(%rsp), %rbx
jmp 0x16998
cmpl $0x76, %ecx
movq 0x10(%rsp), %rbx
jne 0x16998
movl (%r13), %edx
jmp 0x16986
movl 0x8(%r13), %esi
movq (%rsp), %rax
testq %rax, %rax
je 0x16934
movl 0x18(%rax), %eax
movl %eax, %edx
shrl $0x1f, %edx
addl %eax, %edx
sarl %edx
jmp 0x1698a
movl 0x8(%r13), %esi
leaq 0xa73d(%rip), %rdi      # 0x20feb
movl $0x1, %edx
jmp 0x16991
movl 0x8(%r13), %esi
leaq 0xace7(%rip), %rdi      # 0x215aa
xorl %eax, %eax
callq 0x10b0
cmpq $0x0, 0x8(%r15)
je 0x16944
movq 0x8(%r15), %rax
cmpl $0x0, (%rax)
jle 0x16952
leaq 0xacc8(%rip), %r12      # 0x215a9
xorl %ebp, %ebp
movq 0x10(%r15), %rax
movq (%rax,%rbp,8), %rdi
movq %r14, %rsi
callq 0x81e0
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 0x14832
incq %rbp
movq 0x8(%r15), %rax
movslq (%rax), %rax
cmpq %rax, %rbp
jl 0x168e3
jmp 0x16952
movq 0x8(%r15), %rax
testq %rax, %rax
je 0x1695e
movl (%rax), %edx
jmp 0x16960
movl 0x4(%r13), %edx
jmp 0x16986
leaq 0x97a4(%rip), %rdi      # 0x200df
xorl %eax, %eax
callq 0x10b0
jmp 0x16998
leaq 0xa3e9(%rip), %rdi      # 0x20d34
xorl %eax, %eax
callq 0x10b0
movl $0xa, %edi
callq 0x1040
jmp 0x16998
xorl %edx, %edx
movq (%r15), %rcx
testq %rcx, %rcx
je 0x16986
movslq (%rcx), %rax
testq %rax, %rax
jle 0x16986
movq 0x10(%rcx), %rcx
xorl %esi, %esi
cmpq $0x1, (%rcx,%rsi,8)
sbbl $-0x1, %edx
incq %rsi
cmpq %rsi, %rax
jne 0x16976
movl 0x8(%r13), %esi
leaq 0xa65a(%rip), %rdi      # 0x20feb
xorl %eax, %eax
callq 0x10b0
movq %r14, %rdi
movq (%rsp), %rsi
callq 0x1b644
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x173f3
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq