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


x86 assembly (clang, -O0):
<quick_sort>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     1161 <quick_sort+0x31>
cmpl   $0x0,-0xc(%rbp)
je     1161 <quick_sort+0x31>
cmpl   $0x0,-0x10(%rbp)
jne    1166 <quick_sort+0x36>
jmp    1193 <quick_sort+0x63>
mov    -0x10(%rbp),%edi
call   1050 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%esi
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
mov    -0x18(%rbp),%r8
xor    %edx,%edx
call   1040 <quicksort@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<quick_sort>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
test   %rdi,%rdi
je     117b <quick_sort+0x4b>
mov    %esi,%ebx
test   %esi,%esi
je     117b <quick_sort+0x4b>
mov    %edx,%ebp
test   %edx,%edx
je     117b <quick_sort+0x4b>
mov    %rdi,%r14
mov    %ebp,%edi
call   1050 <malloc@plt>
mov    %rax,%r15
add    $0xffffffff,%ebx
mov    %r14,%rdi
mov    %ebp,%esi
xor    %edx,%edx
mov    %ebx,%ecx
mov    %rax,%r8
call   1040 <quicksort@plt>
mov    %r15,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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