#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*/ print_arr(int *, size_t);
int /*<<< orphan*/ printf(char *);
int scanf(char *, ...);
int /*<<< orphan*/ slow_sort(int *, size_t);
int main(void) {
  static int arr_buff[1024];
  size_t arr_len;
  printf("Enter array size, followed by the elements.\n");
  printf("> ");
  while (scanf("%zu", &arr_len) == 1) {
    size_t i;
    for (i = 0; i < arr_len; i++)
      scanf("%d", &arr_buff[i]);
    slow_sort(arr_buff, arr_len);
    print_arr(arr_buff, arr_len);
    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
call   1040 <printf@plt>
lea    0xed3(%rip),%rdi
call   1040 <printf@plt>
lea    0xebf(%rip),%rdi
lea    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
cmp    $0x1,%eax
jne    11fa <main+0xba>
movq   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    11c9 <main+0x89>
mov    -0x18(%rbp),%rax
lea    0x2ead(%rip),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe80(%rip),%rdi
mov    $0x0,%al
call   1050 <scanf@plt>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    118a <main+0x4a>
mov    -0x10(%rbp),%rsi
lea    0x2e7c(%rip),%rdi
call   1060 <slow_sort@plt>
mov    -0x10(%rbp),%rsi
lea    0x2e6c(%rip),%rdi
call   1030 <print_arr@plt>
lea    0xe44(%rip),%rdi
call   1040 <printf@plt>
jmp    1167 <main+0x27>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xea9(%rip),%rdi
call   1030 <puts@plt>
lea    0xe9a(%rip),%rdi
call   1050 <printf@plt>
lea    0xe86(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
cmp    $0x1,%eax
jne    1220 <main+0xd0>
lea    0x2ecc(%rip),%r13
lea    0xe65(%rip),%r15
mov    %rsp,%r12
lea    0xe5f(%rip),%rbx
jmp    11e4 <main+0x94>
nopw   0x0(%rax,%rax,1)
xor    %esi,%esi
mov    %r13,%rdi
call   1070 <slow_sort@plt>
mov    (%rsp),%rsi
mov    %r13,%rdi
call   1040 <print_arr@plt>
lea    0xe3a(%rip),%rdi
call   1050 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
cmp    $0x1,%eax
jne    1220 <main+0xd0>
cmpq   $0x0,(%rsp)
je     11b0 <main+0x60>
mov    %r13,%rbp
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
add    $0x1,%r14
mov    (%rsp),%rsi
add    $0x4,%rbp
cmp    %rsi,%r14
jb     1200 <main+0xb0>
jmp    11b2 <main+0x62>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@main.arr_buff = internal global [1024 x i32] zeroinitializer
@.str = [45 x i8] c"Enter array size, followed by the elements.\0A\00"
@.str.1 = [3 x i8] c"> \00"
@.str.2 = [4 x i8] c"%zu\00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [4 x i8] c"\0A> \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i64
store i32 0, i32* %1
%4 = call i32 @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %6
6: ; preds = %21, %0
%7 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i64* %2)
%8 = icmp eq i32 %7, 1
br i1 %8, label %9, label %27
9: ; preds = %6
store i64 0, i64* %3
br label %10
10: ; preds = %18, %9
%11 = load i64, i64* %3
%12 = load i64, i64* %2
%13 = icmp ult i64 %11, %12
br i1 %13, label %14, label %21
14: ; preds = %10
%15 = load i64, i64* %3
%16 = getelementptr inbounds [1024 x i32], [1024 x i32]* @main.arr_buff, i64 0, i64 %15
%17 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %16)
br label %18
18: ; preds = %14
%19 = load i64, i64* %3
%20 = add i64 %19, 1
store i64 %20, i64* %3
br label %10
21: ; preds = %10
%22 = load i64, i64* %2
%23 = call i32 @slow_sort(i32* getelementptr inbounds ([1024 x i32], [1024 x i32]* @main.arr_buff, i64 0, i64 0), i64 %22)
%24 = load i64, i64* %2
%25 = call i32 @print_arr(i32* getelementptr inbounds ([1024 x i32], [1024 x i32]* @main.arr_buff, i64 0, i64 0), i64 %24)
%26 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
br label %6
27: ; preds = %6
ret i32 0
}

LLVM IR (-O2):
@main.arr_buff = internal global [1024 x i32] zeroinitializer
@.str.1 = [3 x i8] c"> \00"
@.str.2 = [4 x i8] c"%zu\00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [4 x i8] c"\0A> \00"
@str = [44 x i8] c"Enter array size, followed by the elements.\00"
define i32 @main() {
%1 = alloca i64
%2 = bitcast i64* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%5 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i64* %1)
%6 = icmp eq i32 %5, 1
br i1 %6, label %7, label %25
7: ; preds = %0, %17
%8 = load i64, i64* %1
%9 = icmp eq i64 %8, 0
br i1 %9, label %17, label %10
10: ; preds = %7, %10
%11 = phi i64 [ %14, %10 ], [ 0, %7 ]
%12 = getelementptr inbounds [1024 x i32], [1024 x i32]* @main.arr_buff, i64 0, i64 %11
%13 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %12)
%14 = add nuw i64 %11, 1
%15 = load i64, i64* %1
%16 = icmp ult i64 %14, %15
br i1 %16, label %10, label %17
17: ; preds = %10, %7
%18 = phi i64 [ 0, %7 ], [ %15, %10 ]
%19 = call i32 @slow_sort(i32* getelementptr inbounds ([1024 x i32], [1024 x i32]* @main.arr_buff, i64 0, i64 0), i64 %18)
%20 = load i64, i64* %1
%21 = call i32 @print_arr(i32* getelementptr inbounds ([1024 x i32], [1024 x i32]* @main.arr_buff, i64 0, i64 0), i64 %20)
%22 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%23 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i64* %1)
%24 = icmp eq i32 %23, 1
br i1 %24, label %7, label %25
25: ; preds = %17, %0
ret i32 0
}