// File: /workspace/github_c_makefile_star2_O0/lucvoo[P]sparse-dev/sort.c
// Function: sort_list
void sort_list(struct ptr_list **plist, int (*cmp)(const void *, const void *))
{
	struct ptr_list *head = *plist, *list = head;
	int blocks = 1;

	if (!head)
		return;

	// Sort all the sub-lists
	do {
		array_sort(list->list, list->nr, cmp);
#ifdef PARANOIA
		verify_seq_sorted (list, 1, cmp);
#endif
		list = list->next;
	} while (list != head);

	// Merge the damn things together
	while (1) {
		struct ptr_list *block1 = head;

		do {
			struct ptr_list *block2 = block1;
			struct ptr_list *next, *newhead;
			int i;

			for (i = 0; i < blocks; i++) {
				block2 = block2->next;
				if (block2 == head) {
					if (block1 == head) {
						BEEN_THERE('A');
						*plist = head;
						return;
					}
					BEEN_THERE('B');
					goto next_pass;
				}						
			}

			next = block2;
			for (i = 0; i < blocks; ) {
				next = next->next;
				i++;
				if (next == head) {
					BEEN_THERE('C');
					break;
				}
				BEEN_THERE('D');
			}

			newhead = merge_block_seqs (block1, blocks,
						    block2, i,
						    cmp);
#ifdef PARANOIA
			verify_seq_sorted (newhead, blocks + i, cmp);
#endif
			if (block1 == head) {
				BEEN_THERE('E');
				head = newhead;
			}
			block1 = next;
		} while (block1 != head);
	next_pass:
		blocks <<= 1;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x20(%rbp)
movl $0x1, -0x24(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x3d366
jmp 0x3d4a4
jmp 0x3d368
movq -0x20(%rbp), %rdi
addq $0x18, %rdi
movq -0x20(%rbp), %rax
movw (%rax), %ax
shlw $0x8, %ax
sarw $0x8, %ax
movswl %ax, %esi
movq -0x10(%rbp), %rdx
callq 0x3d4b0
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
cmpq -0x18(%rbp), %rax
jne 0x3d368
jmp 0x3d3a3
movq -0x18(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0x38(%rbp)
movl $0x0, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x3d40c
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
cmpq -0x18(%rbp), %rax
jne 0x3d3ff
movq -0x30(%rbp), %rax
cmpq -0x18(%rbp), %rax
jne 0x3d3f6
jmp 0x3d3e4
jmp 0x3d3e6
movq -0x18(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, (%rax)
jmp 0x3d4a4
jmp 0x3d3f8
jmp 0x3d3fa
jmp 0x3d497
jmp 0x3d401
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0x3d3ba
movq -0x38(%rbp), %rax
movq %rax, -0x40(%rbp)
movl $0x0, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x3d44e
movq -0x40(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x40(%rbp)
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
movq -0x40(%rbp), %rax
cmpq -0x18(%rbp), %rax
jne 0x3d448
jmp 0x3d444
jmp 0x3d446
jmp 0x3d44e
jmp 0x3d44a
jmp 0x3d44c
jmp 0x3d41b
movq -0x30(%rbp), %rdi
movl -0x24(%rbp), %esi
movq -0x38(%rbp), %rdx
movl -0x4c(%rbp), %ecx
movq -0x10(%rbp), %r8
callq 0x3d590
movq %rax, -0x48(%rbp)
movq -0x30(%rbp), %rax
cmpq -0x18(%rbp), %rax
jne 0x3d47f
jmp 0x3d475
jmp 0x3d477
movq -0x48(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x40(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
cmpq -0x18(%rbp), %rax
jne 0x3d3ab
jmp 0x3d497
movl -0x24(%rbp), %eax
shll %eax
movl %eax, -0x24(%rbp)
jmp 0x3d3a3
addq $0x50, %rsp
popq %rbp
retq
nopw (%rax,%rax)