#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(int *, int *, int, int, int);
void splitAndMerge(int *tmp, int *array, int begin, int end) {
  int median;
  if (end - begin >= 1) {
    median = (begin + end) / 2;
    splitAndMerge(array, tmp, begin, median);
    splitAndMerge(array, tmp, median + 1, end);
    merge(tmp, array, begin, median, end);
  }
}


x86 assembly (clang, -O0):
<splitAndMerge>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    -0x18(%rbp),%eax
sub    -0x14(%rbp),%eax
cmp    $0x1,%eax
jl     1196 <splitAndMerge+0x76>
mov    -0x14(%rbp),%eax
add    -0x18(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x1c(%rbp),%ecx
call   1030 <splitAndMerge@plt>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x1c(%rbp),%edx
add    $0x1,%edx
mov    -0x18(%rbp),%ecx
call   1030 <splitAndMerge@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x1c(%rbp),%ecx
mov    -0x18(%rbp),%r8d
call   1040 <merge@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<splitAndMerge>:
cmp    %edx,%ecx
jle    1180 <splitAndMerge+0x60>
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %ecx,%r14d
mov    %edx,%r13d
mov    %rsi,%r15
mov    %rdi,%r12
lea    (%r14,%r13,1),%eax
mov    %eax,%ebx
shr    $0x1f,%ebx
add    %eax,%ebx
sar    %ebx
mov    %rsi,%rdi
mov    %r12,%rsi
mov    %ebx,%ecx
call   1030 <splitAndMerge@plt>
lea    0x1(%rbx),%edx
mov    %r15,%rdi
mov    %r12,%rsi
mov    %r14d,%ecx
call   1030 <splitAndMerge@plt>
mov    %r12,%rdi
mov    %r15,%rsi
mov    %r13d,%edx
mov    %ebx,%ecx
mov    %r14d,%r8d
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1040 <merge@plt>
ret

LLVM IR (-O0):
define void @splitAndMerge(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* %8
%11 = load i32, i32* %7
%12 = sub nsw i32 %10, %11
%13 = icmp sge i32 %12, 1
br i1 %13, label %14, label %34
14: ; preds = %4
%15 = load i32, i32* %7
%16 = load i32, i32* %8
%17 = add nsw i32 %15, %16
%18 = sdiv i32 %17, 2
store i32 %18, i32* %9
%19 = load i32*, i32** %6
%20 = load i32*, i32** %5
%21 = load i32, i32* %7
%22 = load i32, i32* %9
%23 = load i32*, i32** %6
%24 = load i32*, i32** %5
%25 = load i32, i32* %9
%26 = add nsw i32 %25, 1
%27 = load i32, i32* %8
%28 = load i32*, i32** %5
%29 = load i32*, i32** %6
%30 = load i32, i32* %7
%31 = load i32, i32* %9
%32 = load i32, i32* %8
%33 = call i32 @merge(i32* %28, i32* %29, i32 %30, i32 %31, i32 %32)
br label %34
34: ; preds = %14, %4
ret void
}

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