#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 place_pivot(void *, int, int, int (*)(void *, int, int),
                void (*)(void *, int, int));
void quicksort(void *array, int low, int high, int Compare(void *, int, int),
               void Swap(void *, int, int)) {
  if (low >= high)
    return;
  int pivot = place_pivot(array, low, high, Compare, Swap);
  quicksort(array, low, pivot - 1, Compare, Swap);
  quicksort(array, pivot + 1, high, Compare, Swap);
}


x86 assembly (clang, -O0):
<quicksort>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jl     114b <quicksort+0x2b>
jmp    1199 <quicksort+0x79>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x18(%rbp),%rcx
mov    -0x20(%rbp),%r8
call   1040 <place_pivot@plt>
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x24(%rbp),%edx
sub    $0x1,%edx
mov    -0x18(%rbp),%rcx
mov    -0x20(%rbp),%r8
call   1030 <quicksort@plt>
mov    -0x8(%rbp),%rdi
mov    -0x24(%rbp),%esi
add    $0x1,%esi
mov    -0x10(%rbp),%edx
mov    -0x18(%rbp),%rcx
mov    -0x20(%rbp),%r8
call   1030 <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    %edx,%esi
jge    1172 <quicksort+0x52>
mov    %r8,%r14
mov    %rcx,%r15
mov    %edx,%r12d
mov    %esi,%ebp
mov    %rdi,%r13
nopl   (%rax)
mov    %r13,%rdi
mov    %ebp,%esi
mov    %r12d,%edx
mov    %r15,%rcx
mov    %r14,%r8
call   1040 <place_pivot@plt>
mov    %eax,%ebx
lea    -0x1(%rbx),%edx
mov    %r13,%rdi
mov    %ebp,%esi
mov    %r15,%rcx
mov    %r14,%r8
call   1030 <quicksort@plt>
add    $0x1,%ebx
mov    %ebx,%ebp
cmp    %r12d,%ebx
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 %2, i32 (i8*, i32, i32)* %3, void (i8*, i32, i32)* %4) {
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32 (i8*, i32, i32)*
%10 = alloca void (i8*, i32, i32)*
%11 = alloca i32
store i8* %0, i8** %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32 (i8*, i32, i32)* %3, i32 (i8*, i32, i32)** %9
store void (i8*, i32, i32)* %4, void (i8*, i32, i32)** %10
%12 = load i32, i32* %7
%13 = load i32, i32* %8
%14 = icmp sge i32 %12, %13
br i1 %14, label %15, label %16
15: ; preds = %5
br label %35
16: ; preds = %5
%17 = load i8*, i8** %6
%18 = load i32, i32* %7
%19 = load i32, i32* %8
%20 = load i32 (i8*, i32, i32)*, i32 (i8*, i32, i32)** %9
%21 = load void (i8*, i32, i32)*, void (i8*, i32, i32)** %10
%22 = call i32 @place_pivot(i8* %17, i32 %18, i32 %19, i32 (i8*, i32, i32)* %20, void (i8*, i32, i32)* %21)
store i32 %22, i32* %11
%23 = load i8*, i8** %6
%24 = load i32, i32* %7
%25 = load i32, i32* %11
%26 = sub nsw i32 %25, 1
%27 = load i32 (i8*, i32, i32)*, i32 (i8*, i32, i32)** %9
%28 = load void (i8*, i32, i32)*, void (i8*, i32, i32)** %10
%29 = load i8*, i8** %6
%30 = load i32, i32* %11
%31 = add nsw i32 %30, 1
%32 = load i32, i32* %8
%33 = load i32 (i8*, i32, i32)*, i32 (i8*, i32, i32)** %9
%34 = load void (i8*, i32, i32)*, void (i8*, i32, i32)** %10
br label %35
35: ; preds = %16, %15
ret void
}

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