#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ Sort(int *, int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, int *);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ puts(char *);
int main(void) {
  int input[5000];
  int i = 0;
  FILE *fp;
  fp = fopen("file1", "r");
  for (i = 0; i < 5000; i++) {
    fscanf(fp, "%d", &input[i]);
  }
  Sort(input, 5000);
  for (i = 0; i < 5000; i++) {
    printf("%d ", input[i]);
  }
  puts("");
  fclose(fp);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x4e40,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x4e34(%rbp)
lea    0xe7d(%rip),%rdi
lea    0xe7c(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x4e40(%rbp)
movl   $0x0,-0x4e34(%rbp)
cmpl   $0x1388,-0x4e34(%rbp)
jge    11ec <main+0x8c>
mov    -0x4e40(%rbp),%rdi
movslq -0x4e34(%rbp),%rax
lea    -0x4e30(%rbp),%rdx
shl    $0x2,%rax
add    %rax,%rdx
lea    0xe35(%rip),%rsi
call   1070 <fscanf@plt>
mov    -0x4e34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4e34(%rbp)
jmp    11a0 <main+0x40>
lea    -0x4e30(%rbp),%rdi
mov    $0x1388,%esi
call   1040 <Sort@plt>
movl   $0x0,-0x4e34(%rbp)
cmpl   $0x1388,-0x4e34(%rbp)
jge    1245 <main+0xe5>
movslq -0x4e34(%rbp),%rax
mov    -0x4e30(%rbp,%rax,4),%esi
lea    0xddf(%rip),%rdi
call   1060 <printf@plt>
mov    -0x4e34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4e34(%rbp)
jmp    1207 <main+0xa7>
lea    0xdc2(%rip),%rdi
call   1030 <puts@plt>
mov    -0x4e40(%rbp),%rdi
call   1050 <fclose@plt>
xor    %eax,%eax
add    $0x4e40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x4e20,%rsp
lea    0xe8d(%rip),%rdi
lea    0xe8c(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%r15
xor    %ebx,%ebx
lea    0xe7d(%rip),%r14
nopl   0x0(%rax,%rax,1)
lea    (%rsp,%rbx,1),%rdx
mov    %r15,%rdi
mov    %r14,%rsi
call   1070 <fscanf@plt>
add    $0x4,%rbx
cmp    $0x4e20,%rbx
jne    1190 <main+0x30>
mov    %rsp,%rdi
mov    $0x1388,%esi
call   1040 <Sort@plt>
xor    %ebx,%ebx
lea    0xe49(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    (%rsp,%rbx,4),%esi
mov    %r14,%rdi
call   1060 <printf@plt>
add    $0x1,%rbx
cmp    $0x1388,%rbx
jne    11d0 <main+0x70>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r15,%rdi
call   1050 <fclose@plt>
xor    %eax,%eax
add    $0x4e20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [6 x i8] c"file1\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [4 x i8] c"%d \00"
@.str.4 = [1 x i8] zeroinitializer
define i32 @main() {
%1 = alloca i32
%2 = alloca [5000 x i32]
%3 = alloca i32
%4 = alloca i32*
store i32 0, i32* %1
store i32 0, i32* %3
%5 = call i32* @fopen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %5, i32** %4
store i32 0, i32* %3
br label %6
6: ; preds = %15, %0
%7 = load i32, i32* %3
%8 = icmp slt i32 %7, 5000
br i1 %8, label %9, label %18
9: ; preds = %6
%10 = load i32*, i32** %4
%11 = load i32, i32* %3
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [5000 x i32], [5000 x i32]* %2, i64 0, i64 %12
%14 = call i32 @fscanf(i32* %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %13)
br label %15
15: ; preds = %9
%16 = load i32, i32* %3
%17 = add nsw i32 %16, 1
store i32 %17, i32* %3
br label %6
18: ; preds = %6
%19 = getelementptr inbounds [5000 x i32], [5000 x i32]* %2, i64 0, i64 0
%20 = call i32 @Sort(i32* %19, i32 5000)
store i32 0, i32* %3
br label %21
21: ; preds = %30, %18
%22 = load i32, i32* %3
%23 = icmp slt i32 %22, 5000
br i1 %23, label %24, label %33
24: ; preds = %21
%25 = load i32, i32* %3
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [5000 x i32], [5000 x i32]* %2, i64 0, i64 %26
%28 = load i32, i32* %27
%29 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %28)
br label %30
30: ; preds = %24
%31 = load i32, i32* %3
%32 = add nsw i32 %31, 1
store i32 %32, i32* %3
br label %21
33: ; preds = %21
%34 = call i32 @puts(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.4, i64 0, i64 0))
%35 = load i32*, i32** %4
%36 = call i32 @fclose(i32* %35)
ret i32 0
}

LLVM IR (-O2):
@.str = [6 x i8] c"file1\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [4 x i8] c"%d \00"
define i32 @main() {
%1 = alloca [5000 x i32]
%2 = bitcast [5000 x i32]* %1 to i8*
%3 = tail call i32* @fopen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %4
4: ; preds = %0, %4
%5 = phi i64 [ 0, %0 ], [ %8, %4 ]
%6 = getelementptr inbounds [5000 x i32], [5000 x i32]* %1, i64 0, i64 %5
%7 = call i32 @fscanf(i32* %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %6)
%8 = add nuw nsw i64 %5, 1
%9 = icmp eq i64 %8, 5000
br i1 %9, label %10, label %4
10: ; preds = %4
%11 = getelementptr inbounds [5000 x i32], [5000 x i32]* %1, i64 0, i64 0
%12 = call i32 @Sort(i32* %11, i32 5000)
br label %13
13: ; preds = %10, %13
%14 = phi i64 [ 0, %10 ], [ %18, %13 ]
%15 = getelementptr inbounds [5000 x i32], [5000 x i32]* %1, i64 0, i64 %14
%16 = load i32, i32* %15
%17 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %16)
%18 = add nuw nsw i64 %14, 1
%19 = icmp eq i64 %18, 5000
br i1 %19, label %20, label %13
20: ; preds = %13
%21 = call i32 @putchar(i32 10)
%22 = call i32 @fclose(i32* %3)
ret i32 0
}