#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 inode {
  int dummy;
};

/* Variables and functions */
struct inode *new_inode(int);
struct inode **rsearch(int, struct inode **);
int insert(int data, struct inode *root) {
  struct inode **res = rsearch(data, &root);
  if (*res != NULL)
    return 0;
  *res = new_inode(data);
  if (*res == NULL)
    return 0;
  return 1;
}


x86 assembly (clang, -O0):
<insert>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%edi
lea    -0x10(%rbp),%rsi
call   1030 <rsearch@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmpq   $0x0,(%rax)
je     1159 <insert+0x39>
movl   $0x0,-0x4(%rbp)
jmp    118c <insert+0x6c>
mov    -0x8(%rbp),%edi
call   1040 <new_inode@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
cmpq   $0x0,(%rax)
jne    1185 <insert+0x65>
movl   $0x0,-0x4(%rbp)
jmp    118c <insert+0x6c>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<insert>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebp
mov    %rsi,(%rsp)
mov    %rsp,%rsi
call   1030 <rsearch@plt>
mov    %rax,%rbx
xor    %eax,%eax
cmpq   $0x0,(%rbx)
jne    1151 <insert+0x31>
mov    %ebp,%edi
call   1040 <new_inode@plt>
mov    %rax,%rcx
mov    %rax,(%rbx)
xor    %eax,%eax
test   %rcx,%rcx
setne  %al
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.inode = type { i32 }
define i32 @insert(i32 %0, %struct.inode* %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca %struct.inode*
%6 = alloca %struct.inode**
store i32 %0, i32* %4
store %struct.inode* %1, %struct.inode** %5
%7 = load i32, i32* %4
%8 = call %struct.inode** @rsearch(i32 %7, %struct.inode** %5)
store %struct.inode** %8, %struct.inode*** %6
%9 = load %struct.inode**, %struct.inode*** %6
%10 = load %struct.inode*, %struct.inode** %9
%11 = icmp ne %struct.inode* %10, null
br i1 %11, label %12, label %13
12: ; preds = %2
store i32 0, i32* %3
br label %22
13: ; preds = %2
%14 = load i32, i32* %4
%15 = call %struct.inode* @new_inode(i32 %14)
%16 = load %struct.inode**, %struct.inode*** %6
store %struct.inode* %15, %struct.inode** %16
%17 = load %struct.inode**, %struct.inode*** %6
%18 = load %struct.inode*, %struct.inode** %17
%19 = icmp eq %struct.inode* %18, null
br i1 %19, label %20, label %21
20: ; preds = %13
store i32 0, i32* %3
br label %22
21: ; preds = %13
store i32 1, i32* %3
br label %22
22: ; preds = %21, %20, %12
%23 = load i32, i32* %3
ret i32 %23
}

LLVM IR (-O2):
%struct.inode = type { i32 }
define i32 @insert(i32 %0, %struct.inode* %1) {
%3 = alloca %struct.inode*
store %struct.inode* %1, %struct.inode** %3
%4 = call %struct.inode** @rsearch(i32 %0, %struct.inode** %3)
%5 = load %struct.inode*, %struct.inode** %4
%6 = icmp eq %struct.inode* %5, null
br i1 %6, label %7, label %11
7: ; preds = %2
%8 = call %struct.inode* @new_inode(i32 %0)
store %struct.inode* %8, %struct.inode** %4
%9 = icmp ne %struct.inode* %8, null
%10 = zext i1 %9 to i32
br label %11
11: ; preds = %7, %2
%12 = phi i32 [ 0, %2 ], [ %10, %7 ]
ret i32 %12
}