#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*/ fnDispArray(int *, int);
int /*<<< orphan*/ fnGenRandInput(int *, int);
int /*<<< orphan*/ fnInsertionSort(int *, int);
int /*<<< orphan*/ fnSelectSort(int *, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int main(void) {
  int iaArr[100], iNum;
  printf("\nInsertion Sort\n");
  printf("\nEnter the number of elements to sort\n");
  scanf("%d", &iNum);
  fnGenRandInput(iaArr, iNum);
  printf("\nUnsorted Array\n");
  fnDispArray(iaArr, iNum);
  fnInsertionSort(iaArr, iNum);
  printf("\nSorted Array\n");
  fnDispArray(iaArr, iNum);
  printf("\nSelection Sort\n");
  printf("\nEnter the number of elements to sort\n");
  scanf("%d", &iNum);
  fnGenRandInput(iaArr, iNum);
  printf("\nUnsorted Array\n");
  fnDispArray(iaArr, iNum);
  fnSelectSort(iaArr, iNum);
  printf("\nSorted Array\n");
  fnDispArray(iaArr, iNum);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1b0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe87(%rip),%rdi
call   1050 <printf@plt>
lea    0xe8c(%rip),%rdi
call   1050 <printf@plt>
lea    0xea7(%rip),%rdi
lea    -0x1a4(%rbp),%rsi
call   1070 <scanf@plt>
lea    -0x1a0(%rbp),%rdi
mov    -0x1a4(%rbp),%esi
call   1040 <fnGenRandInput@plt>
lea    0xe85(%rip),%rdi
call   1050 <printf@plt>
lea    -0x1a0(%rbp),%rdi
mov    -0x1a4(%rbp),%esi
call   1030 <fnDispArray@plt>
lea    -0x1a0(%rbp),%rdi
mov    -0x1a4(%rbp),%esi
call   1080 <fnInsertionSort@plt>
lea    0xe66(%rip),%rdi
call   1050 <printf@plt>
lea    -0x1a0(%rbp),%rdi
mov    -0x1a4(%rbp),%esi
call   1030 <fnDispArray@plt>
lea    0xe57(%rip),%rdi
call   1050 <printf@plt>
lea    0xe01(%rip),%rdi
call   1050 <printf@plt>
lea    0xe1c(%rip),%rdi
lea    -0x1a4(%rbp),%rsi
call   1070 <scanf@plt>
lea    -0x1a0(%rbp),%rdi
mov    -0x1a4(%rbp),%esi
call   1040 <fnGenRandInput@plt>
lea    0xdfa(%rip),%rdi
call   1050 <printf@plt>
lea    -0x1a0(%rbp),%rdi
mov    -0x1a4(%rbp),%esi
call   1030 <fnDispArray@plt>
lea    -0x1a0(%rbp),%rdi
mov    -0x1a4(%rbp),%esi
call   1060 <fnSelectSort@plt>
lea    0xddb(%rip),%rdi
call   1050 <printf@plt>
lea    -0x1a0(%rbp),%rdi
mov    -0x1a4(%rbp),%esi
call   1030 <fnDispArray@plt>
xor    %eax,%eax
add    $0x1b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1a8,%rsp
lea    0xe8b(%rip),%rdi
call   1040 <puts@plt>
lea    0xe9f(%rip),%r14
mov    %r14,%rdi
call   1040 <puts@plt>
lea    0xe6d(%rip),%r15
lea    0xc(%rsp),%r12
mov    %r15,%rdi
mov    %r12,%rsi
call   1070 <scanf@plt>
mov    0xc(%rsp),%esi
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   1050 <fnGenRandInput@plt>
lea    0xe8e(%rip),%r13
mov    %r13,%rdi
call   1040 <puts@plt>
mov    0xc(%rsp),%esi
mov    %rbx,%rdi
call   1030 <fnDispArray@plt>
mov    0xc(%rsp),%esi
mov    %rbx,%rdi
call   1080 <fnInsertionSort@plt>
lea    0xe77(%rip),%rbp
mov    %rbp,%rdi
call   1040 <puts@plt>
mov    0xc(%rsp),%esi
mov    %rbx,%rdi
call   1030 <fnDispArray@plt>
lea    0xe16(%rip),%rdi
call   1040 <puts@plt>
mov    %r14,%rdi
call   1040 <puts@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1070 <scanf@plt>
mov    0xc(%rsp),%esi
mov    %rbx,%rdi
call   1050 <fnGenRandInput@plt>
mov    %r13,%rdi
call   1040 <puts@plt>
mov    0xc(%rsp),%esi
mov    %rbx,%rdi
call   1030 <fnDispArray@plt>
mov    0xc(%rsp),%esi
mov    %rbx,%rdi
call   1060 <fnSelectSort@plt>
mov    %rbp,%rdi
call   1040 <puts@plt>
mov    0xc(%rsp),%esi
mov    %rbx,%rdi
call   1030 <fnDispArray@plt>
xor    %eax,%eax
add    $0x1a8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [17 x i8] c"\0AInsertion Sort\0A\00"
@.str.1 = [39 x i8] c"\0AEnter the number of elements to sort\0A\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [17 x i8] c"\0AUnsorted Array\0A\00"
@.str.4 = [15 x i8] c"\0ASorted Array\0A\00"
@.str.5 = [17 x i8] c"\0ASelection Sort\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i32]
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%7 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 0
%8 = load i32, i32* %3
%9 = call i32 @fnGenRandInput(i32* %7, i32 %8)
%10 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
%11 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 0
%12 = load i32, i32* %3
%13 = call i32 @fnDispArray(i32* %11, i32 %12)
%14 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 0
%15 = load i32, i32* %3
%16 = call i32 @fnInsertionSort(i32* %14, i32 %15)
%17 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
%18 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 0
%19 = load i32, i32* %3
%20 = call i32 @fnDispArray(i32* %18, i32 %19)
%21 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0))
%22 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0))
%23 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%24 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 0
%25 = load i32, i32* %3
%26 = call i32 @fnGenRandInput(i32* %24, i32 %25)
%27 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
%28 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 0
%29 = load i32, i32* %3
%30 = call i32 @fnDispArray(i32* %28, i32 %29)
%31 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 0
%32 = load i32, i32* %3
%33 = call i32 @fnSelectSort(i32* %31, i32 %32)
%34 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
%35 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 0
%36 = load i32, i32* %3
%37 = call i32 @fnDispArray(i32* %35, i32 %36)
ret i32 0
}

