#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 int /*<<< orphan*/ arr;

/* Variables and functions */
int /*<<< orphan*/ merge_sort(int *, int /*<<< orphan*/, int);
int /*<<< orphan*/ print_arr(int *, int);
int rand();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(void) {
  int arr[100];
  int i;
  srand(time(NULL));
  for (i = 0; i < 100; i++)
    arr[i] = rand() % (100 * 10);
  print_arr(arr, 100);
  merge_sort(arr, 0, sizeof(arr) / sizeof(int) - 1);
  print_arr(arr, 100);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1b0,%rsp
movl   $0x0,-0x4(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
movl   $0x0,-0x1a4(%rbp)
cmpl   $0x64,-0x1a4(%rbp)
jge    11ba <main+0x6a>
mov    $0x0,%al
call   1070 <rand@plt>
mov    $0x3e8,%ecx
cltd
idiv   %ecx
movslq -0x1a4(%rbp),%rax
mov    %edx,-0x1a0(%rbp,%rax,4)
mov    -0x1a4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1a4(%rbp)
jmp    117c <main+0x2c>
lea    -0x1a0(%rbp),%rdi
mov    $0x64,%esi
call   1030 <print_arr@plt>
lea    -0x1a0(%rbp),%rdi
xor    %esi,%esi
mov    $0x63,%edx
call   1060 <merge_sort@plt>
lea    -0x1a0(%rbp),%rdi
mov    $0x64,%esi
call   1030 <print_arr@plt>
xor    %eax,%eax
add    $0x1b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x190,%rsp
xor    %edi,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1070 <rand@plt>
cltq
imul   $0x10624dd3,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x26,%rcx
add    %edx,%ecx
imul   $0x3e8,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,(%rsp,%rbx,4)
add    $0x1,%rbx
cmp    $0x64,%rbx
jne    1170 <main+0x20>
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x64,%esi
call   1030 <print_arr@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x63,%edx
call   1060 <merge_sort@plt>
mov    %rbx,%rdi
mov    $0x64,%esi
call   1030 <print_arr@plt>
xor    %eax,%eax
add    $0x190,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i32]
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 @time(i32* null)
%5 = call i32 @srand(i32 %4)
store i32 0, i32* %3
br label %6
6: ; preds = %15, %0
%7 = load i32, i32* %3
%8 = icmp slt i32 %7, 100
br i1 %8, label %9, label %18
9: ; preds = %6
%10 = call i32 (...) @rand()
%11 = srem i32 %10, 1000
%12 = load i32, i32* %3
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %13
store i32 %11, i32* %14
br label %15
15: ; preds = %9
%16 = load i32, i32* %3
%17 = add nsw i32 %16, 1
store i32 %17, i32* %3
br label %6
18: ; preds = %6
%19 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 0
%20 = call i32 @print_arr(i32* %19, i32 100)
%21 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 0
%22 = call i32 @merge_sort(i32* %21, i32 0, i32 99)
%23 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 0
%24 = call i32 @print_arr(i32* %23, i32 100)
ret i32 0
}

LLVM IR (-O2):
define i32 @main() {
%1 = alloca [100 x i32]
%2 = bitcast [100 x i32]* %1 to i8*
%3 = tail call i32 @time(i32* null)
%4 = tail call i32 @srand(i32 %3)
br label %5
5: ; preds = %0, %5
%6 = phi i64 [ 0, %0 ], [ %10, %5 ]
%7 = tail call i32 (...) @rand()
%8 = srem i32 %7, 1000
%9 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %6
store i32 %8, i32* %9
%10 = add nuw nsw i64 %6, 1
%11 = icmp eq i64 %10, 100
br i1 %11, label %12, label %5
12: ; preds = %5
%13 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 0
%14 = call i32 @print_arr(i32* %13, i32 100)
%15 = call i32 @merge_sort(i32* %13, i32 0, i32 99)
%16 = call i32 @print_arr(i32* %13, i32 100)
ret i32 0
}