#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*/ printf(char *, ...);
int /*<<< orphan*/ quicksort(int *, int /*<<< orphan*/, int);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int i, c, n, j;
  printf("Enter the number of elements to be sorted: ");
  scanf("%d", &n);
  int A[n];
  for (i = 0; i < n; i++)
    scanf("%d", &A[i]);
  quicksort(A, 0, n - 1);
  printf("Sorted elements: ");
  for (i = 0; i < n; i++)
    printf("%d ", A[i]);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xed8(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x10(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x20(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11c0 <main+0x90>
mov    -0x30(%rbp),%rsi
movslq -0x8(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe7f(%rip),%rdi
call   1050 <scanf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    118b <main+0x5b>
mov    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%edx
sub    $0x1,%edx
xor    %esi,%esi
call   1030 <quicksort@plt>
lea    0xe57(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    1219 <main+0xe9>
mov    -0x30(%rbp),%rax
movslq -0x8(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe3d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11e6 <main+0xb6>
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xebb(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xed9(%rip),%rdi
lea    -0x2c(%rbp),%rsi
call   1050 <scanf@plt>
mov    %rsp,%r12
mov    -0x2c(%rbp),%eax
mov    %rsp,%r15
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r15
mov    %r15,%rsp
mov    -0x2c(%rbp),%edx
test   %edx,%edx
jle    11ac <main+0x7c>
xor    %r13d,%r13d
lea    0xea4(%rip),%r14
mov    %r15,%rbx
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
add    $0x1,%r13
movslq -0x2c(%rbp),%rdx
add    $0x4,%rbx
cmp    %rdx,%r13
jl     1190 <main+0x60>
add    $0xffffffff,%edx
mov    %r15,%rdi
xor    %esi,%esi
call   1030 <quicksort@plt>
lea    0xe6f(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmpl   $0x0,-0x2c(%rbp)
jle    11fb <main+0xcb>
lea    0xe6d(%rip),%r14
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
mov    (%r15,%rbx,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbx
movslq -0x2c(%rbp),%rax
cmp    %rax,%rbx
jl     11e0 <main+0xb0>
mov    %r12,%rsp
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [44 x i8] c"Enter the number of elements to be sorted: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [18 x i8] c"Sorted elements: \00"
@.str.3 = [4 x i8] c"%d \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i64
store i32 0, i32* %1
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%10 = load i32, i32* %4
%11 = zext i32 %10 to i64
%12 = call i8* @llvm.stacksave()
store i8* %12, i8** %6
%13 = alloca i32, i64 %11
store i64 %11, i64* %7
store i32 0, i32* %2
br label %14
14: ; preds = %23, %0
%15 = load i32, i32* %2
%16 = load i32, i32* %4
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %26
18: ; preds = %14
%19 = load i32, i32* %2
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i32, i32* %13, i64 %20
%22 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %21)
br label %23
23: ; preds = %18
%24 = load i32, i32* %2
%25 = add nsw i32 %24, 1
store i32 %25, i32* %2
br label %14
26: ; preds = %14
%27 = load i32, i32* %4
%28 = sub nsw i32 %27, 1
%29 = call i32 @quicksort(i32* %13, i32 0, i32 %28)
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %2
br label %31
31: ; preds = %41, %26
%32 = load i32, i32* %2
%33 = load i32, i32* %4
%34 = icmp slt i32 %32, %33
br i1 %34, label %35, label %44
35: ; preds = %31
%36 = load i32, i32* %2
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i32, i32* %13, i64 %37
%39 = load i32, i32* %38
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %39)
br label %41
41: ; preds = %35
%42 = load i32, i32* %2
%43 = add nsw i32 %42, 1
store i32 %43, i32* %2
br label %31
44: ; preds = %31
%45 = load i8*, i8** %6
%46 = load i32, i32* %1
ret i32 %46
}

LLVM IR (-O2):
@.str = [44 x i8] c"Enter the number of elements to be sorted: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [18 x i8] c"Sorted elements: \00"
@.str.3 = [4 x i8] c"%d \00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
%6 = zext i32 %5 to i64
%7 = call i8* @llvm.stacksave()
%8 = alloca i32, i64 %6
%9 = load i32, i32* %1
%10 = icmp sgt i32 %9, 0
br i1 %10, label %11, label %19
11: ; preds = %0, %11
%12 = phi i64 [ %15, %11 ], [ 0, %0 ]
%13 = getelementptr inbounds i32, i32* %8, i64 %12
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %13)
%15 = add nuw nsw i64 %12, 1
%16 = load i32, i32* %1
%17 = sext i32 %16 to i64
%18 = icmp slt i64 %15, %17
br i1 %18, label %11, label %19
19: ; preds = %11, %0
%20 = phi i32 [ %9, %0 ], [ %16, %11 ]
%21 = add nsw i32 %20, -1
%22 = call i32 @quicksort(i32* %8, i32 0, i32 %21)
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
%24 = load i32, i32* %1
%25 = icmp sgt i32 %24, 0
br i1 %25, label %26, label %35
26: ; preds = %19, %26
%27 = phi i64 [ %31, %26 ], [ 0, %19 ]
%28 = getelementptr inbounds i32, i32* %8, i64 %27
%29 = load i32, i32* %28
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %29)
%31 = add nuw nsw i64 %27, 1
%32 = load i32, i32* %1
%33 = sext i32 %32 to i64
%34 = icmp slt i64 %31, %33
br i1 %34, label %26, label %35
35: ; preds = %26, %19
ret i32 0
}