#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 *tmp, int len) {
  if (len <= 1)
    return;
  int mid = len / 2;
  sort(tmp, arr, mid);
  sort(tmp + mid, arr + mid, len - mid);
  merge(tmp, mid, tmp + mid, len - mid, arr);
}


x86 assembly (clang, -O0):
<sort>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
cmpl   $0x1,-0x14(%rbp)
jg     1142 <sort+0x22>
jmp    11ae <sort+0x8e>
mov    -0x14(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x18(%rbp),%edx
call   1030 <sort@plt>
mov    -0x10(%rbp),%rdi
movslq -0x18(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdi
mov    -0x8(%rbp),%rsi
movslq -0x18(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
mov    -0x14(%rbp),%edx
sub    -0x18(%rbp),%edx
call   1030 <sort@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%esi
mov    -0x10(%rbp),%rdx
movslq -0x18(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdx
mov    -0x14(%rbp),%ecx
sub    -0x18(%rbp),%ecx
mov    -0x8(%rbp),%r8
call   1040 <merge@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sort>:
cmp    $0x1,%edx
jg     1126 <sort+0x6>
ret
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edx,%ebp
mov    %rsi,%r15
mov    %rdi,%r14
mov    %edx,%ebx
shr    %ebx
mov    %rsi,%rdi
mov    %r14,%rsi
mov    %ebx,%edx
call   1030 <sort@plt>
lea    (%r15,%rbx,4),%r12
lea    (%r14,%rbx,4),%rsi
sub    %ebx,%ebp
mov    %r12,%rdi
mov    %ebp,%edx
call   1030 <sort@plt>
mov    %r15,%rdi
mov    %ebx,%esi
mov    %r12,%rdx
mov    %ebp,%ecx
mov    %r14,%r8
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* %6
%9 = icmp sle i32 %8, 1
br i1 %9, label %10, label %11
10: ; preds = %3
br label %39
11: ; preds = %3
%12 = load i32, i32* %6
%13 = sdiv i32 %12, 2
store i32 %13, i32* %7
%14 = load i32*, i32** %5
%15 = load i32*, i32** %4
%16 = load i32, i32* %7
%17 = load i32*, i32** %5
%18 = load i32, i32* %7
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i32, i32* %17, i64 %19
%21 = load i32*, i32** %4
%22 = load i32, i32* %7
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i32, i32* %21, i64 %23
%25 = load i32, i32* %6
%26 = load i32, i32* %7
%27 = sub nsw i32 %25, %26
%28 = load i32*, i32** %5
%29 = load i32, i32* %7
%30 = load i32*, i32** %5
%31 = load i32, i32* %7
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i32, i32* %30, i64 %32
%34 = load i32, i32* %6
%35 = load i32, i32* %7
%36 = sub nsw i32 %34, %35
%37 = load i32*, i32** %4
%38 = call i32 @merge(i32* %28, i32 %29, i32* %33, i32 %36, i32* %37)
br label %39
39: ; preds = %11, %10
ret void
}

LLVM IR (-O2):
define void @sort(i32* %0, i32* %1, i32 %2) {
%4 = icmp slt i32 %2, 2
br i1 %4, label %5, label %6
5: ; preds = %3, %6
ret void
6: ; preds = %3
%7 = lshr i32 %2, 1
tail call void @sort(i32* %1, i32* %0, i32 %7)
%8 = zext i32 %7 to i64
%9 = getelementptr inbounds i32, i32* %1, i64 %8
%10 = getelementptr inbounds i32, i32* %0, i64 %8
%11 = sub nsw i32 %2, %7
tail call void @sort(i32* %9, i32* %10, i32 %11)
%12 = tail call i32 @merge(i32* %1, i32 %7, i32* %9, i32 %11, i32* %0)
br label %5
}