// File: /workspace/github_c_makefile_star2_O2/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, 0x18(%rsp)
movl %ecx, 0x14(%rsp)
movl %edx, %ebp
movq %rsi, %r12
movq %rdi, %r15
movq %rsi, %r14
movq %rdi, %rbx
movq 0x8(%rbx), %rbx
movq 0x8(%r14), %r14
movq (%rbx), %rdi
movq (%r14), %rsi
callq 0x1130
cmpq %r15, %rbx
je 0x3ee4
testl %eax, %eax
js 0x3eed
jne 0x3eea
movq 0x18(%rbx), %rax
movq (%rax), %rdi
movq 0x18(%r14), %rax
movq (%rax), %rsi
callq 0x1130
testl %eax, %eax
js 0x3eed
je 0x3eab
jmp 0x3eea
testl %eax, %eax
js 0x3eed
je 0x3eff
movq %r12, %r15
movq %r15, %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x18(%rbx), %rax
movq (%rax), %rdi
movq 0x18(%r14), %rax
movq (%rax), %rsi
callq 0x1130
testl %eax, %eax
js 0x3eed
jne 0x3eea
incl %ebp
movq %r12, 0x28(%rsp)
movl %ebp, 0x4(%rsp)
movq %r15, 0x20(%rsp)
movq 0x8(%rbx), %rbx
cmpq %r15, %rbx
je 0x3eed
movq 0x8(%r14), %r14
movq 0x18(%rbx), %r12
movl $0x0, (%rsp)
movl 0x14(%rsp), %r15d
movq 0x8(%r12), %r12
testq %r12, %r12
je 0x3f83
movq 0x10(%r12), %rax
movl 0x28(%rax), %edi
subl %r15d, %edi
movl %ebp, %esi
callq 0x752c
movl %eax, %r13d
movq 0x18(%r12), %rax
movl 0x28(%rax), %edi
subl %r15d, %edi
movl %ebp, %esi
callq 0x752c
xorl %ecx, %ecx
cmpl %eax, %r13d
setl %cl
addl %ecx, (%rsp)
jmp 0x3f45
movq 0x18(%r14), %r12
xorl %r13d, %r13d
movq 0x8(%r12), %r12
testq %r12, %r12
je 0x3fd3
movq 0x10(%r12), %rax
movl 0x28(%rax), %edi
movl 0x18(%rsp), %ebp
subl %ebp, %edi
movl 0x4(%rsp), %r15d
movl %r15d, %esi
callq 0x752c
movl %eax, 0x8(%rsp)
movq 0x18(%r12), %rax
movl 0x28(%rax), %edi
subl %ebp, %edi
movl %r15d, %esi
callq 0x752c
xorl %ecx, %ecx
cmpl %eax, 0x8(%rsp)
setl %cl
addl %ecx, %r13d
jmp 0x3f8a
cmpl %r13d, (%rsp)
jb 0x41b0
movq 0x28(%rsp), %r12
ja 0x4194
movl %r13d, 0x1c(%rsp)
movl (%rsp), %eax
testl %eax, %eax
movl 0x4(%rsp), %ebp
movq 0x20(%rsp), %r15
je 0x3f28
cmpl $0x1, %eax
je 0x41ba
movl %eax, (%rsp)
movl %eax, %eax
movq %rax, 0x40(%rsp)
leaq (,%rax,8), %rdi
callq 0x1180
movq %rax, 0x8(%rsp)
movl 0x1c(%rsp), %eax
movq %rax, 0x38(%rsp)
leaq (,%rax,8), %rdi
callq 0x1180
movq %rax, 0x30(%rsp)
movq 0x18(%rbx), %r13
xorl %r12d, %r12d
movl 0x14(%rsp), %r15d
cmpl (%rsp), %r12d
jae 0x4098
movq 0x8(%r13), %r13
movq 0x10(%r13), %rax
movl 0x28(%rax), %edi
subl %r15d, %edi
movl %ebp, %esi
callq 0x752c
movl %eax, 0x24(%r13)
movq 0x18(%r13), %rax
movl 0x28(%rax), %edi
subl %r15d, %edi
movl %ebp, %esi
callq 0x752c
movl %eax, 0x20(%r13)
cmpl %eax, 0x24(%r13)
jge 0x404d
movl %r12d, %eax
movq 0x8(%rsp), %rcx
movq %r13, (%rcx,%rax,8)
incl %r12d
jmp 0x404d
movq 0x18(%r14), %r12
xorl %r13d, %r13d
movl 0x1c(%rsp), %r15d
cmpl %r15d, %r13d
jae 0x40fc
movq 0x8(%r12), %r12
movq 0x10(%r12), %rax
movl 0x28(%rax), %edi
movl 0x18(%rsp), %ebp
subl %ebp, %edi
movl 0x4(%rsp), %esi
callq 0x752c
movl %eax, 0x24(%r12)
movq 0x18(%r12), %rax
movl 0x28(%rax), %edi
subl %ebp, %edi
movl 0x4(%rsp), %ebp
movl %ebp, %esi
callq 0x752c
movl %eax, 0x20(%r12)
cmpl %eax, 0x24(%r12)
jge 0x40a4
movl %r13d, %eax
movq 0x30(%rsp), %rcx
movq %r12, (%rcx,%rax,8)
incl %r13d
jmp 0x40a4
movq 0x8(%rsp), %rdi
movq 0x40(%rsp), %r13
movq %r13, %rsi
pushq $0x8
popq %r12
movq %r12, %rdx
leaq -0x2a7(%rip), %r15      # 0x3e70
movq %r15, %rcx
callq 0x1080
movq 0x30(%rsp), %rdi
movq 0x38(%rsp), %rsi
movq %r12, %rdx
movq %r15, %rcx
movq %rdi, %r15
callq 0x1080
leaq 0x8(,%r13,8), %r12
xorl %esi, %esi
leaq 0x8(%rsi), %r13
cmpq %r13, %r12
je 0x4166
movq 0x8(%rsp), %rax
leaq (%rax,%rsi), %rdi
addq %r15, %rsi
callq 0x3e70
testl %eax, %eax
js 0x4182
movq %r13, %rsi
je 0x4141
jmp 0x419e
movq 0x8(%rsp), %rdi
callq 0x1030
movq %r15, %rdi
callq 0x1030
movq 0x20(%rsp), %r15
jmp 0x3f28
movq 0x8(%rsp), %rdi
callq 0x1030
movq %r15, %rdi
callq 0x1030
movq 0x20(%rsp), %r15
jmp 0x3eed
movq 0x8(%rsp), %rdi
callq 0x1030
movq %r15, %rdi
callq 0x1030
movq 0x28(%rsp), %r15
jmp 0x3eed
movq 0x18(%rbx), %rax
movq 0x8(%rax), %rax
movq 0x18(%rax), %rax
movl 0x28(%rax), %edi
subl 0x14(%rsp), %edi
movl %ebp, %esi
callq 0x752c
movq %r12, %rbx
movl %eax, %r12d
movq 0x18(%r14), %rax
movq 0x8(%rax), %rax
movq 0x18(%rax), %rax
movl 0x28(%rax), %edi
subl 0x18(%rsp), %edi
movl %ebp, %esi
callq 0x752c
cmpl %eax, %r12d
cmovgq %rbx, %r15
jmp 0x3eed