#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 ceil(float);
int /*<<< orphan*/ merge(int, int, int, int *);
int merge_sort_(int begin, int end, int *array, int *sortedArray) {
  if (begin < end) {
    int middle;
    middle = ceil((float)end + begin) / 2;
    merge_sort_(begin, middle, array, sortedArray);
    merge_sort_(middle + 1, end, array, sortedArray);
    merge(begin, middle, end, array);
  }
  return 0;
}


x86 assembly (clang, -O0):
<merge_sort_>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    -0x4(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11ab <merge_sort_+0x7b>
cvtsi2ssl -0x8(%rbp),%xmm0
cvtsi2ssl -0x4(%rbp),%xmm1
addss  %xmm1,%xmm0
call   1030 <ceil@plt>
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x1c(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x1c(%rbp),%esi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
call   1050 <merge_sort_@plt>
mov    -0x1c(%rbp),%edi
add    $0x1,%edi
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
call   1050 <merge_sort_@plt>
mov    -0x4(%rbp),%edi
mov    -0x1c(%rbp),%esi
mov    -0x8(%rbp),%edx
mov    -0x10(%rbp),%rcx
call   1040 <merge@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<merge_sort_>:
cmp    %esi,%edi
jge    1198 <merge_sort_+0x68>
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rcx,%r15
mov    %rdx,%r14
mov    %esi,%r12d
mov    %edi,%ebx
cvtsi2ss %esi,%xmm1
cvtsi2ss %edi,%xmm0
addss  %xmm1,%xmm0
call   1030 <ceil@plt>
mov    %eax,%ebp
shr    $0x1f,%ebp
add    %eax,%ebp
sar    %ebp
mov    %ebx,%edi
mov    %ebp,%esi
mov    %r14,%rdx
mov    %r15,%rcx
call   1050 <merge_sort_@plt>
lea    0x1(%rbp),%edi
mov    %r12d,%esi
mov    %r14,%rdx
mov    %r15,%rcx
call   1050 <merge_sort_@plt>
mov    %ebx,%edi
mov    %ebp,%esi
mov    %r12d,%edx
mov    %r14,%rcx
call   1040 <merge@plt>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
xor    %eax,%eax
ret

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

LLVM IR (-O2):
define i32 @merge_sort_(i32 %0, i32 %1, i32* %2, i32* %3) {
%5 = icmp slt i32 %0, %1
br i1 %5, label %7, label %6
6: ; preds = %4, %7
ret i32 0
7: ; preds = %4
%8 = sitofp i32 %1 to float
%9 = sitofp i32 %0 to float
%10 = fadd float %9, %8
%11 = tail call i32 @ceil(float %10)
%12 = sdiv i32 %11, 2
%13 = tail call i32 @merge_sort_(i32 %0, i32 %12, i32* %2, i32* %3)
%14 = add nsw i32 %12, 1
%15 = tail call i32 @merge_sort_(i32 %14, i32 %1, i32* %2, i32* %3)
%16 = tail call i32 @merge(i32 %0, i32 %12, i32 %1, i32* %2)
br label %6
}