#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(double *, int, double, int);
void mergeSort(double arr[], int l, int r) {
  if (l < r) {
    double m = l + (r - l) / 2;
    mergeSort(arr, l, m);
    mergeSort(arr, m + 1, r);
    merge(arr, l, m, r);
  }
}


x86 assembly (clang, -O0):
<mergeSort>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11a4 <mergeSort+0x84>
mov    -0xc(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%eax
sub    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
add    %ecx,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
cvttsd2si -0x18(%rbp),%edx
call   1030 <mergeSort@plt>
mov    -0x8(%rbp),%rdi
movsd  0xe81(%rip),%xmm0
addsd  -0x18(%rbp),%xmm0
cvttsd2si %xmm0,%esi
mov    -0x10(%rbp),%edx
call   1030 <mergeSort@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
movsd  -0x18(%rbp),%xmm0
mov    -0x10(%rbp),%edx
call   1040 <merge@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mergeSort>:
mov    %edx,%eax
sub    %esi,%eax
jle    1185 <mergeSort+0x65>
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %edx,%ebx
mov    %esi,%ebp
mov    %rdi,%r14
mov    %eax,%edx
shr    $0x1f,%edx
add    %eax,%edx
sar    %edx
add    %esi,%edx
cvtsi2sd %edx,%xmm0
movsd  %xmm0,0x8(%rsp)
call   1030 <mergeSort@plt>
movsd  0xea9(%rip),%xmm0
addsd  0x8(%rsp),%xmm0
cvttsd2si %xmm0,%esi
mov    %r14,%rdi
mov    %ebx,%edx
call   1030 <mergeSort@plt>
mov    %r14,%rdi
mov    %ebp,%esi
movsd  0x8(%rsp),%xmm0
mov    %ebx,%edx
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <merge@plt>
ret

LLVM IR (-O0):
define void @mergeSort(double* %0, i32 %1, i32 %2) {
%4 = alloca double*
%5 = alloca i32
%6 = alloca i32
%7 = alloca double
store double* %0, double** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%8 = load i32, i32* %5
%9 = load i32, i32* %6
%10 = icmp slt i32 %8, %9
br i1 %10, label %11, label %33
11: ; preds = %3
%12 = load i32, i32* %5
%13 = load i32, i32* %6
%14 = load i32, i32* %5
%15 = sub nsw i32 %13, %14
%16 = sdiv i32 %15, 2
%17 = add nsw i32 %12, %16
%18 = sitofp i32 %17 to double
store double %18, double* %7
%19 = load double*, double** %4
%20 = load i32, i32* %5
%21 = load double, double* %7
%22 = fptosi double %21 to i32
%23 = load double*, double** %4
%24 = load double, double* %7
%25 = fadd double %24, 1.000000e+00
%26 = fptosi double %25 to i32
%27 = load i32, i32* %6
%28 = load double*, double** %4
%29 = load i32, i32* %5
%30 = load double, double* %7
%31 = load i32, i32* %6
%32 = call i32 @merge(double* %28, i32 %29, double %30, i32 %31)
br label %33
33: ; preds = %11, %3
ret void
}

LLVM IR (-O2):
define void @mergeSort(double* %0, i32 %1, i32 %2) {
%4 = icmp sgt i32 %2, %1
br i1 %4, label %6, label %5
5: ; preds = %3, %6
ret void
6: ; preds = %3
%7 = sub nsw i32 %2, %1
%8 = sdiv i32 %7, 2
%9 = add nsw i32 %8, %1
%10 = sitofp i32 %9 to double
tail call void @mergeSort(double* %0, i32 %1, i32 %9)
%11 = fadd double %10, 1.000000e+00
%12 = fptosi double %11 to i32
tail call void @mergeSort(double* %0, i32 %12, i32 %2)
%13 = tail call i32 @merge(double* %0, i32 %1, double %10, i32 %2)
br label %5
}