#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*/ PrintSimpleArray(int /*<<< orphan*/);
int /*<<< orphan*/ merge_sort(int *, int);
int rand();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main() {
  srand(time(NULL));
  int ElementRange = 40;
  int startArray[20];
  for (int i = 0; i < 20; i++) {
    startArray[i] = rand() % 40;
  }
  PrintSimpleArray(merge_sort(startArray, 20));
  return 1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1040 <time@plt>
mov    %eax,%edi
call   1030 <srand@plt>
movl   $0x28,-0x8(%rbp)
movl   $0x0,-0x64(%rbp)
cmpl   $0x14,-0x64(%rbp)
jge    11ac <main+0x5c>
mov    $0x0,%al
call   1070 <rand@plt>
mov    $0x28,%ecx
cltd
idiv   %ecx
movslq -0x64(%rbp),%rax
mov    %edx,-0x60(%rbp,%rax,4)
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    117d <main+0x2d>
lea    -0x60(%rbp),%rdi
mov    $0x14,%esi
call   1050 <merge_sort@plt>
mov    %eax,%edi
call   1060 <PrintSimpleArray@plt>
mov    $0x1,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x50,%rsp
xor    %edi,%edi
call   1040 <time@plt>
mov    %eax,%edi
call   1030 <srand@plt>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
xor    %eax,%eax
call   1070 <rand@plt>
cltq
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x24,%rcx
add    %edx,%ecx
shl    $0x3,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%eax
mov    %eax,(%rsp,%rbx,4)
add    $0x1,%rbx
cmp    $0x14,%rbx
jne    1170 <main+0x20>
mov    %rsp,%rdi
mov    $0x14,%esi
call   1050 <merge_sort@plt>
mov    %eax,%edi
call   1060 <PrintSimpleArray@plt>
mov    $0x1,%eax
add    $0x50,%rsp
pop    %rbx
ret

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

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