// File: /workspace/github_c_makefile_star2_O3/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 $0x38, %rsp
movq %r9, 0x30(%rsp)
movl %r8d, %ebp
movq %rcx, %r14
movq %rdx, %rbx
movl %esi, %r12d
movq %rdi, %r15
movq %rdx, %rsi
callq 0xb23b
movq %rax, %rdi
movq %r15, %rsi
movq %r14, %rdx
movq %rbx, %rcx
callq 0x173bf
cmpl $-0x1, %r12d
jne 0x16550
movl (%r15), %r12d
testq %rax, %rax
je 0x1689a
movq %r15, 0x8(%rsp)
movl %ebp, 0x24(%rsp)
movq %rax, %r13
movq 0x78(%rsp), %r15
movq 0x70(%rsp), %rbp
movq (%rax), %rdi
movl %r12d, %esi
movq %rbx, %rdx
callq 0x1de48
movq %rax, %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x1b614
movq %rax, %rsi
movl $0x0, 0x4(%rsp)
movq %r13, 0x28(%rsp)
movq 0x8(%r13), %rdi
testq %rdi, %rdi
movq %rax, 0x10(%rsp)
je 0x16650
movl %r12d, %esi
movq %rbx, %rdx
callq 0x1de48
movq %rax, %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x1b614
movq 0x10(%rsp), %rdx
movq %rax, %r12
movl 0x18(%rax), %edi
addl 0x18(%rdx), %edi
movq (%rbp), %rcx
cmpl (%r15), %edi
jle 0x1661e
movq %rbx, 0x18(%rsp)
movq %rbp, %rbx
testq %rcx, %rcx
movq %rdx, %rbp
je 0x165fd
movq %rcx, %rdi
callq 0x1030
movl 0x18(%r12), %edi
addl 0x18(%rbp), %edi
callq 0x1ada1
movq %rax, %rcx
movq %rax, (%rbx)
movl 0x18(%r12), %eax
addl 0x18(%rbp), %eax
movl %eax, (%r15)
movq %rbp, %rdx
movq %rbx, %rbp
movq 0x18(%rsp), %rbx
leaq 0x4(%rsp), %r8
movq %rdx, %rdi
movq %r12, %rsi
movl $0x1, %edx
movq 0x10(%rsp), %r9
pushq %r14
pushq $0x0
callq 0x1b3ee
addq $0x10, %rsp
movq %r14, %rdi
movq %r12, %rsi
callq 0x1b546
movq 0x10(%rsp), %rsi
movl 0x18(%rsi), %edi
movq (%rbp), %rcx
cmpl (%r15), %edi
jle 0x16688
testq %rcx, %rcx
movq %rsi, %r12
je 0x16671
movq %rcx, %rdi
callq 0x1030
movl 0x18(%r12), %edi
callq 0x1ada1
movq %rax, %rcx
movq %rax, (%rbp)
movl 0x18(%r12), %eax
movl %eax, (%r15)
movq %r12, %rsi
xorl %eax, %eax
leaq 0x4(%rsp), %r12
movl %eax, (%r12)
movq 0x30(%rsp), %rdi
movl $0x1, %edx
movq %r12, %r8
movq %rdi, %r9
pushq %r14
pushq %rax
callq 0x1aefc
addq $0x10, %rsp
movq (%rbp), %rdi
movslq (%r12), %rsi
leaq 0x46f3(%rip), %rcx      # 0x1adb1
movl $0xc, %edx
callq 0x1080
movsbl 0x24(%rsp), %ecx
leal -0x61(%rcx), %eax
cmpl $0xe, %eax
movq 0x28(%rsp), %r15
ja 0x16759
leaq 0xa5db(%rip), %rcx      # 0x20cbc
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %rbx, 0x18(%rsp)
movq 0x8(%rsp), %rax
movl 0xc(%rax), %esi
leaq 0xaeac(%rip), %rdi      # 0x215aa
xorl %eax, %eax
callq 0x10b0
cmpl $0x0, 0x4(%rsp)
jle 0x16745
movq %rbp, %rbx
movl $0x4, %r13d
leaq 0x99bc(%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 0x4(%rsp), %rax
addq $0xc, %r13
cmpq %rax, %rbp
jl 0x1671e
movl $0xa, %edi
callq 0x1040
movq 0x18(%rsp), %rbx
jmp 0x1687f
cmpl $0x76, %ecx
jne 0x1687f
movq 0x8(%rsp), %rax
movl (%rax), %edx
jmp 0x1686e
movq 0x8(%rsp), %rax
movl 0x8(%rax), %esi
movq 0x10(%rsp), %rax
movl 0x18(%rax), %eax
movl %eax, %edx
shrl $0x1f, %edx
addl %eax, %edx
sarl %edx
jmp 0x16871
movq 0x8(%rsp), %rax
movl 0x8(%rax), %esi
leaq 0xa850(%rip), %rdi      # 0x20feb
movl $0x1, %edx
jmp 0x16878
movq 0x8(%rsp), %rax
movl 0x8(%rax), %esi
leaq 0xadf6(%rip), %rdi      # 0x215aa
xorl %eax, %eax
callq 0x10b0
movq 0x8(%r15), %rax
testq %rax, %rax
je 0x16827
cmpl $0x0, (%rax)
jle 0x16835
leaq 0xadd9(%rip), %r12      # 0x215a9
xorl %ebp, %ebp
movq 0x10(%r15), %rax
movq (%rax,%rbp,8), %rdi
movq %r14, %rsi
callq 0x8250
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 0x14700
incq %rbp
movq 0x8(%r15), %rax
movslq (%rax), %rax
cmpq %rax, %rbp
jl 0x167d2
jmp 0x16835
movq 0x8(%r15), %rax
testq %rax, %rax
je 0x16841
movl (%rax), %edx
jmp 0x16843
movq 0x8(%rsp), %rax
movl 0x4(%rax), %edx
jmp 0x1686e
leaq 0xa506(%rip), %rdi      # 0x20d34
xorl %eax, %eax
callq 0x10b0
movl $0xa, %edi
callq 0x1040
jmp 0x1687f
xorl %edx, %edx
movq (%r15), %rcx
testq %rcx, %rcx
je 0x16869
movslq (%rcx), %rax
testq %rax, %rax
jle 0x16869
movq 0x10(%rcx), %rcx
xorl %esi, %esi
cmpq $0x1, (%rcx,%rsi,8)
sbbl $-0x1, %edx
incq %rsi
cmpq %rsi, %rax
jne 0x16859
movq 0x8(%rsp), %rax
movl 0x8(%rax), %esi
leaq 0xa773(%rip), %rdi      # 0x20feb
xorl %eax, %eax
callq 0x10b0
movq %r14, %rdi
movq 0x10(%rsp), %rsi
callq 0x1b546
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x172c8
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq