#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 /*<<< orphan*/ compare_quicksort(void *, unsigned int, int /*<<< orphan*/,
                                     unsigned int, int (*)(void *, void *),
                                     void *);
int /*<<< orphan*/ free(void *);
void *malloc(unsigned int);
void compare_quick_sort(void *arr, unsigned int arr_size,
                        unsigned int entry_size,
                        int (*compare)(void *first, void *second)) {
  if (arr == 0 || arr_size == 0 || entry_size == 0)
    return;
  void *tmp = malloc(entry_size);
  compare_quicksort(arr, entry_size, 0, arr_size - 1, compare, tmp);
  free(tmp);
}


x86 assembly (clang, -O0):
<compare_quick_sort>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     1165 <compare_quick_sort+0x35>
cmpl   $0x0,-0xc(%rbp)
je     1165 <compare_quick_sort+0x35>
cmpl   $0x0,-0x10(%rbp)
jne    116a <compare_quick_sort+0x3a>
jmp    119b <compare_quick_sort+0x6b>
mov    -0x10(%rbp),%edi
call   1050 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%esi
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
mov    -0x18(%rbp),%r8
mov    -0x20(%rbp),%r9
xor    %edx,%edx
call   1040 <compare_quicksort@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<compare_quick_sort>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
test   %rdi,%rdi
je     1180 <compare_quick_sort+0x50>
mov    %esi,%ebp
test   %esi,%esi
je     1180 <compare_quick_sort+0x50>
mov    %edx,%ebx
test   %edx,%edx
je     1180 <compare_quick_sort+0x50>
mov    %rcx,%r14
mov    %rdi,%r15
mov    %ebx,%edi
call   1050 <malloc@plt>
mov    %rax,%r12
add    $0xffffffff,%ebp
mov    %r15,%rdi
mov    %ebx,%esi
xor    %edx,%edx
mov    %ebp,%ecx
mov    %r14,%r8
mov    %rax,%r9
call   1040 <compare_quicksort@plt>
mov    %r12,%rdi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @compare_quick_sort(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 i8*
store i8* %0, i8** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 (i8*, i8*)* %3, i32 (i8*, i8*)** %8
%10 = load i8*, i8** %5
%11 = icmp eq i8* %10, null
br i1 %11, label %18, label %12
12: ; preds = %4
%13 = load i32, i32* %6
%14 = icmp eq i32 %13, 0
br i1 %14, label %18, label %15
15: ; preds = %12
%16 = load i32, i32* %7
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %15, %12, %4
br label %31
19: ; preds = %15
%20 = load i32, i32* %7
%21 = call i8* @malloc(i32 %20)
store i8* %21, i8** %9
%22 = load i8*, i8** %5
%23 = load i32, i32* %7
%24 = load i32, i32* %6
%25 = sub i32 %24, 1
%26 = load i32 (i8*, i8*)*, i32 (i8*, i8*)** %8
%27 = load i8*, i8** %9
%28 = call i32 @compare_quicksort(i8* %22, i32 %23, i32 0, i32 %25, i32 (i8*, i8*)* %26, i8* %27)
%29 = load i8*, i8** %9
%30 = call i32 @free(i8* %29)
br label %31
31: ; preds = %19, %18
ret void
}

LLVM IR (-O2):
define void @compare_quick_sort(i8* %0, i32 %1, i32 %2, i32 (i8*, i8*)* %3) {
%5 = icmp eq i8* %0, null
%6 = icmp eq i32 %1, 0
%7 = or i1 %5, %6
%8 = icmp eq i32 %2, 0
%9 = or i1 %7, %8
br i1 %9, label %15, label %10
10: ; preds = %4
%11 = tail call i8* @malloc(i32 %2)
%12 = add i32 %1, -1
%13 = tail call i32 @compare_quicksort(i8* %0, i32 %2, i32 0, i32 %12, i32 (i8*, i8*)* %3, i8* %11)
%14 = tail call i32 @free(i8* %11)
br label %15
15: ; preds = %4, %10
ret void
}