#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 qpartition(void **, int, int, int (*)(void *, void *));
void quicksort(void **array, int i, int j, int (*compare)(void *, void *)) {
  int q = 0;
  if (i < j) {
    q = qpartition(array, i, j, compare);
    quicksort(array, i, q, compare);
    quicksort(array, q + 1, j, compare);
  }
}


x86 assembly (clang, -O0):
<quicksort>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    1188 <quicksort+0x68>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x18(%rbp),%rcx
call   1040 <qpartition@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    -0x18(%rbp),%rcx
call   1030 <quicksort@plt>
mov    -0x8(%rbp),%rdi
mov    -0x1c(%rbp),%esi
add    $0x1,%esi
mov    -0x10(%rbp),%edx
mov    -0x18(%rbp),%rcx
call   1030 <quicksort@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<quicksort>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
cmp    %edx,%esi
jge    116b <quicksort+0x4b>
mov    %rcx,%r14
mov    %edx,%r15d
mov    %esi,%ebx
mov    %rdi,%r12
nopw   0x0(%rax,%rax,1)
mov    %r12,%rdi
mov    %ebx,%esi
mov    %r15d,%edx
mov    %r14,%rcx
call   1040 <qpartition@plt>
mov    %eax,%ebp
mov    %r12,%rdi
mov    %ebx,%esi
mov    %eax,%edx
mov    %r14,%rcx
call   1030 <quicksort@plt>
add    $0x1,%ebp
mov    %ebp,%ebx
cmp    %r15d,%ebp
jl     1140 <quicksort+0x20>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

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