#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 */
scalar_t__ CLOCKS_PER_SEC;
int atoi(char *);
scalar_t__ clock();
int *create_vector(int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ printf(char *, float);
int *radix_sort(int *, int);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  if (argc != 2) {
    fprintf(stderr, "Correct Usage: %s <VECTOR_LENGTH>\n", argv[0]);
    exit(-1);
  }
  int *vec, length;
  clock_t init, end;
  length = atoi(argv[1]);
  vec = create_vector(length);
  init = clock();
  vec = radix_sort(vec, length);
  end = clock();
  printf("%f\n", (float)(end - init) / (float)CLOCKS_PER_SEC);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     11b6 <main+0x46>
mov    0x2e41(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe59(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0xffffffff,%edi
call   1090 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1080 <atoi@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%edi
call   1070 <create_vector@plt>
mov    %rax,-0x18(%rbp)
mov    $0x0,%al
call   1030 <clock@plt>
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1050 <radix_sort@plt>
mov    %rax,-0x18(%rbp)
mov    $0x0,%al
call   1030 <clock@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
sub    -0x28(%rbp),%rax
cvtsi2ss %rax,%xmm0
mov    0x2ddc(%rip),%rax
cvtsi2ssq (%rax),%xmm1
divss  %xmm1,%xmm0
lea    0xe07(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
cmp    $0x2,%edi
jne    11d6 <main+0x66>
mov    0x8(%rsi),%rdi
call   1080 <atoi@plt>
mov    %eax,%ebx
mov    %eax,%edi
call   1070 <create_vector@plt>
mov    %rax,%r14
xor    %eax,%eax
call   1030 <clock@plt>
mov    %rax,%r15
mov    %r14,%rdi
mov    %ebx,%esi
call   1050 <radix_sort@plt>
xor    %eax,%eax
call   1030 <clock@plt>
sub    %r15,%rax
cvtsi2ss %rax,%xmm0
mov    0x2e2f(%rip),%rax
cvtsi2ssq (%rax),%xmm1
divss  %xmm1,%xmm0
lea    0xe5a(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret
mov    0x2dfb(%rip),%rax
mov    (%rax),%edi
mov    (%rsi),%rdx
lea    0xe17(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0xffffffff,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [35 x i8] c"Correct Usage: %s <VECTOR_LENGTH>\0A\00"
@.str.1 = [4 x i8] c"%f\0A\00"
@CLOCKS_PER_SEC = global i64 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
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = icmp ne i32 %10, 2
br i1 %11, label %12, label %19
12: ; preds = %2
%13 = load i32, i32* @stderr
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 0
%16 = load i8*, i8** %15
%17 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i8* %16)
%18 = call i32 @exit(i32 -1)
unreachable
19: ; preds = %2
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = load i8*, i8** %21
%23 = call i32 @atoi(i8* %22)
store i32 %23, i32* %7
%24 = load i32, i32* %7
%25 = call i32* @create_vector(i32 %24)
store i32* %25, i32** %6
%26 = call i64 (...) @clock()
store i64 %26, i64* %8
%27 = load i32*, i32** %6
%28 = load i32, i32* %7
%29 = call i32* @radix_sort(i32* %27, i32 %28)
store i32* %29, i32** %6
%30 = call i64 (...) @clock()
store i64 %30, i64* %9
%31 = load i64, i64* %9
%32 = load i64, i64* %8
%33 = sub nsw i64 %31, %32
%34 = sitofp i64 %33 to float
%35 = load i64, i64* @CLOCKS_PER_SEC
%36 = sitofp i64 %35 to float
%37 = fdiv float %34, %36
%38 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), float %37)
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [35 x i8] c"Correct Usage: %s <VECTOR_LENGTH>\0A\00"
@.str.1 = [4 x i8] c"%f\0A\00"
@CLOCKS_PER_SEC = global i64 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %9, label %4
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = load i8*, i8** %1
%7 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = tail call i32 @exit(i32 -1)
unreachable
9: ; preds = %2
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = tail call i32 @atoi(i8* %11)
%13 = tail call i32* @create_vector(i32 %12)
%14 = tail call i64 (...) @clock()
%15 = tail call i32* @radix_sort(i32* %13, i32 %12)
%16 = tail call i64 (...) @clock()
%17 = sub nsw i64 %16, %14
%18 = sitofp i64 %17 to float
%19 = load i64, i64* @CLOCKS_PER_SEC
%20 = sitofp i64 %19 to float
%21 = fdiv float %18, %20
%22 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), float %21)
ret i32 0
}