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

/* Variables and functions */
struct node *delete (struct node *, int);
struct node *insert(struct node *, int);
int /*<<< orphan*/ printf(char *, ...);
int search(struct node *, int);
int main() {
  struct node *root = NULL;
  root = insert(root, 10);
  insert(root, 1);
  insert(root, 20);
  printf("insert done\n");
  printf("find 10: %d\n", search(root, 10));
  printf("find 3: %d\n", search(root, 3));
  printf("find 1: %d\n", search(root, 1));
  printf("find 20: %d\n", search(root, 20));
  root = delete (root, 1);
  printf("delete done\n");
  printf("find 10: %d\n", search(root, 10));
  printf("find 3: %d\n", search(root, 3));
  printf("find 1: %d\n", search(root, 1));
  printf("find 20: %d\n", search(root, 20));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0xa,%esi
call   1050 <insert@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x1,%esi
call   1050 <insert@plt>
mov    -0x10(%rbp),%rdi
mov    $0x14,%esi
call   1050 <insert@plt>
lea    0xe74(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    $0xa,%esi
call   1040 <search@plt>
mov    %eax,%esi
lea    0xe63(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    $0x3,%esi
call   1040 <search@plt>
mov    %eax,%esi
lea    0xe52(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    $0x1,%esi
call   1040 <search@plt>
mov    %eax,%esi
lea    0xe40(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    $0x14,%esi
call   1040 <search@plt>
mov    %eax,%esi
lea    0xe2e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    $0x1,%esi
call   1060 <delete@plt>
mov    %rax,-0x10(%rbp)
lea    0xe1b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    $0xa,%esi
call   1040 <search@plt>
mov    %eax,%esi
lea    0xdcb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    $0x3,%esi
call   1040 <search@plt>
mov    %eax,%esi
lea    0xdba(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    $0x1,%esi
call   1040 <search@plt>
mov    %eax,%esi
lea    0xda8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    $0x14,%esi
call   1040 <search@plt>
mov    %eax,%esi
lea    0xd96(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
xor    %edi,%edi
mov    $0xa,%esi
call   1060 <insert@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    $0x1,%esi
call   1060 <insert@plt>
mov    %rbx,%rdi
mov    $0x14,%esi
call   1060 <insert@plt>
lea    0xea9(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    $0xa,%esi
call   1050 <search@plt>
lea    0xe5e(%rip),%r14
mov    %r14,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
call   1050 <search@plt>
lea    0xe4b(%rip),%r15
mov    %r15,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
call   1050 <search@plt>
lea    0xe37(%rip),%r12
mov    %r12,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x14,%esi
call   1050 <search@plt>
lea    0xe23(%rip),%r13
mov    %r13,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
call   1070 <delete@plt>
mov    %rax,%rbx
lea    0xe19(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    $0xa,%esi
call   1050 <search@plt>
mov    %r14,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
call   1050 <search@plt>
mov    %r15,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
call   1050 <search@plt>
mov    %r12,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x14,%esi
call   1050 <search@plt>
mov    %r13,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.node = type { i32 }
@.str = [13 x i8] c"insert done\0A\00"
@.str.1 = [13 x i8] c"find 10: %d\0A\00"
@.str.2 = [12 x i8] c"find 3: %d\0A\00"
@.str.3 = [12 x i8] c"find 1: %d\0A\00"
@.str.4 = [13 x i8] c"find 20: %d\0A\00"
@.str.5 = [13 x i8] c"delete done\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.node*
store i32 0, i32* %1
store %struct.node* null, %struct.node** %2
%3 = load %struct.node*, %struct.node** %2
%4 = call %struct.node* @insert(%struct.node* %3, i32 10)
store %struct.node* %4, %struct.node** %2
%5 = load %struct.node*, %struct.node** %2
%6 = call %struct.node* @insert(%struct.node* %5, i32 1)
%7 = load %struct.node*, %struct.node** %2
%8 = call %struct.node* @insert(%struct.node* %7, i32 20)
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%10 = load %struct.node*, %struct.node** %2
%11 = call i32 @search(%struct.node* %10, i32 10)
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %11)
%13 = load %struct.node*, %struct.node** %2
%14 = call i32 @search(%struct.node* %13, i32 3)
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 %14)
%16 = load %struct.node*, %struct.node** %2
%17 = call i32 @search(%struct.node* %16, i32 1)
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 %17)
%19 = load %struct.node*, %struct.node** %2
%20 = call i32 @search(%struct.node* %19, i32 20)
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i32 %20)
%22 = load %struct.node*, %struct.node** %2
%23 = call %struct.node* @delete(%struct.node* %22, i32 1)
store %struct.node* %23, %struct.node** %2
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
%25 = load %struct.node*, %struct.node** %2
%26 = call i32 @search(%struct.node* %25, i32 10)
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %26)
%28 = load %struct.node*, %struct.node** %2
%29 = call i32 @search(%struct.node* %28, i32 3)
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 %29)
%31 = load %struct.node*, %struct.node** %2
%32 = call i32 @search(%struct.node* %31, i32 1)
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 %32)
%34 = load %struct.node*, %struct.node** %2
%35 = call i32 @search(%struct.node* %34, i32 20)
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i32 %35)
ret i32 0
}

LLVM IR (-O2):
%struct.node = type { i32 }
@.str.1 = [13 x i8] c"find 10: %d\0A\00"
@.str.2 = [12 x i8] c"find 3: %d\0A\00"
@.str.3 = [12 x i8] c"find 1: %d\0A\00"
@.str.4 = [13 x i8] c"find 20: %d\0A\00"
@str = [12 x i8] c"insert done\00"
@str.6 = [12 x i8] c"delete done\00"
define i32 @main() {
%1 = tail call %struct.node* @insert(%struct.node* null, i32 10)
%2 = tail call %struct.node* @insert(%struct.node* %1, i32 1)
%3 = tail call %struct.node* @insert(%struct.node* %1, i32 20)
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str, i64 0, i64 0))
%5 = tail call i32 @search(%struct.node* %1, i32 10)
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %5)
%7 = tail call i32 @search(%struct.node* %1, i32 3)
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 %7)
%9 = tail call i32 @search(%struct.node* %1, i32 1)
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 %9)
%11 = tail call i32 @search(%struct.node* %1, i32 20)
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i32 %11)
%13 = tail call %struct.node* @delete(%struct.node* %1, i32 1)
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.6, i64 0, i64 0))
%15 = tail call i32 @search(%struct.node* %13, i32 10)
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %15)
%17 = tail call i32 @search(%struct.node* %13, i32 3)
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 %17)
%19 = tail call i32 @search(%struct.node* %13, i32 1)
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 %19)
%21 = tail call i32 @search(%struct.node* %13, i32 20)
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i32 %21)
ret i32 0
}