#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 _merge_sort(int *array, int *aux, int low, int high) {
  if (low >= high)
    return;
  int mid = low + (high - low) / 2;
  _merge_sort(array, aux, low, mid);
  _merge_sort(array, aux, mid + 1, high);
  _merge(array, aux, low, mid, high);
}


x86 assembly (clang, -O0):
<_merge_sort>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jl     1147 <_merge_sort+0x27>
jmp    11a5 <_merge_sort+0x85>
mov    -0x14(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%eax
sub    -0x14(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x1c(%rbp),%ecx
call   1040 <_merge_sort@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x1c(%rbp),%edx
add    $0x1,%edx
mov    -0x18(%rbp),%ecx
call   1040 <_merge_sort@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x1c(%rbp),%ecx
mov    -0x18(%rbp),%r8d
call   1030 <_merge@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_merge_sort>:
mov    %ecx,%eax
sub    %edx,%eax
jle    1186 <_merge_sort+0x66>
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %ecx,%r13d
mov    %edx,%ebx
mov    %rsi,%r14
mov    %rdi,%r15
mov    %eax,%ebp
shr    $0x1f,%ebp
add    %eax,%ebp
sar    %ebp
lea    (%rbx,%rbp,1),%r12d
mov    %r12d,%ecx
call   1040 <_merge_sort@plt>
lea    (%rbx,%rbp,1),%edx
add    $0x1,%edx
mov    %r15,%rdi
mov    %r14,%rsi
mov    %r13d,%ecx
call   1040 <_merge_sort@plt>
mov    %r15,%rdi
mov    %r14,%rsi
mov    %ebx,%edx
mov    %r12d,%ecx
mov    %r13d,%r8d
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <_merge@plt>
ret

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

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