// File: /workspace/github_c_makefile_star2_O1/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 0x8908
movq %rax, %r12
cmpl $0x0, 0x10(%r15)
je 0x6768
movq (%r15), %r13
testq %r13, %r13
je 0x66e6
movq 0x10(%rbx), %rsi
movq %r13, %rdi
callq 0x7bc0
movq 0x10(%r13), %rcx
movq 0x8(%rcx), %rdx
movq %rdx, 0x8(%rax)
movq %rax, 0x8(%rcx)
movq 0x10(%rbx), %rsi
movq %r13, %rdi
callq 0x7bdc
movq 0x18(%r13), %rcx
movq 0x8(%rcx), %rdx
movq %rdx, 0x8(%rax)
movq %rax, 0x8(%rcx)
movq 0x8(%r13), %r13
jmp 0x66a3
movq %r14, %rdi
movq %rbx, %rsi
callq 0x6318
movq %rax, %r13
movq 0x268cd(%rip), %rax     # 0x2cfc8
movq (%rax), %rsi
movq %r13, %rdi
callq 0x70ff
movq %r12, %rdi
movq %rbx, %rsi
callq 0x6318
movq %rax, %rbp
movq 0x268dd(%rip), %rax     # 0x2cff8
movq (%rax), %rsi
movq %rbp, %rdi
callq 0x70ff
movq %rbx, %rdi
movq %r12, %rsi
callq 0x14b19
movq %rbx, %rdi
movq %r14, %rsi
callq 0x14b19
movq %rbx, %rdi
movq %r15, %rsi
callq 0x14b19
movq (%r13), %rdi
movq (%rbp), %rsi
callq 0x5a8a
movq %rbx, %rdi
testl %eax, %eax
js 0x6797
movq %r13, %rsi
callq 0x14b19
movq %rbp, %r13
jmp 0x679f
movq %rbx, %rdi
movq %r15, %rsi
callq 0x14b19
movq %rbx, %rdi
movq %r12, %rsi
callq 0x14b19
movq %r14, %rdi
movq %rbx, %rsi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x5d59
movq %rbp, %rsi
callq 0x14b19
movq %r13, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq