#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 sort(int arr[], int low1, int high1) {
  int mid = (low1 + high1) / 2;
  if (low1 == high1)
    return;
  else {
    sort(arr, low1, mid);
    sort(arr, mid + 1, high1);
    merge(arr, low1, mid, mid + 1, high1);
  }
}


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

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

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

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