#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 ls_set {
  int dummy;
};
struct ls_entry {
  int dummy;
};

/* Variables and functions */
struct ls_entry *ls_find_entry(struct ls_set const *, char const *);
int /*<<< orphan*/ puts(char *);
unsigned int ls_exists(const struct ls_set *set, const char *key) {
  struct ls_entry *she = 0;
  if (!set) {
    puts("ls_exists: set undef");
    return 0;
  }
  if (!key) {
    puts("ls_exists: key undef");
    return 0;
  }
  she = ls_find_entry(set, key);
  if (!she) {
    return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<ls_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 <ls_exists+0x3b>
lea    0xeb6(%rip),%rdi
call   1030 <puts@plt>
movl   $0x0,-0x4(%rbp)
jmp    11ad <ls_exists+0x8d>
cmpq   $0x0,-0x18(%rbp)
jne    117e <ls_exists+0x5e>
lea    0xea8(%rip),%rdi
call   1030 <puts@plt>
movl   $0x0,-0x4(%rbp)
jmp    11ad <ls_exists+0x8d>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <ls_find_entry@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11a6 <ls_exists+0x86>
movl   $0x0,-0x4(%rbp)
jmp    11ad <ls_exists+0x8d>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

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

LLVM IR (-O0):
%struct.ls_set = type { i32 }
%struct.ls_entry = type { i32 }
@.str = [21 x i8] c"ls_exists: set undef\00"
@.str.1 = [21 x i8] c"ls_exists: key undef\00"
define i32 @ls_exists(%struct.ls_set* %0, i8* %1) {
%3 = alloca i32
%4 = alloca %struct.ls_set*
%5 = alloca i8*
%6 = alloca %struct.ls_entry*
store %struct.ls_set* %0, %struct.ls_set** %4
store i8* %1, i8** %5
store %struct.ls_entry* null, %struct.ls_entry** %6
%7 = load %struct.ls_set*, %struct.ls_set** %4
%8 = icmp ne %struct.ls_set* %7, null
br i1 %8, label %11, label %9
9: ; preds = %2
%10 = call i32 @puts(i8* getelementptr inbounds ([21 x i8], [21 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 ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %3
br label %24
16: ; preds = %11
%17 = load %struct.ls_set*, %struct.ls_set** %4
%18 = load i8*, i8** %5
%19 = call %struct.ls_entry* @ls_find_entry(%struct.ls_set* %17, i8* %18)
store %struct.ls_entry* %19, %struct.ls_entry** %6
%20 = load %struct.ls_entry*, %struct.ls_entry** %6
%21 = icmp ne %struct.ls_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.ls_set = type { i32 }
%struct.ls_entry = type { i32 }
@.str = [21 x i8] c"ls_exists: set undef\00"
@.str.1 = [21 x i8] c"ls_exists: key undef\00"
define i32 @ls_exists(%struct.ls_set* %0, i8* %1) {
%3 = icmp eq %struct.ls_set* %0, null
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 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 ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
br label %14
10: ; preds = %6
%11 = tail call %struct.ls_entry* @ls_find_entry(%struct.ls_set* %0, i8* %1)
%12 = icmp ne %struct.ls_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
}