#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*/ arraySort(int *, int);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int numbers[1000];
  int i;
  for (i = 0; i < 1000; i++) {
    int number;
    scanf("%d", &number);
    if (number == 42) {
      break;
    } else {
      numbers[i] = number;
    }
  }
  int arrayLenght = i;
  arraySort(numbers, arrayLenght);
  for (i = 0; i < arrayLenght; i++) {
    printf("%d\n", numbers[i]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xfc0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xfb4(%rbp)
cmpl   $0x3e8,-0xfb4(%rbp)
jge    11ae <main+0x7e>
lea    0xe9d(%rip),%rdi
lea    -0xfb8(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x2a,-0xfb8(%rbp)
jne    1181 <main+0x51>
jmp    11ae <main+0x7e>
mov    -0xfb8(%rbp),%ecx
movslq -0xfb4(%rbp),%rax
mov    %ecx,-0xfb0(%rbp,%rax,4)
jmp    119a <main+0x6a>
mov    -0xfb4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xfb4(%rbp)
jmp    114c <main+0x1c>
mov    -0xfb4(%rbp),%eax
mov    %eax,-0xfbc(%rbp)
lea    -0xfb0(%rbp),%rdi
mov    -0xfbc(%rbp),%esi
call   1050 <arraySort@plt>
movl   $0x0,-0xfb4(%rbp)
mov    -0xfb4(%rbp),%eax
cmp    -0xfbc(%rbp),%eax
jge    1216 <main+0xe6>
movslq -0xfb4(%rbp),%rax
mov    -0xfb0(%rbp,%rax,4),%esi
lea    0xe06(%rip),%rdi
call   1030 <printf@plt>
mov    -0xfb4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xfb4(%rbp)
jmp    11d6 <main+0xa6>
xor    %eax,%eax
add    $0xfc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0xfb8,%rsp
xor    %r12d,%r12d
lea    0xeb8(%rip),%r14
lea    0xc(%rsp),%r15
nopl   (%rax)
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <scanf@plt>
mov    0xc(%rsp),%eax
cmp    $0x2a,%eax
je     118d <main+0x5d>
mov    %eax,0x10(%rsp,%r12,4)
add    $0x1,%r12
cmp    $0x3e8,%r12
jne    1150 <main+0x20>
lea    0x10(%rsp),%rdi
mov    $0x3e8,%esi
call   1050 <arraySort@plt>
mov    $0x3e8,%r12d
jmp    119f <main+0x6f>
lea    0x10(%rsp),%rdi
mov    %r12d,%esi
call   1050 <arraySort@plt>
test   %r12d,%r12d
je     11c5 <main+0x95>
xor    %ebx,%ebx
lea    0xe5b(%rip),%r14
nopl   0x0(%rax,%rax,1)
mov    0x10(%rsp,%rbx,4),%esi
mov    %r14,%rdi
call   1030 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r12
jne    11b0 <main+0x80>
xor    %eax,%eax
add    $0xfb8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca [1000 x i32]
%2 = alloca i32
%3 = bitcast [1000 x i32]* %1 to i8*
%4 = bitcast i32* %2 to i8*
br label %5
5: ; preds = %0, %10
%6 = phi i64 [ 0, %0 ], [ %12, %10 ]
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%8 = load i32, i32* %2
%9 = icmp eq i32 %8, 42
br i1 %9, label %17, label %10
10: ; preds = %5
%11 = getelementptr inbounds [1000 x i32], [1000 x i32]* %1, i64 0, i64 %6
store i32 %8, i32* %11
%12 = add nuw nsw i64 %6, 1
%13 = icmp eq i64 %12, 1000
br i1 %13, label %14, label %5
14: ; preds = %10
%15 = getelementptr inbounds [1000 x i32], [1000 x i32]* %1, i64 0, i64 0
%16 = call i32 @arraySort(i32* %15, i32 1000)
br label %22
17: ; preds = %5
%18 = trunc i64 %6 to i32
%19 = getelementptr inbounds [1000 x i32], [1000 x i32]* %1, i64 0, i64 0
%20 = call i32 @arraySort(i32* %19, i32 %18)
%21 = icmp eq i32 %18, 0
br i1 %21, label %32, label %22
22: ; preds = %14, %17
%23 = phi i64 [ 1000, %14 ], [ %6, %17 ]
%24 = and i64 %23, 4294967295
br label %25
25: ; preds = %22, %25
%26 = phi i64 [ 0, %22 ], [ %30, %25 ]
%27 = getelementptr inbounds [1000 x i32], [1000 x i32]* %1, i64 0, i64 %26
%28 = load i32, i32* %27
%29 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %28)
%30 = add nuw nsw i64 %26, 1
%31 = icmp eq i64 %30, %24
br i1 %31, label %32, label %25
32: ; preds = %25, %17
ret i32 0
}