#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 partition(void *, int, int (*)(void const *, void const *), int, int);
void quicksort(void *base, int size, int (*compare)(const void *, const void *),
               int low, int high) {
  if (low >= high)
    return;
  else {
    int i = partition(base, size, compare, low, high);
    quicksort(base, size, compare, low, i);
    quicksort(base, size, compare, i + 1, high);
  }
}


x86 assembly (clang, -O0):
<quicksort>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x20(%rbp),%eax
jl     114b <quicksort+0x2b>
jmp    1196 <quicksort+0x76>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x18(%rbp),%rdx
mov    -0x1c(%rbp),%ecx
mov    -0x20(%rbp),%r8d
call   1030 <partition@plt>
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x18(%rbp),%rdx
mov    -0x1c(%rbp),%ecx
mov    -0x24(%rbp),%r8d
call   1040 <quicksort@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x18(%rbp),%rdx
mov    -0x24(%rbp),%ecx
add    $0x1,%ecx
mov    -0x20(%rbp),%r8d
call   1040 <quicksort@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<quicksort>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    %r8d,%ecx
jge    1172 <quicksort+0x52>
mov    %r8d,%r14d
mov    %ecx,%ebx
mov    %rdx,%r15
mov    %esi,%r12d
mov    %rdi,%r13
xchg   %ax,%ax
mov    %r13,%rdi
mov    %r12d,%esi
mov    %r15,%rdx
mov    %ebx,%ecx
mov    %r14d,%r8d
call   1030 <partition@plt>
mov    %eax,%ebp
mov    %r13,%rdi
mov    %r12d,%esi
mov    %r15,%rdx
mov    %ebx,%ecx
mov    %eax,%r8d
call   1040 <quicksort@plt>
add    $0x1,%ebp
mov    %ebp,%ebx
cmp    %r14d,%ebp
jl     1140 <quicksort+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @quicksort(i8* %0, i32 %1, i32 (i8*, i8*)* %2, i32 %3, i32 %4) {
%6 = icmp slt i32 %3, %4
br i1 %6, label %7, label %12
7: ; preds = %5, %7
%8 = phi i32 [ %10, %7 ], [ %3, %5 ]
%9 = tail call i32 @partition(i8* %0, i32 %1, i32 (i8*, i8*)* %2, i32 %8, i32 %4)
tail call void @quicksort(i8* %0, i32 %1, i32 (i8*, i8*)* %2, i32 %8, i32 %9)
%10 = add nsw i32 %9, 1
%11 = icmp slt i32 %10, %4
br i1 %11, label %7, label %12
12: ; preds = %7, %5
ret void
}