#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_sort(unsigned long *, unsigned long);
unsigned long *malloc(unsigned long);
int /*<<< orphan*/ print_array(unsigned long *, unsigned long);
int /*<<< orphan*/ printf(char *);
int random();
int /*<<< orphan*/ srandom(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main() {
  unsigned long c = 0;
  unsigned long elements = 10000;
  unsigned long *numray = malloc(elements * sizeof(unsigned long));
  srandom(time(NULL));
  for (; c < elements; c++)
    numray[c] = (random() % 9999999999) * 1000000000000000000;
  print_array(numray, elements);
  printf("====================\n");
  insertion_sort(numray, elements);
  print_array(numray, elements);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
movq   $0x2710,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
shl    $0x3,%rdi
call   1080 <malloc@plt>
mov    %rax,-0x20(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1030 <srandom@plt>
mov    -0x10(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    1201 <main+0x91>
mov    $0x0,%al
call   1070 <random@plt>
cltq
movabs $0x2540be3ff,%rcx
cqto
idiv   %rcx
movabs $0xde0b6b3a7640000,%rax
b6 e0 0d
imul   %rax,%rdx
mov    -0x20(%rbp),%rax
mov    -0x10(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    11b0 <main+0x40>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <print_array@plt>
lea    0xdeb(%rip),%rdi
call   1050 <printf@plt>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1090 <insertion_sort@plt>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <print_array@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
mov    $0x13880,%edi
call   1080 <malloc@plt>
mov    %rax,%r15
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1030 <srandom@plt>
movabs $0xde0b6b3a7640000,%r14
b6 e0 0d
xor    %ebx,%ebx
nopl   0x0(%rax)
xor    %eax,%eax
call   1070 <random@plt>
cltq
imul   %r14,%rax
mov    %rax,(%r15,%rbx,8)
add    $0x1,%rbx
cmp    $0x2710,%rbx
jne    11a0 <main+0x30>
mov    $0x2710,%esi
mov    %r15,%rdi
call   1050 <print_array@plt>
lea    0xe2e(%rip),%rdi
call   1040 <puts@plt>
mov    $0x2710,%esi
mov    %r15,%rdi
call   1090 <insertion_sort@plt>
mov    $0x2710,%esi
mov    %r15,%rdi
call   1050 <print_array@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [22 x i8] c"====================\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i64
%4 = alloca i64*
store i32 0, i32* %1
store i64 0, i64* %2
store i64 10000, i64* %3
%5 = load i64, i64* %3
%6 = mul i64 %5, 8
%7 = call i64* @malloc(i64 %6)
store i64* %7, i64** %4
%8 = call i32 @time(i32* null)
%9 = call i32 @srandom(i32 %8)
br label %10
10: ; preds = %22, %0
%11 = load i64, i64* %2
%12 = load i64, i64* %3
%13 = icmp ult i64 %11, %12
br i1 %13, label %14, label %25
14: ; preds = %10
%15 = call i32 (...) @random()
%16 = sext i32 %15 to i64
%17 = srem i64 %16, 9999999999
%18 = mul nsw i64 %17, 1000000000000000000
%19 = load i64*, i64** %4
%20 = load i64, i64* %2
%21 = getelementptr inbounds i64, i64* %19, i64 %20
store i64 %18, i64* %21
br label %22
22: ; preds = %14
%23 = load i64, i64* %2
%24 = add i64 %23, 1
store i64 %24, i64* %2
br label %10
25: ; preds = %10
%26 = load i64*, i64** %4
%27 = load i64, i64* %3
%28 = call i32 @print_array(i64* %26, i64 %27)
%29 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%30 = load i64*, i64** %4
%31 = load i64, i64* %3
%32 = call i32 @insertion_sort(i64* %30, i64 %31)
%33 = load i64*, i64** %4
%34 = load i64, i64* %3
%35 = call i32 @print_array(i64* %33, i64 %34)
ret i32 0
}

LLVM IR (-O2):
@str = [21 x i8] c"====================\00"
define i32 @main() {
%1 = tail call i64* @malloc(i64 80000)
%2 = tail call i32 @time(i32* null)
%3 = tail call i32 @srandom(i32 %2)
br label %4
4: ; preds = %0, %4
%5 = phi i64 [ 0, %0 ], [ %10, %4 ]
%6 = tail call i32 (...) @random()
%7 = sext i32 %6 to i64
%8 = mul nsw i64 %7, 1000000000000000000
%9 = getelementptr inbounds i64, i64* %1, i64 %5
store i64 %8, i64* %9
%10 = add nuw nsw i64 %5, 1
%11 = icmp eq i64 %10, 10000
br i1 %11, label %12, label %4
12: ; preds = %4
%13 = tail call i32 @print_array(i64* %1, i64 10000)
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
%15 = tail call i32 @insertion_sort(i64* %1, i64 10000)
%16 = tail call i32 @print_array(i64* %1, i64 10000)
ret i32 0
}