#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(void) {
  int nums[10], temp;
  printf("Enter any 10 numbers: \n");
  for (int i = 0; i < 10; i++) {
    scanf("%d", &nums[i]);
  }
  for (int i = 0; i < (10 - 1); i++) {
    for (int j = 0; j < (10 - 1) - i; j++) {
      if (nums[j] > nums[j + 1]) {
        temp = nums[j];
        nums[j] = nums[j + 1];
        nums[j + 1] = temp;
      }
    }
  }
  printf("\nSorted Numbers: \n");
  for (int i = 0; i < 10; i++) {
    printf("%d \t", nums[i]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x38(%rbp)
cmpl   $0xa,-0x38(%rbp)
jge    1177 <main+0x57>
movslq -0x38(%rbp),%rax
lea    -0x30(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xeb4(%rip),%rdi
call   1040 <scanf@plt>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    1144 <main+0x24>
movl   $0x0,-0x3c(%rbp)
cmpl   $0x9,-0x3c(%rbp)
jge    1211 <main+0xf1>
movl   $0x0,-0x40(%rbp)
mov    -0x40(%rbp),%eax
mov    $0x9,%ecx
sub    -0x3c(%rbp),%ecx
cmp    %ecx,%eax
jge    11fe <main+0xde>
movslq -0x40(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%eax
mov    -0x40(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
cmp    -0x30(%rbp,%rcx,4),%eax
jle    11eb <main+0xcb>
movslq -0x40(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%eax
mov    %eax,-0x34(%rbp)
mov    -0x40(%rbp),%eax
add    $0x1,%eax
cltq
mov    -0x30(%rbp,%rax,4),%ecx
movslq -0x40(%rbp),%rax
mov    %ecx,-0x30(%rbp,%rax,4)
mov    -0x34(%rbp),%ecx
mov    -0x40(%rbp),%eax
add    $0x1,%eax
cltq
mov    %ecx,-0x30(%rbp,%rax,4)
jmp    11f0 <main+0xd0>
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    118f <main+0x6f>
jmp    1203 <main+0xe3>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    117e <main+0x5e>
lea    0xe03(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x44(%rbp)
cmpl   $0xa,-0x44(%rbp)
jge    1254 <main+0x134>
movslq -0x44(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%esi
lea    0xdef(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    1226 <main+0x106>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x30,%rsp
lea    0xecc(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb8(%rip),%rbx
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0x4(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0x14(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0x18(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0x1c(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0x20(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0x24(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
mov    $0x9,%r8d
xor    %ecx,%ecx
jmp    11ed <main+0xbd>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%rcx
add    $0xffffffffffffffff,%r8
cmp    $0x9,%ecx
je     1262 <main+0x132>
mov    (%rsp),%eax
cmp    $0x8,%rcx
jne    1210 <main+0xe0>
xor    %ebx,%ebx
test   $0x1,%r8b
je     11e0 <main+0xb0>
mov    0x4(%rsp,%rbx,4),%edx
cmp    %edx,%eax
jle    11e0 <main+0xb0>
mov    %edx,(%rsp,%rbx,4)
mov    %eax,0x4(%rsp,%rbx,4)
jmp    11e0 <main+0xb0>
nop
mov    %r8,%rsi
and    $0xfffffffffffffffe,%rsi
xor    %edi,%edi
jmp    1230 <main+0x100>
nopl   0x0(%rax,%rax,1)
mov    %edx,0x4(%rsp,%rdi,4)
mov    %eax,0x8(%rsp,%rdi,4)
mov    %rbx,%rdi
cmp    %rbx,%rsi
je     11f8 <main+0xc8>
mov    0x4(%rsp,%rdi,4),%edx
cmp    %edx,%eax
jle    1250 <main+0x120>
mov    %edx,(%rsp,%rdi,4)
mov    %eax,0x4(%rsp,%rdi,4)
jmp    1252 <main+0x122>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %edx,%eax
lea    0x2(%rdi),%rbx
mov    0x8(%rsp,%rdi,4),%edx
cmp    %edx,%eax
jg     1220 <main+0xf0>
mov    %edx,%eax
jmp    1228 <main+0xf8>
lea    0xdb6(%rip),%rdi
call   1030 <puts@plt>
mov    (%rsp),%esi
lea    0xd8b(%rip),%rbx
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x4(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0xc(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x10(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x14(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x18(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x1c(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x20(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x24(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
ret

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

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