#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 glh_table {
  int dummy;
};
struct glh_entry {
  int dummy;
};

/* Variables and functions */
struct glh_entry *glh_find_entry(struct glh_table const *, char const *);
int /*<<< orphan*/ puts(char *);
unsigned int glh_exists(const struct glh_table *table, const char *key) {
  struct glh_entry *she = 0;
  if (!table) {
    puts("glh_exists: table undef");
    return 0;
  }
  if (!key) {
    puts("glh_exists: key undef");
    return 0;
  }
  she = glh_find_entry(table, key);
  if (!she) {
    return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<glh_exists>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    115b <glh_exists+0x3b>
lea    0xeb6(%rip),%rdi
call   1030 <puts@plt>
movl   $0x0,-0x4(%rbp)
jmp    11ad <glh_exists+0x8d>
cmpq   $0x0,-0x18(%rbp)
jne    117e <glh_exists+0x5e>
lea    0xeab(%rip),%rdi
call   1030 <puts@plt>
movl   $0x0,-0x4(%rbp)
jmp    11ad <glh_exists+0x8d>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <glh_find_entry@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11a6 <glh_exists+0x86>
movl   $0x0,-0x4(%rbp)
jmp    11ad <glh_exists+0x8d>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<glh_exists>:
push   %rax
test   %rdi,%rdi
je     113d <glh_exists+0x1d>
test   %rsi,%rsi
je     1146 <glh_exists+0x26>
call   1040 <glh_find_entry@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
setne  %al
pop    %rcx
ret
lea    0xebc(%rip),%rdi
jmp    114d <glh_exists+0x2d>
lea    0xecb(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
%struct.glh_table = type { i32 }
%struct.glh_entry = type { i32 }
@.str = [24 x i8] c"glh_exists: table undef\00"
@.str.1 = [22 x i8] c"glh_exists: key undef\00"
define i32 @glh_exists(%struct.glh_table* %0, i8* %1) {
%3 = alloca i32
%4 = alloca %struct.glh_table*
%5 = alloca i8*
%6 = alloca %struct.glh_entry*
store %struct.glh_table* %0, %struct.glh_table** %4
store i8* %1, i8** %5
store %struct.glh_entry* null, %struct.glh_entry** %6
%7 = load %struct.glh_table*, %struct.glh_table** %4
%8 = icmp ne %struct.glh_table* %7, null
br i1 %8, label %11, label %9
9: ; preds = %2
%10 = call i32 @puts(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %24
11: ; preds = %2
%12 = load i8*, i8** %5
%13 = icmp ne i8* %12, null
br i1 %13, label %16, label %14
14: ; preds = %11
%15 = call i32 @puts(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %3
br label %24
16: ; preds = %11
%17 = load %struct.glh_table*, %struct.glh_table** %4
%18 = load i8*, i8** %5
%19 = call %struct.glh_entry* @glh_find_entry(%struct.glh_table* %17, i8* %18)
store %struct.glh_entry* %19, %struct.glh_entry** %6
%20 = load %struct.glh_entry*, %struct.glh_entry** %6
%21 = icmp ne %struct.glh_entry* %20, null
br i1 %21, label %23, label %22
22: ; preds = %16
store i32 0, i32* %3
br label %24
23: ; preds = %16
store i32 1, i32* %3
br label %24
24: ; preds = %23, %22, %14, %9
%25 = load i32, i32* %3
ret i32 %25
}

LLVM IR (-O2):
%struct.glh_table = type { i32 }
%struct.glh_entry = type { i32 }
@.str = [24 x i8] c"glh_exists: table undef\00"
@.str.1 = [22 x i8] c"glh_exists: key undef\00"
define i32 @glh_exists(%struct.glh_table* %0, i8* %1) {
%3 = icmp eq %struct.glh_table* %0, null
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
br label %14
6: ; preds = %2
%7 = icmp eq i8* %1, null
br i1 %7, label %8, label %10
8: ; preds = %6
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
br label %14
10: ; preds = %6
%11 = tail call %struct.glh_entry* @glh_find_entry(%struct.glh_table* %0, i8* %1)
%12 = icmp ne %struct.glh_entry* %11, null
%13 = zext i1 %12 to i32
br label %14
14: ; preds = %10, %8, %4
%15 = phi i32 [ 0, %8 ], [ 0, %4 ], [ %13, %10 ]
ret i32 %15
}