// File: /workspace/github_c_makefile_star2_O0/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:
subq $0x48, %rsp
movq %rdi, 0x38(%rsp)
movq %rsi, 0x30(%rsp)
movq %rdx, 0x28(%rsp)
movq 0x38(%rsp), %rdi
movq 0x28(%rsp), %rsi
callq 0xc060
movq %rax, 0x8(%rsp)
movq 0x30(%rsp), %rax
cmpl $0x0, 0x10(%rax)
jne 0x7a39
movq 0x28(%rsp), %rdi
movq 0x30(%rsp), %rsi
callq 0x1ff70
movq 0x28(%rsp), %rdi
movq 0x8(%rsp), %rsi
callq 0x1ff70
movq 0x38(%rsp), %rdi
movq 0x28(%rsp), %rsi
callq 0x6a00
movq %rax, 0x40(%rsp)
jmp 0x7baa
movq 0x30(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x20(%rsp)
cmpq $0x0, 0x20(%rsp)
je 0x7adf
movq 0x20(%rsp), %rdi
movq 0x28(%rsp), %rax
movq 0x10(%rax), %rsi
callq 0xa310
movq %rax, (%rsp)
movq 0x20(%rsp), %rax
movq 0x10(%rax), %rax
movq 0x8(%rax), %rcx
movq (%rsp), %rax
movq %rcx, 0x8(%rax)
movq (%rsp), %rcx
movq 0x20(%rsp), %rax
movq 0x10(%rax), %rax
movq %rcx, 0x8(%rax)
movq 0x20(%rsp), %rdi
movq 0x28(%rsp), %rax
movq 0x10(%rax), %rsi
callq 0xa370
movq %rax, (%rsp)
movq 0x20(%rsp), %rax
movq 0x18(%rax), %rax
movq 0x8(%rax), %rcx
movq (%rsp), %rax
movq %rcx, 0x8(%rax)
movq (%rsp), %rcx
movq 0x20(%rsp), %rax
movq 0x18(%rax), %rax
movq %rcx, 0x8(%rax)
movq 0x20(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x20(%rsp)
jmp 0x7a46
movq 0x38(%rsp), %rdi
movq 0x28(%rsp), %rsi
callq 0x73c0
movq %rax, 0x18(%rsp)
movq 0x18(%rsp), %rdi
movq 0x364c9(%rip), %rax     # 0x3dfc8
movq (%rax), %rsi
callq 0x9130
movq 0x8(%rsp), %rdi
movq 0x28(%rsp), %rsi
callq 0x73c0
movq %rax, 0x10(%rsp)
movq 0x10(%rsp), %rdi
movq 0x364d1(%rip), %rax     # 0x3dff8
movq (%rax), %rsi
callq 0x9130
movq 0x28(%rsp), %rdi
movq 0x8(%rsp), %rsi
callq 0x1ff70
movq 0x28(%rsp), %rdi
movq 0x38(%rsp), %rsi
callq 0x1ff70
movq 0x28(%rsp), %rdi
movq 0x30(%rsp), %rsi
callq 0x1ff70
movq 0x18(%rsp), %rax
movq (%rax), %rdi
movq 0x10(%rsp), %rax
movq (%rax), %rsi
callq 0x6390
cmpl $0x0, %eax
jge 0x7b91
movq 0x28(%rsp), %rdi
movq 0x10(%rsp), %rsi
callq 0x1ff70
movq 0x18(%rsp), %rax
movq %rax, 0x40(%rsp)
jmp 0x7baa
movq 0x28(%rsp), %rdi
movq 0x18(%rsp), %rsi
callq 0x1ff70
movq 0x10(%rsp), %rax
movq %rax, 0x40(%rsp)
movq 0x40(%rsp), %rax
addq $0x48, %rsp
retq
nopw %cs:(%rax,%rax)