#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*/ displayArray(int *, int);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ promptValue(int *);
int /*<<< orphan*/ sortArray(int *, int);
int /*<<< orphan*/ stdout;
int main() {
  int tab_length = 10;
  int tab[tab_length];
  for (int i = 0; i < tab_length; i++) {
    tab[i] = 0;
  }
  for (int i = 0; i < tab_length; i++) {
    printf("Enter integer value at array's index[%d]? ", i);
    fflush(stdout);
    promptValue(&tab[i]);
  }
  printf("\nView array content unsorted:\n");
  displayArray(tab, tab_length);
  printf("\nNow, sorting the array...\n");
  sortArray(tab, tab_length);
  printf("\nView array content sorted:\n");
  displayArray(tab, tab_length);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xa,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x10(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x28(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11bd <main+0x6d>
mov    -0x28(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movl   $0x0,(%rax,%rcx,4)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1194 <main+0x44>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1211 <main+0xc1>
mov    -0x20(%rbp),%esi
lea    0xe26(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2df8(%rip),%rax
mov    (%rax),%edi
call   1060 <fflush@plt>
mov    -0x28(%rbp),%rdi
movslq -0x20(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdi
call   1050 <promptValue@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11c4 <main+0x74>
lea    0xe13(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1070 <displayArray@plt>
lea    0xe18(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1040 <sortArray@plt>
lea    0xe1a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1070 <displayArray@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x30,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
movq   $0x0,0x20(%rsp)
lea    0x20(%rsp),%r15
lea    0x10(%rsp),%r12
lea    0xe6d(%rip),%r13
mov    %r13,%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2e3a(%rip),%rbx
mov    (%rbx),%edi
call   1070 <fflush@plt>
mov    %rsp,%r14
mov    %r14,%rdi
call   1060 <promptValue@plt>
mov    %r13,%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%rbx),%edi
call   1070 <fflush@plt>
lea    0x4(%rsp),%rdi
call   1060 <promptValue@plt>
mov    %r13,%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%rbx),%edi
call   1070 <fflush@plt>
lea    0x8(%rsp),%rdi
call   1060 <promptValue@plt>
mov    %r13,%rdi
mov    $0x3,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%rbx),%edi
call   1070 <fflush@plt>
lea    0xc(%rsp),%rdi
call   1060 <promptValue@plt>
mov    %r13,%rdi
mov    $0x4,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%rbx),%edi
call   1070 <fflush@plt>
mov    %r12,%rdi
call   1060 <promptValue@plt>
mov    %r13,%rdi
mov    $0x5,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%rbx),%edi
call   1070 <fflush@plt>
lea    0x14(%rsp),%rdi
call   1060 <promptValue@plt>
mov    %r13,%rdi
mov    $0x6,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%rbx),%edi
call   1070 <fflush@plt>
lea    0x18(%rsp),%rdi
call   1060 <promptValue@plt>
mov    %r13,%rdi
mov    $0x7,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%rbx),%edi
call   1070 <fflush@plt>
lea    0x1c(%rsp),%rdi
call   1060 <promptValue@plt>
mov    %r13,%rdi
mov    $0x8,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%rbx),%edi
call   1070 <fflush@plt>
mov    %r15,%rdi
call   1060 <promptValue@plt>
mov    %r13,%rdi
mov    $0x9,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%rbx),%edi
call   1070 <fflush@plt>
lea    0x24(%rsp),%rdi
call   1060 <promptValue@plt>
lea    0xd50(%rip),%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
mov    $0xa,%esi
call   1080 <displayArray@plt>
lea    0xd55(%rip),%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
mov    $0xa,%esi
call   1050 <sortArray@plt>
lea    0xd57(%rip),%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
mov    $0xa,%esi
call   1080 <displayArray@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [43 x i8] c"Enter integer value at array's index[%d]? \00"
@stdout = global i32 0
@.str.1 = [31 x i8] c"\0AView array content unsorted:\0A\00"
@.str.2 = [28 x i8] c"\0ANow, sorting the array...\0A\00"
@.str.3 = [29 x i8] c"\0AView array content sorted:\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
store i32 10, i32* %2
%7 = load i32, i32* %2
%8 = zext i32 %7 to i64
%9 = call i8* @llvm.stacksave()
store i8* %9, i8** %3
%10 = alloca i32, i64 %8
store i64 %8, i64* %4
store i32 0, i32* %5
br label %11
11: ; preds = %19, %0
%12 = load i32, i32* %5
%13 = load i32, i32* %2
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %22
15: ; preds = %11
%16 = load i32, i32* %5
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i32, i32* %10, i64 %17
store i32 0, i32* %18
br label %19
19: ; preds = %15
%20 = load i32, i32* %5
%21 = add nsw i32 %20, 1
store i32 %21, i32* %5
br label %11
22: ; preds = %11
store i32 0, i32* %6
br label %23
23: ; preds = %36, %22
%24 = load i32, i32* %6
%25 = load i32, i32* %2
%26 = icmp slt i32 %24, %25
br i1 %26, label %27, label %39
27: ; preds = %23
%28 = load i32, i32* %6
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i32 %28)
%30 = load i32, i32* @stdout
%31 = call i32 @fflush(i32 %30)
%32 = load i32, i32* %6
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i32, i32* %10, i64 %33
%35 = call i32 @promptValue(i32* %34)
br label %36
36: ; preds = %27
%37 = load i32, i32* %6
%38 = add nsw i32 %37, 1
store i32 %38, i32* %6
br label %23
39: ; preds = %23
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
%41 = load i32, i32* %2
%42 = call i32 @displayArray(i32* %10, i32 %41)
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
%44 = load i32, i32* %2
%45 = call i32 @sortArray(i32* %10, i32 %44)
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0))
%47 = load i32, i32* %2
%48 = call i32 @displayArray(i32* %10, i32 %47)
store i32 0, i32* %1
%49 = load i8*, i8** %3
%50 = load i32, i32* %1
ret i32 %50
}

