#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 */
scalar_t__ EOF;
int /*<<< orphan*/ print_array(int *, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ quicksort(int *, int);
scalar_t__ scanf(char *, int *);
int main(int argc, char **argv) {
  int v;
  int array[1024];
  int i = 0;
  while (scanf("%d", &v) != EOF) {
    array[i++] = v;
    if (i > 1023)
      break;
  }
  print_array(array, i);
  printf("------------\n");
  quicksort(array, i);
  print_array(array, i);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1030,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x1024(%rbp)
lea    0xe96(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1060 <scanf@plt>
mov    0x2e6e(%rip),%rcx
cmp    (%rcx),%rax
je     11ba <main+0x7a>
mov    -0x14(%rbp),%ecx
mov    -0x1024(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x1024(%rbp)
cltq
mov    %ecx,-0x1020(%rbp,%rax,4)
cmpl   $0x3ff,-0x1024(%rbp)
jle    11b5 <main+0x75>
jmp    11ba <main+0x7a>
jmp    1163 <main+0x23>
lea    -0x1020(%rbp),%rdi
mov    -0x1024(%rbp),%esi
call   1030 <print_array@plt>
lea    0xe30(%rip),%rdi
call   1050 <printf@plt>
lea    -0x1020(%rbp),%rdi
mov    -0x1024(%rbp),%esi
call   1040 <quicksort@plt>
lea    -0x1020(%rbp),%rdi
mov    -0x1024(%rbp),%esi
call   1030 <print_array@plt>
mov    -0x4(%rbp),%eax
add    $0x1030,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x1018,%rsp
xor    %ebx,%ebx
lea    0xea9(%rip),%r14
lea    0xc(%rsp),%r15
mov    0x2e85(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r14,%rdi
mov    %r15,%rsi
call   1060 <scanf@plt>
cmp    (%r12),%rax
je     119b <main+0x5b>
mov    0xc(%rsp),%eax
mov    %eax,0x10(%rsp,%rbx,4)
add    $0x1,%rbx
cmp    $0x400,%rbx
jne    1170 <main+0x30>
mov    $0x400,%ebx
lea    0x10(%rsp),%r14
mov    %r14,%rdi
mov    %ebx,%esi
call   1040 <print_array@plt>
lea    0xe52(%rip),%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
mov    %ebx,%esi
call   1050 <quicksort@plt>
mov    %r14,%rdi
mov    %ebx,%esi
call   1040 <print_array@plt>
xor    %eax,%eax
add    $0x1018,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@EOF = global i64 0
@.str.1 = [14 x i8] c"------------\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [1024 x i32]
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %8
br label %9
9: ; preds = %22, %2
%10 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %6)
%11 = load i64, i64* @EOF
%12 = icmp ne i64 %10, %11
br i1 %12, label %13, label %23
13: ; preds = %9
%14 = load i32, i32* %6
%15 = load i32, i32* %8
%16 = add nsw i32 %15, 1
store i32 %16, i32* %8
%17 = sext i32 %15 to i64
%18 = getelementptr inbounds [1024 x i32], [1024 x i32]* %7, i64 0, i64 %17
store i32 %14, i32* %18
%19 = load i32, i32* %8
%20 = icmp sgt i32 %19, 1023
br i1 %20, label %21, label %22
21: ; preds = %13
br label %23
22: ; preds = %13
br label %9
23: ; preds = %21, %9
%24 = getelementptr inbounds [1024 x i32], [1024 x i32]* %7, i64 0, i64 0
%25 = load i32, i32* %8
%26 = call i32 @print_array(i32* %24, i32 %25)
%27 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%28 = getelementptr inbounds [1024 x i32], [1024 x i32]* %7, i64 0, i64 0
%29 = load i32, i32* %8
%30 = call i32 @quicksort(i32* %28, i32 %29)
%31 = getelementptr inbounds [1024 x i32], [1024 x i32]* %7, i64 0, i64 0
%32 = load i32, i32* %8
%33 = call i32 @print_array(i32* %31, i32 %32)
%34 = load i32, i32* %3
ret i32 %34
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@EOF = global i64 0
@str = [13 x i8] c"------------\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca [1024 x i32]
%5 = bitcast i32* %3 to i8*
%6 = bitcast [1024 x i32]* %4 to i8*
br label %7
7: ; preds = %12, %2
%8 = phi i64 [ %14, %12 ], [ 0, %2 ]
%9 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%10 = load i64, i64* @EOF
%11 = icmp eq i64 %9, %10
br i1 %11, label %17, label %12
12: ; preds = %7
%13 = load i32, i32* %3
%14 = add nuw nsw i64 %8, 1
%15 = getelementptr inbounds [1024 x i32], [1024 x i32]* %4, i64 0, i64 %8
store i32 %13, i32* %15
%16 = icmp eq i64 %14, 1024
br i1 %16, label %19, label %7
17: ; preds = %7
%18 = trunc i64 %8 to i32
br label %19
19: ; preds = %12, %17
%20 = phi i32 [ %18, %17 ], [ 1024, %12 ]
%21 = getelementptr inbounds [1024 x i32], [1024 x i32]* %4, i64 0, i64 0
%22 = call i32 @print_array(i32* %21, i32 %20)
%23 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str, i64 0, i64 0))
%24 = call i32 @quicksort(i32* %21, i32 %20)
%25 = call i32 @print_array(i32* %21, i32 %20)
ret i32 0
}