#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;
  scalar_t__ d_type;
};

/* Variables and functions */
scalar_t__ DT_DIR;
scalar_t__ DT_REG;
int /*<<< orphan*/ strcmp(char *, char *);
int file_filter(const struct dirent *entry) {
  if (!strcmp(entry->d_name, ".."))
    return 0;
  if (entry->d_name[0] == '.')
    return 0;
  if (entry->d_type == DT_DIR)
    return 1;
  if (entry->d_type == DT_REG)
    return 1;
  return 0;
}


x86 assembly (clang, -O0):
<file_filter>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xed6(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    1144 <file_filter+0x34>
movl   $0x0,-0x4(%rbp)
jmp    11b2 <file_filter+0xa2>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
jne    1163 <file_filter+0x53>
movl   $0x0,-0x4(%rbp)
jmp    11b2 <file_filter+0xa2>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    0x2e66(%rip),%rcx
cmp    (%rcx),%rax
jne    1187 <file_filter+0x77>
movl   $0x1,-0x4(%rbp)
jmp    11b2 <file_filter+0xa2>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    0x2e4a(%rip),%rcx
cmp    (%rcx),%rax
jne    11ab <file_filter+0x9b>
movl   $0x1,-0x4(%rbp)
jmp    11b2 <file_filter+0xa2>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<file_filter>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    (%rdi),%rbx
lea    0xedf(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
mov    %eax,%ecx
xor    %eax,%eax
test   %ecx,%ecx
je     115a <file_filter+0x4a>
cmpb   $0x2e,(%rbx)
je     115a <file_filter+0x4a>
mov    0x8(%r14),%rcx
mov    0x2e97(%rip),%rdx
mov    $0x1,%eax
cmp    (%rdx),%rcx
je     115a <file_filter+0x4a>
mov    0x2e8e(%rip),%rdx
xor    %eax,%eax
cmp    (%rdx),%rcx
sete   %al
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.dirent = type { i8*, i64 }
@.str = [3 x i8] c"..\00"
@DT_DIR = global i64 0
@DT_REG = global i64 0
define i32 @file_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 0
%6 = load i8*, i8** %5
%7 = call i32 @strcmp(i8* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%8 = icmp ne i32 %7, 0
br i1 %8, label %10, label %9
9: ; preds = %1
store i32 0, i32* %2
br label %34
10: ; preds = %1
%11 = load %struct.dirent*, %struct.dirent** %3
%12 = getelementptr inbounds %struct.dirent, %struct.dirent* %11, i32 0, i32 0
%13 = load i8*, i8** %12
%14 = getelementptr inbounds i8, i8* %13, i64 0
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp eq i32 %16, 46
br i1 %17, label %18, label %19
18: ; preds = %10
store i32 0, i32* %2
br label %34
19: ; preds = %10
%20 = load %struct.dirent*, %struct.dirent** %3
%21 = getelementptr inbounds %struct.dirent, %struct.dirent* %20, i32 0, i32 1
%22 = load i64, i64* %21
%23 = load i64, i64* @DT_DIR
%24 = icmp eq i64 %22, %23
br i1 %24, label %25, label %26
25: ; preds = %19
store i32 1, i32* %2
br label %34
26: ; preds = %19
%27 = load %struct.dirent*, %struct.dirent** %3
%28 = getelementptr inbounds %struct.dirent, %struct.dirent* %27, i32 0, i32 1
%29 = load i64, i64* %28
%30 = load i64, i64* @DT_REG
%31 = icmp eq i64 %29, %30
br i1 %31, label %32, label %33
32: ; preds = %26
store i32 1, i32* %2
br label %34
33: ; preds = %26
store i32 0, i32* %2
br label %34
34: ; preds = %33, %32, %25, %18, %9
%35 = load i32, i32* %2
ret i32 %35
}

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