#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*/ chk_file(char *, char *);
int /*<<< orphan*/ puts(char *);
char *get_data_dir(int verbose) {
  if (verbose)
    puts("Looking for data directory:");
  if (verbose)
    puts("./data/ ..");
  if (!chk_file("./data/", "spgraf"))
    return "./data/";
  if (verbose)
    puts("/usr/local/share/phear/data/ ..");
  if (!chk_file("/usr/local/share/phear/data/", "spgraf"))
    return "/usr/local/share/phear/data/";
  if (verbose)
    puts("/usr/share/phear/data/ ..");
  if (!chk_file("/usr/share/phear/data/", "spgraf"))
    return "/usr/share/phear/data/";
  if (verbose)
    puts("Data not found");
  return NULL;
}


x86 assembly (clang, -O0):
<get_data_dir>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     1141 <get_data_dir+0x21>
lea    0xec4(%rip),%rdi
call   1030 <puts@plt>
cmpl   $0x0,-0xc(%rbp)
je     1157 <get_data_dir+0x37>
lea    0xeca(%rip),%rdi
call   1030 <puts@plt>
lea    0xec9(%rip),%rdi
lea    0xeca(%rip),%rsi
call   1040 <chk_file@plt>
cmp    $0x0,%eax
jne    1183 <get_data_dir+0x63>
lea    0xead(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1225 <get_data_dir+0x105>
cmpl   $0x0,-0xc(%rbp)
je     1199 <get_data_dir+0x79>
lea    0xea2(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb6(%rip),%rdi
lea    0xe88(%rip),%rsi
call   1040 <chk_file@plt>
cmp    $0x0,%eax
jne    11c5 <get_data_dir+0xa5>
lea    0xe9a(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1225 <get_data_dir+0x105>
cmpl   $0x0,-0xc(%rbp)
je     11db <get_data_dir+0xbb>
lea    0xe9d(%rip),%rdi
call   1030 <puts@plt>
lea    0xeab(%rip),%rdi
lea    0xe46(%rip),%rsi
call   1040 <chk_file@plt>
cmp    $0x0,%eax
jne    1207 <get_data_dir+0xe7>
lea    0xe8f(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1225 <get_data_dir+0x105>
cmpl   $0x0,-0xc(%rbp)
je     121d <get_data_dir+0xfd>
lea    0xe8c(%rip),%rdi
call   1030 <puts@plt>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_data_dir>:
push   %rbp
push   %r14
push   %rbx
mov    %edi,%ebp
test   %edi,%edi
je     1194 <get_data_dir+0x74>
lea    0xecf(%rip),%rdi
call   1030 <puts@plt>
lea    0xedf(%rip),%rdi
call   1030 <puts@plt>
lea    0xede(%rip),%rbx
lea    0xedf(%rip),%rsi
mov    %rbx,%rdi
call   1040 <chk_file@plt>
test   %eax,%eax
je     11fc <get_data_dir+0xdc>
lea    0xecf(%rip),%rdi
call   1030 <puts@plt>
lea    0xee3(%rip),%rbx
lea    0xeb5(%rip),%rsi
mov    %rbx,%rdi
call   1040 <chk_file@plt>
test   %eax,%eax
je     11fc <get_data_dir+0xdc>
lea    0xee6(%rip),%rdi
call   1030 <puts@plt>
jmp    11c8 <get_data_dir+0xa8>
lea    0xe8c(%rip),%rbx
lea    0xe8d(%rip),%rsi
mov    %rbx,%rdi
call   1040 <chk_file@plt>
test   %eax,%eax
je     11fc <get_data_dir+0xdc>
lea    0xea1(%rip),%rbx
lea    0xe73(%rip),%rsi
mov    %rbx,%rdi
call   1040 <chk_file@plt>
test   %eax,%eax
je     11fc <get_data_dir+0xdc>
lea    0xebe(%rip),%r14
lea    0xe59(%rip),%rsi
mov    %r14,%rdi
call   1040 <chk_file@plt>
xor    %ebx,%ebx
test   %eax,%eax
cmove  %r14,%rbx
test   %ebp,%ebp
je     11fc <get_data_dir+0xdc>
test   %eax,%eax
je     11fc <get_data_dir+0xdc>
lea    0xeaf(%rip),%rdi
call   1030 <puts@plt>
xor    %ebx,%ebx
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [28 x i8] c"Looking for data directory:\00"
@.str.1 = [11 x i8] c"./data/ ..\00"
@.str.2 = [8 x i8] c"./data/\00"
@.str.3 = [7 x i8] c"spgraf\00"
@.str.4 = [32 x i8] c"/usr/local/share/phear/data/ ..\00"
@.str.5 = [29 x i8] c"/usr/local/share/phear/data/\00"
@.str.6 = [26 x i8] c"/usr/share/phear/data/ ..\00"
@.str.7 = [23 x i8] c"/usr/share/phear/data/\00"
@.str.8 = [15 x i8] c"Data not found\00"
define i8* @get_data_dir(i32 %0) {
%2 = alloca i8*
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
%5 = icmp ne i32 %4, 0
br i1 %5, label %6, label %8
6: ; preds = %1
%7 = call i32 @puts(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
br label %8
8: ; preds = %6, %1
%9 = load i32, i32* %3
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %8
%12 = call i32 @puts(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
br label %13
13: ; preds = %11, %8
%14 = call i32 @chk_file(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%15 = icmp ne i32 %14, 0
br i1 %15, label %17, label %16
16: ; preds = %13
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8** %2
br label %41
17: ; preds = %13
%18 = load i32, i32* %3
%19 = icmp ne i32 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %17
%21 = call i32 @puts(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0))
br label %22
22: ; preds = %20, %17
%23 = call i32 @chk_file(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%24 = icmp ne i32 %23, 0
br i1 %24, label %26, label %25
25: ; preds = %22
store i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0), i8** %2
br label %41
26: ; preds = %22
%27 = load i32, i32* %3
%28 = icmp ne i32 %27, 0
br i1 %28, label %29, label %31
29: ; preds = %26
%30 = call i32 @puts(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i64 0, i64 0))
br label %31
31: ; preds = %29, %26
%32 = call i32 @chk_file(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%33 = icmp ne i32 %32, 0
br i1 %33, label %35, label %34
34: ; preds = %31
store i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0), i8** %2
br label %41
35: ; preds = %31
%36 = load i32, i32* %3
%37 = icmp ne i32 %36, 0
br i1 %37, label %38, label %40
38: ; preds = %35
%39 = call i32 @puts(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0))
br label %40
40: ; preds = %38, %35
store i8* null, i8** %2
br label %41
41: ; preds = %40, %34, %25, %16
%42 = load i8*, i8** %2
ret i8* %42
}

LLVM IR (-O2):
@.str = [28 x i8] c"Looking for data directory:\00"
@.str.1 = [11 x i8] c"./data/ ..\00"
@.str.2 = [8 x i8] c"./data/\00"
@.str.3 = [7 x i8] c"spgraf\00"
@.str.4 = [32 x i8] c"/usr/local/share/phear/data/ ..\00"
@.str.5 = [29 x i8] c"/usr/local/share/phear/data/\00"
@.str.6 = [26 x i8] c"/usr/share/phear/data/ ..\00"
@.str.7 = [23 x i8] c"/usr/share/phear/data/\00"
@.str.8 = [15 x i8] c"Data not found\00"
define i8* @get_data_dir(i32 %0) {
%2 = icmp eq i32 %0, 0
br i1 %2, label %3, label %6
3: ; preds = %1
%4 = tail call i32 @chk_file(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%5 = icmp eq i32 %4, 0
br i1 %5, label %27, label %11
6: ; preds = %1
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%9 = tail call i32 @chk_file(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%10 = icmp eq i32 %9, 0
br i1 %10, label %27, label %14
11: ; preds = %3
%12 = tail call i32 @chk_file(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%13 = icmp eq i32 %12, 0
br i1 %13, label %27, label %20
14: ; preds = %6
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0))
%16 = tail call i32 @chk_file(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%17 = icmp eq i32 %16, 0
br i1 %17, label %27, label %18
18: ; preds = %14
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i64 0, i64 0))
br label %20
20: ; preds = %11, %18
%21 = tail call i32 @chk_file(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%22 = icmp eq i32 %21, 0
%23 = or i1 %2, %22
%24 = select i1 %22, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0), i8* null
br i1 %23, label %27, label %25
25: ; preds = %20
%26 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0))
br label %27
27: ; preds = %14, %6, %20, %25, %11, %3
%28 = phi i8* [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), %3 ], [ getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0), %11 ], [ %24, %20 ], [ null, %25 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), %6 ], [ getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0), %14 ]
ret i8* %28
}