#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 */
size_t _partition(void **, size_t, size_t, int (*)(void *, void *));
void _sort(void **a, size_t start, size_t end, int (*comp)(void *, void *)) {
  if (start >= end)
    return;
  size_t p = _partition(a, start, end, comp);
  if (p > 0)
    _sort(a, start, p - 1, comp);
  _sort(a, p + 1, 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    -0x10(%rbp),%rax
cmp    -0x18(%rbp),%rax
jb     114b <_sort+0x2b>
jmp    11a1 <_sort+0x81>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
call   1030 <_partition@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jbe    1188 <_sort+0x68>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x28(%rbp),%rdx
sub    $0x1,%rdx
mov    -0x20(%rbp),%rcx
call   1040 <_sort@plt>
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%rsi
add    $0x1,%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
call   1040 <_sort@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_sort>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
cmp    %rdx,%rsi
jae    1179 <_sort+0x59>
mov    %rcx,%r14
mov    %rdx,%r12
mov    %rsi,%r13
mov    %rdi,%r15
jmp    114c <_sort+0x2c>
nopl   0x0(%rax)
add    $0x1,%rbx
mov    %rbx,%r13
cmp    %r12,%rbx
jae    1179 <_sort+0x59>
mov    %r15,%rdi
mov    %r13,%rsi
mov    %r12,%rdx
mov    %r14,%rcx
call   1030 <_partition@plt>
mov    %rax,%rbx
test   %rax,%rax
je     1140 <_sort+0x20>
lea    -0x1(%rbx),%rdx
mov    %r15,%rdi
mov    %r13,%rsi
mov    %r14,%rcx
call   1040 <_sort@plt>
jmp    1140 <_sort+0x20>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define void @_sort(i8** %0, i64 %1, i64 %2, i32 (i8*, i8*)* %3) {
%5 = icmp ult i64 %1, %2
br i1 %5, label %6, label %15
6: ; preds = %4, %12
%7 = phi i64 [ %13, %12 ], [ %1, %4 ]
%8 = tail call i64 @_partition(i8** %0, i64 %7, i64 %2, i32 (i8*, i8*)* %3)
%9 = icmp eq i64 %8, 0
br i1 %9, label %12, label %10
10: ; preds = %6
%11 = add i64 %8, -1
tail call void @_sort(i8** %0, i64 %7, i64 %11, i32 (i8*, i8*)* %3)
br label %12
12: ; preds = %10, %6
%13 = add i64 %8, 1
%14 = icmp ult i64 %13, %2
br i1 %14, label %6, label %15
15: ; preds = %12, %4
ret void
}