// File: /workspace/github_c_makefile_star2_O1/pwelke[P]GraphMiningTools/cs_Outerplanar.c
// Function: _compareBlockRepresentations
struct VertexList* __compareBlockRepresentations(struct VertexList* c1, struct VertexList* c2, int m, int o1, int o2) {
	struct VertexList* idx1 = c1;
	struct VertexList* idx2 = c2;


	/* check for differences in the following edges */
	for (idx1=idx1->next, idx2=idx2->next;
			(idx1!=c1);
			idx1=idx1->next, idx2=idx2->next) {

		/* check for differences in the edge label */
		if (strcmp(idx1->label, idx2->label) < 0) {
			return c1;
		}
		if (strcmp(idx1->label, idx2->label) > 0) {
			return c2;
		}
		if (strcmp(idx1->label, idx2->label) == 0) {
			/* if edge labels do not differ, check for differences in endPoint label */
			if (strcmp(idx1->endPoint->label, idx2->endPoint->label) < 0) {
				return c1;
			}
			if (strcmp(idx1->endPoint->label, idx2->endPoint->label) > 0) {
				return c2;
			}
		}
	}

	/* check for differences in the edge label of the first edge*/
	if (strcmp(idx1->label, idx2->label) < 0) {
		return c1;
	}
	if (strcmp(idx1->label, idx2->label) > 0) {
		return c2;
	}
	if (strcmp(idx1->label, idx2->label) == 0) {
		/* if edge labels do not differ, check for differences in endPoint label */
		if (strcmp(idx1->endPoint->label, idx2->endPoint->label) < 0) {
			return c1;
		}
		if (strcmp(idx1->endPoint->label, idx2->endPoint->label) > 0) {
			return c2;
		}
	}


	/* if no difference is found in the hamiltonian cycle, check the diagonals */
	for (idx1=idx1->next, idx2=idx2->next; idx1!=c1; idx1=idx1->next, idx2=idx2->next) {
		struct VertexList* e;
		int i;

		int neighbors1 = 0;
		int neighbors2 = 0;

		struct VertexList** narray1;
		struct VertexList** narray2;

		/* count number of diagonals that go from the current vertex to a vertex with a higher
		 * index wrt the current permutation */
		for (e=idx1->endPoint->neighborhood; e; e=e->next) {
			if (mod(e->startPoint->d - o1, m + 1) < mod(e->endPoint->d - o1, m + 1)) {
				++neighbors1;
			}
		}
		for (e=idx2->endPoint->neighborhood; e; e=e->next) {
			if (mod(e->startPoint->d - o2, m + 1) < mod(e->endPoint->d - o2, m + 1)) {
				++neighbors2;
			}
		}



		/* if there are more edges with a low start vertex index, the resulting cstring is smaller */
		if (neighbors1 < neighbors2) {
			return c2;
		}
		if (neighbors2 < neighbors1) {
			return c1;
		}

		/* special cases where current vertices have no or just one incident diagonal */
		if (neighbors1 == 0) {
			continue;
		}
		if (neighbors1 == 1) {
			if (mod(idx1->endPoint->neighborhood->endPoint->d - o1, m + 1) > mod(idx2->endPoint->neighborhood->endPoint->d - o2, m + 1)) {
				return c2;
			} else {
				return c1;
			}
		}

		/* otherwise we have to sort the edges wrt their endpoints modulo the permutation */

		/* sort the edges according to their cycle indices modulo the permutation */
		narray1 = malloc(neighbors1 * sizeof(struct VertexList*));
		narray2 = malloc(neighbors2 * sizeof(struct VertexList*));
		for (i=0, e=idx1->endPoint->neighborhood; i<neighbors1; e=e->next) {
			e->flag = mod(e->startPoint->d - o1, m + 1);
			e->used = mod(e->endPoint->d - o1, m + 1);
			if (e->flag < e->used) {
				narray1[i] = e;
				++i;
			}
		}
		for (i=0, e=idx2->endPoint->neighborhood; i<neighbors2; e=e->next) {
			e->flag = mod(e->startPoint->d - o2, m + 1);
			e->used = mod(e->endPoint->d - o2, m + 1);
			if (e->flag < e->used) {
				narray2[i] = e;
				++i;
			}
		}

		qsort(narray1, neighbors1, sizeof(struct VertexList*), __compareDiagonals);
		qsort(narray2, neighbors2, sizeof(struct VertexList*), __compareDiagonals);

		/* check if the indices of the endpoints of the diagonals differ */
		for (i=0; i<neighbors1; ++i) {
			if (__compareDiagonals(&(narray1[i]), &(narray2[i])) < 0) {
				free(narray1);
				free(narray2);
				return c1;
			}
			if (__compareDiagonals(&(narray1[i]), &(narray2[i])) > 0) {
				free(narray1);
				free(narray2);
				return c2;
			}
			/* otherwise continue with the next loop iteration */
		}
		free(narray1);
		free(narray2);

	}

