#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*/ insertion(int, int *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int i, j;
  int ARR[10];
  printf("enter the number of elements to be inserted into the original "
         "array\n for selection sort:-");
  scanf("%d", &i);
  for (j = 0; j < i; j++) {
    scanf("%d", &ARR[j]);
  }
  insertion(i, ARR);
  for (j = 0; j < i; j++) {
    printf("%d\t", ARR[j]);
  }
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf06(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1199 <main+0x69>
movslq -0xc(%rbp),%rax
lea    -0x40(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xed4(%rip),%rdi
call   1050 <scanf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1164 <main+0x34>
mov    -0x8(%rbp),%edi
lea    -0x40(%rbp),%rsi
call   1040 <insertion@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11dc <main+0xac>
movslq -0xc(%rbp),%rax
mov    -0x40(%rbp,%rax,4),%esi
lea    0xe96(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11ac <main+0x7c>
lea    0xe7e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x40,%rsp
lea    0xeb0(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xefc(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1060 <scanf@plt>
mov    0xc(%rsp),%edi
test   %edi,%edi
jle    119d <main+0x5d>
lea    0x10(%rsp),%r15
xor    %ebx,%ebx
lea    0xedc(%rip),%r14
xchg   %ax,%ax
mov    %r14,%rdi
mov    %r15,%rsi
call   1060 <scanf@plt>
add    $0x1,%rbx
movslq 0xc(%rsp),%rdi
add    $0x4,%r15
cmp    %rdi,%rbx
jl     1180 <main+0x40>
lea    0x10(%rsp),%rsi
call   1050 <insertion@plt>
cmpl   $0x0,0xc(%rsp)
jle    11dc <main+0x9c>
lea    0xea8(%rip),%r14
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
mov    0x10(%rsp,%rbx,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbx
movslq 0xc(%rsp),%rax
cmp    %rax,%rbx
jl     11c0 <main+0x80>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [90 x i8] c"enter the number of elements to be inserted into the original array\0A for selection sort:-\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [4 x i8] c"%d\09\00"
@.str.3 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [10 x i32]
store i32 0, i32* %1
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([90 x i8], [90 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)
store i32 0, i32* %3
br label %7
7: ; preds = %16, %0
%8 = load i32, i32* %3
%9 = load i32, i32* %2
%10 = icmp slt i32 %8, %9
br i1 %10, label %11, label %19
11: ; preds = %7
%12 = load i32, i32* %3
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [10 x i32], [10 x i32]* %4, i64 0, i64 %13
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %14)
br label %16
16: ; preds = %11
%17 = load i32, i32* %3
%18 = add nsw i32 %17, 1
store i32 %18, i32* %3
br label %7
19: ; preds = %7
%20 = load i32, i32* %2
%21 = getelementptr inbounds [10 x i32], [10 x i32]* %4, i64 0, i64 0
%22 = call i32 @insertion(i32 %20, i32* %21)
store i32 0, i32* %3
br label %23
23: ; preds = %33, %19
%24 = load i32, i32* %3
%25 = load i32, i32* %2
%26 = icmp slt i32 %24, %25
br i1 %26, label %27, label %36
27: ; preds = %23
%28 = load i32, i32* %3
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [10 x i32], [10 x i32]* %4, i64 0, i64 %29
%31 = load i32, i32* %30
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %31)
br label %33
33: ; preds = %27
%34 = load i32, i32* %3
%35 = add nsw i32 %34, 1
store i32 %35, i32* %3
br label %23
36: ; preds = %23
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [90 x i8] c"enter the number of elements to be inserted into the original array\0A for selection sort:-\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [4 x i8] c"%d\09\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [10 x i32]
%3 = bitcast i32* %1 to i8*
%4 = bitcast [10 x i32]* %2 to i8*
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([90 x i8], [90 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* %1)
%7 = load i32, i32* %1
%8 = icmp sgt i32 %7, 0
br i1 %8, label %9, label %17
9: ; preds = %0, %9
%10 = phi i64 [ %13, %9 ], [ 0, %0 ]
%11 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 %10
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %11)
%13 = add nuw nsw i64 %10, 1
%14 = load i32, i32* %1
%15 = sext i32 %14 to i64
%16 = icmp slt i64 %13, %15
br i1 %16, label %9, label %17
17: ; preds = %9, %0
%18 = phi i32 [ %7, %0 ], [ %14, %9 ]
%19 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 0
%20 = call i32 @insertion(i32 %18, i32* %19)
%21 = load i32, i32* %1
%22 = icmp sgt i32 %21, 0
br i1 %22, label %23, label %32
23: ; preds = %17, %23
%24 = phi i64 [ %28, %23 ], [ 0, %17 ]
%25 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 %24
%26 = load i32, i32* %25
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %26)
%28 = add nuw nsw i64 %24, 1
%29 = load i32, i32* %1
%30 = sext i32 %29 to i64
%31 = icmp slt i64 %28, %30
br i1 %31, label %23, label %32
32: ; preds = %23, %17
%33 = call i32 @putchar(i32 10)
ret i32 0
}