// File: /workspace/github_c_makefile_star2_O3/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 $0x48, %rsp
movl %r8d, %r13d
movl %ecx, 0x10(%rsp)
movl %edx, %ebp
movq %rsi, %r12
movq %rdi, %rbx
movq %rsi, %r14
movq %rdi, %r15
movq 0x8(%r15), %r15
movq 0x8(%r14), %r14
movq (%r15), %rdi
movq (%r14), %rsi
callq 0x1140
cmpq %rbx, %r15
je 0x5f1a
testl %eax, %eax
js 0x5f23
jne 0x5f20
movq 0x18(%r15), %rax
movq (%rax), %rdi
movq 0x18(%r14), %rax
movq (%rax), %rsi
callq 0x1140
testl %eax, %eax
js 0x5f23
je 0x5ee1
jmp 0x5f20
testl %eax, %eax
js 0x5f23
je 0x5f35
movq %r12, %rbx
movq %rbx, %rax
addq $0x48, %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 0x5f23
jne 0x5f20
movq 0x8(%r15), %rax
cmpq %rbx, %rax
je 0x5f23
movq %r12, 0x28(%rsp)
incl %ebp
movl %ebp, %r12d
movl 0x10(%rsp), %ecx
movl %ebp, 0x8(%rsp)
movl %r13d, 0x14(%rsp)
movq 0x8(%r14), %r14
movq %rax, 0x30(%rsp)
movq 0x18(%rax), %rax
movq 0x8(%rax), %r15
movl $0x0, %ebp
testq %r15, %r15
je 0x5fca
movl %ecx, %r13d
xorl %ebp, %ebp
movq 0x10(%r15), %rax
movl 0x28(%rax), %edi
subl %r13d, %edi
movl %r12d, %esi
callq 0x9900
movl %eax, 0x4(%rsp)
movq 0x18(%r15), %rax
movl 0x28(%rax), %edi
subl %r13d, %edi
movl %r12d, %esi
callq 0x9900
xorl %ecx, %ecx
cmpl %eax, 0x4(%rsp)
setl %cl
addl %ecx, %ebp
movq 0x8(%r15), %r15
testq %r15, %r15
jne 0x5f8e
movl %ebp, 0xc(%rsp)
movq 0x18(%r14), %rax
movq 0x8(%rax), %rbp
xorl %eax, %eax
testq %rbp, %rbp
je 0x6026
movl %eax, 0x4(%rsp)
movq 0x10(%rbp), %rax
movl 0x28(%rax), %edi
movl 0x14(%rsp), %r12d
subl %r12d, %edi
movl 0x8(%rsp), %r15d
movl %r15d, %esi
callq 0x9900
movl %eax, %r13d
movq 0x18(%rbp), %rax
movl 0x28(%rax), %edi
subl %r12d, %edi
movl %r15d, %esi
callq 0x9900
xorl %ecx, %ecx
cmpl %eax, %r13d
movl 0x4(%rsp), %eax
setl %cl
addl %ecx, %eax
movq 0x8(%rbp), %rbp
jmp 0x5fd8
movl 0xc(%rsp), %ebp
cmpl %eax, %ebp
movl 0x14(%rsp), %r13d
jb 0x6238
ja 0x5f23
testl %ebp, %ebp
movl 0x8(%rsp), %r12d
je 0x61e6
cmpl $0x1, %ebp
movl 0x10(%rsp), %r15d
je 0x6242
movl %ebp, %ecx
movq %rcx, 0x40(%rsp)
leaq (,%rcx,8), %rdi
movl %eax, %r12d
callq 0x1190
movq %rax, 0x18(%rsp)
movl %r12d, 0x4(%rsp)
movl %r12d, %eax
movq %rax, 0x38(%rsp)
leaq (,%rax,8), %rdi
callq 0x1190
movq %rax, 0x20(%rsp)
testl %ebp, %ebp
jle 0x60f8
movq 0x30(%rsp), %rax
movq 0x18(%rax), %r13
xorl %ebp, %ebp
movq 0x8(%r13), %r13
movq 0x10(%r13), %rax
movl 0x28(%rax), %edi
subl %r15d, %edi
movl 0x8(%rsp), %r12d
movl %r12d, %esi
callq 0x9900
movl %eax, 0x24(%r13)
movq 0x18(%r13), %rax
movl 0x28(%rax), %edi
subl %r15d, %edi
movl %r12d, %esi
callq 0x9900
movl %eax, 0x20(%r13)
cmpl %eax, 0x24(%r13)
jge 0x60eb
movslq %ebp, %rbp
movq 0x18(%rsp), %rax
movq %r13, (%rax,%rbp,8)
incl %ebp
movl 0xc(%rsp), %eax
cmpl %eax, %ebp
movl 0x10(%rsp), %r15d
jl 0x60a2
cmpl $0x0, 0x4(%rsp)
jle 0x615b
movq 0x18(%r14), %r13
xorl %ebp, %ebp
movq 0x8(%r13), %r13
movq 0x10(%r13), %rax
movl 0x28(%rax), %edi
movl 0x14(%rsp), %r15d
subl %r15d, %edi
movl 0x8(%rsp), %r12d
movl %r12d, %esi
callq 0x9900
movl %eax, 0x24(%r13)
movq 0x18(%r13), %rax
movl 0x28(%rax), %edi
subl %r15d, %edi
movl %r12d, %esi
callq 0x9900
movl %eax, 0x20(%r13)
cmpl %eax, 0x24(%r13)
jge 0x6153
movslq %ebp, %rbp
movq 0x20(%rsp), %rax
movq %r13, (%rax,%rbp,8)
incl %ebp
movl 0x4(%rsp), %eax
cmpl %eax, %ebp
jl 0x6105
movl $0x8, %edx
movq 0x18(%rsp), %rdi
movq 0x40(%rsp), %rbp
movq %rbp, %rsi
leaq -0x2cc(%rip), %r15      # 0x5ea8
movq %r15, %rcx
callq 0x1080
movl $0x8, %edx
movq 0x20(%rsp), %rdi
movq 0x38(%rsp), %rsi
movq %r15, %rcx
callq 0x1080
cmpl $0x0, 0xc(%rsp)
movq 0x28(%rsp), %r15
movl 0x8(%rsp), %r12d
je 0x61d2
xorl %eax, %eax
movq 0x18(%rsp), %rcx
movq (%rcx,%rax,8), %rcx
movq 0x20(%rsp), %rdx
movq (%rdx,%rax,8), %rdx
movl 0x24(%rdx), %esi
cmpl %esi, 0x24(%rcx)
jne 0x6201
movl 0x20(%rdx), %edx
cmpl %edx, 0x20(%rcx)
jl 0x6203
jg 0x621c
incq %rax
cmpq %rax, %rbp
jne 0x61a6
movq 0x18(%rsp), %rdi
callq 0x1030
movq 0x20(%rsp), %rdi
callq 0x1030
movq 0x30(%rsp), %rax
movq 0x8(%rax), %rax
cmpq %rbx, %rax
movl 0x10(%rsp), %ecx
jne 0x5f6e
jmp 0x5f23
jge 0x621c
movq 0x18(%rsp), %rdi
callq 0x1030
movq 0x20(%rsp), %rdi
callq 0x1030
jmp 0x5f23
movq 0x18(%rsp), %rdi
callq 0x1030
movq 0x20(%rsp), %rdi
callq 0x1030
movq %r15, %rbx
jmp 0x5f23
movq 0x28(%rsp), %rbx
jmp 0x5f23
movq 0x30(%rsp), %rax
movq 0x18(%rax), %rax
movq 0x8(%rax), %rax
movq 0x18(%rax), %rax
movl 0x28(%rax), %edi
subl %r15d, %edi
movl %r12d, %ebp
movl %r12d, %esi
callq 0x9900
movl %eax, %r12d
movq 0x18(%r14), %rax
movq 0x8(%rax), %rax
movq 0x18(%rax), %rax
movl 0x28(%rax), %edi
subl %r13d, %edi
movl %ebp, %esi
callq 0x9900
cmpl %eax, %r12d
cmovgq 0x28(%rsp), %rbx
jmp 0x5f23