#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 data[100], n, temp, i, j;
  printf("Enter number of terms: ");
  scanf("%d", &n);
  printf("Enter elements: ");
  for (i = 0; i < n; i++) {
    scanf("%d", &data[i]);
  }
  for (i = 1; i < n; i++) {
    temp = data[i];
    j = i - 1;
    while (temp < data[j] && j >= 0) {
      data[j + 1] = data[j];
      --j;
    }
    data[j + 1] = temp;
  }
  printf("In ascending order: ");
  for (i = 0; i < n; i++)
    printf("%d\t", data[i]);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1c0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xec7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed1(%rip),%rdi
lea    -0x1a4(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xec1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x1ac(%rbp)
mov    -0x1ac(%rbp),%eax
cmp    -0x1a4(%rbp),%eax
jge    11b2 <main+0x92>
movslq -0x1ac(%rbp),%rax
lea    -0x1a0(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe7f(%rip),%rdi
call   1040 <scanf@plt>
mov    -0x1ac(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1ac(%rbp)
jmp    116b <main+0x4b>
movl   $0x1,-0x1ac(%rbp)
mov    -0x1ac(%rbp),%eax
cmp    -0x1a4(%rbp),%eax
jge    1296 <main+0x176>
movslq -0x1ac(%rbp),%rax
mov    -0x1a0(%rbp,%rax,4),%eax
mov    %eax,-0x1a8(%rbp)
mov    -0x1ac(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x1b0(%rbp)
mov    -0x1a8(%rbp),%ecx
movslq -0x1b0(%rbp),%rdx
xor    %eax,%eax
cmp    -0x1a0(%rbp,%rdx,4),%ecx
mov    %al,-0x1b1(%rbp)
jge    1223 <main+0x103>
cmpl   $0x0,-0x1b0(%rbp)
setge  %al
mov    %al,-0x1b1(%rbp)
mov    -0x1b1(%rbp),%al
test   $0x1,%al
jne    1236 <main+0x116>
jmp    126a <main+0x14a>
movslq -0x1b0(%rbp),%rax
mov    -0x1a0(%rbp,%rax,4),%ecx
mov    -0x1b0(%rbp),%eax
add    $0x1,%eax
cltq
mov    %ecx,-0x1a0(%rbp,%rax,4)
mov    -0x1b0(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x1b0(%rbp)
jmp    11f1 <main+0xd1>
mov    -0x1a8(%rbp),%ecx
mov    -0x1b0(%rbp),%eax
add    $0x1,%eax
cltq
mov    %ecx,-0x1a0(%rbp,%rax,4)
mov    -0x1ac(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1ac(%rbp)
jmp    11bc <main+0x9c>
lea    0xd8f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x1ac(%rbp)
mov    -0x1ac(%rbp),%eax
cmp    -0x1a4(%rbp),%eax
jge    12f0 <main+0x1d0>
movslq -0x1ac(%rbp),%rax
mov    -0x1a0(%rbp,%rax,4),%esi
lea    0xd6c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1ac(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1ac(%rbp)
jmp    12ae <main+0x18e>
xor    %eax,%eax
add    $0x1c0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x1a0,%rsp
lea    0xecd(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xed7(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
lea    0xec9(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
cmpl   $0x0,0xc(%rsp)
jle    11fd <main+0xdd>
lea    0x10(%rsp),%r15
xor    %ebx,%ebx
lea    0xea6(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <scanf@plt>
add    $0x1,%rbx
movslq 0xc(%rsp),%r8
add    $0x4,%r15
cmp    %r8,%rbx
jl     1180 <main+0x60>
cmp    $0x2,%r8d
jl     11fd <main+0xdd>
add    $0xffffffff,%r8d
mov    $0x1,%eax
xor    %edx,%edx
jmp    11c8 <main+0xa8>
add    $0x1,%rbx
movslq %ebx,%rcx
mov    %esi,0x10(%rsp,%rcx,4)
add    $0x1,%rax
add    $0x1,%rdx
cmp    %r8,%rdx
je     11fd <main+0xdd>
mov    0xc(%rsp,%rax,4),%edi
mov    0x10(%rsp,%rax,4),%esi
mov    %rax,%rbx
cmp    %edi,%esi
jge    11b4 <main+0x94>
mov    %rdx,%rcx
nopw   0x0(%rax,%rax,1)
lea    0x1(%rcx),%ebx
mov    %edi,0x10(%rsp,%rbx,4)
lea    -0x1(%rcx),%rbx
mov    0xc(%rsp,%rcx,4),%edi
cmp    %edi,%esi
jge    11b0 <main+0x90>
test   %rcx,%rcx
mov    %rbx,%rcx
jg     11e0 <main+0xc0>
jmp    11b0 <main+0x90>
lea    0xe28(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
cmpl   $0x0,0xc(%rsp)
jle    123c <main+0x11c>
lea    0xe28(%rip),%r14
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
mov    0x10(%rsp,%rbx,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x1,%rbx
movslq 0xc(%rsp),%rax
cmp    %rax,%rbx
jl     1220 <main+0x100>
xor    %eax,%eax
add    $0x1a0,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [24 x i8] c"Enter number of terms: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [17 x i8] c"Enter elements: \00"
@.str.3 = [21 x i8] c"In ascending order: \00"
@.str.4 = [4 x i8] c"%d\09\00"
define i32 @main() {
%1 = alloca [100 x i32]
%2 = alloca i32
%3 = bitcast [100 x i32]* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%8 = load i32, i32* %2
%9 = icmp sgt i32 %8, 0
br i1 %9, label %15, label %52
10: ; preds = %15
%11 = icmp sgt i32 %20, 1
br i1 %11, label %12, label %52
12: ; preds = %10
%13 = add nsw i32 %20, -1
%14 = zext i32 %13 to i64
br label %23
15: ; preds = %0, %15
%16 = phi i64 [ %19, %15 ], [ 0, %0 ]
%17 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %16
%18 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %17)
%19 = add nuw nsw i64 %16, 1
%20 = load i32, i32* %2
%21 = sext i32 %20 to i64
%22 = icmp slt i64 %19, %21
br i1 %22, label %15, label %10
23: ; preds = %12, %44
%24 = phi i64 [ 1, %12 ], [ %49, %44 ]
%25 = phi i64 [ 0, %12 ], [ %50, %44 ]
%26 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %24
%27 = load i32, i32* %26
%28 = add nsw i64 %24, -1
%29 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %28
%30 = load i32, i32* %29
%31 = icmp slt i32 %27, %30
br i1 %31, label %32, label %44
32: ; preds = %23, %32
%33 = phi i64 [ %38, %32 ], [ %25, %23 ]
%34 = phi i32 [ %40, %32 ], [ %30, %23 ]
%35 = phi i64 [ %33, %32 ], [ %24, %23 ]
%36 = and i64 %35, 4294967295
%37 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %36
store i32 %34, i32* %37
%38 = add nsw i64 %33, -1
%39 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %38
%40 = load i32, i32* %39
%41 = icmp slt i32 %27, %40
%42 = icmp sgt i64 %33, 0
%43 = select i1 %41, i1 %42, i1 false
br i1 %43, label %32, label %44
44: ; preds = %32, %23
%45 = phi i64 [ %24, %23 ], [ %33, %32 ]
%46 = shl i64 %45, 32
%47 = ashr exact i64 %46, 32
%48 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %47
store i32 %27, i32* %48
%49 = add nuw nsw i64 %24, 1
%50 = add nuw nsw i64 %25, 1
%51 = icmp eq i64 %50, %14
br i1 %51, label %52, label %23
52: ; preds = %44, %0, %10
%53 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
%54 = load i32, i32* %2
%55 = icmp sgt i32 %54, 0
br i1 %55, label %56, label %65
56: ; preds = %52, %56
%57 = phi i64 [ %61, %56 ], [ 0, %52 ]
%58 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %57
%59 = load i32, i32* %58
%60 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %59)
%61 = add nuw nsw i64 %57, 1
%62 = load i32, i32* %2
%63 = sext i32 %62 to i64
%64 = icmp slt i64 %61, %63
br i1 %64, label %56, label %65
65: ; preds = %56, %52
ret i32 0
}