#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 /*<<< orphan*/ assert(int /*<<< orphan*/);
int insert_internal(struct bplus *, int, void *);
int insert_leaf(struct bplus *, int, void *);
int insert(struct bplus *tree, int nodeid, void *value) {
  assert(value != NULL);
  if (nodeid < 0)
    return insert_leaf(tree, nodeid, value);
  else if (nodeid > 0)
    return insert_internal(tree, nodeid, value);
  else
    abort();
}


x86 assembly (clang, -O0):
<insert>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
cmpl   $0x0,-0x14(%rbp)
jge    1187 <insert+0x47>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x20(%rbp),%rdx
call   1040 <insert_leaf@plt>
mov    %eax,-0x4(%rbp)
jmp    11b0 <insert+0x70>
cmpl   $0x0,-0x14(%rbp)
jle    11a9 <insert+0x69>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x20(%rbp),%rdx
call   1060 <insert_internal@plt>
mov    %eax,-0x4(%rbp)
jmp    11b0 <insert+0x70>
mov    $0x0,%al
call   1030 <abort@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<insert>:
push   %rbp
push   %r14
push   %rbx
mov    %rdx,%rbx
mov    %esi,%ebp
mov    %rdi,%r14
xor    %edi,%edi
test   %rdx,%rdx
setne  %dil
call   1050 <assert@plt>
test   %ebp,%ebp
js     1171 <insert+0x31>
je     1182 <insert+0x42>
mov    %r14,%rdi
mov    %ebp,%esi
mov    %rbx,%rdx
pop    %rbx
pop    %r14
pop    %rbp
jmp    1060 <insert_internal@plt>
mov    %r14,%rdi
mov    %ebp,%esi
mov    %rbx,%rdx
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <insert_leaf@plt>
xor    %eax,%eax
call   1030 <abort@plt>

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

LLVM IR (-O2):
%struct.bplus = type { i32 }
define i32 @insert(%struct.bplus* %0, i32 %1, i8* %2) {
%4 = icmp ne i8* %2, null
%5 = zext i1 %4 to i32
%6 = tail call i32 @assert(i32 %5)
%7 = icmp slt i32 %1, 0
br i1 %7, label %8, label %10
8: ; preds = %3
%9 = tail call i32 @insert_leaf(%struct.bplus* %0, i32 %1, i8* %2)
br label %16
10: ; preds = %3
%11 = icmp eq i32 %1, 0
br i1 %11, label %14, label %12
12: ; preds = %10
%13 = tail call i32 @insert_internal(%struct.bplus* %0, i32 %1, i8* %2)
br label %16
14: ; preds = %10
%15 = tail call i32 (...) @abort()
unreachable
16: ; preds = %12, %8
%17 = phi i32 [ %9, %8 ], [ %13, %12 ]
ret i32 %17
}