LLVM IR (-O2):
@.str.2 = [3 x i8] c"%d\00"
@str = [16 x i8] c"\0AInsertion Sort\00"
@str.9 = [16 x i8] c"\0ASelection Sort\00"
@str.10 = [38 x i8] c"\0AEnter the number of elements to sort\00"
@str.11 = [16 x i8] c"\0AUnsorted Array\00"
@str.12 = [14 x i8] c"\0ASorted 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 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str, i64 0, i64 0))
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str.10, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
%8 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 0
%9 = load i32, i32* %2
%10 = call i32 @fnGenRandInput(i32* %8, i32 %9)
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.11, i64 0, i64 0))
%12 = load i32, i32* %2
%13 = call i32 @fnDispArray(i32* %8, i32 %12)
%14 = load i32, i32* %2
%15 = call i32 @fnInsertionSort(i32* %8, i32 %14)
%16 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.12, i64 0, i64 0))
%17 = load i32, i32* %2
%18 = call i32 @fnDispArray(i32* %8, i32 %17)
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.9, i64 0, i64 0))
%20 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str.10, i64 0, i64 0))
%21 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
%22 = load i32, i32* %2
%23 = call i32 @fnGenRandInput(i32* %8, i32 %22)
%24 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.11, i64 0, i64 0))
%25 = load i32, i32* %2
%26 = call i32 @fnDispArray(i32* %8, i32 %25)
%27 = load i32, i32* %2
%28 = call i32 @fnSelectSort(i32* %8, i32 %27)
%29 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.12, i64 0, i64 0))
%30 = load i32, i32* %2
%31 = call i32 @fnDispArray(i32* %8, i32 %30)
ret i32 0
}