#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__ strcmp(char *, char *);
int filter_directories(const struct dirent *dir) {
  int is_hidden = (dir->d_name[0] == '.') || (strcmp(dir->d_name, ".") == 0 ||
                                              strcmp(dir->d_name, "..") == 0);
  if (is_hidden && dir->d_type == DT_DIR)
    return 0;
  if (dir->d_type == DT_DIR)
    return 1;
  return 0;
}


x86 assembly (clang, -O0):
<filter_directories>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%ecx
mov    $0x1,%al
cmp    $0x2e,%ecx
mov    %al,-0x15(%rbp)
je     117c <filter_directories+0x6c>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xebf(%rip),%rsi
call   1030 <strcmp@plt>
mov    %rax,%rcx
mov    $0x1,%al
cmp    $0x0,%rcx
mov    %al,-0x16(%rbp)
je     1176 <filter_directories+0x66>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xe99(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
sete   %al
mov    %al,-0x16(%rbp)
mov    -0x16(%rbp),%al
mov    %al,-0x15(%rbp)
mov    -0x15(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     11b5 <filter_directories+0xa5>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    0x2e40(%rip),%rcx
cmp    (%rcx),%rax
jne    11b5 <filter_directories+0xa5>
movl   $0x0,-0x4(%rbp)
jmp    11e0 <filter_directories+0xd0>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    0x2e1c(%rip),%rcx
cmp    (%rcx),%rax
jne    11d9 <filter_directories+0xc9>
movl   $0x1,-0x4(%rbp)
jmp    11e0 <filter_directories+0xd0>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<filter_directories>:
push   %rbx
mov    %rdi,%rbx
mov    (%rdi),%rdi
cmpb   $0x2e,(%rdi)
je     1151 <filter_directories+0x41>
lea    0xede(%rip),%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1151 <filter_directories+0x41>
mov    (%rbx),%rdi
lea    0xec9(%rip),%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1151 <filter_directories+0x41>
mov    0x8(%rbx),%rcx
mov    0x2e94(%rip),%rax
mov    (%rax),%rdx
jmp    1166 <filter_directories+0x56>
mov    0x8(%rbx),%rcx
mov    0x2e84(%rip),%rax
mov    (%rax),%rdx
xor    %eax,%eax
cmp    %rdx,%rcx
je     116e <filter_directories+0x5e>
xor    %eax,%eax
cmp    %rdx,%rcx
sete   %al
pop    %rbx
ret

LLVM IR (-O0):
%struct.dirent = type { i8*, i64 }
@.str = [2 x i8] c".\00"
@.str.1 = [3 x i8] c"..\00"
@DT_DIR = global i64 0
define i32 @filter_directories(%struct.dirent* %0) {
%2 = alloca i32
%3 = alloca %struct.dirent*
%4 = alloca i32
store %struct.dirent* %0, %struct.dirent** %3
%5 = load %struct.dirent*, %struct.dirent** %3
%6 = getelementptr inbounds %struct.dirent, %struct.dirent* %5, i32 0, i32 0
%7 = load i8*, i8** %6
%8 = getelementptr inbounds i8, i8* %7, i64 0
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
%11 = icmp eq i32 %10, 46
br i1 %11, label %26, label %12
12: ; preds = %1
%13 = load %struct.dirent*, %struct.dirent** %3
%14 = getelementptr inbounds %struct.dirent, %struct.dirent* %13, i32 0, i32 0
%15 = load i8*, i8** %14
%16 = call i64 @strcmp(i8* %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%17 = icmp eq i64 %16, 0
br i1 %17, label %24, label %18
18: ; preds = %12
%19 = load %struct.dirent*, %struct.dirent** %3
%20 = getelementptr inbounds %struct.dirent, %struct.dirent* %19, i32 0, i32 0
%21 = load i8*, i8** %20
%22 = call i64 @strcmp(i8* %21, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
br label %24
24: ; preds = %18, %12
%25 = phi i1 [ true, %12 ], [ %23, %18 ]
br label %26
26: ; preds = %24, %1
%27 = phi i1 [ true, %1 ], [ %25, %24 ]
%28 = zext i1 %27 to i32
store i32 %28, i32* %4
%29 = load i32, i32* %4
%30 = icmp ne i32 %29, 0
br i1 %30, label %31, label %38
31: ; preds = %26
%32 = load %struct.dirent*, %struct.dirent** %3
%33 = getelementptr inbounds %struct.dirent, %struct.dirent* %32, i32 0, i32 1
%34 = load i64, i64* %33
%35 = load i64, i64* @DT_DIR
%36 = icmp eq i64 %34, %35
br i1 %36, label %37, label %38
37: ; preds = %31
store i32 0, i32* %2
br label %46
38: ; preds = %31, %26
%39 = load %struct.dirent*, %struct.dirent** %3
%40 = getelementptr inbounds %struct.dirent, %struct.dirent* %39, i32 0, i32 1
%41 = load i64, i64* %40
%42 = load i64, i64* @DT_DIR
%43 = icmp eq i64 %41, %42
br i1 %43, label %44, label %45
44: ; preds = %38
store i32 1, i32* %2
br label %46
45: ; preds = %38
store i32 0, i32* %2
br label %46
46: ; preds = %45, %44, %37
%47 = load i32, i32* %2
ret i32 %47
}

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