#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 */
typedef scalar_t__ clock_t;

/* Variables and functions */
double CLOCKS_PER_SEC;
int EXIT_SUCCESS;
int atoi(char *);
scalar_t__ clock();
int /*<<< orphan*/ insertion_sort(int *, int);
int *parse_input(char *, int);
int /*<<< orphan*/ print_int_array(int *, int);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char **argv) {
  if (argc != 3) {
    printf("Usage : <your_program> <input_file> <N>\n");
  }
  int arr_size = atoi(argv[2]);
  int *arr = parse_input(argv[1], arr_size);
  clock_t start = clock();
  insertion_sort(arr, arr_size);
  clock_t stop = clock();
  double elapsed = (double)(stop - start) * 1000.0 / CLOCKS_PER_SEC;
  print_int_array(arr, arr_size);
  printf("Running time = %f ms\n", elapsed);
  return (EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     118e <main+0x2e>
lea    0xe81(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x14(%rbp),%esi
call   1050 <parse_input@plt>
mov    %rax,-0x20(%rbp)
mov    $0x0,%al
call   1030 <clock@plt>
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1080 <insertion_sort@plt>
mov    $0x0,%al
call   1030 <clock@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
sub    -0x28(%rbp),%rax
cvtsi2sd %rax,%xmm0
movsd  0xe17(%rip),%xmm1
mulsd  %xmm1,%xmm0
mov    0x2df4(%rip),%rax
divsd  (%rax),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1070 <print_int_array@plt>
movsd  -0x38(%rbp),%xmm0
lea    0xe1c(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    0x2db5(%rip),%rax
mov    (%rax),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
cmp    $0x3,%edi
je     118c <main+0x1c>
lea    0xe97(%rip),%rdi
call   1030 <puts@plt>
mov    0x10(%rbx),%rdi
call   1070 <atoi@plt>
mov    %eax,%ebp
mov    0x8(%rbx),%rdi
mov    %eax,%esi
call   1060 <parse_input@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1040 <clock@plt>
mov    %rax,%r14
mov    %rbx,%rdi
mov    %ebp,%esi
call   1090 <insertion_sort@plt>
xor    %eax,%eax
call   1040 <clock@plt>
sub    %r14,%rax
cvtsi2sd %rax,%xmm0
mulsd  0xe30(%rip),%xmm0
mov    0x2e11(%rip),%rax
divsd  (%rax),%xmm0
movsd  %xmm0,0x8(%rsp)
mov    %rbx,%rdi
mov    %ebp,%esi
call   1080 <print_int_array@plt>
lea    0xe16(%rip),%rdi
movsd  0x8(%rsp),%xmm0
mov    $0x1,%al
call   1050 <printf@plt>
mov    0x2dd2(%rip),%rax
mov    (%rax),%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [41 x i8] c"Usage : <your_program> <input_file> <N>\0A\00"
@CLOCKS_PER_SEC = global double 0.000000e+00
@.str.1 = [22 x i8] c"Running time = %f ms\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32*
%8 = alloca i64
%9 = alloca i64
%10 = alloca double
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* %4
%12 = icmp ne i32 %11, 3
br i1 %12, label %13, label %15
13: ; preds = %2
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
br label %15
15: ; preds = %13, %2
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 2
%18 = load i8*, i8** %17
%19 = call i32 @atoi(i8* %18)
store i32 %19, i32* %6
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = load i8*, i8** %21
%23 = load i32, i32* %6
%24 = call i32* @parse_input(i8* %22, i32 %23)
store i32* %24, i32** %7
%25 = call i64 (...) @clock()
store i64 %25, i64* %8
%26 = load i32*, i32** %7
%27 = load i32, i32* %6
%28 = call i32 @insertion_sort(i32* %26, i32 %27)
%29 = call i64 (...) @clock()
store i64 %29, i64* %9
%30 = load i64, i64* %9
%31 = load i64, i64* %8
%32 = sub nsw i64 %30, %31
%33 = sitofp i64 %32 to double
%34 = fmul double %33, 1.000000e+03
%35 = load double, double* @CLOCKS_PER_SEC
%36 = fdiv double %34, %35
store double %36, double* %10
%37 = load i32*, i32** %7
%38 = load i32, i32* %6
%39 = call i32 @print_int_array(i32* %37, i32 %38)
%40 = load double, double* %10
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), double %40)
%42 = load i32, i32* @EXIT_SUCCESS
ret i32 %42
}

LLVM IR (-O2):
@CLOCKS_PER_SEC = global double 0.000000e+00
@.str.1 = [22 x i8] c"Running time = %f ms\0A\00"
@EXIT_SUCCESS = global i32 0
@str = [40 x i8] c"Usage : <your_program> <input_file> <N>\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 3
br i1 %3, label %6, label %4
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str, i64 0, i64 0))
br label %6
6: ; preds = %4, %2
%7 = getelementptr inbounds i8*, i8** %1, i64 2
%8 = load i8*, i8** %7
%9 = tail call i32 @atoi(i8* %8)
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = tail call i32* @parse_input(i8* %11, i32 %9)
%13 = tail call i64 (...) @clock()
%14 = tail call i32 @insertion_sort(i32* %12, i32 %9)
%15 = tail call i64 (...) @clock()
%16 = sub nsw i64 %15, %13
%17 = sitofp i64 %16 to double
%18 = fmul double %17, 1.000000e+03
%19 = load double, double* @CLOCKS_PER_SEC
%20 = fdiv double %18, %19
%21 = tail call i32 @print_int_array(i32* %12, i32 %9)
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), double %20)
%23 = load i32, i32* @EXIT_SUCCESS
ret i32 %23
}