// File: /workspace/github_c_makefile_star2_O3/pwelke[P]GraphMiningTools/cs_Outerplanar.c
// Function: canonicalStringOfOuterplanarBlock
struct ShallowGraph* canonicalStringOfOuterplanarBlock(struct ShallowGraph* hamiltonianCycle, struct ShallowGraph* diagonals, struct ShallowGraphPool* sgp) {
	struct VertexList* idx;
	struct ShallowGraph* result1;
	struct ShallowGraph* result2;
	struct ShallowGraph* inverse = inverseCycle(hamiltonianCycle, sgp);

	/* special case. if block is a cycle, return the canonical string of that cycle */
	if (diagonals->m == 0) {
		dumpShallowGraph(sgp, diagonals);
		dumpShallowGraph(sgp, inverse);
		return getCyclePatterns(hamiltonianCycle, sgp);
	}

	/* add diagonals to the graph underlying the shallowgraphs */
	for (idx=diagonals->edges; idx; idx=idx->next) {
		struct VertexList* e = shallowCopyEdge(idx, sgp->listPool);
		e->next = idx->startPoint->neighborhood;
		idx->startPoint->neighborhood = e;

		e = inverseEdge(idx, sgp->listPool);
		e->next = idx->endPoint->neighborhood;
		idx->endPoint->neighborhood = e;
	}

	/* now find the permutation and orientation of the hamiltonian cycle that results in the lex.
	 * smallest string */

	result1 = __permutateBlock(hamiltonianCycle, sgp);

	//debug
	printCanonicalString(result1, stdout);

	result2 = __permutateBlock(inverse, sgp);

	//debug
	printCanonicalString(result2, stderr);

	/* garbage collection */
	dumpShallowGraph(sgp, inverse);
	dumpShallowGraph(sgp, hamiltonianCycle);
	dumpShallowGraph(sgp, diagonals);

	/* compare cStrings and return the better one */
	if (compareVertexLists(result1->edges, result2->edges) < 0) {
		dumpShallowGraph(sgp, result2);
		return result1;
	} else {
		dumpShallowGraph(sgp, result1);
		return result2;
	}

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rsi, %r15
movq %rdi, %r14
movq %rdx, %rsi
callq 0x8965
movq %rax, %r12
cmpl $0x0, 0x10(%r15)
je 0x67ce
movq (%r15), %r13
testq %r13, %r13
je 0x674c
movq 0x10(%rbx), %rsi
movq %r13, %rdi
callq 0x7bec
movq 0x10(%r13), %rcx
movq 0x8(%rcx), %rdx
movq %rdx, 0x8(%rax)
movq %rax, 0x8(%rcx)
movq 0x10(%rbx), %rsi
movq %r13, %rdi
callq 0x7c08
movq 0x18(%r13), %rcx
movq 0x8(%rcx), %rdx
movq %rdx, 0x8(%rax)
movq %rax, 0x8(%rcx)
movq 0x8(%r13), %r13
jmp 0x6709
movq %r14, %rdi
movq %rbx, %rsi
callq 0x6376
movq %rax, %r13
movq 0x26867(%rip), %rax     # 0x2cfc8
movq (%rax), %rsi
movq %r13, %rdi
callq 0x7142
movq %r12, %rdi
movq %rbx, %rsi
callq 0x6376
movq %rax, %rbp
movq 0x26877(%rip), %rax     # 0x2cff8
movq (%rax), %rsi
movq %rbp, %rdi
callq 0x7142
movq %rbx, %rdi
movq %r12, %rsi
callq 0x149f4
movq %rbx, %rdi
movq %r14, %rsi
callq 0x149f4
movq %rbx, %rdi
movq %r15, %rsi
callq 0x149f4
movq (%r13), %rdi
movq (%rbp), %rsi
callq 0x5b2a
movq %rbx, %rdi
testl %eax, %eax
js 0x67fd
movq %r13, %rsi
callq 0x149f4
movq %rbp, %r13
jmp 0x6805
movq %rbx, %rdi
movq %r15, %rsi
callq 0x149f4
movq %rbx, %rdi
movq %r12, %rsi
callq 0x149f4
movq %r14, %rdi
movq %rbx, %rsi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x5de1
movq %rbp, %rsi
callq 0x149f4
movq %r13, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq