#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 int32_t;

/* Variables and functions */
int delete (char *, int);
int /*<<< orphan*/ exit(int);
int insert(char *, int, int);
int /*<<< orphan*/ print();
int /*<<< orphan*/ printf(char *, ...);
int search(char *, int, int *);
int self_tests() {
  int rv;
  int32_t ip = 0;
  rv = insert("abc", 3, 4);
  if (!rv)
    do {
      print();
      printf("Failed to insert key abc\n");
      exit(1);
    } while (0);
  rv = delete ("abc", 3);
  if (!rv)
    do {
      print();
      printf("Failed to delete key abc\n");
      exit(1);
    } while (0);
  rv = insert("google", 6, 5);
  if (!rv)
    do {
      print();
      printf("Failed to insert key google\n");
      exit(1);
    } while (0);
  rv = insert("goggle", 6, 4);
  if (!rv)
    do {
      print();
      printf("Failed to insert key goggle\n");
      exit(1);
    } while (0);
  rv = delete ("goggle", 6);
  if (!rv)
    do {
      print();
      printf("Failed to delete key goggle\n");
      exit(1);
    } while (0);
  rv = delete ("google", 6);
  if (!rv)
    do {
      print();
      printf("Failed to delete key google\n");
      exit(1);
    } while (0);
  rv = insert("ab", 2, 2);
  if (!rv)
    do {
      print();
      printf("Failed to insert key ab\n");
      exit(1);
    } while (0);
  rv = insert("bb", 2, 2);
  if (!rv)
    do {
      print();
      printf("Failed to insert key bb\n");
      exit(1);
    } while (0);
  print();
  printf("So far so good\n\n");
  rv = search("ab", 2, &ip);
  printf("Rv is %d\n", rv);
  if (!rv)
    do {
      print();
      printf("Failed to find key ab\n");
      exit(1);
    } while (0);
  if (ip != 2)
    do {
      print();
      printf("Found bad IP for key ab\n");
      exit(1);
    } while (0);
  rv = search("aa", 2, NULL);
  if (rv)
    do {
      print();
      printf("Found bogus key aa\n");
      exit(1);
    } while (0);
  ip = 0;
  rv = search("bb", 2, &ip);
  if (!rv)
    do {
      print();
      printf("Failed to find key bb\n");
      exit(1);
    } while (0);
  if (ip != 2)
    do {
      print();
      printf("Found bad IP for key bb\n");
      exit(1);
    } while (0);
  ip = 0;
  rv = delete ("cb", 2);
  if (rv)
    do {
      print();
      printf("deleted bogus key cb\n");
      exit(1);
    } while (0);
  rv = delete ("bb", 2);
  if (!rv)
    do {
      print();
      printf("Failed to delete real key bb\n");
      exit(1);
    } while (0);
  rv = search("ab", 2, &ip);
  if (!rv)
    do {
      print();
      printf("Failed to find key ab\n");
      exit(1);
    } while (0);
  if (ip != 2)
    do {
      print();
      printf("Found bad IP for key ab\n");
      exit(1);
    } while (0);
  ip = 0;
  rv = delete ("ab", 2);
  if (!rv)
    do {
      print();
      printf("Failed to delete real key ab\n");
      exit(1);
    } while (0);
  printf("End of self-tests, tree is:\n");
  print();
  return 0;
}


