#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 size_of_array;
  printf(
      "Enter the size of your array with respect to the number of elements: ");
  scanf("%d", &size_of_array);
  int integer_array[size_of_array];
  int i, j, key;
  printf("Enter %d elements into the array: ", size_of_array);
  for (i = 0; i < size_of_array; i++)
    scanf("%d", &integer_array[i]);
  printf("The unsorted list is: ");
  for (i = 0; i < size_of_array; i++)
    printf("%d ", integer_array[i]);
  printf("\n\n");
  for (j = 1; j < size_of_array; j++) {
    key = integer_array[j];
    i = j - 1;
    while (i >= 0 && integer_array[i] > key) {
      integer_array[i + 1] = integer_array[i];
      i = i - 1;
      integer_array[i + 1] = key;
    }
  }
  printf("\nNow the sorted array is: ");
  for (i = 0; i < size_of_array; i++)
    printf("%d ", integer_array[i]);
  printf("\n\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xf02(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x10(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%esi
lea    0xecb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11c1 <main+0xa1>
mov    -0x30(%rbp),%rsi
movslq -0x1c(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe98(%rip),%rdi
call   1040 <scanf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    118c <main+0x6c>
lea    0xea4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1209 <main+0xe9>
mov    -0x30(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe8f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11d6 <main+0xb6>
lea    0xe77(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    12bb <main+0x19b>
mov    -0x30(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x1c(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x1c(%rbp)
mov    %al,-0x31(%rbp)
jl     1264 <main+0x144>
mov    -0x30(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
cmp    -0x24(%rbp),%eax
setg   %al
mov    %al,-0x31(%rbp)
mov    -0x31(%rbp),%al
test   $0x1,%al
jne    1274 <main+0x154>
jmp    12a8 <main+0x188>
mov    -0x30(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
mov    -0x1c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
mov    %ecx,-0x1c(%rbp)
mov    -0x24(%rbp),%edx
mov    -0x1c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
jmp    1241 <main+0x121>
jmp    12ad <main+0x18d>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    121e <main+0xfe>
lea    0xdc8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1303 <main+0x1e3>
mov    -0x30(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xd95(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    12d0 <main+0x1b0>
lea    0xd7d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xebb(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xef3(%rip),%rdi
lea    -0x2c(%rbp),%rsi
call   1050 <scanf@plt>
mov    %rsp,%r15
mov    -0x2c(%rbp),%eax
mov    %rsp,%rbx
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
mov    -0x2c(%rbp),%esi
lea    0xec8(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmpl   $0x0,-0x2c(%rbp)
jle    11bc <main+0x8c>
xor    %r13d,%r13d
lea    0xeae(%rip),%r14
mov    %rbx,%r12
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %r12,%rsi
call   1050 <scanf@plt>
add    $0x1,%r13
movslq -0x2c(%rbp),%rax
add    $0x4,%r12
cmp    %rax,%r13
jl     11a0 <main+0x70>
lea    0xea9(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmpl   $0x0,-0x2c(%rbp)
jle    11fb <main+0xcb>
lea    0xeac(%rip),%r14
xor    %r12d,%r12d
nopw   0x0(%rax,%rax,1)
mov    (%rbx,%r12,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%r12
movslq -0x2c(%rbp),%rax
cmp    %rax,%r12
jl     11e0 <main+0xb0>
lea    0xea0(%rip),%rdi
call   1030 <puts@plt>
mov    -0x2c(%rbp),%r8d
cmp    $0x2,%r8d
jl     1263 <main+0x133>
mov    $0x1,%ecx
xor    %r9d,%r9d
jmp    122d <main+0xfd>
nopl   0x0(%rax,%rax,1)
add    $0x1,%rcx
add    $0x1,%r9
cmp    %r8,%rcx
je     1263 <main+0x133>
mov    (%rbx,%rcx,4),%esi
mov    %r9,%rdi
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %edi,%eax
mov    (%rbx,%rax,4),%edx
cmp    %esi,%edx
jle    1220 <main+0xf0>
mov    %edx,0x4(%rbx,%rdi,4)
mov    %esi,(%rbx,%rax,4)
lea    -0x1(%rdi),%rax
add    $0x1,%rdi
cmp    $0x1,%rdi
mov    %rax,%rdi
jg     1240 <main+0x110>
jmp    1220 <main+0xf0>
lea    0xe1d(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmpl   $0x0,-0x2c(%rbp)
jle    12ab <main+0x17b>
lea    0xe05(%rip),%r14
xor    %r12d,%r12d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    (%rbx,%r12,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%r12
movslq -0x2c(%rbp),%rax
cmp    %rax,%r12
jl     1290 <main+0x160>
lea    0xdf0(%rip),%rdi
call   1030 <puts@plt>
mov    %r15,%rsp
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [70 x i8] c"Enter the size of your array with respect to the number of elements: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [35 x i8] c"Enter %d elements into the array: \00"
@.str.3 = [23 x i8] c"The unsorted list is: \00"
@.str.4 = [4 x i8] c"%d \00"
@.str.5 = [3 x i8] c"\0A\0A\00"
@.str.6 = [27 x i8] c"\0ANow the sorted array is: \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([70 x i8], [70 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%10 = load i32, i32* %2
%11 = zext i32 %10 to i64
%12 = call i8* @llvm.stacksave()
store i8* %12, i8** %3
%13 = alloca i32, i64 %11
store i64 %11, i64* %4
%14 = load i32, i32* %2
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0), i32 %14)
store i32 0, i32* %5
br label %16
16: ; preds = %25, %0
%17 = load i32, i32* %5
%18 = load i32, i32* %2
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %28
20: ; preds = %16
%21 = load i32, i32* %5
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i32, i32* %13, i64 %22
%24 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %23)
br label %25
25: ; preds = %20
%26 = load i32, i32* %5
%27 = add nsw i32 %26, 1
store i32 %27, i32* %5
br label %16
28: ; preds = %16
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %5
br label %30
30: ; preds = %40, %28
%31 = load i32, i32* %5
%32 = load i32, i32* %2
%33 = icmp slt i32 %31, %32
br i1 %33, label %34, label %43
34: ; preds = %30
%35 = load i32, i32* %5
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i32, i32* %13, i64 %36
%38 = load i32, i32* %37
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %38)
br label %40
40: ; preds = %34
%41 = load i32, i32* %5
%42 = add nsw i32 %41, 1
store i32 %42, i32* %5
br label %30
43: ; preds = %30
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
store i32 1, i32* %6
br label %45
45: ; preds = %85, %43
%46 = load i32, i32* %6
%47 = load i32, i32* %2
%48 = icmp slt i32 %46, %47
br i1 %48, label %49, label %88
49: ; preds = %45
%50 = load i32, i32* %6
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds i32, i32* %13, i64 %51
%53 = load i32, i32* %52
store i32 %53, i32* %7
%54 = load i32, i32* %6
%55 = sub nsw i32 %54, 1
store i32 %55, i32* %5
br label %56
56: ; preds = %68, %49
%57 = load i32, i32* %5
%58 = icmp sge i32 %57, 0
br i1 %58, label %59, label %66
59: ; preds = %56
%60 = load i32, i32* %5
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds i32, i32* %13, i64 %61
%63 = load i32, i32* %62
%64 = load i32, i32* %7
%65 = icmp sgt i32 %63, %64
br label %66
66: ; preds = %59, %56
%67 = phi i1 [ false, %56 ], [ %65, %59 ]
br i1 %67, label %68, label %84
68: ; preds = %66
%69 = load i32, i32* %5
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds i32, i32* %13, i64 %70
%72 = load i32, i32* %71
%73 = load i32, i32* %5
%74 = add nsw i32 %73, 1
%75 = sext i32 %74 to i64
%76 = getelementptr inbounds i32, i32* %13, i64 %75
store i32 %72, i32* %76
%77 = load i32, i32* %5
%78 = sub nsw i32 %77, 1
store i32 %78, i32* %5
%79 = load i32, i32* %7
%80 = load i32, i32* %5
%81 = add nsw i32 %80, 1
%82 = sext i32 %81 to i64
%83 = getelementptr inbounds i32, i32* %13, i64 %82
store i32 %79, i32* %83
br label %56
84: ; preds = %66
br label %85
85: ; preds = %84
%86 = load i32, i32* %6
%87 = add nsw i32 %86, 1
store i32 %87, i32* %6
br label %45
88: ; preds = %45
%89 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0))
store i32 0, i32* %5
br label %90
90: ; preds = %100, %88
%91 = load i32, i32* %5
%92 = load i32, i32* %2
%93 = icmp slt i32 %91, %92
br i1 %93, label %94, label %103
94: ; preds = %90
%95 = load i32, i32* %5
%96 = sext i32 %95 to i64
%97 = getelementptr inbounds i32, i32* %13, i64 %96
%98 = load i32, i32* %97
%99 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %98)
br label %100
100: ; preds = %94
%101 = load i32, i32* %5
%102 = add nsw i32 %101, 1
store i32 %102, i32* %5
br label %90
103: ; preds = %90
%104 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
store i32 0, i32* %1
%105 = load i8*, i8** %3
%106 = load i32, i32* %1
ret i32 %106
}

LLVM IR (-O2):
@.str = [70 x i8] c"Enter the size of your array with respect to the number of elements: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [35 x i8] c"Enter %d elements into the array: \00"
@.str.3 = [23 x i8] c"The unsorted list is: \00"
@.str.4 = [4 x i8] c"%d \00"
@.str.6 = [27 x i8] c"\0ANow the sorted array is: \00"
@str.7 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([70 x i8], [70 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
%6 = zext i32 %5 to i64
%7 = call i8* @llvm.stacksave()
%8 = alloca i32, i64 %6
%9 = load i32, i32* %1
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0), i32 %9)
%11 = load i32, i32* %1
%12 = icmp sgt i32 %11, 0
br i1 %12, label %13, label %21
13: ; preds = %0, %13
%14 = phi i64 [ %17, %13 ], [ 0, %0 ]
%15 = getelementptr inbounds i32, i32* %8, i64 %14
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %15)
%17 = add nuw nsw i64 %14, 1
%18 = load i32, i32* %1
%19 = sext i32 %18 to i64
%20 = icmp slt i64 %17, %19
br i1 %20, label %13, label %21
21: ; preds = %13, %0
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0))
%23 = load i32, i32* %1
%24 = icmp sgt i32 %23, 0
br i1 %24, label %25, label %34
25: ; preds = %21, %25
%26 = phi i64 [ %30, %25 ], [ 0, %21 ]
%27 = getelementptr inbounds i32, i32* %8, i64 %26
%28 = load i32, i32* %27
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %28)
%30 = add nuw nsw i64 %26, 1
%31 = load i32, i32* %1
%32 = sext i32 %31 to i64
%33 = icmp slt i64 %30, %32
br i1 %33, label %25, label %34
34: ; preds = %25, %21
%35 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str.7, i64 0, i64 0))
%36 = load i32, i32* %1
%37 = icmp sgt i32 %36, 1
br i1 %37, label %38, label %57
38: ; preds = %34
%39 = zext i32 %36 to i64
br label %40
40: ; preds = %38, %54
%41 = phi i64 [ 1, %38 ], [ %55, %54 ]
%42 = getelementptr inbounds i32, i32* %8, i64 %41
%43 = load i32, i32* %42
br label %44
44: ; preds = %40, %51
%45 = phi i64 [ %41, %40 ], [ %46, %51 ]
%46 = add nsw i64 %45, -1
%47 = and i64 %46, 4294967295
%48 = getelementptr inbounds i32, i32* %8, i64 %47
%49 = load i32, i32* %48
%50 = icmp sgt i32 %49, %43
br i1 %50, label %51, label %54
51: ; preds = %44
%52 = getelementptr inbounds i32, i32* %8, i64 %45
store i32 %49, i32* %52
store i32 %43, i32* %48
%53 = icmp sgt i64 %45, 1
br i1 %53, label %44, label %54
54: ; preds = %44, %51
%55 = add nuw nsw i64 %41, 1
%56 = icmp eq i64 %55, %39
br i1 %56, label %57, label %40
57: ; preds = %54, %34
%58 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0))
%59 = load i32, i32* %1
%60 = icmp sgt i32 %59, 0
br i1 %60, label %61, label %70
61: ; preds = %57, %61
%62 = phi i64 [ %66, %61 ], [ 0, %57 ]
%63 = getelementptr inbounds i32, i32* %8, i64 %62
%64 = load i32, i32* %63
%65 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %64)
%66 = add nuw nsw i64 %62, 1
%67 = load i32, i32* %1
%68 = sext i32 %67 to i64
%69 = icmp slt i64 %66, %68
br i1 %69, label %61, label %70
70: ; preds = %61, %57
%71 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str.7, i64 0, i64 0))
ret i32 0
}