	/* if neither checking the hamiltonian cycle nor checking the diagonals resulted
	 * in any difference, return c1 */
	return c1;

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movl %r8d, %ebp
movl %ecx, 0x14(%rsp)
movl %edx, 0x8(%rsp)
movq %rsi, %r12
movq %rdi, %r13
movq %rsi, %r14
movq %rdi, %r15
movq 0x8(%r15), %r15
movq 0x8(%r14), %r14
movq (%r15), %rdi
movq (%r14), %rsi
callq 0x1140
cmpq %r13, %r15
je 0x5e94
testl %eax, %eax
js 0x5e9d
jne 0x5e9a
movq 0x18(%r15), %rax
movq (%rax), %rdi
movq 0x18(%r14), %rax
movq (%rax), %rsi
callq 0x1140
testl %eax, %eax
js 0x5e9d
je 0x5e5b
jmp 0x5e9a
testl %eax, %eax
js 0x5e9d
je 0x5eaf
movq %r12, %r13
movq %r13, %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x18(%r15), %rax
movq (%rax), %rdi
movq 0x18(%r14), %rax
movq (%rax), %rsi
callq 0x1140
testl %eax, %eax
js 0x5e9d
jne 0x5e9a
movq 0x8(%r15), %r15
cmpq %r13, %r15
je 0x5e9d
incl 0x8(%rsp)
movq %r12, 0x38(%rsp)
movl %ebp, 0xc(%rsp)
movq %r13, 0x40(%rsp)
movq 0x8(%r14), %r14
movq %r15, 0x28(%rsp)
movq 0x18(%r15), %rax
movq 0x8(%rax), %r15
movl $0x0, %ebp
testq %r15, %r15
movl 0x14(%rsp), %r12d
movl 0x8(%rsp), %ebx
je 0x5f41
xorl %ebp, %ebp
movq 0x10(%r15), %rax
movl 0x28(%rax), %edi
subl %r12d, %edi
movl %ebx, %esi
callq 0x98f4
movl %eax, %r13d
movq 0x18(%r15), %rax
movl 0x28(%rax), %edi
subl %r12d, %edi
movl %ebx, %esi
callq 0x98f4
xorl %ecx, %ecx
cmpl %eax, %r13d
setl %cl
addl %ecx, %ebp
movq 0x8(%r15), %r15
testq %r15, %r15
jne 0x5f09
movl %ebp, 0x10(%rsp)
movq 0x18(%r14), %rax
movq 0x8(%rax), %r12
xorl %r15d, %r15d
testq %r12, %r12
je 0x5f97
movl 0xc(%rsp), %ebx
movl 0x8(%rsp), %ebp
movq 0x10(%r12), %rax
movl 0x28(%rax), %edi
subl %ebx, %edi
movl %ebp, %esi
callq 0x98f4
movl %eax, %r13d
movq 0x18(%r12), %rax
movl 0x28(%rax), %edi
subl %ebx, %edi
movl %ebp, %esi
callq 0x98f4
xorl %ecx, %ecx
cmpl %eax, %r13d
setl %cl
addl %ecx, %r15d
movq 0x8(%r12), %r12
testq %r12, %r12
jne 0x5f5d
movl $0x1, %eax
movl 0x10(%rsp), %ebx
cmpl %r15d, %ebx
jae 0x5fb6
movq 0x38(%rsp), %r12
movq %r12, 0x30(%rsp)
movq 0x40(%rsp), %r13
jmp 0x6033
movq 0x40(%rsp), %r13
jbe 0x5fc4
movq %r13, 0x30(%rsp)
jmp 0x6033
testl %ebx, %ebx
je 0x602e
cmpl $0x1, %ebx
jne 0x6057
movq 0x28(%rsp), %r15
movq 0x18(%r15), %rax
movq 0x8(%rax), %rax
movq 0x18(%rax), %rax
movl 0x28(%rax), %edi
subl 0x14(%rsp), %edi
movl 0x8(%rsp), %ebx
movl %ebx, %esi
callq 0x98f4
movl %eax, %r12d
movq 0x18(%r14), %rax
movq 0x8(%rax), %rax
movq 0x18(%rax), %rax
movl 0x28(%rax), %edi
movl 0xc(%rsp), %ebp
subl %ebp, %edi
movl %ebx, %esi
callq 0x98f4
cmpl %eax, %r12d
movq %r13, %rax
movq 0x38(%rsp), %r12
cmovgq %r12, %rax
movq %rax, 0x30(%rsp)
movl $0x1, %eax
jmp 0x6038
movl $0x7, %eax
movq 0x28(%rsp), %r15
cmpl $0x7, %eax
je 0x6045
testl %eax, %eax
jne 0x6226
movq 0x8(%r15), %r15
cmpq %r13, %r15
jne 0x5ee3
jmp 0x5e9d
movl %ebx, %eax
movq %rax, 0x50(%rsp)
leaq (,%rax,8), %rdi
callq 0x1190
movq %rax, 0x18(%rsp)
movl %r15d, %eax
movq %rax, 0x48(%rsp)
leaq (,%rax,8), %rdi
callq 0x1190
movq %rax, 0x20(%rsp)
testl %ebx, %ebx
movl 0x14(%rsp), %ebx
movl 0x8(%rsp), %r12d
jle 0x60ea
movq 0x28(%rsp), %rax
movq 0x18(%rax), %r13
xorl %ebp, %ebp
movq 0x8(%r13), %r13
movq 0x10(%r13), %rax
movl 0x28(%rax), %edi
subl %ebx, %edi
movl %r12d, %esi
callq 0x98f4
movl %eax, 0x24(%r13)
movq 0x18(%r13), %rax
movl 0x28(%rax), %edi
subl %ebx, %edi
movl %r12d, %esi
callq 0x98f4
movl %eax, 0x20(%r13)
cmpl %eax, 0x24(%r13)
jge 0x60e4
movslq %ebp, %rbp
movq 0x18(%rsp), %rax
movq %r13, (%rax,%rbp,8)
incl %ebp
cmpl 0x10(%rsp), %ebp
jl 0x60a2
testl %r15d, %r15d
jle 0x6140
movq 0x18(%r14), %r13
xorl %ebp, %ebp
movq 0x8(%r13), %r13
movq 0x10(%r13), %rax
movl 0x28(%rax), %edi
movl 0xc(%rsp), %ebx
subl %ebx, %edi
movl %r12d, %esi
callq 0x98f4
movl %eax, 0x24(%r13)
movq 0x18(%r13), %rax
movl 0x28(%rax), %edi
subl %ebx, %edi
movl %r12d, %esi
callq 0x98f4
movl %eax, 0x20(%r13)
cmpl %eax, 0x24(%r13)
jge 0x613b
movslq %ebp, %rbp
movq 0x20(%rsp), %rax
movq %r13, (%rax,%rbp,8)
incl %ebp
cmpl %r15d, %ebp
jl 0x60f5
movl $0x8, %edx
movq 0x18(%rsp), %rdi
movq 0x50(%rsp), %r15
movq %r15, %rsi
leaq -0x339(%rip), %rbx      # 0x5e20
movq %rbx, %rcx
callq 0x1080
movl $0x8, %edx
movq 0x20(%rsp), %rdi
movq 0x48(%rsp), %rsi
movq %rbx, %rcx
callq 0x1080
movq %r15, %r8
cmpl $0x0, 0x10(%rsp)
movq 0x38(%rsp), %r12
movq 0x40(%rsp), %r13
movq 0x28(%rsp), %r15
je 0x61cf
xorl %eax, %eax
movq 0x18(%rsp), %rcx
movq (%rcx,%rax,8), %rsi
movq 0x20(%rsp), %rcx
movq (%rcx,%rax,8), %rdx
movl 0x24(%rsi), %ecx
subl 0x24(%rdx), %ecx
movl %ecx, %edi
jne 0x61b5
movl 0x20(%rsi), %edi
subl 0x20(%rdx), %edi
testl %edi, %edi
js 0x61ea
testl %ecx, %ecx
jne 0x61c3
movl 0x20(%rsi), %ecx
subl 0x20(%rdx), %ecx
testl %ecx, %ecx
jg 0x6208
incq %rax
cmpq %rax, %r8
jne 0x6193
movq 0x18(%rsp), %rdi
callq 0x1030
movq 0x20(%rsp), %rdi
callq 0x1030
xorl %eax, %eax
jmp 0x6038
movq 0x18(%rsp), %rdi
callq 0x1030
movq 0x20(%rsp), %rdi
callq 0x1030
movq %r13, 0x30(%rsp)
jmp 0x6027
movq 0x18(%rsp), %rdi
callq 0x1030
movq 0x20(%rsp), %rdi
callq 0x1030
movq %r12, 0x30(%rsp)
jmp 0x6027
movq 0x30(%rsp), %r13
jmp 0x5e9d