#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_LNK;
scalar_t__ DT_REG;
scalar_t__ DT_UNKNOWN;
scalar_t__ is_image(char *);
int filter_images(const struct dirent *d) {
  return ((*d->d_name != '.') &&
          ((d->d_type == DT_DIR) || (d->d_type == DT_LNK) ||
           (d->d_type == DT_UNKNOWN) ||
           ((d->d_type == DT_REG) && is_image(d->d_name))));
}


x86 assembly (clang, -O0):
<filter_images>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x2e,%ecx
mov    %al,-0x9(%rbp)
je     11ca <filter_images+0xba>
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rcx
mov    $0x1,%al
mov    0x2e8b(%rip),%rdx
cmp    (%rdx),%rcx
mov    %al,-0xa(%rbp)
je     11c4 <filter_images+0xb4>
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rcx
mov    $0x1,%al
mov    0x2e66(%rip),%rdx
cmp    (%rdx),%rcx
mov    %al,-0xa(%rbp)
je     11c4 <filter_images+0xb4>
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rcx
mov    $0x1,%al
mov    0x2e69(%rip),%rdx
cmp    (%rdx),%rcx
mov    %al,-0xa(%rbp)
je     11c4 <filter_images+0xb4>
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rcx
xor    %eax,%eax
mov    0x2e3c(%rip),%rdx
cmp    (%rdx),%rcx
mov    %al,-0xb(%rbp)
jne    11be <filter_images+0xae>
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
call   1030 <is_image@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0xb(%rbp)
mov    -0xb(%rbp),%al
mov    %al,-0xa(%rbp)
mov    -0xa(%rbp),%al
mov    %al,-0x9(%rbp)
mov    -0x9(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<filter_images>:
push   %rax
mov    %rdi,%rcx
mov    (%rdi),%rdi
xor    %eax,%eax
cmpb   $0x2e,(%rdi)
je     116c <filter_images+0x5c>
mov    0x8(%rcx),%rcx
mov    0x2ea7(%rip),%rdx
mov    $0x1,%eax
cmp    (%rdx),%rcx
je     116c <filter_images+0x5c>
mov    0x2e8e(%rip),%rdx
cmp    (%rdx),%rcx
je     116c <filter_images+0x5c>
mov    0x2ea2(%rip),%rdx
cmp    (%rdx),%rcx
je     116c <filter_images+0x5c>
mov    0x2e86(%rip),%rdx
mov    $0x0,%eax
cmp    (%rdx),%rcx
jne    116c <filter_images+0x5c>
call   1030 <is_image@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
setne  %al
pop    %rcx
ret

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

LLVM IR (-O2):
%struct.dirent = type { i8*, i64 }
@DT_DIR = global i64 0
@DT_LNK = global i64 0
@DT_UNKNOWN = global i64 0
@DT_REG = global i64 0
define i32 @filter_images(%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 %24, label %6
6: ; preds = %1
%7 = getelementptr inbounds %struct.dirent, %struct.dirent* %0, i64 0, i32 1
%8 = load i64, i64* %7
%9 = load i64, i64* @DT_DIR
%10 = icmp eq i64 %8, %9
%11 = load i64, i64* @DT_LNK
%12 = icmp eq i64 %8, %11
%13 = select i1 %10, i1 true, i1 %12
%14 = load i64, i64* @DT_UNKNOWN
%15 = icmp eq i64 %8, %14
%16 = select i1 %13, i1 true, i1 %15
br i1 %16, label %24, label %17
17: ; preds = %6
%18 = load i64, i64* @DT_REG
%19 = icmp eq i64 %8, %18
br i1 %19, label %20, label %24
20: ; preds = %17
%21 = tail call i64 @is_image(i8* %3)
%22 = icmp ne i64 %21, 0
%23 = zext i1 %22 to i32
br label %24
24: ; preds = %6, %20, %17, %1
%25 = phi i32 [ 0, %1 ], [ 1, %6 ], [ 0, %17 ], [ %23, %20 ]
ret i32 %25
}