#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*/ print_array(int *, size_t);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ quick_sort(int *, int /*<<< orphan*/, size_t);
void test_sort(int *array, size_t len) {
  printf("Before:");
  print_array(array, len);
  printf("\n");
  quick_sort(array, 0, len - 1);
  printf("After:");
  print_array(array, len);
  printf("\n\n");
}


x86 assembly (clang, -O0):
<test_sort>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xeb9(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <print_array@plt>
lea    0xeb0(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
sub    $0x1,%rdx
xor    %esi,%esi
call   1050 <quick_sort@plt>
lea    0xe89(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <print_array@plt>
lea    0xe77(%rip),%rdi
call   1040 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_sort>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xe9f(%rip),%rdi
call   1060 <printf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <print_array@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    -0x1(%r14),%rdx
mov    %rbx,%rdi
xor    %esi,%esi
call   1070 <quick_sort@plt>
lea    0xe78(%rip),%rdi
call   1060 <printf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <print_array@plt>
lea    0xe68(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <puts@plt>

LLVM IR (-O0):
@.str = [8 x i8] c"Before:\00"
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [7 x i8] c"After:\00"
@.str.3 = [3 x i8] c"\0A\0A\00"
define void @test_sort(i32* %0, i64 %1) {
%3 = alloca i32*
%4 = alloca i64
store i32* %0, i32** %3
store i64 %1, i64* %4
%5 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%6 = load i32*, i32** %3
%7 = load i64, i64* %4
%8 = call i32 @print_array(i32* %6, i64 %7)
%9 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%10 = load i32*, i32** %3
%11 = load i64, i64* %4
%12 = sub i64 %11, 1
%13 = call i32 @quick_sort(i32* %10, i32 0, i64 %12)
%14 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%15 = load i32*, i32** %3
%16 = load i64, i64* %4
%17 = call i32 @print_array(i32* %15, i64 %16)
%18 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [8 x i8] c"Before:\00"
@.str.2 = [7 x i8] c"After:\00"
@str = [2 x i8] c"\0A\00"
define void @test_sort(i32* %0, i64 %1) {
%3 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 @print_array(i32* %0, i64 %1)
%5 = tail call i32 @putchar(i32 10)
%6 = add i64 %1, -1
%7 = tail call i32 @quick_sort(i32* %0, i32 0, i64 %6)
%8 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%9 = tail call i32 @print_array(i32* %0, i64 %1)
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
ret void
}