#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*/ fill_array(int *, int);
int /*<<< orphan*/ insertion_sort(int *, int, int);
int /*<<< orphan*/ print(char *);
int /*<<< orphan*/ print_array(int *, int);
int /*<<< orphan*/ readStr();
int str_to_int(int /*<<< orphan*/);
void sort() {
  int arr[100];
  print("\nArray size: ");
  int n = str_to_int(readStr());
  print("\n");
  fill_array(arr, n);
  print("Before sorting:\n");
  print_array(arr, n);
  print("\nOrdre: (1 for increassing/ 0 for decreassing): ");
  int ordre = str_to_int(readStr());
  insertion_sort(arr, n, ordre);
  print("\nAfter sorting:\n");
  print_array(arr, n);
}


x86 assembly (clang, -O0):
<sort>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1a0,%rsp
lea    0xe8e(%rip),%rdi
call   1050 <print@plt>
mov    $0x0,%al
call   1070 <readStr@plt>
mov    %eax,%edi
call   1030 <str_to_int@plt>
mov    %eax,-0x194(%rbp)
lea    0xe8b(%rip),%rdi
call   1050 <print@plt>
lea    -0x190(%rbp),%rdi
mov    -0x194(%rbp),%esi
call   1060 <fill_array@plt>
lea    0xe5e(%rip),%rdi
call   1050 <print@plt>
lea    -0x190(%rbp),%rdi
mov    -0x194(%rbp),%esi
call   1040 <print_array@plt>
lea    0xe51(%rip),%rdi
call   1050 <print@plt>
mov    $0x0,%al
call   1070 <readStr@plt>
mov    %eax,%edi
call   1030 <str_to_int@plt>
mov    %eax,-0x198(%rbp)
lea    -0x190(%rbp),%rdi
mov    -0x194(%rbp),%esi
mov    -0x198(%rbp),%edx
call   1080 <insertion_sort@plt>
lea    0xe4a(%rip),%rdi
call   1050 <print@plt>
lea    -0x190(%rbp),%rdi
mov    -0x194(%rbp),%esi
call   1040 <print_array@plt>
add    $0x1a0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sort>:
push   %r14
push   %rbx
sub    $0x198,%rsp
lea    0xe8f(%rip),%rdi
call   1050 <print@plt>
xor    %eax,%eax
call   1070 <readStr@plt>
mov    %eax,%edi
call   1030 <str_to_int@plt>
mov    %eax,%ebx
lea    0xe90(%rip),%rdi
call   1050 <print@plt>
mov    %rsp,%r14
mov    %r14,%rdi
mov    %ebx,%esi
call   1060 <fill_array@plt>
lea    0xe68(%rip),%rdi
call   1050 <print@plt>
mov    %r14,%rdi
mov    %ebx,%esi
call   1040 <print_array@plt>
lea    0xe63(%rip),%rdi
call   1050 <print@plt>
xor    %eax,%eax
call   1070 <readStr@plt>
mov    %eax,%edi
call   1030 <str_to_int@plt>
mov    %r14,%rdi
mov    %ebx,%esi
mov    %eax,%edx
call   1080 <insertion_sort@plt>
lea    0xe6e(%rip),%rdi
call   1050 <print@plt>
mov    %r14,%rdi
mov    %ebx,%esi
call   1040 <print_array@plt>
add    $0x198,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [14 x i8] c"\0AArray size: \00"
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [17 x i8] c"Before sorting:\0A\00"
@.str.3 = [49 x i8] c"\0AOrdre: (1 for increassing/ 0 for decreassing): \00"
@.str.4 = [17 x i8] c"\0AAfter sorting:\0A\00"
define void @sort() {
%1 = alloca [100 x i32]
%2 = alloca i32
%3 = alloca i32
%4 = call i32 @print(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%5 = call i32 (...) @readStr()
%6 = call i32 @str_to_int(i32 %5)
store i32 %6, i32* %2
%7 = call i32 @print(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%8 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 0
%9 = load i32, i32* %2
%10 = call i32 @fill_array(i32* %8, i32 %9)
%11 = call i32 @print(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%12 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 0
%13 = load i32, i32* %2
%14 = call i32 @print_array(i32* %12, i32 %13)
%15 = call i32 @print(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.3, i64 0, i64 0))
%16 = call i32 (...) @readStr()
%17 = call i32 @str_to_int(i32 %16)
store i32 %17, i32* %3
%18 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 0
%19 = load i32, i32* %2
%20 = load i32, i32* %3
%21 = call i32 @insertion_sort(i32* %18, i32 %19, i32 %20)
%22 = call i32 @print(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
%23 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 0
%24 = load i32, i32* %2
%25 = call i32 @print_array(i32* %23, i32 %24)
ret void
}

LLVM IR (-O2):
@.str = [14 x i8] c"\0AArray size: \00"
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [17 x i8] c"Before sorting:\0A\00"
@.str.3 = [49 x i8] c"\0AOrdre: (1 for increassing/ 0 for decreassing): \00"
@.str.4 = [17 x i8] c"\0AAfter sorting:\0A\00"
define void @sort() {
%1 = alloca [100 x i32]
%2 = bitcast [100 x i32]* %1 to i8*
%3 = tail call i32 @print(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 (...) @readStr()
%5 = tail call i32 @str_to_int(i32 %4)
%6 = tail call i32 @print(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%7 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 0
%8 = call i32 @fill_array(i32* %7, i32 %5)
%9 = call i32 @print(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 @print_array(i32* %7, i32 %5)
%11 = call i32 @print(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.3, i64 0, i64 0))
%12 = call i32 (...) @readStr()
%13 = call i32 @str_to_int(i32 %12)
%14 = call i32 @insertion_sort(i32* %7, i32 %5, i32 %13)
%15 = call i32 @print(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
%16 = call i32 @print_array(i32* %7, i32 %5)
ret void
}