// File: /workspace/github_c_makefile_star2_O0/OhYee[P]computer_application_programming_experiment/hash_search/array_search/../../utils/sort/sort.c
// Function: sort
void sort(int l, int r, void *args, sort_compare_function compare,
          sort_swap_function swap) {
    if (l < r) {
        int left = l;
        int right = r;
        int mid = l;

        int a = compare(args, l, r), b = compare(args, l, (l + r) / 2),
            c = compare(args, (l + r) / 2, r);
        if (a == b && b == c) {
            mid = (l + r) / 2;
        } else if (a == c) {
            mid = l;
        } else {
            mid = r;
        }

        while (left < right) {
            while (left < right && mid < right &&
                   compare(args, mid, right) < 0) {
                right--;
            }
            if (left < right && mid < right) {
                swap(args, left++, right);
                mid = right;
            }
            while (left < right && left < mid && compare(args, left, mid) < 0) {
                left++;
            }
            if (left < right && left < mid) {
                swap(args, left, right--);
                mid = left;
            }
        }
        // swap(left, mid);

        // 递归调用
        sort(l, mid - 1, args, compare, swap); // 排序mid左边
        sort(mid + 1, r, args, compare, swap); // 排序mid右边
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movl %edi, -0x4(%rbp)
movl %esi, -0x8(%rbp)
movq %rdx, -0x10(%rbp)
movq %rcx, -0x18(%rbp)
movq %r8, -0x20(%rbp)
movl -0x4(%rbp), %eax
cmpl -0x8(%rbp), %eax
jge 0x460b
movl -0x4(%rbp), %eax
movl %eax, -0x24(%rbp)
movl -0x8(%rbp), %eax
movl %eax, -0x28(%rbp)
movl -0x4(%rbp), %eax
movl %eax, -0x2c(%rbp)
movq -0x18(%rbp), %rax
movq -0x10(%rbp), %rdi
movl -0x4(%rbp), %esi
movl -0x8(%rbp), %edx
callq *%rax
movl %eax, -0x30(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x10(%rbp), %rdi
movl -0x4(%rbp), %esi
movl -0x4(%rbp), %eax
addl -0x8(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %edx
movq -0x48(%rbp), %rax
callq *%rax
movl %eax, -0x34(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x10(%rbp), %rdi
movl -0x4(%rbp), %eax
addl -0x8(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %esi
movq -0x40(%rbp), %rax
movl -0x8(%rbp), %edx
callq *%rax
movl %eax, -0x38(%rbp)
movl -0x30(%rbp), %eax
cmpl -0x34(%rbp), %eax
jne 0x44be
movl -0x34(%rbp), %eax
cmpl -0x38(%rbp), %eax
jne 0x44be
movl -0x4(%rbp), %eax
addl -0x8(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, -0x2c(%rbp)
jmp 0x44d6
movl -0x30(%rbp), %eax
cmpl -0x38(%rbp), %eax
jne 0x44ce
movl -0x4(%rbp), %eax
movl %eax, -0x2c(%rbp)
jmp 0x44d4
movl -0x8(%rbp), %eax
movl %eax, -0x2c(%rbp)
jmp 0x44d6
jmp 0x44d8
movl -0x24(%rbp), %eax
cmpl -0x28(%rbp), %eax
jge 0x45d7
jmp 0x44e6
movl -0x24(%rbp), %ecx
xorl %eax, %eax
cmpl -0x28(%rbp), %ecx
movb %al, -0x49(%rbp)
jge 0x4519
movl -0x2c(%rbp), %ecx
xorl %eax, %eax
cmpl -0x28(%rbp), %ecx
movb %al, -0x49(%rbp)
jge 0x4519
movq -0x18(%rbp), %rax
movq -0x10(%rbp), %rdi
movl -0x2c(%rbp), %esi
movl -0x28(%rbp), %edx
callq *%rax
cmpl $0x0, %eax
setl %al
movb %al, -0x49(%rbp)
movb -0x49(%rbp), %al
testb $0x1, %al
jne 0x4522
jmp 0x452d
movl -0x28(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x44e6
movl -0x24(%rbp), %eax
cmpl -0x28(%rbp), %eax
jge 0x455b
movl -0x2c(%rbp), %eax
cmpl -0x28(%rbp), %eax
jge 0x455b
movq -0x20(%rbp), %rax
movq -0x10(%rbp), %rdi
movl -0x24(%rbp), %esi
movl %esi, %ecx
addl $0x1, %ecx
movl %ecx, -0x24(%rbp)
movl -0x28(%rbp), %edx
callq *%rax
movl -0x28(%rbp), %eax
movl %eax, -0x2c(%rbp)
jmp 0x455d
movl -0x24(%rbp), %ecx
xorl %eax, %eax
cmpl -0x28(%rbp), %ecx
movb %al, -0x4a(%rbp)
jge 0x4590
movl -0x24(%rbp), %ecx
xorl %eax, %eax
cmpl -0x2c(%rbp), %ecx
movb %al, -0x4a(%rbp)
jge 0x4590
movq -0x18(%rbp), %rax
movq -0x10(%rbp), %rdi
movl -0x24(%rbp), %esi
movl -0x2c(%rbp), %edx
callq *%rax
cmpl $0x0, %eax
setl %al
movb %al, -0x4a(%rbp)
movb -0x4a(%rbp), %al
testb $0x1, %al
jne 0x4599
jmp 0x45a4
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x455d
movl -0x24(%rbp), %eax
cmpl -0x28(%rbp), %eax
jge 0x45d2
movl -0x24(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jge 0x45d2
movq -0x20(%rbp), %rax
movq -0x10(%rbp), %rdi
movl -0x24(%rbp), %esi
movl -0x28(%rbp), %edx
movl %edx, %ecx
addl $-0x1, %ecx
movl %ecx, -0x28(%rbp)
callq *%rax
movl -0x24(%rbp), %eax
movl %eax, -0x2c(%rbp)
jmp 0x44d8
movl -0x4(%rbp), %edi
movl -0x2c(%rbp), %esi
subl $0x1, %esi
movq -0x10(%rbp), %rdx
movq -0x18(%rbp), %rcx
movq -0x20(%rbp), %r8
callq 0x4400
movl -0x2c(%rbp), %edi
addl $0x1, %edi
movl -0x8(%rbp), %esi
movq -0x10(%rbp), %rdx
movq -0x18(%rbp), %rcx
movq -0x20(%rbp), %r8
callq 0x4400
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
nopl (%rax,%rax)