#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*/ mergesort(int *, int, int, int, int);
void splitmerge(int *a, int start, int end, int size) {
  int mid, i;
  if (start == end)
    return;
  mid = (start + end) / 2;
  splitmerge(a, start, mid, size);
  splitmerge(a, mid + 1, end, size);
  mergesort(a, start, mid, end, size);
}


x86 assembly (clang, -O0):
<splitmerge>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jne    1146 <splitmerge+0x26>
jmp    1194 <splitmerge+0x74>
mov    -0xc(%rbp),%eax
add    -0x10(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x14(%rbp),%ecx
call   1030 <splitmerge@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%esi
add    $0x1,%esi
mov    -0x10(%rbp),%edx
mov    -0x14(%rbp),%ecx
call   1030 <splitmerge@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x10(%rbp),%ecx
mov    -0x14(%rbp),%r8d
call   1040 <mergesort@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<splitmerge>:
cmp    %edx,%esi
jne    1125 <splitmerge+0x5>
ret
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %ecx,%r14d
mov    %edx,%r12d
mov    %esi,%ebp
mov    %rdi,%r15
lea    (%r12,%rbp,1),%eax
mov    %eax,%ebx
shr    $0x1f,%ebx
add    %eax,%ebx
sar    %ebx
mov    %ebx,%edx
call   1030 <splitmerge@plt>
lea    0x1(%rbx),%esi
mov    %r15,%rdi
mov    %r12d,%edx
mov    %r14d,%ecx
call   1030 <splitmerge@plt>
mov    %r15,%rdi
mov    %ebp,%esi
mov    %ebx,%edx
mov    %r12d,%ecx
mov    %r14d,%r8d
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <mergesort@plt>

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

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