#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 {
  scalar_t__ d_type;
  int /*<<< orphan*/ d_name;
};

/* Variables and functions */
scalar_t__ DT_REG;
int /*<<< orphan*/ R_OK;
int access(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ strncmp(int /*<<< orphan*/, char *, int);
int input_filter(const struct dirent *entry) {
  if (access(entry->d_name, R_OK) == -1)
    return 0;
  if (entry->d_type != DT_REG)
    return 0;
  return !strncmp(entry->d_name, "input", 5);
}


x86 assembly (clang, -O0):
<input_filter>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%edi
mov    0x2e9e(%rip),%rax
mov    (%rax),%esi
call   1040 <access@plt>
cmp    $0xffffffff,%eax
jne    1156 <input_filter+0x36>
movl   $0x0,-0x4(%rbp)
jmp    11a1 <input_filter+0x81>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    0x2e7c(%rip),%rcx
cmp    (%rcx),%rax
je     1179 <input_filter+0x59>
movl   $0x0,-0x4(%rbp)
jmp    11a1 <input_filter+0x81>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%edi
lea    0xe79(%rip),%rsi
mov    $0x5,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<input_filter>:
push   %rbx
mov    %rdi,%rbx
mov    0x8(%rdi),%edi
mov    0x2eaa(%rip),%rax
mov    (%rax),%esi
call   1040 <access@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0xffffffff,%ecx
je     116a <input_filter+0x4a>
mov    (%rbx),%rcx
mov    0x2e98(%rip),%rdx
cmp    (%rdx),%rcx
jne    116a <input_filter+0x4a>
mov    0x8(%rbx),%edi
lea    0xea9(%rip),%rsi
mov    $0x5,%edx
call   1030 <strncmp@plt>
mov    %eax,%ecx
xor    %eax,%eax
test   %ecx,%ecx
sete   %al
pop    %rbx
ret

LLVM IR (-O0):
%struct.dirent = type { i64, i32 }
@R_OK = global i32 0
@DT_REG = global i64 0
@.str = [6 x i8] c"input\00"
define i32 @input_filter(%struct.dirent* %0) {
%2 = alloca i32
%3 = alloca %struct.dirent*
store %struct.dirent* %0, %struct.dirent** %3
%4 = load %struct.dirent*, %struct.dirent** %3
%5 = getelementptr inbounds %struct.dirent, %struct.dirent* %4, i32 0, i32 1
%6 = load i32, i32* %5
%7 = load i32, i32* @R_OK
%8 = call i32 @access(i32 %6, i32 %7)
%9 = icmp eq i32 %8, -1
br i1 %9, label %10, label %11
10: ; preds = %1
store i32 0, i32* %2
br label %26
11: ; preds = %1
%12 = load %struct.dirent*, %struct.dirent** %3
%13 = getelementptr inbounds %struct.dirent, %struct.dirent* %12, i32 0, i32 0
%14 = load i64, i64* %13
%15 = load i64, i64* @DT_REG
%16 = icmp ne i64 %14, %15
br i1 %16, label %17, label %18
17: ; preds = %11
store i32 0, i32* %2
br label %26
18: ; preds = %11
%19 = load %struct.dirent*, %struct.dirent** %3
%20 = getelementptr inbounds %struct.dirent, %struct.dirent* %19, i32 0, i32 1
%21 = load i32, i32* %20
%22 = call i32 @strncmp(i32 %21, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 5)
%23 = icmp ne i32 %22, 0
%24 = xor i1 %23, true
%25 = zext i1 %24 to i32
store i32 %25, i32* %2
br label %26
26: ; preds = %18, %17, %10
%27 = load i32, i32* %2
ret i32 %27
}

LLVM IR (-O2):
%struct.dirent = type { i64, i32 }
@R_OK = global i32 0
@DT_REG = global i64 0
@.str = [6 x i8] c"input\00"
define i32 @input_filter(%struct.dirent* nocapture %0) {
%2 = getelementptr inbounds %struct.dirent, %struct.dirent* %0, i64 0, i32 1
%3 = load i32, i32* %2
%4 = load i32, i32* @R_OK
%5 = tail call i32 @access(i32 %3, i32 %4)
%6 = icmp eq i32 %5, -1
br i1 %6, label %17, label %7
7: ; preds = %1
%8 = getelementptr inbounds %struct.dirent, %struct.dirent* %0, i64 0, i32 0
%9 = load i64, i64* %8
%10 = load i64, i64* @DT_REG
%11 = icmp eq i64 %9, %10
br i1 %11, label %12, label %17
12: ; preds = %7
%13 = load i32, i32* %2
%14 = tail call i32 @strncmp(i32 %13, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 5)
%15 = icmp eq i32 %14, 0
%16 = zext i1 %15 to i32
br label %17
17: ; preds = %7, %1, %12
%18 = phi i32 [ %16, %12 ], [ 0, %1 ], [ 0, %7 ]
ret i32 %18
}