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

/* Variables and functions */
struct Table *create_table();
int /*<<< orphan*/ destroy(struct Table *);
int erase(struct Table *, char *);
int find(struct Table *, char *);
int /*<<< orphan*/ insert(struct Table *, char *, int);
int /*<<< orphan*/ print_table(struct Table *);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  struct Table *tbl = create_table();
  insert(tbl, "value0", 0);
  insert(tbl, "value1", 1);
  insert(tbl, "value2", 2);
  print_table(tbl);
  printf("Removing value1\n");
  {
    int val = erase(tbl, "value1");
    printf("value1 had value %d\n", val);
  }
  print_table(tbl);
  {
    int val = find(tbl, "value2");
    printf("value2 has value %d\n", val);
    val = find(tbl, "valuex");
    if (val == -99999)
      printf("can't find valuex\n");
    val = erase(tbl, "valuex");
    if (val == -99999)
      printf("can't erase valuex\n");
  }
  destroy(tbl);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1040 <create_table@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe6b(%rip),%rsi
xor    %edx,%edx
call   1090 <insert@plt>
mov    -0x10(%rbp),%rdi
lea    0xe60(%rip),%rsi
mov    $0x1,%edx
call   1090 <insert@plt>
mov    -0x10(%rbp),%rdi
lea    0xe52(%rip),%rsi
mov    $0x2,%edx
call   1090 <insert@plt>
mov    -0x10(%rbp),%rdi
call   1030 <print_table@plt>
lea    0xe3f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
lea    0xe1f(%rip),%rsi
call   1060 <erase@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xe2c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <print_table@plt>
mov    -0x10(%rbp),%rdi
lea    0xdf9(%rip),%rsi
call   1080 <find@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%esi
lea    0xe14(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
lea    0xe17(%rip),%rsi
call   1080 <find@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0xfffe7961,-0x18(%rbp)
jne    125c <main+0xec>
lea    0xe02(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
lea    0xde9(%rip),%rsi
call   1060 <erase@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0xfffe7961,-0x18(%rbp)
jne    128a <main+0x11a>
lea    0xde7(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1070 <destroy@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
xor    %eax,%eax
call   1040 <create_table@plt>
mov    %rax,%rbx
lea    0xe6a(%rip),%rsi
mov    %rax,%rdi
xor    %edx,%edx
call   10a0 <insert@plt>
lea    0xe9a(%rip),%r15
mov    %rbx,%rdi
mov    %r15,%rsi
mov    $0x1,%edx
call   10a0 <insert@plt>
lea    0xe49(%rip),%r14
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x2,%edx
call   10a0 <insert@plt>
mov    %rbx,%rdi
call   1030 <print_table@plt>
lea    0xe5b(%rip),%rdi
call   1050 <puts@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1070 <erase@plt>
lea    0xe1a(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
call   1030 <print_table@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1090 <find@plt>
lea    0xe0c(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe3f(%rip),%rsi
mov    %rbx,%rdi
call   1090 <find@plt>
cmp    $0xfffe7961,%eax
jne    1242 <main+0xc2>
lea    0xe1e(%rip),%rdi
call   1050 <puts@plt>
lea    0xe1d(%rip),%rsi
mov    %rbx,%rdi
call   1070 <erase@plt>
cmp    $0xfffe7961,%eax
jne    1264 <main+0xe4>
lea    0xde9(%rip),%rdi
call   1050 <puts@plt>
mov    %rbx,%rdi
call   1080 <destroy@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.Table = type { i32 }
@.str = [7 x i8] c"value0\00"
@.str.1 = [7 x i8] c"value1\00"
@.str.2 = [7 x i8] c"value2\00"
@.str.3 = [17 x i8] c"Removing value1\0A\00"
@.str.4 = [21 x i8] c"value1 had value %d\0A\00"
@.str.5 = [21 x i8] c"value2 has value %d\0A\00"
@.str.6 = [7 x i8] c"valuex\00"
@.str.7 = [19 x i8] c"can't find valuex\0A\00"
@.str.8 = [20 x i8] c"can't erase valuex\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.Table*
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = call %struct.Table* (...) @create_table()
store %struct.Table* %5, %struct.Table** %2
%6 = load %struct.Table*, %struct.Table** %2
%7 = call i32 @insert(%struct.Table* %6, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 0)
%8 = load %struct.Table*, %struct.Table** %2
%9 = call i32 @insert(%struct.Table* %8, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 1)
%10 = load %struct.Table*, %struct.Table** %2
%11 = call i32 @insert(%struct.Table* %10, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 2)
%12 = load %struct.Table*, %struct.Table** %2
%13 = call i32 @print_table(%struct.Table* %12)
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
%15 = load %struct.Table*, %struct.Table** %2
%16 = call i32 @erase(%struct.Table* %15, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
store i32 %16, i32* %3
%17 = load i32, i32* %3
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i32 %17)
%19 = load %struct.Table*, %struct.Table** %2
%20 = call i32 @print_table(%struct.Table* %19)
%21 = load %struct.Table*, %struct.Table** %2
%22 = call i32 @find(%struct.Table* %21, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
store i32 %22, i32* %4
%23 = load i32, i32* %4
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0), i32 %23)
%25 = load %struct.Table*, %struct.Table** %2
%26 = call i32 @find(%struct.Table* %25, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
store i32 %26, i32* %4
%27 = load i32, i32* %4
%28 = icmp eq i32 %27, -99999
br i1 %28, label %29, label %31
29: ; preds = %0
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0))
br label %31
31: ; preds = %29, %0
%32 = load %struct.Table*, %struct.Table** %2
%33 = call i32 @erase(%struct.Table* %32, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
store i32 %33, i32* %4
%34 = load i32, i32* %4
%35 = icmp eq i32 %34, -99999
br i1 %35, label %36, label %38
36: ; preds = %31
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.8, i64 0, i64 0))
br label %38
38: ; preds = %36, %31
%39 = load %struct.Table*, %struct.Table** %2
%40 = call i32 @destroy(%struct.Table* %39)
%41 = load i32, i32* %1
ret i32 %41
}

LLVM IR (-O2):
%struct.Table = type { i32 }
@.str = [7 x i8] c"value0\00"
@.str.1 = [7 x i8] c"value1\00"
@.str.2 = [7 x i8] c"value2\00"
@.str.4 = [21 x i8] c"value1 had value %d\0A\00"
@.str.5 = [21 x i8] c"value2 has value %d\0A\00"
@.str.6 = [7 x i8] c"valuex\00"
@str = [16 x i8] c"Removing value1\00"
@str.9 = [19 x i8] c"can't erase valuex\00"
@str.10 = [18 x i8] c"can't find valuex\00"
define i32 @main() {
%1 = tail call %struct.Table* (...) @create_table()
%2 = tail call i32 @insert(%struct.Table* %1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 0)
%3 = tail call i32 @insert(%struct.Table* %1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 1)
%4 = tail call i32 @insert(%struct.Table* %1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 2)
%5 = tail call i32 @print_table(%struct.Table* %1)
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str, i64 0, i64 0))
%7 = tail call i32 @erase(%struct.Table* %1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i32 %7)
%9 = tail call i32 @print_table(%struct.Table* %1)
%10 = tail call i32 @find(%struct.Table* %1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0), i32 %10)
%12 = tail call i32 @find(%struct.Table* %1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
%13 = icmp eq i32 %12, -99999
br i1 %13, label %14, label %16
14: ; preds = %0
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.10, i64 0, i64 0))
br label %16
16: ; preds = %14, %0
%17 = tail call i32 @erase(%struct.Table* %1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
%18 = icmp eq i32 %17, -99999
br i1 %18, label %19, label %21
19: ; preds = %16
%20 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.9, i64 0, i64 0))
br label %21
21: ; preds = %19, %16
%22 = tail call i32 @destroy(%struct.Table* %1)
ret i32 0
}