#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*/ assert(int);
int /*<<< orphan*/ merge(int *const, int const, int, int const, int *const);
void mergeSortHelper(int *const arr, const int start, const int end,
                     int *const temp) {
  assert(start >= 0);
  assert(start < end);
  if (end - start < 2) {
    return;
  }
  int middle = (start + end) / 2;
  mergeSortHelper(arr, start, middle, temp);
  mergeSortHelper(arr, middle, end, temp);
  merge(arr, start, middle, end, temp);
}


x86 assembly (clang, -O0):
<mergeSortHelper>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
cmpl   $0x0,-0xc(%rbp)
setge  %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
setl   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x10(%rbp),%eax
sub    -0xc(%rbp),%eax
cmp    $0x2,%eax
jge    117e <mergeSortHelper+0x4e>
jmp    11cb <mergeSortHelper+0x9b>
mov    -0xc(%rbp),%eax
add    -0x10(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    -0x18(%rbp),%rcx
call   1050 <mergeSortHelper@plt>
mov    -0x8(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x18(%rbp),%rcx
call   1050 <mergeSortHelper@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    -0x10(%rbp),%ecx
mov    -0x18(%rbp),%r8
call   1040 <merge@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mergeSortHelper>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rcx,%r14
mov    %edx,%r15d
mov    %esi,%ebx
mov    %rdi,%r12
mov    %esi,%edi
not    %edi
shr    $0x1f,%edi
call   1030 <assert@plt>
xor    %edi,%edi
mov    %r15d,%ebp
sub    %ebx,%ebp
setg   %dil
call   1030 <assert@plt>
cmp    $0x1,%ebp
jg     116d <mergeSortHelper+0x3d>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    (%r15,%rbx,1),%eax
mov    %eax,%ebp
shr    $0x1f,%ebp
add    %eax,%ebp
sar    %ebp
mov    %r12,%rdi
mov    %ebx,%esi
mov    %ebp,%edx
mov    %r14,%rcx
call   1050 <mergeSortHelper@plt>
mov    %r12,%rdi
mov    %ebp,%esi
mov    %r15d,%edx
mov    %r14,%rcx
call   1050 <mergeSortHelper@plt>
mov    %r12,%rdi
mov    %ebx,%esi
mov    %ebp,%edx
mov    %r15d,%ecx
mov    %r14,%r8
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <merge@plt>

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

LLVM IR (-O2):
define void @mergeSortHelper(i32* %0, i32 %1, i32 %2, i32* %3) {
%5 = xor i32 %1, -1
%6 = lshr i32 %5, 31
%7 = tail call i32 @assert(i32 %6)
%8 = icmp sgt i32 %2, %1
%9 = zext i1 %8 to i32
%10 = tail call i32 @assert(i32 %9)
%11 = sub nsw i32 %2, %1
%12 = icmp slt i32 %11, 2
br i1 %12, label %13, label %14
13: ; preds = %4, %14
ret void
14: ; preds = %4
%15 = add nsw i32 %2, %1
%16 = sdiv i32 %15, 2
tail call void @mergeSortHelper(i32* %0, i32 %1, i32 %16, i32* %3)
tail call void @mergeSortHelper(i32* %0, i32 %16, i32 %2, i32* %3)
%17 = tail call i32 @merge(i32* %0, i32 %1, i32 %16, i32 %2, i32* %3)
br label %13
}