x86 assembly (clang, -O0):
<self_tests>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x8(%rbp)
lea    0xe8a(%rip),%rdi
mov    $0x3,%esi
mov    $0x4,%edx
call   1060 <insert@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    11b6 <self_tests+0x56>
jmp    1197 <self_tests+0x37>
mov    $0x0,%al
call   1050 <print@plt>
lea    0xe5f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
lea    0xe43(%rip),%rdi
mov    $0x3,%esi
call   1070 <delete@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    11f8 <self_tests+0x98>
jmp    11d9 <self_tests+0x79>
mov    $0x0,%al
call   1050 <print@plt>
lea    0xe37(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
lea    0xe39(%rip),%rdi
mov    $0x6,%esi
mov    $0x5,%edx
call   1060 <insert@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    123f <self_tests+0xdf>
jmp    1220 <self_tests+0xc0>
mov    $0x0,%al
call   1050 <print@plt>
lea    0xe11(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
lea    0xe16(%rip),%rdi
mov    $0x6,%esi
mov    $0x4,%edx
call   1060 <insert@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    1286 <self_tests+0x126>
jmp    1267 <self_tests+0x107>
mov    $0x0,%al
call   1050 <print@plt>
lea    0xdee(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
lea    0xdcf(%rip),%rdi
mov    $0x6,%esi
call   1070 <delete@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    12c8 <self_tests+0x168>
jmp    12a9 <self_tests+0x149>
mov    $0x0,%al
call   1050 <print@plt>
lea    0xdc9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
lea    0xd69(%rip),%rdi
mov    $0x6,%esi
call   1070 <delete@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    130a <self_tests+0x1aa>
jmp    12eb <self_tests+0x18b>
mov    $0x0,%al
call   1050 <print@plt>
lea    0xda4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
lea    0xda9(%rip),%rdi
mov    $0x2,%edx
mov    %edx,%esi
call   1060 <insert@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    134e <self_tests+0x1ee>
jmp    132f <self_tests+0x1cf>
mov    $0x0,%al
call   1050 <print@plt>
lea    0xd80(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
lea    0xd81(%rip),%rdi
mov    $0x2,%edx
mov    %edx,%esi
call   1060 <insert@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    1392 <self_tests+0x232>
jmp    1373 <self_tests+0x213>
mov    $0x0,%al
call   1050 <print@plt>
lea    0xd58(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    $0x0,%al
call   1050 <print@plt>
lea    0xd52(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xd0c(%rip),%rdi
mov    $0x2,%esi
lea    -0x8(%rbp),%rdx
call   1040 <search@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%esi
lea    0xd3a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x0,-0x4(%rbp)
jne    13fe <self_tests+0x29e>
jmp    13df <self_tests+0x27f>
mov    $0x0,%al
call   1050 <print@plt>
lea    0xd20(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
cmpl   $0x2,-0x8(%rbp)
je     142c <self_tests+0x2cc>
jmp    140d <self_tests+0x2ad>
mov    $0x0,%al
call   1050 <print@plt>
lea    0xd09(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
lea    0xd0a(%rip),%rdi
mov    $0x2,%esi
xor    %eax,%eax
mov    %eax,%edx
call   1040 <search@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
je     1472 <self_tests+0x312>
jmp    1453 <self_tests+0x2f3>
mov    $0x0,%al
call   1050 <print@plt>
lea    0xcdf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
movl   $0x0,-0x8(%rbp)
lea    0xc56(%rip),%rdi
mov    $0x2,%esi
lea    -0x8(%rbp),%rdx
call   1040 <search@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    14bf <self_tests+0x35f>
jmp    14a0 <self_tests+0x340>
mov    $0x0,%al
call   1050 <print@plt>
lea    0xca6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
cmpl   $0x2,-0x8(%rbp)
je     14ed <self_tests+0x38d>
jmp    14ce <self_tests+0x36e>
mov    $0x0,%al
call   1050 <print@plt>
lea    0xc8f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
movl   $0x0,-0x8(%rbp)
lea    0xc89(%rip),%rdi
mov    $0x2,%esi
call   1070 <delete@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
je     1536 <self_tests+0x3d6>
jmp    1517 <self_tests+0x3b7>
mov    $0x0,%al
call   1050 <print@plt>
lea    0xc62(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
lea    0xb99(%rip),%rdi
mov    $0x2,%esi
call   1070 <delete@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    1578 <self_tests+0x418>
jmp    1559 <self_tests+0x3f9>
mov    $0x0,%al
call   1050 <print@plt>
lea    0xc36(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
lea    0xb3b(%rip),%rdi
mov    $0x2,%esi
lea    -0x8(%rbp),%rdx
call   1040 <search@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    15be <self_tests+0x45e>
jmp    159f <self_tests+0x43f>
mov    $0x0,%al
call   1050 <print@plt>
lea    0xb60(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
cmpl   $0x2,-0x8(%rbp)
je     15ec <self_tests+0x48c>
jmp    15cd <self_tests+0x46d>
mov    $0x0,%al
call   1050 <print@plt>
lea    0xb49(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
movl   $0x0,-0x8(%rbp)
lea    0xac0(%rip),%rdi
mov    $0x2,%esi
call   1070 <delete@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    1635 <self_tests+0x4d5>
jmp    1616 <self_tests+0x4b6>
mov    $0x0,%al
call   1050 <print@plt>
lea    0xb97(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
lea    0xb9d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1050 <print@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<self_tests>:
push   %rbx
sub    $0x10,%rsp
movl   $0x0,0xc(%rsp)
lea    0xeb4(%rip),%rdi
mov    $0x3,%esi
mov    $0x4,%edx
call   1070 <insert@plt>
test   %eax,%eax
je     13b7 <self_tests+0x247>
lea    0xe96(%rip),%rdi
mov    $0x3,%esi
call   1080 <delete@plt>
test   %eax,%eax
je     13ca <self_tests+0x25a>
lea    0xeea(%rip),%rdi
mov    $0x6,%esi
mov    $0x5,%edx
call   1070 <insert@plt>
test   %eax,%eax
je     13dd <self_tests+0x26d>
lea    0xeb0(%rip),%rdi
mov    $0x6,%esi
mov    $0x4,%edx
call   1070 <insert@plt>
test   %eax,%eax
je     13f0 <self_tests+0x280>
lea    0xe92(%rip),%rdi
mov    $0x6,%esi
call   1080 <delete@plt>
test   %eax,%eax
je     1403 <self_tests+0x293>
lea    0xe95(%rip),%rdi
mov    $0x6,%esi
call   1080 <delete@plt>
test   %eax,%eax
je     1416 <self_tests+0x2a6>
lea    0xf09(%rip),%rdi
mov    $0x2,%esi
mov    $0x2,%edx
call   1070 <insert@plt>
test   %eax,%eax
je     1426 <self_tests+0x2b6>
lea    0xeb8(%rip),%rdi
mov    $0x2,%esi
mov    $0x2,%edx
call   1070 <insert@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1060 <print@plt>
test   %ebx,%ebx
je     1436 <self_tests+0x2c6>
lea    0xe6e(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb8(%rip),%rdi
lea    0xc(%rsp),%rdx
mov    $0x2,%esi
call   1050 <search@plt>
mov    %eax,%ebx
lea    0xd6e(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
test   %ebx,%ebx
je     1391 <self_tests+0x221>
cmpl   $0x2,0xc(%rsp)
jne    13a4 <self_tests+0x234>
lea    0xef6(%rip),%rdi
mov    $0x2,%esi
xor    %edx,%edx
call   1050 <search@plt>
test   %eax,%eax
jne    143f <self_tests+0x2cf>
movl   $0x0,0xc(%rsp)
lea    0xe27(%rip),%rdi
lea    0xc(%rsp),%rdx
mov    $0x2,%esi
call   1050 <search@plt>
test   %eax,%eax
je     144f <self_tests+0x2df>
cmpl   $0x2,0xc(%rsp)
jne    145f <self_tests+0x2ef>
movl   $0x0,0xc(%rsp)
lea    0xe77(%rip),%rdi
mov    $0x2,%esi
call   1080 <delete@plt>
test   %eax,%eax
jne    146f <self_tests+0x2ff>
lea    0xddd(%rip),%rdi
mov    $0x2,%esi
call   1080 <delete@plt>
test   %eax,%eax
je     147f <self_tests+0x30f>
lea    0xdf7(%rip),%rdi
lea    0xc(%rsp),%rdx
mov    $0x2,%esi
call   1050 <search@plt>
test   %eax,%eax
je     1391 <self_tests+0x221>
cmpl   $0x2,0xc(%rsp)
jne    13a4 <self_tests+0x234>
movl   $0x0,0xc(%rsp)
lea    0xdce(%rip),%rdi
mov    $0x2,%esi
call   1080 <delete@plt>
test   %eax,%eax
je     148f <self_tests+0x31f>
lea    0xdd5(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1060 <print@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret
xor    %eax,%eax
call   1060 <print@plt>
lea    0xd80(%rip),%rdi
jmp    149d <self_tests+0x32d>
xor    %eax,%eax
call   1060 <print@plt>
lea    0xdfc(%rip),%rdi
jmp    149d <self_tests+0x32d>
xor    %eax,%eax
call   1060 <print@plt>
lea    0xc45(%rip),%rdi
jmp    149d <self_tests+0x32d>
xor    %eax,%eax
call   1060 <print@plt>
lea    0xc4b(%rip),%rdi
jmp    149d <self_tests+0x32d>
xor    %eax,%eax
call   1060 <print@plt>
lea    0xc51(%rip),%rdi
jmp    149d <self_tests+0x32d>
xor    %eax,%eax
call   1060 <print@plt>
lea    0xc5a(%rip),%rdi
jmp    149d <self_tests+0x32d>
xor    %eax,%eax
call   1060 <print@plt>
lea    0xc63(%rip),%rdi
jmp    149d <self_tests+0x32d>
xor    %eax,%eax
call   1060 <print@plt>
lea    0xc6c(%rip),%rdi
jmp    149d <self_tests+0x32d>
xor    %eax,%eax
call   1060 <print@plt>
lea    0xc78(%rip),%rdi
jmp    149d <self_tests+0x32d>
lea    0xc87(%rip),%rdi
jmp    149d <self_tests+0x32d>
xor    %eax,%eax
call   1060 <print@plt>
lea    0xd4e(%rip),%rdi
jmp    149d <self_tests+0x32d>
xor    %eax,%eax
call   1060 <print@plt>
lea    0xc8f(%rip),%rdi
jmp    149d <self_tests+0x32d>
xor    %eax,%eax
call   1060 <print@plt>
lea    0xd16(%rip),%rdi
jmp    149d <self_tests+0x32d>
xor    %eax,%eax
call   1060 <print@plt>
lea    0xcf1(%rip),%rdi
jmp    149d <self_tests+0x32d>
xor    %eax,%eax
call   1060 <print@plt>
lea    0xc75(%rip),%rdi
jmp    149d <self_tests+0x32d>
xor    %eax,%eax
call   1060 <print@plt>
lea    0xc98(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"abc\00"
@.str.1 = [26 x i8] c"Failed to insert key abc\0A\00"
@.str.2 = [26 x i8] c"Failed to delete key abc\0A\00"
@.str.3 = [7 x i8] c"google\00"
@.str.4 = [29 x i8] c"Failed to insert key google\0A\00"
@.str.5 = [7 x i8] c"goggle\00"
@.str.6 = [29 x i8] c"Failed to insert key goggle\0A\00"
@.str.7 = [29 x i8] c"Failed to delete key goggle\0A\00"
@.str.8 = [29 x i8] c"Failed to delete key google\0A\00"
@.str.9 = [3 x i8] c"ab\00"
@.str.10 = [25 x i8] c"Failed to insert key ab\0A\00"
@.str.11 = [3 x i8] c"bb\00"
@.str.12 = [25 x i8] c"Failed to insert key bb\0A\00"
@.str.13 = [17 x i8] c"So far so good\0A\0A\00"
@.str.14 = [10 x i8] c"Rv is %d\0A\00"
@.str.15 = [23 x i8] c"Failed to find key ab\0A\00"
@.str.16 = [25 x i8] c"Found bad IP for key ab\0A\00"
@.str.17 = [3 x i8] c"aa\00"
@.str.18 = [20 x i8] c"Found bogus key aa\0A\00"
@.str.19 = [23 x i8] c"Failed to find key bb\0A\00"
@.str.20 = [25 x i8] c"Found bad IP for key bb\0A\00"
@.str.21 = [3 x i8] c"cb\00"
@.str.22 = [22 x i8] c"deleted bogus key cb\0A\00"
@.str.23 = [30 x i8] c"Failed to delete real key bb\0A\00"
@.str.24 = [30 x i8] c"Failed to delete real key ab\0A\00"
@.str.25 = [29 x i8] c"End of self-tests, tree is:\0A\00"
define i32 @self_tests() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %2
%3 = call i32 @insert(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 3, i32 4)
store i32 %3, i32* %1
%4 = load i32, i32* %1
%5 = icmp ne i32 %4, 0
br i1 %5, label %12, label %6
6: ; preds = %0
br label %7
7: ; preds = %6
%8 = call i32 (...) @print()
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 @exit(i32 1)
unreachable
11: ; No predecessors!
br label %12
12: ; preds = %11, %0
%13 = call i32 @delete(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 3)
store i32 %13, i32* %1
%14 = load i32, i32* %1
%15 = icmp ne i32 %14, 0
br i1 %15, label %22, label %16
16: ; preds = %12
br label %17
17: ; preds = %16
%18 = call i32 (...) @print()
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
%20 = call i32 @exit(i32 1)
unreachable
21: ; No predecessors!
br label %22
22: ; preds = %21, %12
%23 = call i32 @insert(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 6, i32 5)
store i32 %23, i32* %1
%24 = load i32, i32* %1
%25 = icmp ne i32 %24, 0
br i1 %25, label %32, label %26
26: ; preds = %22
br label %27
27: ; preds = %26
%28 = call i32 (...) @print()
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0))
%30 = call i32 @exit(i32 1)
unreachable
31: ; No predecessors!
br label %32
32: ; preds = %31, %22
%33 = call i32 @insert(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i32 6, i32 4)
store i32 %33, i32* %1
%34 = load i32, i32* %1
%35 = icmp ne i32 %34, 0
br i1 %35, label %42, label %36
36: ; preds = %32
br label %37
37: ; preds = %36
%38 = call i32 (...) @print()
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.6, i64 0, i64 0))
%40 = call i32 @exit(i32 1)
unreachable
41: ; No predecessors!
br label %42
42: ; preds = %41, %32
%43 = call i32 @delete(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i32 6)
store i32 %43, i32* %1
%44 = load i32, i32* %1
%45 = icmp ne i32 %44, 0
br i1 %45, label %52, label %46
46: ; preds = %42
br label %47
47: ; preds = %46
%48 = call i32 (...) @print()
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.7, i64 0, i64 0))
%50 = call i32 @exit(i32 1)
unreachable
51: ; No predecessors!
br label %52
52: ; preds = %51, %42
%53 = call i32 @delete(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 6)
store i32 %53, i32* %1
%54 = load i32, i32* %1
%55 = icmp ne i32 %54, 0
br i1 %55, label %62, label %56
56: ; preds = %52
br label %57
57: ; preds = %56
%58 = call i32 (...) @print()
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.8, i64 0, i64 0))
%60 = call i32 @exit(i32 1)
unreachable
61: ; No predecessors!
br label %62
62: ; preds = %61, %52
%63 = call i32 @insert(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i32 2, i32 2)
store i32 %63, i32* %1
%64 = load i32, i32* %1
%65 = icmp ne i32 %64, 0
br i1 %65, label %72, label %66
66: ; preds = %62
br label %67
67: ; preds = %66
%68 = call i32 (...) @print()
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.10, i64 0, i64 0))
%70 = call i32 @exit(i32 1)
unreachable
71: ; No predecessors!
br label %72
72: ; preds = %71, %62
%73 = call i32 @insert(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0), i32 2, i32 2)
store i32 %73, i32* %1
%74 = load i32, i32* %1
%75 = icmp ne i32 %74, 0
br i1 %75, label %82, label %76
76: ; preds = %72
br label %77
77: ; preds = %76
%78 = call i32 (...) @print()
%79 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.12, i64 0, i64 0))
%80 = call i32 @exit(i32 1)
unreachable
81: ; No predecessors!
br label %82
82: ; preds = %81, %72
%83 = call i32 (...) @print()
%84 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.13, i64 0, i64 0))
%85 = call i32 @search(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i32 2, i32* %2)
store i32 %85, i32* %1
%86 = load i32, i32* %1
%87 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.14, i64 0, i64 0), i32 %86)
%88 = load i32, i32* %1
%89 = icmp ne i32 %88, 0
br i1 %89, label %96, label %90
90: ; preds = %82
br label %91
91: ; preds = %90
%92 = call i32 (...) @print()
%93 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.15, i64 0, i64 0))
%94 = call i32 @exit(i32 1)
unreachable
95: ; No predecessors!
br label %96
96: ; preds = %95, %82
%97 = load i32, i32* %2
%98 = icmp ne i32 %97, 2
br i1 %98, label %99, label %105
99: ; preds = %96
br label %100
100: ; preds = %99
%101 = call i32 (...) @print()
%102 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.16, i64 0, i64 0))
%103 = call i32 @exit(i32 1)
unreachable
104: ; No predecessors!
br label %105
105: ; preds = %104, %96
%106 = call i32 @search(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.17, i64 0, i64 0), i32 2, i32* null)
store i32 %106, i32* %1
%107 = load i32, i32* %1
%108 = icmp ne i32 %107, 0
br i1 %108, label %109, label %115
109: ; preds = %105
br label %110
110: ; preds = %109
%111 = call i32 (...) @print()
%112 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.18, i64 0, i64 0))
%113 = call i32 @exit(i32 1)
unreachable
114: ; No predecessors!
br label %115
115: ; preds = %114, %105
store i32 0, i32* %2
%116 = call i32 @search(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0), i32 2, i32* %2)
store i32 %116, i32* %1
%117 = load i32, i32* %1
%118 = icmp ne i32 %117, 0
br i1 %118, label %125, label %119
119: ; preds = %115
br label %120
120: ; preds = %119
%121 = call i32 (...) @print()
%122 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.19, i64 0, i64 0))
%123 = call i32 @exit(i32 1)
unreachable
124: ; No predecessors!
br label %125
125: ; preds = %124, %115
%126 = load i32, i32* %2
%127 = icmp ne i32 %126, 2
br i1 %127, label %128, label %134
128: ; preds = %125
br label %129
129: ; preds = %128
%130 = call i32 (...) @print()
%131 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.20, i64 0, i64 0))
%132 = call i32 @exit(i32 1)
unreachable
133: ; No predecessors!
br label %134
134: ; preds = %133, %125
store i32 0, i32* %2
%135 = call i32 @delete(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.21, i64 0, i64 0), i32 2)
store i32 %135, i32* %1
%136 = load i32, i32* %1
%137 = icmp ne i32 %136, 0
br i1 %137, label %138, label %144
138: ; preds = %134
br label %139
139: ; preds = %138
%140 = call i32 (...) @print()
%141 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.22, i64 0, i64 0))
%142 = call i32 @exit(i32 1)
unreachable
143: ; No predecessors!
br label %144
144: ; preds = %143, %134
%145 = call i32 @delete(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0), i32 2)
store i32 %145, i32* %1
%146 = load i32, i32* %1
%147 = icmp ne i32 %146, 0
br i1 %147, label %154, label %148
148: ; preds = %144
br label %149
149: ; preds = %148
%150 = call i32 (...) @print()
%151 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.23, i64 0, i64 0))
%152 = call i32 @exit(i32 1)
unreachable
153: ; No predecessors!
br label %154
154: ; preds = %153, %144
%155 = call i32 @search(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i32 2, i32* %2)
store i32 %155, i32* %1
%156 = load i32, i32* %1
%157 = icmp ne i32 %156, 0
br i1 %157, label %164, label %158
158: ; preds = %154
br label %159
159: ; preds = %158
%160 = call i32 (...) @print()
%161 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.15, i64 0, i64 0))
%162 = call i32 @exit(i32 1)
unreachable
163: ; No predecessors!
br label %164
164: ; preds = %163, %154
%165 = load i32, i32* %2
%166 = icmp ne i32 %165, 2
br i1 %166, label %167, label %173
167: ; preds = %164
br label %168
168: ; preds = %167
%169 = call i32 (...) @print()
%170 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.16, i64 0, i64 0))
%171 = call i32 @exit(i32 1)
unreachable
172: ; No predecessors!
br label %173
173: ; preds = %172, %164
store i32 0, i32* %2
%174 = call i32 @delete(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i32 2)
store i32 %174, i32* %1
%175 = load i32, i32* %1
%176 = icmp ne i32 %175, 0
br i1 %176, label %183, label %177
177: ; preds = %173
br label %178
178: ; preds = %177
%179 = call i32 (...) @print()
%180 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.24, i64 0, i64 0))
%181 = call i32 @exit(i32 1)
unreachable
182: ; No predecessors!
br label %183
183: ; preds = %182, %173
%184 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.25, i64 0, i64 0))
%185 = call i32 (...) @print()
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"abc\00"
@.str.3 = [7 x i8] c"google\00"
@.str.5 = [7 x i8] c"goggle\00"
@.str.9 = [3 x i8] c"ab\00"
@.str.11 = [3 x i8] c"bb\00"
@.str.14 = [10 x i8] c"Rv is %d\0A\00"
@.str.17 = [3 x i8] c"aa\00"
@.str.21 = [3 x i8] c"cb\00"
@str = [25 x i8] c"Failed to insert key abc\00"
@str.26 = [25 x i8] c"Failed to delete key abc\00"
@str.27 = [28 x i8] c"Failed to insert key google\00"
@str.28 = [28 x i8] c"Failed to insert key goggle\00"
@str.29 = [28 x i8] c"Failed to delete key goggle\00"
@str.30 = [28 x i8] c"Failed to delete key google\00"
@str.31 = [24 x i8] c"Failed to insert key ab\00"
@str.32 = [24 x i8] c"Failed to insert key bb\00"
@str.33 = [16 x i8] c"So far so good\0A\00"
@str.35 = [22 x i8] c"Failed to find key bb\00"
@str.36 = [29 x i8] c"Failed to delete real key bb\00"
@str.37 = [22 x i8] c"Failed to find key ab\00"
@str.38 = [29 x i8] c"Failed to delete real key ab\00"
@str.39 = [28 x i8] c"End of self-tests, tree is:\00"
@str.41 = [21 x i8] c"deleted bogus key cb\00"
@str.42 = [24 x i8] c"Found bad IP for key bb\00"
@str.43 = [19 x i8] c"Found bogus key aa\00"
@str.44 = [24 x i8] c"Found bad IP for key ab\00"
define i32 @self_tests() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%3 = tail call i32 @insert(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 3, i32 4)
%4 = icmp eq i32 %3, 0
br i1 %4, label %5, label %9
5: ; preds = %0
%6 = tail call i32 (...) @print()
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str, i64 0, i64 0))
%8 = tail call i32 @exit(i32 1)
unreachable
9: ; preds = %0
%10 = tail call i32 @delete(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 3)
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %16
12: ; preds = %9
%13 = tail call i32 (...) @print()
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.26, i64 0, i64 0))
%15 = tail call i32 @exit(i32 1)
unreachable
16: ; preds = %9
%17 = tail call i32 @insert(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 6, i32 5)
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %23
19: ; preds = %16
%20 = tail call i32 (...) @print()
%21 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.27, i64 0, i64 0))
%22 = tail call i32 @exit(i32 1)
unreachable
23: ; preds = %16
%24 = tail call i32 @insert(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i32 6, i32 4)
%25 = icmp eq i32 %24, 0
br i1 %25, label %26, label %30
26: ; preds = %23
%27 = tail call i32 (...) @print()
%28 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.28, i64 0, i64 0))
%29 = tail call i32 @exit(i32 1)
unreachable
30: ; preds = %23
%31 = tail call i32 @delete(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i32 6)
%32 = icmp eq i32 %31, 0
br i1 %32, label %33, label %37
33: ; preds = %30
%34 = tail call i32 (...) @print()
%35 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.29, i64 0, i64 0))
%36 = tail call i32 @exit(i32 1)
unreachable
37: ; preds = %30
%38 = tail call i32 @delete(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 6)
%39 = icmp eq i32 %38, 0
br i1 %39, label %40, label %44
40: ; preds = %37
%41 = tail call i32 (...) @print()
%42 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.30, i64 0, i64 0))
%43 = tail call i32 @exit(i32 1)
unreachable
44: ; preds = %37
%45 = tail call i32 @insert(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i32 2, i32 2)
%46 = icmp eq i32 %45, 0
br i1 %46, label %47, label %51
47: ; preds = %44
%48 = tail call i32 (...) @print()
%49 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.31, i64 0, i64 0))
%50 = tail call i32 @exit(i32 1)
unreachable
51: ; preds = %44
%52 = tail call i32 @insert(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0), i32 2, i32 2)
%53 = icmp eq i32 %52, 0
%54 = tail call i32 (...) @print()
br i1 %53, label %55, label %58
55: ; preds = %51
%56 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.32, i64 0, i64 0))
%57 = tail call i32 @exit(i32 1)
unreachable
58: ; preds = %51
%59 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.33, i64 0, i64 0))
%60 = call i32 @search(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i32 2, i32* %1)
%61 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.14, i64 0, i64 0), i32 %60)
%62 = icmp eq i32 %60, 0
br i1 %62, label %63, label %67
63: ; preds = %58
%64 = call i32 (...) @print()
%65 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.37, i64 0, i64 0))
%66 = call i32 @exit(i32 1)
unreachable
67: ; preds = %58
%68 = load i32, i32* %1
%69 = icmp eq i32 %68, 2
br i1 %69, label %74, label %70
70: ; preds = %67
%71 = call i32 (...) @print()
%72 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.44, i64 0, i64 0))
%73 = call i32 @exit(i32 1)
unreachable
74: ; preds = %67
%75 = call i32 @search(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.17, i64 0, i64 0), i32 2, i32* null)
%76 = icmp eq i32 %75, 0
br i1 %76, label %81, label %77
77: ; preds = %74
%78 = call i32 (...) @print()
%79 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.43, i64 0, i64 0))
%80 = call i32 @exit(i32 1)
unreachable
81: ; preds = %74
store i32 0, i32* %1
%82 = call i32 @search(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0), i32 2, i32* %1)
%83 = icmp eq i32 %82, 0
br i1 %83, label %84, label %88
84: ; preds = %81
%85 = call i32 (...) @print()
%86 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.35, i64 0, i64 0))
%87 = call i32 @exit(i32 1)
unreachable
88: ; preds = %81
%89 = load i32, i32* %1
%90 = icmp eq i32 %89, 2
br i1 %90, label %95, label %91
91: ; preds = %88
%92 = call i32 (...) @print()
%93 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.42, i64 0, i64 0))
%94 = call i32 @exit(i32 1)
unreachable
95: ; preds = %88
store i32 0, i32* %1
%96 = call i32 @delete(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.21, i64 0, i64 0), i32 2)
%97 = icmp eq i32 %96, 0
br i1 %97, label %102, label %98
98: ; preds = %95
%99 = call i32 (...) @print()
%100 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.41, i64 0, i64 0))
%101 = call i32 @exit(i32 1)
unreachable
102: ; preds = %95
%103 = call i32 @delete(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0), i32 2)
%104 = icmp eq i32 %103, 0
br i1 %104, label %105, label %109
105: ; preds = %102
%106 = call i32 (...) @print()
%107 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.36, i64 0, i64 0))
%108 = call i32 @exit(i32 1)
unreachable
109: ; preds = %102
%110 = call i32 @search(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i32 2, i32* %1)
%111 = icmp eq i32 %110, 0
br i1 %111, label %112, label %116
112: ; preds = %109
%113 = call i32 (...) @print()
%114 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.37, i64 0, i64 0))
%115 = call i32 @exit(i32 1)
unreachable
116: ; preds = %109
%117 = load i32, i32* %1
%118 = icmp eq i32 %117, 2
br i1 %118, label %123, label %119
119: ; preds = %116
%120 = call i32 (...) @print()
%121 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.44, i64 0, i64 0))
%122 = call i32 @exit(i32 1)
unreachable
123: ; preds = %116
store i32 0, i32* %1
%124 = call i32 @delete(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i32 2)
%125 = icmp eq i32 %124, 0
br i1 %125, label %126, label %130
126: ; preds = %123
%127 = call i32 (...) @print()
%128 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.38, i64 0, i64 0))
%129 = call i32 @exit(i32 1)
unreachable
130: ; preds = %123
%131 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.39, i64 0, i64 0))
%132 = call i32 (...) @print()
ret i32 0
}