LLVM IR (-O2):
@.str = [43 x i8] c"Enter integer value at array's index[%d]? \00"
@stdout = global i32 0
@str = [30 x i8] c"\0AView array content unsorted:\00"
@str.4 = [27 x i8] c"\0ANow, sorting the array...\00"
@str.5 = [28 x i8] c"\0AView array content sorted:\00"
define i32 @main() {
%1 = alloca [10 x i32]
%2 = bitcast [10 x i32]* %1 to i8*
%3 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i32 0)
%4 = load i32, i32* @stdout
%5 = call i32 @fflush(i32 %4)
%6 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 0
%7 = call i32 @promptValue(i32* %6)
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i32 1)
%9 = load i32, i32* @stdout
%10 = call i32 @fflush(i32 %9)
%11 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 1
%12 = call i32 @promptValue(i32* %11)
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i32 2)
%14 = load i32, i32* @stdout
%15 = call i32 @fflush(i32 %14)
%16 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 2
%17 = call i32 @promptValue(i32* %16)
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i32 3)
%19 = load i32, i32* @stdout
%20 = call i32 @fflush(i32 %19)
%21 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 3
%22 = call i32 @promptValue(i32* %21)
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i32 4)
%24 = load i32, i32* @stdout
%25 = call i32 @fflush(i32 %24)
%26 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 4
%27 = call i32 @promptValue(i32* %26)
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i32 5)
%29 = load i32, i32* @stdout
%30 = call i32 @fflush(i32 %29)
%31 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 5
%32 = call i32 @promptValue(i32* %31)
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i32 6)
%34 = load i32, i32* @stdout
%35 = call i32 @fflush(i32 %34)
%36 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 6
%37 = call i32 @promptValue(i32* %36)
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i32 7)
%39 = load i32, i32* @stdout
%40 = call i32 @fflush(i32 %39)
%41 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 7
%42 = call i32 @promptValue(i32* %41)
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i32 8)
%44 = load i32, i32* @stdout
%45 = call i32 @fflush(i32 %44)
%46 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 8
%47 = call i32 @promptValue(i32* %46)
%48 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i32 9)
%49 = load i32, i32* @stdout
%50 = call i32 @fflush(i32 %49)
%51 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 9
%52 = call i32 @promptValue(i32* %51)
%53 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str, i64 0, i64 0))
%54 = call i32 @displayArray(i32* %6, i32 10)
%55 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.4, i64 0, i64 0))
%56 = call i32 @sortArray(i32* %6, i32 10)
%57 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.5, i64 0, i64 0))
%58 = call i32 @displayArray(i32* %6, i32 10)
ret i32 0
}