#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*/ copy_array(void *, void *, int, int, int);
int /*<<< orphan*/ merge(void *, int, int, int, void *, int,
                         int (*)(void *, void *));
void m_split_sort_t2d(void *a, int iBegin, int iEnd, void *b, int esize,
                      int compare(void *key1, void *key2)) {
  int iMiddle;
  if ((iEnd - iBegin) < 1)
    return;
  iMiddle = (iBegin + iEnd - 1) / 2;
  m_split_sort_t2d(a, iBegin, iMiddle, b, esize, compare);
  m_split_sort_t2d(a, iMiddle + 1, iEnd, b, esize, compare);
  merge(a, iBegin, iMiddle, iEnd, b, esize, compare);
  copy_array(a, b, iBegin, iEnd, esize);
  return;
}


x86 assembly (clang, -O0):
<m_split_sort_t2d>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
mov    %r9,-0x28(%rbp)
mov    -0x10(%rbp),%eax
sub    -0xc(%rbp),%eax
cmp    $0x1,%eax
jge    1162 <m_split_sort_t2d+0x32>
jmp    11e8 <m_split_sort_t2d+0xb8>
mov    -0xc(%rbp),%eax
add    -0x10(%rbp),%eax
sub    $0x1,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x2c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x2c(%rbp),%edx
mov    -0x18(%rbp),%rcx
mov    -0x1c(%rbp),%r8d
mov    -0x28(%rbp),%r9
call   1030 <m_split_sort_t2d@plt>
mov    -0x8(%rbp),%rdi
mov    -0x2c(%rbp),%esi
add    $0x1,%esi
mov    -0x10(%rbp),%edx
mov    -0x18(%rbp),%rcx
mov    -0x1c(%rbp),%r8d
mov    -0x28(%rbp),%r9
call   1030 <m_split_sort_t2d@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x2c(%rbp),%edx
mov    -0x10(%rbp),%ecx
mov    -0x18(%rbp),%r8
mov    -0x1c(%rbp),%r9d
mov    -0x28(%rbp),%rax
mov    %rax,(%rsp)
call   1040 <merge@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
mov    -0x1c(%rbp),%r8d
call   1050 <copy_array@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<m_split_sort_t2d>:
cmp    %esi,%edx
jle    11ce <m_split_sort_t2d+0x9e>
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %edx,%ebx
mov    %esi,%ebp
lea    (%rbx,%rbp,1),%eax
lea    (%rbx,%rbp,1),%edx
add    $0xffffffff,%edx
shr    $0x1f,%edx
lea    (%rdx,%rax,1),%r13d
add    $0xffffffff,%r13d
sar    %r13d
mov    %rdi,%r12
mov    %r13d,%edx
mov    %r8d,%r15d
mov    %r9,%r14
mov    %rcx,0x10(%rsp)
call   1030 <m_split_sort_t2d@plt>
lea    0x1(%r13),%esi
mov    %r12,%rdi
mov    %ebx,%edx
mov    0x10(%rsp),%rcx
mov    %r15d,%r8d
mov    %r14,%r9
call   1030 <m_split_sort_t2d@plt>
mov    %r14,(%rsp)
mov    %r12,%rdi
mov    %ebp,%esi
mov    %r13d,%edx
mov    %ebx,%ecx
mov    0x10(%rsp),%r14
mov    %r14,%r8
mov    %r15d,%r9d
call   1040 <merge@plt>
mov    %r12,%rdi
mov    %r14,%rsi
mov    %ebp,%edx
mov    %ebx,%ecx
mov    %r15d,%r8d
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <copy_array@plt>
ret

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

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