#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 *, int);
int /*<<< orphan*/ getchar();
int /*<<< orphan*/ printf(char *, ...);
int quick_sort(int *, int /*<<< orphan*/, int);
int main(void) {
  int A[] = {2, 9, 4, 7, 1, 5, 8, 3};
  int n = sizeof(A) / sizeof(A[0]);
  int *pA, ncnt;
  pA = A;
  array_print(" Input", pA, n);
  ncnt = quick_sort(A, 0, n - 1);
  array_print("Output", pA, n);
  printf("Iteration = %d\n", ncnt);
  printf("Press any key to end...");
  getchar();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeaa(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xea7(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xea4(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xea1(%rip),%rax
mov    %rax,-0x18(%rbp)
movl   $0x8,-0x34(%rbp)
lea    -0x30(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rsi
mov    -0x34(%rbp),%edx
lea    0xe88(%rip),%rdi
call   1060 <array_print@plt>
lea    -0x30(%rbp),%rdi
mov    -0x34(%rbp),%edx
sub    $0x1,%edx
xor    %esi,%esi
call   1050 <quick_sort@plt>
mov    %eax,-0x44(%rbp)
mov    -0x40(%rbp),%rsi
mov    -0x34(%rbp),%edx
lea    0xe68(%rip),%rdi
call   1060 <array_print@plt>
mov    -0x44(%rbp),%esi
lea    0xe60(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe62(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x28,%rsp
movaps 0xec3(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xea7(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0xebc(%rip),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
mov    $0x8,%edx
call   1060 <array_print@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x7,%edx
call   1050 <quick_sort@plt>
mov    %eax,%ebp
lea    0xe9b(%rip),%rdi
mov    %rbx,%rsi
mov    $0x8,%edx
call   1060 <array_print@plt>
lea    0xe8e(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe8e(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
call   1040 <getchar@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %rbp
ret

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

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