#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(void *, void *, size_t, size_t, size_t, size_t,
                         int (*)(void const *, void const *));
void MergeSortR(void *arr, void *out, size_t l, size_t r, size_t data_size,
                int (*cmp)(const void *a, const void *b)) {
  size_t q;
  if (r <= l) {
    return;
  }
  q = (l + r) / 2;
  MergeSortR(arr, out, l, q, data_size, cmp);
  MergeSortR(arr, out, q + 1, r, data_size, cmp);
  Merge(arr, out, l, q, r, data_size, cmp);
}


x86 assembly (clang, -O0):
<MergeSortR>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x18(%rbp),%rax
ja     1153 <MergeSortR+0x33>
jmp    11c6 <MergeSortR+0xa6>
mov    -0x18(%rbp),%rax
add    -0x20(%rbp),%rax
shr    $0x1,%rax
mov    %rax,-0x38(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x38(%rbp),%rcx
mov    -0x28(%rbp),%r8
mov    -0x30(%rbp),%r9
call   1040 <MergeSortR@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x38(%rbp),%rdx
add    $0x1,%rdx
mov    -0x20(%rbp),%rcx
mov    -0x28(%rbp),%r8
mov    -0x30(%rbp),%r9
call   1040 <MergeSortR@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x38(%rbp),%rcx
mov    -0x20(%rbp),%r8
mov    -0x28(%rbp),%r9
mov    -0x30(%rbp),%rax
mov    %rax,(%rsp)
call   1030 <Merge@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<MergeSortR>:
cmp    %rdx,%rcx
jbe    119c <MergeSortR+0x7c>
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r9,%r12
mov    %rcx,%r15
mov    %rdx,%rbx
mov    %rsi,%r13
mov    %rdi,%rbp
lea    (%rcx,%rdx,1),%r14
shr    %r14
mov    %r14,%rcx
mov    %r8,0x10(%rsp)
call   1040 <MergeSortR@plt>
lea    0x1(%r14),%rdx
mov    %rbp,%rdi
mov    %r13,%rsi
mov    %r15,%rcx
mov    0x10(%rsp),%r8
mov    %r12,%r9
call   1040 <MergeSortR@plt>
mov    %r12,(%rsp)
mov    %rbp,%rdi
mov    %r13,%rsi
mov    %rbx,%rdx
mov    %r14,%rcx
mov    %r15,%r8
mov    0x10(%rsp),%r9
call   1030 <Merge@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
ret

LLVM IR (-O0):
define void @MergeSortR(i8* %0, i8* %1, i64 %2, i64 %3, i64 %4, i32 (i8*, i8*)* %5) {
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i64
%10 = alloca i64
%11 = alloca i64
%12 = alloca i32 (i8*, i8*)*
%13 = alloca i64
store i8* %0, i8** %7
store i8* %1, i8** %8
store i64 %2, i64* %9
store i64 %3, i64* %10
store i64 %4, i64* %11
store i32 (i8*, i8*)* %5, i32 (i8*, i8*)** %12
%14 = load i64, i64* %10
%15 = load i64, i64* %9
%16 = icmp ule i64 %14, %15
br i1 %16, label %17, label %18
17: ; preds = %6
br label %44
18: ; preds = %6
%19 = load i64, i64* %9
%20 = load i64, i64* %10
%21 = add i64 %19, %20
%22 = udiv i64 %21, 2
store i64 %22, i64* %13
%23 = load i8*, i8** %7
%24 = load i8*, i8** %8
%25 = load i64, i64* %9
%26 = load i64, i64* %13
%27 = load i64, i64* %11
%28 = load i32 (i8*, i8*)*, i32 (i8*, i8*)** %12
%29 = load i8*, i8** %7
%30 = load i8*, i8** %8
%31 = load i64, i64* %13
%32 = add i64 %31, 1
%33 = load i64, i64* %10
%34 = load i64, i64* %11
%35 = load i32 (i8*, i8*)*, i32 (i8*, i8*)** %12
%36 = load i8*, i8** %7
%37 = load i8*, i8** %8
%38 = load i64, i64* %9
%39 = load i64, i64* %13
%40 = load i64, i64* %10
%41 = load i64, i64* %11
%42 = load i32 (i8*, i8*)*, i32 (i8*, i8*)** %12
%43 = call i32 @Merge(i8* %36, i8* %37, i64 %38, i64 %39, i64 %40, i64 %41, i32 (i8*, i8*)* %42)
br label %44
44: ; preds = %18, %17
ret void
}

LLVM IR (-O2):
define void @MergeSortR(i8* %0, i8* %1, i64 %2, i64 %3, i64 %4, i32 (i8*, i8*)* %5) {
%7 = icmp ugt i64 %3, %2
br i1 %7, label %9, label %8
8: ; preds = %6, %9
ret void
9: ; preds = %6
%10 = add i64 %3, %2
%11 = lshr i64 %10, 1
tail call void @MergeSortR(i8* %0, i8* %1, i64 %2, i64 %11, i64 %4, i32 (i8*, i8*)* %5)
%12 = add nuw i64 %11, 1
tail call void @MergeSortR(i8* %0, i8* %1, i64 %12, i64 %3, i64 %4, i32 (i8*, i8*)* %5)
%13 = tail call i32 @Merge(i8* %0, i8* %1, i64 %2, i64 %11, i64 %3, i64 %4, i32 (i8*, i8*)* %5)
br label %8
}