#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 */
struct bplus {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ abort();
int merge_internal(struct bplus *, int, int);
int merge_leaf(struct bplus *, int, int);
int merge(struct bplus *tree, int leftid, int rightid) {
  if (leftid > 0 && rightid > 0)
    return merge_internal(tree, leftid, rightid);
  else if (leftid < 0 && rightid < 0)
    return merge_leaf(tree, leftid, rightid);
  else
    abort();
}


x86 assembly (clang, -O0):
<merge>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
cmpl   $0x0,-0x14(%rbp)
jle    116d <merge+0x3d>
cmpl   $0x0,-0x18(%rbp)
jle    116d <merge+0x3d>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
call   1050 <merge_internal@plt>
mov    %eax,-0x4(%rbp)
jmp    119f <merge+0x6f>
cmpl   $0x0,-0x14(%rbp)
jge    1198 <merge+0x68>
cmpl   $0x0,-0x18(%rbp)
jge    1198 <merge+0x68>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
call   1040 <merge_leaf@plt>
mov    %eax,-0x4(%rbp)
jmp    119f <merge+0x6f>
mov    $0x0,%al
call   1030 <abort@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<merge>:
test   %esi,%esi
jle    113d <merge+0xd>
test   %edx,%edx
jle    113d <merge+0xd>
jmp    1050 <merge_internal@plt>
test   %esi,%edx
jns    1146 <merge+0x16>
jmp    1040 <merge_leaf@plt>
push   %rax
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
%struct.bplus = type { i32 }
define i32 @merge(%struct.bplus* %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca %struct.bplus*
%6 = alloca i32
%7 = alloca i32
store %struct.bplus* %0, %struct.bplus** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
%8 = load i32, i32* %6
%9 = icmp sgt i32 %8, 0
br i1 %9, label %10, label %18
10: ; preds = %3
%11 = load i32, i32* %7
%12 = icmp sgt i32 %11, 0
br i1 %12, label %13, label %18
13: ; preds = %10
%14 = load %struct.bplus*, %struct.bplus** %5
%15 = load i32, i32* %6
%16 = load i32, i32* %7
%17 = call i32 @merge_internal(%struct.bplus* %14, i32 %15, i32 %16)
store i32 %17, i32* %4
br label %31
18: ; preds = %10, %3
%19 = load i32, i32* %6
%20 = icmp slt i32 %19, 0
br i1 %20, label %21, label %29
21: ; preds = %18
%22 = load i32, i32* %7
%23 = icmp slt i32 %22, 0
br i1 %23, label %24, label %29
24: ; preds = %21
%25 = load %struct.bplus*, %struct.bplus** %5
%26 = load i32, i32* %6
%27 = load i32, i32* %7
%28 = call i32 @merge_leaf(%struct.bplus* %25, i32 %26, i32 %27)
store i32 %28, i32* %4
br label %31
29: ; preds = %21, %18
%30 = call i32 (...) @abort()
unreachable
31: ; preds = %24, %13
%32 = load i32, i32* %4
ret i32 %32
}

LLVM IR (-O2):
%struct.bplus = type { i32 }
define i32 @merge(%struct.bplus* %0, i32 %1, i32 %2) {
%4 = icmp sgt i32 %1, 0
%5 = icmp sgt i32 %2, 0
%6 = and i1 %4, %5
br i1 %6, label %7, label %9
7: ; preds = %3
%8 = tail call i32 @merge_internal(%struct.bplus* %0, i32 %1, i32 %2)
br label %16
9: ; preds = %3
%10 = and i32 %2, %1
%11 = icmp slt i32 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %9
%13 = tail call i32 @merge_leaf(%struct.bplus* %0, i32 %1, i32 %2)
br label %16
14: ; preds = %9
%15 = tail call i32 (...) @abort()
unreachable
16: ; preds = %12, %7
%17 = phi i32 [ %8, %7 ], [ %13, %12 ]
ret i32 %17
}