#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*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int nums[1000];
  int i = 0, a, b, m;
  printf("\n\n Type numbers which are not 42, and type 42 to stop typing and "
         "sort other! \n");
  while (i < 1000) {
    printf("\n Number: ");
    scanf("%d", &nums[i]);
    if (nums[i] == 42) {
      break;
    }
    i++;
  }
  for (b = 0; b < i; ++b)
    for (m = i - 1; m > b; m--) {
      if (nums[m - 1] > nums[m]) {
        a = nums[m - 1];
        nums[m - 1] = nums[m];
        nums[m] = a;
      }
    }
  for (a = 0; a < i; a++)
    printf("\n %d", nums[a]);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xfc0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xfb4(%rbp)
lea    0xebd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x3e8,-0xfb4(%rbp)
jge    11b7 <main+0x97>
lea    0xeee(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movslq -0xfb4(%rbp),%rax
lea    -0xfb0(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xed8(%rip),%rdi
call   1040 <scanf@plt>
movslq -0xfb4(%rbp),%rax
cmpl   $0x2a,-0xfb0(%rbp,%rax,4)
2a
jne    11a3 <main+0x83>
jmp    11b7 <main+0x97>
mov    -0xfb4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xfb4(%rbp)
jmp    114a <main+0x2a>
movl   $0x0,-0xfbc(%rbp)
mov    -0xfbc(%rbp),%eax
cmp    -0xfb4(%rbp),%eax
jge    1298 <main+0x178>
mov    -0xfb4(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0xfc0(%rbp)
mov    -0xfc0(%rbp),%eax
cmp    -0xfbc(%rbp),%eax
jle    127f <main+0x15f>
mov    -0xfc0(%rbp),%eax
sub    $0x1,%eax
cltq
mov    -0xfb0(%rbp,%rax,4),%eax
movslq -0xfc0(%rbp),%rcx
cmp    -0xfb0(%rbp,%rcx,4),%eax
jle    1266 <main+0x146>
mov    -0xfc0(%rbp),%eax
sub    $0x1,%eax
cltq
mov    -0xfb0(%rbp,%rax,4),%eax
mov    %eax,-0xfb8(%rbp)
movslq -0xfc0(%rbp),%rax
mov    -0xfb0(%rbp,%rax,4),%ecx
mov    -0xfc0(%rbp),%eax
sub    $0x1,%eax
cltq
mov    %ecx,-0xfb0(%rbp,%rax,4)
mov    -0xfb8(%rbp),%ecx
movslq -0xfc0(%rbp),%rax
mov    %ecx,-0xfb0(%rbp,%rax,4)
jmp    126b <main+0x14b>
mov    -0xfc0(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xfc0(%rbp)
jmp    11e2 <main+0xc2>
jmp    1284 <main+0x164>
mov    -0xfbc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xfbc(%rbp)
jmp    11c1 <main+0xa1>
movl   $0x0,-0xfb8(%rbp)
mov    -0xfb8(%rbp),%eax
cmp    -0xfb4(%rbp),%eax
jge    12e4 <main+0x1c4>
movslq -0xfb8(%rbp),%rax
mov    -0xfb0(%rbp,%rax,4),%esi
lea    0xd91(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xfb8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xfb8(%rbp)
jmp    12a2 <main+0x182>
xor    %eax,%eax
add    $0xfc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0xfa8,%rsp
lea    0xecb(%rip),%rdi
call   1030 <puts@plt>
mov    %rsp,%rbx
lea    0xeac(%rip),%r14
lea    0xeb2(%rip),%r15
xor    %r12d,%r12d
xchg   %ax,%ax
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
cmpl   $0x2a,(%rbx)
je     1193 <main+0x63>
add    $0xffffffffffffffff,%r12
add    $0x4,%rbx
cmp    $0xfffffffffffffc18,%r12
jne    1160 <main+0x30>
mov    $0x3e8,%r12d
jmp    119b <main+0x6b>
test   %r12d,%r12d
je     1216 <main+0xe6>
neg    %r12
mov    %r12d,%r15d
add    $0xffffffff,%r12d
lea    -0x1(%r15),%rax
movslq %r12d,%rcx
xor    %edx,%edx
jmp    11b9 <main+0x89>
nopl   (%rax)
add    $0x1,%rdx
cmp    %r15,%rdx
je     11ed <main+0xbd>
mov    %rax,%rsi
cmp    %rcx,%rdx
jl     11d9 <main+0xa9>
jmp    11b0 <main+0x80>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0xffffffffffffffff,%rsi
cmp    %rdx,%rsi
jle    11b0 <main+0x80>
mov    -0x4(%rsp,%rsi,4),%edi
mov    (%rsp,%rsi,4),%ebx
cmp    %ebx,%edi
jle    11d0 <main+0xa0>
mov    %ebx,-0x4(%rsp,%rsi,4)
mov    %edi,(%rsp,%rsi,4)
jmp    11d0 <main+0xa0>
lea    0xe17(%rip),%r14
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
mov    (%rsp,%rbx,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1200 <main+0xd0>
xor    %eax,%eax
add    $0xfa8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [79 x i8] c"\0A\0A Type numbers which are not 42, and type 42 to stop typing and sort other! \0A\00"
@.str.1 = [11 x i8] c"\0A Number: \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [5 x i8] c"\0A %d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [1000 x i32]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([79 x i8], [79 x i8]* @.str, i64 0, i64 0))
br label %8
8: ; preds = %23, %0
%9 = load i32, i32* %3
%10 = icmp slt i32 %9, 1000
br i1 %10, label %11, label %26
11: ; preds = %8
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%13 = load i32, i32* %3
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [1000 x i32], [1000 x i32]* %2, i64 0, i64 %14
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %15)
%17 = load i32, i32* %3
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [1000 x i32], [1000 x i32]* %2, i64 0, i64 %18
%20 = load i32, i32* %19
%21 = icmp eq i32 %20, 42
br i1 %21, label %22, label %23
22: ; preds = %11
br label %26
23: ; preds = %11
%24 = load i32, i32* %3
%25 = add nsw i32 %24, 1
store i32 %25, i32* %3
br label %8
26: ; preds = %22, %8
store i32 0, i32* %5
br label %27
27: ; preds = %72, %26
%28 = load i32, i32* %5
%29 = load i32, i32* %3
%30 = icmp slt i32 %28, %29
br i1 %30, label %31, label %75
31: ; preds = %27
%32 = load i32, i32* %3
%33 = sub nsw i32 %32, 1
store i32 %33, i32* %6
br label %34
34: ; preds = %68, %31
%35 = load i32, i32* %6
%36 = load i32, i32* %5
%37 = icmp sgt i32 %35, %36
br i1 %37, label %38, label %71
38: ; preds = %34
%39 = load i32, i32* %6
%40 = sub nsw i32 %39, 1
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds [1000 x i32], [1000 x i32]* %2, i64 0, i64 %41
%43 = load i32, i32* %42
%44 = load i32, i32* %6
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds [1000 x i32], [1000 x i32]* %2, i64 0, i64 %45
%47 = load i32, i32* %46
%48 = icmp sgt i32 %43, %47
br i1 %48, label %49, label %67
49: ; preds = %38
%50 = load i32, i32* %6
%51 = sub nsw i32 %50, 1
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds [1000 x i32], [1000 x i32]* %2, i64 0, i64 %52
%54 = load i32, i32* %53
store i32 %54, i32* %4
%55 = load i32, i32* %6
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds [1000 x i32], [1000 x i32]* %2, i64 0, i64 %56
%58 = load i32, i32* %57
%59 = load i32, i32* %6
%60 = sub nsw i32 %59, 1
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds [1000 x i32], [1000 x i32]* %2, i64 0, i64 %61
store i32 %58, i32* %62
%63 = load i32, i32* %4
%64 = load i32, i32* %6
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds [1000 x i32], [1000 x i32]* %2, i64 0, i64 %65
store i32 %63, i32* %66
br label %67
67: ; preds = %49, %38
br label %68
68: ; preds = %67
%69 = load i32, i32* %6
%70 = add nsw i32 %69, -1
store i32 %70, i32* %6
br label %34
71: ; preds = %34
br label %72
72: ; preds = %71
%73 = load i32, i32* %5
%74 = add nsw i32 %73, 1
store i32 %74, i32* %5
br label %27
75: ; preds = %27
store i32 0, i32* %4
br label %76
76: ; preds = %86, %75
%77 = load i32, i32* %4
%78 = load i32, i32* %3
%79 = icmp slt i32 %77, %78
br i1 %79, label %80, label %89
80: ; preds = %76
%81 = load i32, i32* %4
%82 = sext i32 %81 to i64
%83 = getelementptr inbounds [1000 x i32], [1000 x i32]* %2, i64 0, i64 %82
%84 = load i32, i32* %83
%85 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %84)
br label %86
86: ; preds = %80
%87 = load i32, i32* %4
%88 = add nsw i32 %87, 1
store i32 %88, i32* %4
br label %76
89: ; preds = %76
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [11 x i8] c"\0A Number: \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [5 x i8] c"\0A %d\00"
@str = [78 x i8] c"\0A\0A Type numbers which are not 42, and type 42 to stop typing and sort other! \00"
define i32 @main() {
%1 = alloca [1000 x i32]
%2 = bitcast [1000 x i32]* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([78 x i8], [78 x i8]* @str, i64 0, i64 0))
br label %4
4: ; preds = %0, %11
%5 = phi i64 [ 0, %0 ], [ %12, %11 ]
%6 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%7 = getelementptr inbounds [1000 x i32], [1000 x i32]* %1, i64 0, i64 %5
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %7)
%9 = load i32, i32* %7
%10 = icmp eq i32 %9, 42
br i1 %10, label %14, label %11
11: ; preds = %4
%12 = add nuw nsw i64 %5, 1
%13 = icmp eq i64 %12, 1000
br i1 %13, label %17, label %4
14: ; preds = %4
%15 = trunc i64 %5 to i32
%16 = icmp eq i32 %15, 0
br i1 %16, label %52, label %17
17: ; preds = %11, %14
%18 = phi i32 [ %15, %14 ], [ 1000, %11 ]
%19 = add nsw i32 %18, -1
%20 = zext i32 %18 to i64
%21 = add nsw i64 %20, -1
%22 = sext i32 %19 to i64
br label %23
23: ; preds = %17, %42
%24 = phi i64 [ 0, %17 ], [ %43, %42 ]
%25 = icmp slt i64 %24, %22
br i1 %25, label %28, label %42
26: ; preds = %42
%27 = zext i32 %18 to i64
br label %45
28: ; preds = %23, %39
%29 = phi i64 [ %31, %39 ], [ %20, %23 ]
%30 = phi i64 [ %40, %39 ], [ %21, %23 ]
%31 = add nsw i64 %29, -1
%32 = add nsw i64 %29, -2
%33 = getelementptr inbounds [1000 x i32], [1000 x i32]* %1, i64 0, i64 %32
%34 = load i32, i32* %33
%35 = getelementptr inbounds [1000 x i32], [1000 x i32]* %1, i64 0, i64 %30
%36 = load i32, i32* %35
%37 = icmp sgt i32 %34, %36
br i1 %37, label %38, label %39
38: ; preds = %28
store i32 %36, i32* %33
store i32 %34, i32* %35
br label %39
39: ; preds = %28, %38
%40 = add nsw i64 %30, -1
%41 = icmp sgt i64 %40, %24
br i1 %41, label %28, label %42
42: ; preds = %39, %23
%43 = add nuw nsw i64 %24, 1
%44 = icmp eq i64 %43, %20
br i1 %44, label %26, label %23
45: ; preds = %26, %45
%46 = phi i64 [ 0, %26 ], [ %50, %45 ]
%47 = getelementptr inbounds [1000 x i32], [1000 x i32]* %1, i64 0, i64 %46
%48 = load i32, i32* %47
%49 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %48)
%50 = add nuw nsw i64 %46, 1
%51 = icmp eq i64 %50, %27
br i1 %51, label %52, label %45
52: ; preds = %45, %14
ret i32 0
}