#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*/ merge_sort(int *, int);
int /*<<< orphan*/ print_array(int *, int);
int rand();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main() {
  int len = 10;
  int list[len];
  srand(time(NULL));
  for (int i = 0; i < len; ++i) {
    list[i] = rand() % (10 * 10);
  }
  print_array(list, len);
  merge_sort(list, len);
  print_array(list, len);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xa,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x10(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x28(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x18(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11d8 <main+0x88>
mov    $0x0,%al
call   1070 <rand@plt>
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    -0x28(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11a4 <main+0x54>
mov    -0x28(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1030 <print_array@plt>
mov    -0x28(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1060 <merge_sort@plt>
mov    -0x28(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1030 <print_array@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x30,%rsp
xor    %edi,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
xor    %eax,%eax
call   1070 <rand@plt>
cltq
imul   $0x51eb851f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
sar    $0x5,%ecx
add    %edx,%ecx
imul   $0x64,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,(%rsp)
xor    %eax,%eax
call   1070 <rand@plt>
cltq
imul   $0x51eb851f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
sar    $0x5,%ecx
add    %edx,%ecx
imul   $0x64,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,0x4(%rsp)
xor    %eax,%eax
call   1070 <rand@plt>
cltq
imul   $0x51eb851f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
sar    $0x5,%ecx
add    %edx,%ecx
imul   $0x64,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,0x8(%rsp)
xor    %eax,%eax
call   1070 <rand@plt>
cltq
imul   $0x51eb851f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
sar    $0x5,%ecx
add    %edx,%ecx
imul   $0x64,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,0xc(%rsp)
xor    %eax,%eax
call   1070 <rand@plt>
cltq
imul   $0x51eb851f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
sar    $0x5,%ecx
add    %edx,%ecx
imul   $0x64,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,0x10(%rsp)
xor    %eax,%eax
call   1070 <rand@plt>
cltq
imul   $0x51eb851f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
sar    $0x5,%ecx
add    %edx,%ecx
imul   $0x64,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,0x14(%rsp)
xor    %eax,%eax
call   1070 <rand@plt>
cltq
imul   $0x51eb851f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
sar    $0x5,%ecx
add    %edx,%ecx
imul   $0x64,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,0x18(%rsp)
xor    %eax,%eax
call   1070 <rand@plt>
cltq
imul   $0x51eb851f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
sar    $0x5,%ecx
add    %edx,%ecx
imul   $0x64,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,0x1c(%rsp)
xor    %eax,%eax
call   1070 <rand@plt>
cltq
imul   $0x51eb851f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
sar    $0x5,%ecx
add    %edx,%ecx
imul   $0x64,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,0x20(%rsp)
xor    %eax,%eax
call   1070 <rand@plt>
cltq
imul   $0x51eb851f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
sar    $0x5,%ecx
add    %edx,%ecx
imul   $0x64,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,0x24(%rsp)
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0xa,%esi
call   1030 <print_array@plt>
mov    %rbx,%rdi
mov    $0xa,%esi
call   1060 <merge_sort@plt>
mov    %rbx,%rdi
mov    $0xa,%esi
call   1030 <print_array@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i32
store i32 0, i32* %1
store i32 10, i32* %2
%6 = load i32, i32* %2
%7 = zext i32 %6 to i64
%8 = call i8* @llvm.stacksave()
store i8* %8, i8** %3
%9 = alloca i32, i64 %7
store i64 %7, i64* %4
%10 = call i32 @time(i32* null)
%11 = call i32 @srand(i32 %10)
store i32 0, i32* %5
br label %12
12: ; preds = %22, %0
%13 = load i32, i32* %5
%14 = load i32, i32* %2
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %25
16: ; preds = %12
%17 = call i32 (...) @rand()
%18 = srem i32 %17, 100
%19 = load i32, i32* %5
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i32, i32* %9, i64 %20
store i32 %18, i32* %21
br label %22
22: ; preds = %16
%23 = load i32, i32* %5
%24 = add nsw i32 %23, 1
store i32 %24, i32* %5
br label %12
25: ; preds = %12
%26 = load i32, i32* %2
%27 = call i32 @print_array(i32* %9, i32 %26)
%28 = load i32, i32* %2
%29 = call i32 @merge_sort(i32* %9, i32 %28)
%30 = load i32, i32* %2
%31 = call i32 @print_array(i32* %9, i32 %30)
store i32 0, i32* %1
%32 = load i8*, i8** %3
%33 = load i32, i32* %1
ret i32 %33
}

LLVM IR (-O2):
define i32 @main() {
%1 = alloca [10 x i32]
%2 = tail call i32 @time(i32* null)
%3 = tail call i32 @srand(i32 %2)
%4 = tail call i32 (...) @rand()
%5 = srem i32 %4, 100
%6 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 0
store i32 %5, i32* %6
%7 = tail call i32 (...) @rand()
%8 = srem i32 %7, 100
%9 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 1
store i32 %8, i32* %9
%10 = tail call i32 (...) @rand()
%11 = srem i32 %10, 100
%12 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 2
store i32 %11, i32* %12
%13 = tail call i32 (...) @rand()
%14 = srem i32 %13, 100
%15 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 3
store i32 %14, i32* %15
%16 = tail call i32 (...) @rand()
%17 = srem i32 %16, 100
%18 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 4
store i32 %17, i32* %18
%19 = tail call i32 (...) @rand()
%20 = srem i32 %19, 100
%21 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 5
store i32 %20, i32* %21
%22 = tail call i32 (...) @rand()
%23 = srem i32 %22, 100
%24 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 6
store i32 %23, i32* %24
%25 = tail call i32 (...) @rand()
%26 = srem i32 %25, 100
%27 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 7
store i32 %26, i32* %27
%28 = tail call i32 (...) @rand()
%29 = srem i32 %28, 100
%30 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 8
store i32 %29, i32* %30
%31 = tail call i32 (...) @rand()
%32 = srem i32 %31, 100
%33 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 9
store i32 %32, i32* %33
%34 = call i32 @print_array(i32* %6, i32 10)
%35 = call i32 @merge_sort(i32* %6, i32 10)
%36 = call i32 @print_array(i32* %6, i32 10)
ret i32 0
}