#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 *merge(int *, unsigned int, unsigned int);
int *mrgcore(int *a, unsigned left, unsigned right) {
  unsigned mid;
  if (left >= right)
    return a;
  mid = left + (right - left) / 2;
  mrgcore(a, left, mid);
  mrgcore(a, mid + 1, right);
  return merge(a, left, right);
}


x86 assembly (clang, -O0):
<mrgcore>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jb     114b <mrgcore+0x2b>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1190 <mrgcore+0x70>
mov    -0x14(%rbp),%eax
mov    -0x18(%rbp),%ecx
sub    -0x14(%rbp),%ecx
shr    $0x1,%ecx
add    %ecx,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x1c(%rbp),%edx
call   1040 <mrgcore@plt>
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%esi
add    $0x1,%esi
mov    -0x18(%rbp),%edx
call   1040 <mrgcore@plt>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
call   1030 <merge@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mrgcore>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r15
mov    %edx,%ebp
sub    %esi,%ebp
jbe    116a <mrgcore+0x4a>
mov    %edx,%r14d
mov    %esi,%ebx
shr    %ebp
lea    (%rbx,%rbp,1),%edx
mov    %r15,%rdi
call   1040 <mrgcore@plt>
lea    (%rbx,%rbp,1),%esi
add    $0x1,%esi
mov    %r15,%rdi
mov    %r14d,%edx
call   1040 <mrgcore@plt>
mov    %r15,%rdi
mov    %ebx,%esi
mov    %r14d,%edx
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <merge@plt>
mov    %r15,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i32* @mrgcore(i32* %0, i32 %1, i32 %2) {
%4 = icmp ugt i32 %2, %1
br i1 %4, label %7, label %5
5: ; preds = %3, %7
%6 = phi i32* [ %14, %7 ], [ %0, %3 ]
ret i32* %6
7: ; preds = %3
%8 = sub i32 %2, %1
%9 = lshr i32 %8, 1
%10 = add i32 %9, %1
%11 = tail call i32* @mrgcore(i32* %0, i32 %1, i32 %10)
%12 = add i32 %10, 1
%13 = tail call i32* @mrgcore(i32* %0, i32 %12, i32 %2)
%14 = tail call i32* @merge(i32* %0, i32 %1, i32 %2)
br label %5
}