#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 */
struct chashentry {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ merge(struct chashentry **, int, int, int);
void merge_sort(struct chashentry **tmpitems, int start, int end) {
  int middle = (end + start) / 2;
  if (end <= start)
    return;
  merge_sort(tmpitems, start, middle);
  merge_sort(tmpitems, middle + 1, end);
  merge(tmpitems, start, middle + 1, end);
}


x86 assembly (clang, -O0):
<merge_sort>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x10(%rbp),%eax
add    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     1154 <merge_sort+0x34>
jmp    118a <merge_sort+0x6a>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x14(%rbp),%edx
call   1040 <merge_sort@plt>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%esi
add    $0x1,%esi
mov    -0x10(%rbp),%edx
call   1040 <merge_sort@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x14(%rbp),%edx
add    $0x1,%edx
mov    -0x10(%rbp),%ecx
call   1030 <merge@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<merge_sort>:
cmp    %esi,%edx
jle    1170 <merge_sort+0x50>
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 <merge_sort@plt>
add    $0x1,%ebp
mov    %r15,%rdi
mov    %ebp,%esi
mov    %r14d,%edx
call   1040 <merge_sort@plt>
mov    %r15,%rdi
mov    %ebx,%esi
mov    %ebp,%edx
mov    %r14d,%ecx
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <merge@plt>
ret

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

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