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

/* Variables and functions */
struct nlist *install(char *, char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ printhtab();
int /*<<< orphan*/ undef(char *);
main() {
  struct nlist *np;
  if ((np = install("pet", "dog")) != NULL)
    printf("added: pet, dog\n");
  else
    printf("FAIL\n");
  if ((np = install("enemy", "cat")) != NULL)
    printf("added: enemy, cat\n");
  else
    printf("FAIL\n");
  printhtab();
  undef("enemy");
  printf("undefined: enemy\n");
  printhtab();
}


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   1050 <install@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     1181 <main+0x41>
lea    0xe91(%rip),%rdi
call   1040 <printf@plt>
jmp    118d <main+0x4d>
lea    0xe91(%rip),%rdi
call   1040 <printf@plt>
lea    0xe8b(%rip),%rdi
lea    0xe8a(%rip),%rsi
call   1050 <install@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     11bf <main+0x7f>
lea    0xe74(%rip),%rdi
call   1040 <printf@plt>
jmp    11cb <main+0x8b>
lea    0xe53(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1060 <printhtab@plt>
lea    0xe46(%rip),%rdi
call   1030 <undef@plt>
lea    0xe57(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1060 <printhtab@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0xeb5(%rip),%rdi
lea    0xee6(%rip),%rsi
call   1050 <install@plt>
test   %rax,%rax
lea    0xea3(%rip),%rbx
lea    0xec4(%rip),%rdi
cmove  %rbx,%rdi
call   1030 <puts@plt>
lea    0xe9c(%rip),%r14
lea    0xea9(%rip),%rsi
mov    %r14,%rdi
call   1050 <install@plt>
test   %rax,%rax
lea    0xe89(%rip),%rdi
cmove  %rbx,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1060 <printhtab@plt>
mov    %r14,%rdi
call   1040 <undef@plt>
lea    0xe59(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1060 <printhtab@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.nlist = type { i32 }
@.str = [4 x i8] c"pet\00"
@.str.1 = [4 x i8] c"dog\00"
@.str.2 = [17 x i8] c"added: pet, dog\0A\00"
@.str.3 = [6 x i8] c"FAIL\0A\00"
@.str.4 = [6 x i8] c"enemy\00"
@.str.5 = [4 x i8] c"cat\00"
@.str.6 = [19 x i8] c"added: enemy, cat\0A\00"
@.str.7 = [18 x i8] c"undefined: enemy\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.nlist*
store i32 0, i32* %1
%3 = call %struct.nlist* @install(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))
store %struct.nlist* %3, %struct.nlist** %2
%4 = icmp ne %struct.nlist* %3, null
br i1 %4, label %5, label %7
5: ; preds = %0
%6 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
br label %9
7: ; preds = %0
%8 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
br label %9
9: ; preds = %7, %5
%10 = call %struct.nlist* @install(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
store %struct.nlist* %10, %struct.nlist** %2
%11 = icmp ne %struct.nlist* %10, null
br i1 %11, label %12, label %14
12: ; preds = %9
%13 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0))
br label %16
14: ; preds = %9
%15 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
br label %16
16: ; preds = %14, %12
%17 = call i32 (...) @printhtab()
%18 = call i32 @undef(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%19 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0))
%20 = call i32 (...) @printhtab()
%21 = load i32, i32* %1
ret i32 %21
}

LLVM IR (-O2):
%struct.nlist = type { i32 }
@.str = [4 x i8] c"pet\00"
@.str.1 = [4 x i8] c"dog\00"
@.str.4 = [6 x i8] c"enemy\00"
@.str.5 = [4 x i8] c"cat\00"
@str.8 = [5 x i8] c"FAIL\00"
@str.9 = [17 x i8] c"undefined: enemy\00"
@str.10 = [18 x i8] c"added: enemy, cat\00"
@str.11 = [16 x i8] c"added: pet, dog\00"
define i32 @main() {
%1 = tail call %struct.nlist* @install(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 = icmp eq %struct.nlist* %1, null
%3 = select i1 %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @str.8, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @str.11, i64 0, i64 0)
%4 = tail call i32 @puts(i8* dereferenceable(1) %3)
%5 = tail call %struct.nlist* @install(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%6 = icmp eq %struct.nlist* %5, null
%7 = select i1 %6, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @str.8, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @str.10, i64 0, i64 0)
%8 = tail call i32 @puts(i8* dereferenceable(1) %7)
%9 = tail call i32 (...) @printhtab()
%10 = tail call i32 @undef(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.9, i64 0, i64 0))
%12 = tail call i32 (...) @printhtab()
ret i32 0
}