#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;
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_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     11ad <filter_images+0x9d>
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rcx
mov    $0x1,%al
mov    0x2e8b(%rip),%rdx
cmp    (%rdx),%rcx
mov    %al,-0xa(%rbp)
je     11a7 <filter_images+0x97>
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rcx
mov    $0x1,%al
mov    0x2e86(%rip),%rdx
cmp    (%rdx),%rcx
mov    %al,-0xa(%rbp)
je     11a7 <filter_images+0x97>
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rcx
xor    %eax,%eax
mov    0x2e59(%rip),%rdx
cmp    (%rdx),%rcx
mov    %al,-0xb(%rbp)
jne    11a1 <filter_images+0x91>
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     1160 <filter_images+0x50>
mov    0x8(%rcx),%rcx
mov    0x2ea7(%rip),%rdx
mov    $0x1,%eax
cmp    (%rdx),%rcx
je     1160 <filter_images+0x50>
mov    0x2eae(%rip),%rdx
cmp    (%rdx),%rcx
je     1160 <filter_images+0x50>
mov    0x2e92(%rip),%rdx
mov    $0x0,%eax
cmp    (%rdx),%rcx
jne    1160 <filter_images+0x50>
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_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 %37
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 %35, 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_UNKNOWN
%20 = icmp eq i64 %18, %19
br i1 %20, label %35, 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_REG
%26 = icmp eq i64 %24, %25
br i1 %26, label %27, label %33
27: ; preds = %21
%28 = load %struct.dirent*, %struct.dirent** %2
%29 = getelementptr inbounds %struct.dirent, %struct.dirent* %28, i32 0, i32 0
%30 = load i8*, i8** %29
%31 = call i64 @is_image(i8* %30)
%32 = icmp ne i64 %31, 0
br label %33
33: ; preds = %27, %21
%34 = phi i1 [ false, %21 ], [ %32, %27 ]
br label %35
35: ; preds = %33, %15, %9
%36 = phi i1 [ true, %15 ], [ true, %9 ], [ %34, %33 ]
br label %37
37: ; preds = %35, %1
%38 = phi i1 [ false, %1 ], [ %36, %35 ]
%39 = zext i1 %38 to i32
ret i32 %39
}

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