#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*/ Qsort(unsigned long *, int /*<<< orphan*/, int);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, ...);
int main(void) {
  int i, size;
  unsigned long *arr;
  scanf("%d\n", &size);
  arr = (unsigned long *)malloc(sizeof(unsigned long) * size);
  for (i = 0; i < size; i++) {
    scanf("%lu", &arr[i]);
  }
  Qsort(arr, 0, size - 1);
  printf("Sorted Array\n");
  for (i = 0; i < size; i++) {
    printf("%lu \n", arr[i]);
  }
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
lea    -0xc(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
movslq -0xc(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11b2 <main+0x72>
mov    -0x18(%rbp),%rsi
movslq -0x8(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rsi
lea    0xe67(%rip),%rdi
mov    $0x0,%al
call   1050 <scanf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    117b <main+0x3b>
mov    -0x18(%rbp),%rdi
mov    -0xc(%rbp),%edx
sub    $0x1,%edx
xor    %esi,%esi
call   1060 <Qsort@plt>
lea    0xe3e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    120c <main+0xcc>
mov    -0x18(%rbp),%rax
movslq -0x8(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xe1f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11d8 <main+0x98>
lea    0xe07(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xe91(%rip),%rdi
lea    0x4(%rsp),%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
mov    0x4(%rsp),%edi
shl    $0x3,%edi
call   1060 <malloc@plt>
mov    %rax,%r15
mov    0x4(%rsp),%edx
test   %edx,%edx
jle    11bf <main+0x5f>
lea    0xe6b(%rip),%r14
mov    %r15,%r12
xor    %ebx,%ebx
xchg   %ax,%ax
mov    %r14,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
add    $0x1,%rbx
movslq 0x4(%rsp),%rdx
add    $0x8,%r12
cmp    %rdx,%rbx
jl     11a0 <main+0x40>
add    $0xffffffff,%edx
mov    %r15,%rdi
xor    %esi,%esi
call   1080 <Qsort@plt>
lea    0xe3b(%rip),%rdi
call   1040 <puts@plt>
cmpl   $0x0,0x4(%rsp)
jle    120c <main+0xac>
lea    0xe22(%rip),%r14
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
mov    (%r15,%rbx,8),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbx
movslq 0x4(%rsp),%rax
cmp    %rax,%rbx
jl     11f0 <main+0x90>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

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