#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 A[100], j, i, size, key;
  printf("Enter the size: ");
  scanf("%d", &size);
  printf("Enter elements below: \n");
  for (i = 0; i < size; i++)
    scanf("%d", &A[i]);
  printf("\nSorting.....\n");
  for (j = 1; j < size; j++) {
    key = A[j];
    i = j - 1;
    while ((i > -1) && (A[i] >= key)) {
      A[i + 1] = A[i];
      i--;
    }
    A[i + 1] = key;
  }
  printf("Here is the sorted array: \n");
  for (i = 0; i < size; i++)
    printf("%d ", A[i]);
  printf("\n");
  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    0xeca(%rip),%rdi
lea    -0x1ac(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x1a8(%rbp)
mov    -0x1a8(%rbp),%eax
cmp    -0x1ac(%rbp),%eax
jge    11b2 <main+0x92>
movslq -0x1a8(%rbp),%rax
lea    -0x1a0(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe78(%rip),%rdi
call   1040 <scanf@plt>
mov    -0x1a8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1a8(%rbp)
jmp    116b <main+0x4b>
lea    0xe73(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x1a4(%rbp)
mov    -0x1a4(%rbp),%eax
cmp    -0x1ac(%rbp),%eax
jge    12a4 <main+0x184>
movslq -0x1a4(%rbp),%rax
mov    -0x1a0(%rbp,%rax,4),%eax
mov    %eax,-0x1b0(%rbp)
mov    -0x1a4(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x1a8(%rbp)
xor    %eax,%eax
cmpl   $0xffffffff,-0x1a8(%rbp)
mov    %al,-0x1b1(%rbp)
jle    1231 <main+0x111>
movslq -0x1a8(%rbp),%rax
mov    -0x1a0(%rbp,%rax,4),%eax
cmp    -0x1b0(%rbp),%eax
setge  %al
mov    %al,-0x1b1(%rbp)
mov    -0x1b1(%rbp),%al
test   $0x1,%al
jne    1244 <main+0x124>
jmp    1278 <main+0x158>
movslq -0x1a8(%rbp),%rax
mov    -0x1a0(%rbp,%rax,4),%ecx
mov    -0x1a8(%rbp),%eax
add    $0x1,%eax
cltq
mov    %ecx,-0x1a0(%rbp,%rax,4)
mov    -0x1a8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x1a8(%rbp)
jmp    11ff <main+0xdf>
mov    -0x1b0(%rbp),%ecx
mov    -0x1a8(%rbp),%eax
add    $0x1,%eax
cltq
mov    %ecx,-0x1a0(%rbp,%rax,4)
mov    -0x1a4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1a4(%rbp)
jmp    11ca <main+0xaa>
lea    0xd90(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x1a8(%rbp)
mov    -0x1a8(%rbp),%eax
cmp    -0x1ac(%rbp),%eax
jge    12fe <main+0x1de>
movslq -0x1a8(%rbp),%rax
mov    -0x1a0(%rbp,%rax,4),%esi
lea    0xd74(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1a8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1a8(%rbp)
jmp    12bc <main+0x19c>
lea    0xd25(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x1c0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x1a0,%rsp
lea    0xead(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xeb0(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1060 <scanf@plt>
lea    0xea6(%rip),%rdi
call   1040 <puts@plt>
cmpl   $0x0,0xc(%rsp)
jle    11ad <main+0x6d>
lea    0x10(%rsp),%r15
xor    %ebx,%ebx
lea    0xe85(%rip),%r14
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %r15,%rsi
call   1060 <scanf@plt>
add    $0x1,%rbx
movslq 0xc(%rsp),%rax
add    $0x4,%r15
cmp    %rax,%rbx
jl     1190 <main+0x50>
lea    0xe7b(%rip),%rdi
call   1040 <puts@plt>
mov    0xc(%rsp),%eax
cmp    $0x2,%eax
jl     1213 <main+0xd3>
mov    $0x1,%ecx
jmp    11e0 <main+0xa0>
nopl   0x0(%rax)
movslq %esi,%rsi
mov    %edx,0x10(%rsp,%rsi,4)
add    $0x1,%rcx
cmp    %rax,%rcx
je     1213 <main+0xd3>
mov    0x10(%rsp,%rcx,4),%edx
mov    %rcx,%rsi
nopw   0x0(%rax,%rax,1)
lea    -0x1(%rsi),%rdi
mov    %edi,%ebx
mov    0x10(%rsp,%rbx,4),%ebx
cmp    %edx,%ebx
jl     11d0 <main+0x90>
mov    %ebx,0x10(%rsp,%rsi,4)
lea    0x1(%rdi),%rbx
mov    %rdi,%rsi
cmp    $0x1,%rbx
jg     11f0 <main+0xb0>
xor    %esi,%esi
jmp    11d0 <main+0x90>
lea    0xe23(%rip),%rdi
call   1040 <puts@plt>
cmpl   $0x0,0xc(%rsp)
jle    124c <main+0x10c>
lea    0xde7(%rip),%r14
xor    %ebx,%ebx
nop
mov    0x10(%rsp,%rbx,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbx
movslq 0xc(%rsp),%rax
cmp    %rax,%rbx
jl     1230 <main+0xf0>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x1a0,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [17 x i8] c"Enter the size: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [24 x i8] c"Enter elements below: \0A\00"
@.str.3 = [15 x i8] c"\0ASorting.....\0A\00"
@.str.4 = [28 x i8] c"Here is the sorted array: \0A\00"
@.str.5 = [4 x i8] c"%d \00"
@.str.6 = [2 x i8] c"\0A\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 ([17 x i8], [17 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* %5)
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %4
br label %10
10: ; preds = %19, %0
%11 = load i32, i32* %4
%12 = load i32, i32* %5
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %22
14: ; preds = %10
%15 = load i32, i32* %4
%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* %4
%21 = add nsw i32 %20, 1
store i32 %21, i32* %4
br label %10
22: ; preds = %10
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %3
br label %24
24: ; preds = %64, %22
%25 = load i32, i32* %3
%26 = load i32, i32* %5
%27 = icmp slt i32 %25, %26
br i1 %27, label %28, label %67
28: ; preds = %24
%29 = load i32, i32* %3
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %30
%32 = load i32, i32* %31
store i32 %32, i32* %6
%33 = load i32, i32* %3
%34 = sub nsw i32 %33, 1
store i32 %34, i32* %4
br label %35
35: ; preds = %47, %28
%36 = load i32, i32* %4
%37 = icmp sgt i32 %36, -1
br i1 %37, label %38, label %45
38: ; preds = %35
%39 = load i32, i32* %4
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %40
%42 = load i32, i32* %41
%43 = load i32, i32* %6
%44 = icmp sge i32 %42, %43
br label %45
45: ; preds = %38, %35
%46 = phi i1 [ false, %35 ], [ %44, %38 ]
br i1 %46, label %47, label %58
47: ; preds = %45
%48 = load i32, i32* %4
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %49
%51 = load i32, i32* %50
%52 = load i32, i32* %4
%53 = add nsw i32 %52, 1
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %54
store i32 %51, i32* %55
%56 = load i32, i32* %4
%57 = add nsw i32 %56, -1
store i32 %57, i32* %4
br label %35
58: ; preds = %45
%59 = load i32, i32* %6
%60 = load i32, i32* %4
%61 = add nsw i32 %60, 1
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %62
store i32 %59, i32* %63
br label %64
64: ; preds = %58
%65 = load i32, i32* %3
%66 = add nsw i32 %65, 1
store i32 %66, i32* %3
br label %24
67: ; preds = %24
%68 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %4
br label %69
69: ; preds = %79, %67
%70 = load i32, i32* %4
%71 = load i32, i32* %5
%72 = icmp slt i32 %70, %71
br i1 %72, label %73, label %82
73: ; preds = %69
%74 = load i32, i32* %4
%75 = sext i32 %74 to i64
%76 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %75
%77 = load i32, i32* %76
%78 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %77)
br label %79
79: ; preds = %73
%80 = load i32, i32* %4
%81 = add nsw i32 %80, 1
store i32 %81, i32* %4
br label %69
82: ; preds = %69
%83 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [17 x i8] c"Enter the size: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.5 = [4 x i8] c"%d \00"
@str = [23 x i8] c"Enter elements below: \00"
@str.7 = [14 x i8] c"\0ASorting.....\00"
@str.8 = [27 x i8] c"Here is the sorted array: \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 ([17 x i8], [17 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 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
%8 = load i32, i32* %2
%9 = icmp sgt i32 %8, 0
br i1 %9, label %10, label %18
10: ; preds = %0, %10
%11 = phi i64 [ %14, %10 ], [ 0, %0 ]
%12 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %11
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %12)
%14 = add nuw nsw i64 %11, 1
%15 = load i32, i32* %2
%16 = sext i32 %15 to i64
%17 = icmp slt i64 %14, %16
br i1 %17, label %10, label %18
18: ; preds = %10, %0
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.7, i64 0, i64 0))
%20 = load i32, i32* %2
%21 = icmp sgt i32 %20, 1
br i1 %21, label %22, label %45
22: ; preds = %18
%23 = zext i32 %20 to i64
br label %24
24: ; preds = %22, %38
%25 = phi i64 [ 1, %22 ], [ %43, %38 ]
%26 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %25
%27 = load i32, i32* %26
br label %28
28: ; preds = %24, %35
%29 = phi i64 [ %25, %24 ], [ %30, %35 ]
%30 = add nsw i64 %29, -1
%31 = and i64 %30, 4294967295
%32 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %31
%33 = load i32, i32* %32
%34 = icmp slt i32 %33, %27
br i1 %34, label %38, label %35
35: ; preds = %28
%36 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %29
store i32 %33, i32* %36
%37 = icmp sgt i64 %29, 1
br i1 %37, label %28, label %38
38: ; preds = %35, %28
%39 = phi i64 [ 0, %35 ], [ %29, %28 ]
%40 = shl i64 %39, 32
%41 = ashr exact i64 %40, 32
%42 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %41
store i32 %27, i32* %42
%43 = add nuw nsw i64 %25, 1
%44 = icmp eq i64 %43, %23
br i1 %44, label %45, label %24
45: ; preds = %38, %18
%46 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.8, i64 0, i64 0))
%47 = load i32, i32* %2
%48 = icmp sgt i32 %47, 0
br i1 %48, label %49, label %58
49: ; preds = %45, %49
%50 = phi i64 [ %54, %49 ], [ 0, %45 ]
%51 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %50
%52 = load i32, i32* %51
%53 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %52)
%54 = add nuw nsw i64 %50, 1
%55 = load i32, i32* %2
%56 = sext i32 %55 to i64
%57 = icmp slt i64 %54, %56
br i1 %57, label %49, label %58
58: ; preds = %49, %45
%59 = call i32 @putchar(i32 10)
ret i32 0
}