#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*/ merge1(int *, int, int, int);
void merge(int ARR[], int l, int m, int n) {
  if (n < 2)
    return;
  else {
    int mid = l + (m - l) / 2;
    merge(ARR, l, mid, (mid - l) + 1);
    merge(ARR, mid + 1, m, (m - (mid + 1)) + 1);
    merge1(ARR, l, m, mid);
  }
}


x86 assembly (clang, -O0):
<merge>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
cmpl   $0x2,-0x14(%rbp)
jge    1144 <merge+0x24>
jmp    11ac <merge+0x8c>
mov    -0xc(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%eax
sub    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x18(%rbp),%ecx
sub    -0xc(%rbp),%ecx
add    $0x1,%ecx
call   1040 <merge@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%esi
add    $0x1,%esi
mov    -0x10(%rbp),%edx
mov    -0x10(%rbp),%ecx
mov    -0x18(%rbp),%eax
add    $0x1,%eax
sub    %eax,%ecx
add    $0x1,%ecx
call   1040 <merge@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x18(%rbp),%ecx
call   1030 <merge1@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<merge>:
cmp    $0x1,%ecx
jg     1126 <merge+0x6>
ret
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edx,%r12d
mov    %esi,%ebx
mov    %rdi,%r14
mov    %edx,%eax
sub    %esi,%eax
mov    %eax,%ebp
shr    $0x1f,%ebp
add    %eax,%ebp
sar    %ebp
lea    (%rbx,%rbp,1),%r15d
lea    0x1(%rbp),%ecx
mov    %r15d,%edx
call   1040 <merge@plt>
lea    (%rbx,%rbp,1),%esi
add    $0x1,%esi
mov    %r12d,%ecx
sub    %r15d,%ecx
mov    %r14,%rdi
mov    %r12d,%edx
call   1040 <merge@plt>
mov    %r14,%rdi
mov    %ebx,%esi
mov    %r12d,%edx
mov    %r15d,%ecx
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <merge1@plt>

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

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