#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 *);
int is_dir_exist(char *);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  int ret = -2;
  char *home = "HOME";
  printf("$HOME is %s\n", getenv(home));
  if ((ret = is_dir_exist(getenv(home))) == -1)
    printf("dir is not exist or dir_path is wrong\n");
  else
    printf("dir is exist!\n");
  if ((ret = is_dir_exist("ssdir_exist.c")) == -1)
    printf("ssdir_exist.c is not exist or dir_path is wrong\n");
  else
    printf("ssdir_exist.c is exist!\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xfffffffe,-0x8(%rbp)
lea    0xeb3(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <getenv@plt>
mov    %rax,%rsi
lea    0xea1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <getenv@plt>
mov    %rax,%rdi
call   1050 <is_dir_exist@plt>
mov    %eax,-0x8(%rbp)
cmp    $0xffffffff,%eax
jne    119b <main+0x6b>
lea    0xe83(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11a9 <main+0x79>
lea    0xe97(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe98(%rip),%rdi
call   1050 <is_dir_exist@plt>
mov    %eax,-0x8(%rbp)
cmp    $0xffffffff,%eax
jne    11d4 <main+0xa4>
lea    0xe8e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11e2 <main+0xb2>
lea    0xeac(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xeb8(%rip),%rbx
mov    %rbx,%rdi
call   1030 <getenv@plt>
lea    0xeae(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1030 <getenv@plt>
mov    %rax,%rdi
call   1060 <is_dir_exist@plt>
cmp    $0xffffffff,%eax
lea    0xefb(%rip),%rax
lea    0xe9e(%rip),%rdi
cmove  %rax,%rdi
call   1040 <puts@plt>
lea    0xe80(%rip),%rdi
call   1060 <is_dir_exist@plt>
cmp    $0xffffffff,%eax
lea    0xea5(%rip),%rax
lea    0xe86(%rip),%rdi
cmove  %rax,%rdi
call   1040 <puts@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [5 x i8] c"HOME\00"
@.str.1 = [13 x i8] c"$HOME is %s\0A\00"
@.str.2 = [39 x i8] c"dir is not exist or dir_path is wrong\0A\00"
@.str.3 = [15 x i8] c"dir is exist!\0A\00"
@.str.4 = [14 x i8] c"ssdir_exist.c\00"
@.str.5 = [49 x i8] c"ssdir_exist.c is not exist or dir_path is wrong\0A\00"
@.str.6 = [25 x i8] c"ssdir_exist.c is exist!\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8*
store i32 0, i32* %1
store i32 -2, i32* %2
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %3
%4 = load i8*, i8** %3
%5 = call i8* @getenv(i8* %4)
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* %5)
%7 = load i8*, i8** %3
%8 = call i8* @getenv(i8* %7)
%9 = call i32 @is_dir_exist(i8* %8)
store i32 %9, i32* %2
%10 = icmp eq i32 %9, -1
br i1 %10, label %11, label %13
11: ; preds = %0
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0))
br label %15
13: ; preds = %0
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
br label %15
15: ; preds = %13, %11
%16 = call i32 @is_dir_exist(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0))
store i32 %16, i32* %2
%17 = icmp eq i32 %16, -1
br i1 %17, label %18, label %20
18: ; preds = %15
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.5, i64 0, i64 0))
br label %22
20: ; preds = %15
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0))
br label %22
22: ; preds = %20, %18
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"HOME\00"
@.str.1 = [13 x i8] c"$HOME is %s\0A\00"
@.str.4 = [14 x i8] c"ssdir_exist.c\00"
@str = [14 x i8] c"dir is exist!\00"
@str.7 = [24 x i8] c"ssdir_exist.c is exist!\00"
@str.8 = [48 x i8] c"ssdir_exist.c is not exist or dir_path is wrong\00"
@str.9 = [38 x i8] c"dir is not exist or dir_path is wrong\00"
define i32 @main() {
%1 = tail call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* %1)
%3 = tail call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 @is_dir_exist(i8* %3)
%5 = icmp eq i32 %4, -1
%6 = select i1 %5, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @str.9, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0)
%7 = tail call i32 @puts(i8* dereferenceable(1) %6)
%8 = tail call i32 @is_dir_exist(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0))
%9 = icmp eq i32 %8, -1
%10 = select i1 %9, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @str.8, i64 0, i64 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @str.7, i64 0, i64 0)
%11 = tail call i32 @puts(i8* dereferenceable(1) %10)
ret i32 0
}