#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 dirent {
  char *d_name;
};

/* Variables and functions */
int PATH_MAX;
int /*<<< orphan*/ R_OK;
int access(char *, int /*<<< orphan*/);
int /*<<< orphan*/ dwarnx(char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, char *);
int homedir_selector(const struct dirent *directory) {
  char path[PATH_MAX];
  sprintf(path, "/home/%s/.birthday", directory->d_name);
  dwarnx("checking for %s", path);
  return access(path, R_OK) != -1;
}


x86 assembly (clang, -O0):
<homedir_selector>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    0x2ead(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x10(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x20(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rdx
lea    0xe8a(%rip),%rsi
call   1050 <sprintf@plt>
mov    -0x20(%rbp),%rsi
lea    0xe8d(%rip),%rdi
call   1030 <dwarnx@plt>
mov    -0x20(%rbp),%rdi
mov    0x2e42(%rip),%rax
mov    (%rax),%esi
call   1040 <access@plt>
cmp    $0xffffffff,%eax
setne  %al
and    $0x1,%al
movzbl %al,%eax
mov    -0x10(%rbp),%rcx
mov    %rcx,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<homedir_selector>:
push   %rbp
mov    %rsp,%rbp
push   %rbx
push   %rax
mov    0x2eb3(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rbx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
mov    (%rdi),%rdx
lea    0xea6(%rip),%rsi
mov    %rbx,%rdi
call   1050 <sprintf@plt>
lea    0xeaa(%rip),%rdi
mov    %rbx,%rsi
call   1030 <dwarnx@plt>
mov    0x2e60(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   1040 <access@plt>
xor    %ecx,%ecx
cmp    $0xffffffff,%eax
setne  %cl
mov    %ecx,%eax
lea    -0x8(%rbp),%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.dirent = type { i8* }
@PATH_MAX = global i32 0
@.str = [19 x i8] c"/home/%s/.birthday\00"
@.str.1 = [16 x i8] c"checking for %s\00"
@R_OK = global i32 0
define i32 @homedir_selector(%struct.dirent* %0) {
%2 = alloca %struct.dirent*
%3 = alloca i8*
%4 = alloca i64
store %struct.dirent* %0, %struct.dirent** %2
%5 = load i32, i32* @PATH_MAX
%6 = zext i32 %5 to i64
%7 = call i8* @llvm.stacksave()
store i8* %7, i8** %3
%8 = alloca i8, i64 %6
store i64 %6, i64* %4
%9 = load %struct.dirent*, %struct.dirent** %2
%10 = getelementptr inbounds %struct.dirent, %struct.dirent* %9, i32 0, i32 0
%11 = load i8*, i8** %10
%12 = call i32 @sprintf(i8* %8, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %11)
%13 = call i32 @dwarnx(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %8)
%14 = load i32, i32* @R_OK
%15 = call i32 @access(i8* %8, i32 %14)
%16 = icmp ne i32 %15, -1
%17 = zext i1 %16 to i32
%18 = load i8*, i8** %3
ret i32 %17
}

LLVM IR (-O2):
%struct.dirent = type { i8* }
@PATH_MAX = global i32 0
@.str = [19 x i8] c"/home/%s/.birthday\00"
@.str.1 = [16 x i8] c"checking for %s\00"
@R_OK = global i32 0
define i32 @homedir_selector(%struct.dirent* nocapture %0) {
%2 = load i32, i32* @PATH_MAX
%3 = zext i32 %2 to i64
%4 = alloca i8, i64 %3
%5 = getelementptr inbounds %struct.dirent, %struct.dirent* %0, i64 0, i32 0
%6 = load i8*, i8** %5
%7 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = call i32 @dwarnx(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%9 = load i32, i32* @R_OK
%10 = call i32 @access(i8* %4, i32 %9)
%11 = icmp ne i32 %10, -1
%12 = zext i1 %11 to i32
ret i32 %12
}