#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 */
typedef int /*<<< orphan*/ uint32_t;

/* Variables and functions */
int /*<<< orphan*/ merge(int /*<<< orphan*/ *, int, int /*<<< orphan*/ *, int,
                         int /*<<< orphan*/ *);
void recur(uint32_t *buf, uint32_t *tmp, int len) {
  int l = len / 2;
  if (len <= 1)
    return;
  recur(tmp, buf, l);
  recur(tmp + l, buf + l, len - l);
  merge(tmp, l, tmp + l, len - l, buf);
}


x86 assembly (clang, -O0):
<recur>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x18(%rbp)
cmpl   $0x1,-0x14(%rbp)
jg     1150 <recur+0x30>
jmp    11ae <recur+0x8e>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x18(%rbp),%edx
call   1030 <recur@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 <recur@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):
<recur>:
cmp    $0x1,%edx
jg     1126 <recur+0x6>
ret
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edx,%ebx
mov    %rsi,%r15
mov    %rdi,%r14
mov    %edx,%ebp
shr    $0x1f,%ebp
add    %edx,%ebp
sar    %ebp
mov    %rsi,%rdi
mov    %r14,%rsi
mov    %ebp,%edx
call   1030 <recur@plt>
movslq %ebp,%rbp
lea    (%r15,%rbp,4),%r12
lea    (%r14,%rbp,4),%rsi
sub    %ebp,%ebx
mov    %r12,%rdi
mov    %ebx,%edx
call   1030 <recur@plt>
mov    %r15,%rdi
mov    %ebp,%esi
mov    %r12,%rdx
mov    %ebx,%ecx
mov    %r14,%r8
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <merge@plt>

LLVM IR (-O0):
define void @recur(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 = sdiv i32 %8, 2
store i32 %9, i32* %7
%10 = load i32, i32* %6
%11 = icmp sle i32 %10, 1
br i1 %11, label %12, label %13
12: ; preds = %3
br label %39
13: ; preds = %3
%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 = %13, %12
ret void
}

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