#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 */

/* Variables and functions */
int /*<<< orphan*/ define(char *, char *);
int /*<<< orphan*/ *lookup(char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ undefine(char *);
int main() {
  define("foo", "bar");
  define("bar", "baz");
  printf("foo %s\n", lookup("foo") == NULL ? "does not exist" : "exists");
  printf("bar %s\n", lookup("bar") == NULL ? "does not exist" : "exists");
  undefine("foo");
  undefine("bar");
  printf("foo %s\n", lookup("foo") == NULL ? "does not exist" : "exists");
  printf("bar %s\n", lookup("bar") == NULL ? "does not exist" : "exists");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
lea    0xea7(%rip),%rsi
call   1060 <define@plt>
lea    0xe9b(%rip),%rdi
lea    0xe98(%rip),%rsi
call   1060 <define@plt>
lea    0xe84(%rip),%rdi
call   1050 <lookup@plt>
mov    %rax,%rcx
lea    0xe98(%rip),%rsi
lea    0xe82(%rip),%rax
cmp    $0x0,%rcx
cmove  %rax,%rsi
lea    0xe6b(%rip),%rdi
call   1030 <printf@plt>
lea    0xe57(%rip),%rdi
call   1050 <lookup@plt>
mov    %rax,%rcx
lea    0xe67(%rip),%rsi
lea    0xe51(%rip),%rax
cmp    $0x0,%rcx
cmove  %rax,%rsi
lea    0xe58(%rip),%rdi
call   1030 <printf@plt>
lea    0xe22(%rip),%rdi
call   1040 <undefine@plt>
lea    0xe1a(%rip),%rdi
call   1040 <undefine@plt>
lea    0xe0a(%rip),%rdi
call   1050 <lookup@plt>
mov    %rax,%rcx
lea    0xe1e(%rip),%rsi
lea    0xe08(%rip),%rax
cmp    $0x0,%rcx
cmove  %rax,%rsi
lea    0xdf1(%rip),%rdi
call   1030 <printf@plt>
lea    0xddd(%rip),%rdi
call   1050 <lookup@plt>
mov    %rax,%rcx
lea    0xded(%rip),%rsi
lea    0xdd7(%rip),%rax
cmp    $0x0,%rcx
cmove  %rax,%rsi
lea    0xdde(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xeae(%rip),%r15
lea    0xeab(%rip),%r14
mov    %r15,%rdi
mov    %r14,%rsi
call   1060 <define@plt>
lea    0xe9d(%rip),%rsi
mov    %r14,%rdi
call   1060 <define@plt>
mov    %r15,%rdi
call   1050 <lookup@plt>
test   %rax,%rax
lea    0xe8f(%rip),%rbp
lea    0xe97(%rip),%rbx
mov    %rbx,%rsi
cmove  %rbp,%rsi
lea    0xe72(%rip),%r12
mov    %r12,%rdi
call   1030 <printf@plt>
mov    %r14,%rdi
call   1050 <lookup@plt>
test   %rax,%rax
mov    %rbx,%rsi
cmove  %rbp,%rsi
lea    0xe6f(%rip),%r13
mov    %r13,%rdi
call   1030 <printf@plt>
mov    %r15,%rdi
call   1040 <undefine@plt>
mov    %r14,%rdi
call   1040 <undefine@plt>
mov    %r15,%rdi
call   1050 <lookup@plt>
test   %rax,%rax
mov    %rbx,%rsi
cmove  %rbp,%rsi
mov    %r12,%rdi
call   1030 <printf@plt>
mov    %r14,%rdi
call   1050 <lookup@plt>
test   %rax,%rax
cmove  %rbp,%rbx
mov    %r13,%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"foo\00"
@.str.1 = [4 x i8] c"bar\00"
@.str.2 = [4 x i8] c"baz\00"
@.str.3 = [8 x i8] c"foo %s\0A\00"
@.str.4 = [15 x i8] c"does not exist\00"
@.str.5 = [7 x i8] c"exists\00"
@.str.6 = [8 x i8] c"bar %s\0A\00"
define i32 @main() {
%1 = alloca i32
store i32 0, i32* %1
%2 = call i32 @define(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%3 = call i32 @define(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%4 = call i32* @lookup(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i32* %4, null
%6 = zext i1 %5 to i64
%7 = select i1 %5, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0)
%8 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* %7)
%9 = call i32* @lookup(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp eq i32* %9, null
%11 = zext i1 %10 to i64
%12 = select i1 %10, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0)
%13 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0), i8* %12)
%14 = call i32 @undefine(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%15 = call i32 @undefine(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%16 = call i32* @lookup(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%17 = icmp eq i32* %16, null
%18 = zext i1 %17 to i64
%19 = select i1 %17, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0)
%20 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* %19)
%21 = call i32* @lookup(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%22 = icmp eq i32* %21, null
%23 = zext i1 %22 to i64
%24 = select i1 %22, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0)
%25 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0), i8* %24)
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"foo\00"
@.str.1 = [4 x i8] c"bar\00"
@.str.2 = [4 x i8] c"baz\00"
@.str.3 = [8 x i8] c"foo %s\0A\00"
@.str.4 = [15 x i8] c"does not exist\00"
@.str.5 = [7 x i8] c"exists\00"
@.str.6 = [8 x i8] c"bar %s\0A\00"
define i32 @main() {
%1 = tail call i32 @define(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%2 = tail call i32 @define(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%3 = tail call i32* @lookup(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i32* %3, null
%5 = select i1 %4, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0)
%6 = tail call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* %5)
%7 = tail call i32* @lookup(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%8 = icmp eq i32* %7, null
%9 = select i1 %8, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0)
%10 = tail call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0), i8* %9)
%11 = tail call i32 @undefine(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%12 = tail call i32 @undefine(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%13 = tail call i32* @lookup(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%14 = icmp eq i32* %13, null
%15 = select i1 %14, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0)
%16 = tail call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* %15)
%17 = tail call i32* @lookup(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%18 = icmp eq i32* %17, null
%19 = select i1 %18, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0)
%20 = tail call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0), i8* %19)
ret i32 0
}