#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 *malloc(int);
int /*<<< orphan*/ mergeSort(int *, int *, int /*<<< orphan*/, int);
unsigned long my_ftime();
int /*<<< orphan*/ printf(char *, ...);
int rand();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(int argc, char **argv) {
  int n = 100;
  int *original_array = NULL;
  unsigned long start_time_lt, initTime, compTime;
  int c;
  srand(time(NULL));
  printf("\n");
  printf("Start initializing the unsorted array: ");
  original_array = malloc(n * sizeof(int));
  start_time_lt = my_ftime();
  for (c = 0; c < n; c++) {
    original_array[c] = rand() % n;
    printf("%d ", original_array[c]);
  }
  printf("\n");
  printf("\n");
  initTime = my_ftime() - start_time_lt;
  printf("Sorting...");
  int *other_array = malloc(n * sizeof(int));
  mergeSort(original_array, other_array, 0, (n - 1));
  compTime = my_ftime() - start_time_lt - initTime;
  printf("Vector Size=%d\tinitTime=%g\tcomputeTime=%g (%lu min, %lu sec)\n", n,
         initTime / 1000.0, compTime / 1000.0, (compTime / 1000) / 60,
         (compTime / 1000) % 60);
  printf("\n");
  printf("\n");
  printf("This is the sorted array: ");
  for (c = 0; c < n; c++) {
    printf("%d ", original_array[c]);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x64,-0x14(%rbp)
movq   $0x0,-0x20(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
lea    0xef7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe76(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1080 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    $0x0,%al
call   1030 <my_ftime@plt>
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    122f <main+0xbf>
mov    $0x0,%al
call   1090 <rand@plt>
cltd
idivl  -0x14(%rbp)
mov    -0x20(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x20(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe3e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    11e6 <main+0x76>
lea    0xe6d(%rip),%rdi
mov    %rdi,-0x60(%rbp)
xor    %eax,%eax
mov    %eax,-0x58(%rbp)
mov    %al,-0x51(%rbp)
call   1040 <printf@plt>
mov    -0x60(%rbp),%rdi
mov    -0x51(%rbp),%al
call   1040 <printf@plt>
mov    -0x51(%rbp),%al
call   1030 <my_ftime@plt>
mov    %rax,%rcx
mov    -0x51(%rbp),%al
mov    -0x28(%rbp),%rdx
sub    %rdx,%rcx
mov    %rcx,-0x30(%rbp)
lea    0xde9(%rip),%rdi
call   1040 <printf@plt>
mov    -0x14(%rbp),%edi
shl    $0x2,%edi
call   1080 <malloc@plt>
mov    -0x58(%rbp),%edx
mov    %rax,-0x48(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x48(%rbp),%rsi
mov    -0x14(%rbp),%ecx
add    $0xffffffff,%ecx
call   1060 <mergeSort@plt>
mov    -0x51(%rbp),%al
call   1030 <my_ftime@plt>
mov    -0x28(%rbp),%rcx
sub    %rcx,%rax
mov    -0x30(%rbp),%rcx
sub    %rcx,%rax
mov    %rax,-0x38(%rbp)
mov    -0x14(%rbp),%esi
movaps 0xd4f(%rip),%xmm3
movq   -0x30(%rbp),%xmm0
punpckldq %xmm3,%xmm0
movapd 0xd4e(%rip),%xmm2
subpd  %xmm2,%xmm0
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  0xd17(%rip),%xmm1
divsd  %xmm1,%xmm0
movq   -0x38(%rbp),%xmm1
punpckldq %xmm3,%xmm1
subpd  %xmm2,%xmm1
movaps %xmm1,%xmm2
unpckhpd %xmm1,%xmm1
addsd  %xmm2,%xmm1
movsd  0xcf3(%rip),%xmm2
divsd  %xmm2,%xmm1
mov    -0x38(%rbp),%rax
mov    $0x3e8,%ecx
xor    %edx,%edx
div    %rcx
mov    $0x3c,%ecx
xor    %edx,%edx
div    %rcx
mov    %rax,-0x50(%rbp)
mov    -0x38(%rbp),%rax
mov    $0x3e8,%ecx
xor    %edx,%edx
div    %rcx
mov    $0x3c,%ecx
xor    %edx,%edx
div    %rcx
mov    %rdx,%rcx
mov    -0x50(%rbp),%rdx
lea    0xd14(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
lea    0xd42(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xd34(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xd28(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    13be <main+0x24e>
mov    -0x20(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xcaf(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    138b <main+0x21b>
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
xor    %edi,%edi
call   1080 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xe81(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x190,%edi
call   1090 <malloc@plt>
mov    %rax,%r12
xor    %eax,%eax
call   1040 <my_ftime@plt>
mov    %rax,%r14
lea    0xe84(%rip),%r15
xor    %ebx,%ebx
xchg   %ax,%ax
xor    %eax,%eax
call   10a0 <rand@plt>
movslq %eax,%rsi
imul   $0x51eb851f,%rsi,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x25,%rax
add    %ecx,%eax
imul   $0x64,%eax,%eax
sub    %eax,%esi
mov    %esi,(%r12,%rbx,4)
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbx
cmp    $0x64,%rbx
jne    11d0 <main+0x50>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
call   1040 <my_ftime@plt>
mov    %rax,%r15
mov    %rax,%rbx
sub    %r14,%rbx
lea    0xe1e(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x190,%edi
call   1090 <malloc@plt>
mov    %r12,%rdi
mov    %rax,%rsi
xor    %edx,%edx
mov    $0x63,%ecx
call   1070 <mergeSort@plt>
xor    %eax,%eax
call   1040 <my_ftime@plt>
mov    %rax,%rsi
sub    %r15,%rsi
movq   %rbx,%xmm1
movdqa 0xd8d(%rip),%xmm2
punpckldq %xmm2,%xmm1
movapd 0xd91(%rip),%xmm3
subpd  %xmm3,%xmm1
movapd %xmm1,%xmm0
unpckhpd %xmm1,%xmm0
addsd  %xmm1,%xmm0
movsd  0xd89(%rip),%xmm4
divsd  %xmm4,%xmm0
movq   %rsi,%xmm5
punpckldq %xmm2,%xmm5
subpd  %xmm3,%xmm5
movapd %xmm5,%xmm1
unpckhpd %xmm5,%xmm1
addsd  %xmm5,%xmm1
divsd  %xmm4,%xmm1
mov    %rsi,%rax
shr    $0x3,%rax
movabs $0x20c49ba5e353f7cf,%rcx
9b c4 20
mul    %rcx
mov    %rdx,%rcx
shr    $0x5,%rsi
movabs $0x45e7b272f608771,%rdx
7b 5e 04
mov    %rsi,%rax
mul    %rdx
mov    %rdx,%rbx
shr    $0x4,%rcx
movabs $0x8888888888888889,%rdx
88 88 88
mov    %rcx,%rax
mul    %rdx
shr    $0x5,%rbx
shr    $0x5,%rdx
imul   $0x3c,%rdx,%rax
sub    %rax,%rcx
lea    0xd4f(%rip),%rdi
mov    $0x64,%esi
mov    %rbx,%rdx
mov    $0x2,%al
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xd63(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xd08(%rip),%r14
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
mov    (%r12,%rbx,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbx
cmp    $0x64,%rbx
jne    1350 <main+0x1d0>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c"\0A\00"
@.str.1 = [40 x i8] c"Start initializing the unsorted array: \00"
@.str.2 = [4 x i8] c"%d \00"
@.str.3 = [11 x i8] c"Sorting...\00"
@.str.4 = [62 x i8] c"Vector Size=%d\09initTime=%g\09computeTime=%g (%lu min, %lu sec)\0A\00"
@.str.5 = [27 x i8] c"This is the sorted array: \00"
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
%10 = alloca i64
%11 = alloca i32
%12 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 100, i32* %6
store i32* null, i32** %7
%13 = call i32 @time(i32* null)
%14 = call i32 @srand(i32 %13)
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0))
%17 = load i32, i32* %6
%18 = sext i32 %17 to i64
%19 = mul i64 %18, 4
%20 = trunc i64 %19 to i32
%21 = call i32* @malloc(i32 %20)
store i32* %21, i32** %7
%22 = call i64 (...) @my_ftime()
store i64 %22, i64* %8
store i32 0, i32* %11
br label %23
23: ; preds = %41, %2
%24 = load i32, i32* %11
%25 = load i32, i32* %6
%26 = icmp slt i32 %24, %25
br i1 %26, label %27, label %44
27: ; preds = %23
%28 = call i32 (...) @rand()
%29 = load i32, i32* %6
%30 = srem i32 %28, %29
%31 = load i32*, i32** %7
%32 = load i32, i32* %11
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i32, i32* %31, i64 %33
store i32 %30, i32* %34
%35 = load i32*, i32** %7
%36 = load i32, i32* %11
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i32, i32* %35, i64 %37
%39 = load i32, i32* %38
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %39)
br label %41
41: ; preds = %27
%42 = load i32, i32* %11
%43 = add nsw i32 %42, 1
store i32 %43, i32* %11
br label %23
44: ; preds = %23
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%47 = call i64 (...) @my_ftime()
%48 = load i64, i64* %8
%49 = sub i64 %47, %48
store i64 %49, i64* %9
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
%51 = load i32, i32* %6
%52 = sext i32 %51 to i64
%53 = mul i64 %52, 4
%54 = trunc i64 %53 to i32
%55 = call i32* @malloc(i32 %54)
store i32* %55, i32** %12
%56 = load i32*, i32** %7
%57 = load i32*, i32** %12
%58 = load i32, i32* %6
%59 = sub nsw i32 %58, 1
%60 = call i32 @mergeSort(i32* %56, i32* %57, i32 0, i32 %59)
%61 = call i64 (...) @my_ftime()
%62 = load i64, i64* %8
%63 = sub i64 %61, %62
%64 = load i64, i64* %9
%65 = sub i64 %63, %64
store i64 %65, i64* %10
%66 = load i32, i32* %6
%67 = load i64, i64* %9
%68 = uitofp i64 %67 to double
%69 = fdiv double %68, 1.000000e+03
%70 = load i64, i64* %10
%71 = uitofp i64 %70 to double
%72 = fdiv double %71, 1.000000e+03
%73 = load i64, i64* %10
%74 = udiv i64 %73, 1000
%75 = udiv i64 %74, 60
%76 = load i64, i64* %10
%77 = udiv i64 %76, 1000
%78 = urem i64 %77, 60
%79 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.4, i64 0, i64 0), i32 %66, double %69, double %72, i64 %75, i64 %78)
%80 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%81 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%82 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0))
store i32 0, i32* %11
br label %83
83: ; preds = %94, %44
%84 = load i32, i32* %11
%85 = load i32, i32* %6
%86 = icmp slt i32 %84, %85
br i1 %86, label %87, label %97
87: ; preds = %83
%88 = load i32*, i32** %7
%89 = load i32, i32* %11
%90 = sext i32 %89 to i64
%91 = getelementptr inbounds i32, i32* %88, i64 %90
%92 = load i32, i32* %91
%93 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %92)
br label %94
94: ; preds = %87
%95 = load i32, i32* %11
%96 = add nsw i32 %95, 1
store i32 %96, i32* %11
br label %83
97: ; preds = %83
%98 = load i32, i32* %3
ret i32 %98
}

LLVM IR (-O2):
@.str.1 = [40 x i8] c"Start initializing the unsorted array: \00"
@.str.2 = [4 x i8] c"%d \00"
@.str.3 = [11 x i8] c"Sorting...\00"
@.str.4 = [62 x i8] c"Vector Size=%d\09initTime=%g\09computeTime=%g (%lu min, %lu sec)\0A\00"
@.str.5 = [27 x i8] c"This is the sorted array: \00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @time(i32* null)
%4 = tail call i32 @srand(i32 %3)
%5 = tail call i32 @putchar(i32 10)
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0))
%7 = tail call i32* @malloc(i32 400)
%8 = tail call i64 (...) @my_ftime()
br label %9
9: ; preds = %2, %9
%10 = phi i64 [ 0, %2 ], [ %15, %9 ]
%11 = tail call i32 (...) @rand()
%12 = srem i32 %11, 100
%13 = getelementptr inbounds i32, i32* %7, i64 %10
store i32 %12, i32* %13
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %12)
%15 = add nuw nsw i64 %10, 1
%16 = icmp eq i64 %15, 100
br i1 %16, label %17, label %9
17: ; preds = %9
%18 = tail call i32 @putchar(i32 10)
%19 = tail call i32 @putchar(i32 10)
%20 = tail call i64 (...) @my_ftime()
%21 = sub i64 %20, %8
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
%23 = tail call i32* @malloc(i32 400)
%24 = tail call i32 @mergeSort(i32* %7, i32* %23, i32 0, i32 99)
%25 = tail call i64 (...) @my_ftime()
%26 = sub i64 %25, %20
%27 = uitofp i64 %21 to double
%28 = fdiv double %27, 1.000000e+03
%29 = uitofp i64 %26 to double
%30 = fdiv double %29, 1.000000e+03
%31 = udiv i64 %26, 1000
%32 = udiv i64 %26, 60000
%33 = urem i64 %31, 60
%34 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([62 x i8], [62 x i8]* @.str.4, i64 0, i64 0), i32 100, double %28, double %30, i64 %32, i64 %33)
%35 = tail call i32 @putchar(i32 10)
%36 = tail call i32 @putchar(i32 10)
%37 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0))
br label %38
38: ; preds = %17, %38
%39 = phi i64 [ 0, %17 ], [ %43, %38 ]
%40 = getelementptr inbounds i32, i32* %7, i64 %39
%41 = load i32, i32* %40
%42 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %41)
%43 = add nuw nsw i64 %39, 1
%44 = icmp eq i64 %43, 100
br i1 %44, label %45, label %38
45: ; preds = %38
ret i32 0
}