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

/* Variables and functions */
scalar_t__ strcmp(int /*<<< orphan*/, char *);
int strpos(int /*<<< orphan*/, char, int /*<<< orphan*/);
int is_file_valid(struct dirent *file) {
  if (strcmp(file->d_name, ".") == 0)
    return !1;
  if (strcmp(file->d_name, "..") == 0)
    return !1;
  if ((file->d_type != 8) && (file->d_type != 4))
    return !1;
  if (strpos(file->d_name, '$', 0) != -1)
    return !1;
  return 1;
}


x86 assembly (clang, -O0):
<is_file_valid>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%edi
lea    0xec7(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1155 <is_file_valid+0x35>
movl   $0x0,-0x4(%rbp)
jmp    11d3 <is_file_valid+0xb3>
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%edi
lea    0xe9d(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    117e <is_file_valid+0x5e>
movl   $0x0,-0x4(%rbp)
jmp    11d3 <is_file_valid+0xb3>
mov    -0x10(%rbp),%rax
cmpl   $0x8,(%rax)
je     11a4 <is_file_valid+0x84>
mov    -0x10(%rbp),%rax
cmpl   $0x4,(%rax)
je     11a4 <is_file_valid+0x84>
movl   $0x0,-0x4(%rbp)
jmp    11d3 <is_file_valid+0xb3>
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%edi
mov    $0x24,%esi
xor    %edx,%edx
call   1040 <strpos@plt>
cmp    $0xffffffff,%eax
je     11cc <is_file_valid+0xac>
movl   $0x0,-0x4(%rbp)
jmp    11d3 <is_file_valid+0xb3>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_file_valid>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    0x4(%rdi),%edi
lea    0xed1(%rip),%rsi
call   1030 <strcmp@plt>
xor    %ebp,%ebp
test   %rax,%rax
je     1174 <is_file_valid+0x54>
mov    0x4(%rbx),%edi
lea    0xeba(%rip),%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1174 <is_file_valid+0x54>
mov    (%rbx),%eax
cmp    $0x8,%eax
je     115c <is_file_valid+0x3c>
cmp    $0x4,%eax
jne    1174 <is_file_valid+0x54>
mov    0x4(%rbx),%edi
mov    $0x24,%esi
xor    %edx,%edx
call   1040 <strpos@plt>
xor    %ebp,%ebp
cmp    $0xffffffff,%eax
sete   %bpl
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

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