#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 */
typedef int /*<<< orphan*/ A;

/* Variables and functions */
int /*<<< orphan*/ array_print(char *, int /*<<< orphan*/, int *, int);
int /*<<< orphan*/ getchar();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ quick_sort(int *, int /*<<< orphan*/, int);
int main(void) {
  int A[] = {2, 9, 4, 7, 6, 7, 5, 8, 3, 1, 2, 9, 4, 7, 6, 7};
  int n = sizeof(A) / sizeof(A[0]);
  int *pA;
  pA = A;
  array_print(" Input", 0, pA, n);
  quick_sort(A, 0, n - 1);
  array_print("Output", 0, pA, n);
  printf("Press any key to end...");
  getchar();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x50(%rbp),%rdi
lea    0xe96(%rip),%rsi
mov    $0x40,%edx
call   1050 <memcpy@plt>
movl   $0x10,-0x54(%rbp)
lea    -0x50(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    -0x60(%rbp),%rdx
mov    -0x54(%rbp),%ecx
lea    0xeaf(%rip),%rdi
xor    %esi,%esi
call   1070 <array_print@plt>
lea    -0x50(%rbp),%rdi
mov    -0x54(%rbp),%edx
sub    $0x1,%edx
xor    %esi,%esi
call   1060 <quick_sort@plt>
mov    -0x60(%rbp),%rdx
mov    -0x54(%rbp),%ecx
lea    0xe90(%rip),%rdi
xor    %esi,%esi
call   1070 <array_print@plt>
lea    0xe89(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x40,%rsp
movaps 0xee4(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xec8(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xeac(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xe90(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0xec5(%rip),%rdi
mov    %rsp,%rbx
xor    %esi,%esi
mov    %rbx,%rdx
mov    $0x10,%ecx
call   1060 <array_print@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0xf,%edx
call   1050 <quick_sort@plt>
lea    0xea4(%rip),%rdi
xor    %esi,%esi
mov    %rbx,%rdx
mov    $0x10,%ecx
call   1060 <array_print@plt>
lea    0xe95(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
call   1040 <getchar@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.A = [16 x i32] [i32 2, i32 9, i32 4, i32 7, i32 6, i32 7, i32 5, i32 8, i32 3, i32 1, i32 2, i32 9, i32 4, i32 7, i32 6, i32 7]
@.str = [7 x i8] c" Input\00"
@.str.1 = [7 x i8] c"Output\00"
@.str.2 = [24 x i8] c"Press any key to end...\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [16 x i32]
%3 = alloca i32
%4 = alloca i32*
store i32 0, i32* %1
%5 = bitcast [16 x i32]* %2 to i8*
store i32 16, i32* %3
%6 = getelementptr inbounds [16 x i32], [16 x i32]* %2, i64 0, i64 0
store i32* %6, i32** %4
%7 = load i32*, i32** %4
%8 = load i32, i32* %3
%9 = call i32 @array_print(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 0, i32* %7, i32 %8)
%10 = getelementptr inbounds [16 x i32], [16 x i32]* %2, i64 0, i64 0
%11 = load i32, i32* %3
%12 = sub nsw i32 %11, 1
%13 = call i32 @quick_sort(i32* %10, i32 0, i32 %12)
%14 = load i32*, i32** %4
%15 = load i32, i32* %3
%16 = call i32 @array_print(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 0, i32* %14, i32 %15)
%17 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%18 = call i32 (...) @getchar()
ret i32 0
}

LLVM IR (-O2):
@__const.main.A = [16 x i32] [i32 2, i32 9, i32 4, i32 7, i32 6, i32 7, i32 5, i32 8, i32 3, i32 1, i32 2, i32 9, i32 4, i32 7, i32 6, i32 7]
@.str = [7 x i8] c" Input\00"
@.str.1 = [7 x i8] c"Output\00"
@.str.2 = [24 x i8] c"Press any key to end...\00"
define i32 @main() {
%1 = alloca [16 x i32]
%2 = bitcast [16 x i32]* %1 to i8*
%3 = getelementptr inbounds [16 x i32], [16 x i32]* %1, i64 0, i64 0
%4 = call i32 @array_print(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 0, i32* %3, i32 16)
%5 = call i32 @quick_sort(i32* %3, i32 0, i32 15)
%6 = call i32 @array_print(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 0, i32* %3, i32 16)
%7 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 (...) @getchar()
ret i32 0
}