#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 */
char *getenv(char *);
char *slurp_file(char *);
const char *get_dedication() {
  const char *dedication;
  if ((dedication = getenv("DEFAULT_HELLO_DEDICATION")) != NULL) {
    return dedication;
  } else if ((dedication = slurp_file("~/.hellorc")) != NULL) {
    return dedication;
  } else if ((dedication = slurp_file("/etc/hello.conf")) != NULL) {
    return dedication;
  } else {
    return "World";
  }
}


x86 assembly (clang, -O0):
<get_dedication>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xed1(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     114f <get_dedication+0x2f>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11a8 <get_dedication+0x88>
lea    0xec3(%rip),%rdi
call   1040 <slurp_file@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     1176 <get_dedication+0x56>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11a8 <get_dedication+0x88>
lea    0xea7(%rip),%rdi
call   1040 <slurp_file@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     119d <get_dedication+0x7d>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11a8 <get_dedication+0x88>
lea    0xe90(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_dedication>:
push   %rax
lea    0xed8(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     1134 <get_dedication+0x14>
pop    %rcx
ret
lea    0xede(%rip),%rdi
call   1040 <slurp_file@plt>
test   %rax,%rax
jne    1132 <get_dedication+0x12>
lea    0xed8(%rip),%rdi
call   1040 <slurp_file@plt>
mov    %rax,%rcx
test   %rax,%rax
lea    0xed6(%rip),%rax
cmovne %rcx,%rax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [25 x i8] c"DEFAULT_HELLO_DEDICATION\00"
@.str.1 = [11 x i8] c"~/.hellorc\00"
@.str.2 = [16 x i8] c"/etc/hello.conf\00"
@.str.3 = [6 x i8] c"World\00"
define i8* @get_dedication() {
%1 = alloca i8*
%2 = alloca i8*
%3 = call i8* @getenv(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
store i8* %3, i8** %2
%4 = icmp ne i8* %3, null
br i1 %4, label %5, label %7
5: ; preds = %0
%6 = load i8*, i8** %2
store i8* %6, i8** %1
br label %18
7: ; preds = %0
%8 = call i8* @slurp_file(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
store i8* %8, i8** %2
%9 = icmp ne i8* %8, null
br i1 %9, label %10, label %12
10: ; preds = %7
%11 = load i8*, i8** %2
store i8* %11, i8** %1
br label %18
12: ; preds = %7
%13 = call i8* @slurp_file(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
store i8* %13, i8** %2
%14 = icmp ne i8* %13, null
br i1 %14, label %15, label %17
15: ; preds = %12
%16 = load i8*, i8** %2
store i8* %16, i8** %1
br label %18
17: ; preds = %12
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8** %1
br label %18
18: ; preds = %17, %15, %10, %5
%19 = load i8*, i8** %1
ret i8* %19
}

LLVM IR (-O2):
@.str = [25 x i8] c"DEFAULT_HELLO_DEDICATION\00"
@.str.1 = [11 x i8] c"~/.hellorc\00"
@.str.2 = [16 x i8] c"/etc/hello.conf\00"
@.str.3 = [6 x i8] c"World\00"
define i8* @get_dedication() {
%1 = tail call i8* @getenv(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%2 = icmp eq i8* %1, null
br i1 %2, label %3, label %10
3: ; preds = %0
%4 = tail call i8* @slurp_file(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%5 = icmp eq i8* %4, null
br i1 %5, label %6, label %10
6: ; preds = %3
%7 = tail call i8* @slurp_file(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%8 = icmp eq i8* %7, null
%9 = select i1 %8, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8* %7
br label %10
10: ; preds = %6, %3, %0
%11 = phi i8* [ %1, %0 ], [ %4, %3 ], [ %9, %6 ]
ret i8* %11
}