#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 elements[10];
  int i, j, temp;
  printf("Please input %d numbers\n", 10);
  for (i = 0; i < 10; i++) {
    scanf("%d", &elements[i]);
  }
  for (i = 0; i < 10; i++) {
    for (j = i + 1; j < 10; j++) {
      if (elements[i] > elements[j]) {
        temp = elements[i];
        elements[i] = elements[j];
        elements[j] = temp;
      }
    }
  }
  printf("Asending order:");
  for (i = 0; i < 10; i++) {
    printf("%4d", elements[i]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0xa,%esi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x34(%rbp)
cmpl   $0xa,-0x34(%rbp)
jge    117c <main+0x5c>
movslq -0x34(%rbp),%rax
lea    -0x30(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xeb0(%rip),%rdi
call   1040 <scanf@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1149 <main+0x29>
movl   $0x0,-0x34(%rbp)
cmpl   $0xa,-0x34(%rbp)
jge    1202 <main+0xe2>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
cmpl   $0xa,-0x38(%rbp)
jge    11ef <main+0xcf>
movslq -0x34(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%eax
movslq -0x38(%rbp),%rcx
cmp    -0x30(%rbp,%rcx,4),%eax
jle    11dc <main+0xbc>
movslq -0x34(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%eax
mov    %eax,-0x3c(%rbp)
movslq -0x38(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%ecx
movslq -0x34(%rbp),%rax
mov    %ecx,-0x30(%rbp,%rax,4)
mov    -0x3c(%rbp),%ecx
movslq -0x38(%rbp),%rax
mov    %ecx,-0x30(%rbp,%rax,4)
jmp    11e1 <main+0xc1>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    1196 <main+0x76>
jmp    11f4 <main+0xd4>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1183 <main+0x63>
lea    0xe13(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x34(%rbp)
cmpl   $0xa,-0x34(%rbp)
jge    1245 <main+0x125>
movslq -0x34(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%esi
lea    0xdfc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1217 <main+0xf7>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x28,%rsp
lea    0xed2(%rip),%rdi
xor    %ebx,%ebx
mov    $0xa,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xed6(%rip),%r14
mov    %rsp,%rsi
mov    %r14,%rdi
call   1040 <scanf@plt>
lea    0x4(%rsp),%rsi
mov    %r14,%rdi
call   1040 <scanf@plt>
lea    0x8(%rsp),%rsi
mov    %r14,%rdi
call   1040 <scanf@plt>
lea    0xc(%rsp),%rsi
mov    %r14,%rdi
call   1040 <scanf@plt>
lea    0x10(%rsp),%rsi
mov    %r14,%rdi
call   1040 <scanf@plt>
lea    0x14(%rsp),%rsi
mov    %r14,%rdi
call   1040 <scanf@plt>
lea    0x18(%rsp),%rsi
mov    %r14,%rdi
call   1040 <scanf@plt>
lea    0x1c(%rsp),%rsi
mov    %r14,%rdi
call   1040 <scanf@plt>
lea    0x20(%rsp),%rsi
mov    %r14,%rdi
call   1040 <scanf@plt>
lea    0x24(%rsp),%rsi
mov    %r14,%rdi
call   1040 <scanf@plt>
mov    $0x1,%eax
jmp    11da <main+0xba>
nopw   0x0(%rax,%rax,1)
add    $0x1,%rax
cmp    $0xa,%rbx
je     120c <main+0xec>
mov    %rbx,%rcx
add    $0x1,%rbx
cmp    $0x8,%rcx
ja     11d0 <main+0xb0>
mov    %rax,%rdx
jmp    11fa <main+0xda>
nopl   0x0(%rax)
add    $0x1,%rdx
cmp    $0xa,%rdx
je     11d0 <main+0xb0>
mov    (%rsp,%rcx,4),%esi
mov    (%rsp,%rdx,4),%edi
cmp    %edi,%esi
jle    11f0 <main+0xd0>
mov    %edi,(%rsp,%rcx,4)
mov    %esi,(%rsp,%rdx,4)
jmp    11f0 <main+0xd0>
lea    0xe09(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    (%rsp),%esi
lea    0xe08(%rip),%rbx
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x4(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x8(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0xc(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x10(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x14(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x18(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x1c(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x20(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x24(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@.str = [25 x i8] c"Please input %d numbers\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [16 x i8] c"Asending order:\00"
@.str.3 = [4 x i8] c"%4d\00"
define i32 @main() {
%1 = alloca [10 x i32]
%2 = bitcast [10 x i32]* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 10)
%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 %27
24: ; preds = %41, %27
%25 = add nuw nsw i64 %29, 1
%26 = icmp eq i64 %30, 10
br i1 %26, label %44, label %27
27: ; preds = %0, %24
%28 = phi i64 [ 0, %0 ], [ %30, %24 ]
%29 = phi i64 [ 1, %0 ], [ %25, %24 ]
%30 = add nuw nsw i64 %28, 1
%31 = icmp ult i64 %28, 9
br i1 %31, label %32, label %24
32: ; preds = %27
%33 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 %28
br label %34
34: ; preds = %32, %41
%35 = phi i64 [ %29, %32 ], [ %42, %41 ]
%36 = load i32, i32* %33
%37 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 %35
%38 = load i32, i32* %37
%39 = icmp sgt i32 %36, %38
br i1 %39, label %40, label %41
40: ; preds = %34
store i32 %38, i32* %33
store i32 %36, i32* %37
br label %41
41: ; preds = %34, %40
%42 = add nuw nsw i64 %35, 1
%43 = icmp eq i64 %42, 10
br i1 %43, label %24, label %34
44: ; preds = %24
%45 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%46 = load i32, i32* %4
%47 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %46)
%48 = load i32, i32* %6
%49 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %48)
%50 = load i32, i32* %8
%51 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %50)
%52 = load i32, i32* %10
%53 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %52)
%54 = load i32, i32* %12
%55 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %54)
%56 = load i32, i32* %14
%57 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %56)
%58 = load i32, i32* %16
%59 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %58)
%60 = load i32, i32* %18
%61 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %60)
%62 = load i32, i32* %20
%63 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %62)
%64 = load i32, i32* %22
%65 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %64)
ret i32 0
}