#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 *, size_t, size_t, size_t,
              int (*)(void const *, void const *));
void qsortHelper(void *base, size_t count, size_t width, size_t lo, size_t hi,
                 int (*cmp)(const void *, const void *)) {
  if (hi - lo < 2) {
    return;
  }
  int mid = partition(base, lo, hi, width, cmp);
  qsortHelper(base, count, width, lo, mid, cmp);
  qsortHelper(base, count, width, mid + 1, hi, cmp);
}


x86 assembly (clang, -O0):
<qsortHelper>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0x28(%rbp),%rax
sub    -0x20(%rbp),%rax
cmp    $0x2,%rax
jae    1157 <qsortHelper+0x37>
jmp    11b2 <qsortHelper+0x92>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
mov    -0x18(%rbp),%rcx
mov    -0x30(%rbp),%r8
call   1030 <partition@plt>
mov    %eax,-0x34(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
movslq -0x34(%rbp),%r8
mov    -0x30(%rbp),%r9
call   1040 <qsortHelper@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x34(%rbp),%eax
add    $0x1,%eax
movslq %eax,%rcx
mov    -0x28(%rbp),%r8
mov    -0x30(%rbp),%r9
call   1040 <qsortHelper@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<qsortHelper>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,(%rsp)
mov    %r8,%rax
sub    %rcx,%rax
cmp    $0x2,%rax
jb     1192 <qsortHelper+0x72>
mov    %r9,%r14
mov    %r8,%r13
mov    %rcx,%rbp
mov    %rdx,%r15
mov    %rdi,%rbx
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %r13,%rdx
mov    %r15,%rcx
mov    %r14,%r8
call   1030 <partition@plt>
movslq %eax,%r12
mov    %rbx,%rdi
mov    (%rsp),%rsi
mov    %r15,%rdx
mov    %rbp,%rcx
mov    %r12,%r8
mov    %r14,%r9
call   1040 <qsortHelper@plt>
add    $0x1,%r12d
movslq %r12d,%rbp
mov    %r13,%rax
sub    %rbp,%rax
cmp    $0x1,%rax
ja     1150 <qsortHelper+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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