#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ _merge(void **, void **, size_t, size_t, size_t,
                          int (*)(void *, void *));
void _sort(void **a, void **aux, size_t start, size_t end,
           int (*comp)(void *, void *)) {
  if (start >= end)
    return;
  size_t mid = start + (end - start) / 2;
  _sort(a, aux, start, mid, comp);
  _sort(a, aux, mid + 1, end, comp);
  _merge(a, aux, start, mid, end, comp);
}


x86 assembly (clang, -O0):
<_sort>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x20(%rbp),%rax
jb     114f <_sort+0x2f>
jmp    11b9 <_sort+0x99>
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%rcx
sub    -0x18(%rbp),%rcx
shr    $0x1,%rcx
add    %rcx,%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x30(%rbp),%rcx
mov    -0x28(%rbp),%r8
call   1040 <_sort@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x30(%rbp),%rdx
add    $0x1,%rdx
mov    -0x20(%rbp),%rcx
mov    -0x28(%rbp),%r8
call   1040 <_sort@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x30(%rbp),%rcx
mov    -0x20(%rbp),%r8
mov    -0x28(%rbp),%r9
call   1030 <_merge@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_sort>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r15
sub    %rdx,%r15
jbe    1191 <_sort+0x71>
mov    %r8,%r14
mov    %rcx,%rbp
mov    %rdx,%rbx
mov    %rsi,%r12
mov    %rdi,%r13
shr    %r15
lea    (%r15,%rdx,1),%rcx
mov    %rcx,(%rsp)
call   1040 <_sort@plt>
lea    (%r15,%rbx,1),%rdx
add    $0x1,%rdx
mov    %r13,%rdi
mov    %r12,%rsi
mov    %rbp,%rcx
mov    %r14,%r8
call   1040 <_sort@plt>
mov    %r13,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
mov    (%rsp),%rcx
mov    %rbp,%r8
mov    %r14,%r9
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <_merge@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @_sort(i8** %0, i8** %1, i64 %2, i64 %3, i32 (i8*, i8*)* %4) {
%6 = alloca i8**
%7 = alloca i8**
%8 = alloca i64
%9 = alloca i64
%10 = alloca i32 (i8*, i8*)*
%11 = alloca i64
store i8** %0, i8*** %6
store i8** %1, i8*** %7
store i64 %2, i64* %8
store i64 %3, i64* %9
store i32 (i8*, i8*)* %4, i32 (i8*, i8*)** %10
%12 = load i64, i64* %8
%13 = load i64, i64* %9
%14 = icmp uge i64 %12, %13
br i1 %14, label %15, label %16
15: ; preds = %5
br label %41
16: ; preds = %5
%17 = load i64, i64* %8
%18 = load i64, i64* %9
%19 = load i64, i64* %8
%20 = sub i64 %18, %19
%21 = udiv i64 %20, 2
%22 = add i64 %17, %21
store i64 %22, i64* %11
%23 = load i8**, i8*** %6
%24 = load i8**, i8*** %7
%25 = load i64, i64* %8
%26 = load i64, i64* %11
%27 = load i32 (i8*, i8*)*, i32 (i8*, i8*)** %10
%28 = load i8**, i8*** %6
%29 = load i8**, i8*** %7
%30 = load i64, i64* %11
%31 = add i64 %30, 1
%32 = load i64, i64* %9
%33 = load i32 (i8*, i8*)*, i32 (i8*, i8*)** %10
%34 = load i8**, i8*** %6
%35 = load i8**, i8*** %7
%36 = load i64, i64* %8
%37 = load i64, i64* %11
%38 = load i64, i64* %9
%39 = load i32 (i8*, i8*)*, i32 (i8*, i8*)** %10
%40 = call i32 @_merge(i8** %34, i8** %35, i64 %36, i64 %37, i64 %38, i32 (i8*, i8*)* %39)
br label %41
41: ; preds = %16, %15
ret void
}

LLVM IR (-O2):
define void @_sort(i8** %0, i8** %1, i64 %2, i64 %3, i32 (i8*, i8*)* %4) {
%6 = icmp ugt i64 %3, %2
br i1 %6, label %8, label %7
7: ; preds = %5, %8
ret void
8: ; preds = %5
%9 = sub i64 %3, %2
%10 = lshr i64 %9, 1
%11 = add i64 %10, %2
tail call void @_sort(i8** %0, i8** %1, i64 %2, i64 %11, i32 (i8*, i8*)* %4)
%12 = add i64 %11, 1
tail call void @_sort(i8** %0, i8** %1, i64 %12, i64 %3, i32 (i8*, i8*)* %4)
%13 = tail call i32 @_merge(i8** %0, i8** %1, i64 %2, i64 %11, i64 %3, i32 (i8*, i8*)* %4)
br label %7
}