#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*/ MergeHalves(int *, int, int);
int MergeSort(int *Arr, int Low, int High) {
  if (Low < High) {
    int Mid = (Low + High) / 2;
    MergeSort(Arr, Low, Mid);
    MergeSort(Arr, Mid + 1, High);
    MergeHalves(Arr, Low, High);
  }
}


x86 assembly (clang, -O0):
<MergeSort>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    117f <MergeSort+0x5f>
mov    -0x14(%rbp),%eax
add    -0x18(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x1c(%rbp),%edx
call   1040 <MergeSort@plt>
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%esi
add    $0x1,%esi
mov    -0x18(%rbp),%edx
call   1040 <MergeSort@plt>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
call   1030 <MergeHalves@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<MergeSort>:
cmp    %edx,%esi
jge    116e <MergeSort+0x4e>
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%r14d
mov    %esi,%ebx
mov    %rdi,%r15
lea    (%r14,%rbx,1),%eax
mov    %eax,%ebp
shr    $0x1f,%ebp
add    %eax,%ebp
sar    %ebp
mov    %ebp,%edx
call   1040 <MergeSort@plt>
add    $0x1,%ebp
mov    %r15,%rdi
mov    %ebp,%esi
mov    %r14d,%edx
call   1040 <MergeSort@plt>
mov    %r15,%rdi
mov    %ebx,%esi
mov    %r14d,%edx
call   1030 <MergeHalves@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @MergeSort(i32* %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32* %0, i32** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
%9 = load i32, i32* %6
%10 = load i32, i32* %7
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %30
12: ; preds = %3
%13 = load i32, i32* %6
%14 = load i32, i32* %7
%15 = add nsw i32 %13, %14
%16 = sdiv i32 %15, 2
store i32 %16, i32* %8
%17 = load i32*, i32** %5
%18 = load i32, i32* %6
%19 = load i32, i32* %8
%20 = call i32 @MergeSort(i32* %17, i32 %18, i32 %19)
%21 = load i32*, i32** %5
%22 = load i32, i32* %8
%23 = add nsw i32 %22, 1
%24 = load i32, i32* %7
%25 = call i32 @MergeSort(i32* %21, i32 %23, i32 %24)
%26 = load i32*, i32** %5
%27 = load i32, i32* %6
%28 = load i32, i32* %7
%29 = call i32 @MergeHalves(i32* %26, i32 %27, i32 %28)
br label %30
30: ; preds = %12, %3
%31 = load i32, i32* %4
ret i32 %31
}

LLVM IR (-O2):
define i32 @MergeSort(i32* %0, i32 %1, i32 %2) {
%4 = icmp slt i32 %1, %2
br i1 %4, label %6, label %5
5: ; preds = %3, %6
ret i32 undef
6: ; preds = %3
%7 = add nsw i32 %2, %1
%8 = sdiv i32 %7, 2
%9 = tail call i32 @MergeSort(i32* %0, i32 %1, i32 %8)
%10 = add nsw i32 %8, 1
%11 = tail call i32 @MergeSort(i32* %0, i32 %10, i32 %2)
%12 = tail call i32 @MergeHalves(i32* %0, i32 %1, i32 %2)
br label %5
}