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

/* Variables and functions */
int strlen(char *);
int filtro(const struct dirent *d) {
  int n = strlen(d->d_name);
  return (d->d_name[n - 1] == 'X' && d->d_name[n - 2] == '.');
}


x86 assembly (clang, -O0):
<filtro>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
call   1030 <strlen@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%ecx
xor    %eax,%eax
cmp    $0x58,%ecx
mov    %al,-0xd(%rbp)
jne    116a <filtro+0x5a>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    -0xc(%rbp),%ecx
sub    $0x2,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2e,%eax
sete   %al
mov    %al,-0xd(%rbp)
mov    -0xd(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<filtro>:
push   %rbx
mov    %rdi,%rbx
mov    (%rdi),%rdi
call   1030 <strlen@plt>
mov    (%rbx),%rcx
movslq %eax,%rdx
xor    %eax,%eax
cmpb   $0x58,-0x1(%rdx,%rcx,1)
jne    1135 <filtro+0x25>
xor    %eax,%eax
cmpb   $0x2e,-0x2(%rdx,%rcx,1)
sete   %al
pop    %rbx
ret

LLVM IR (-O0):
%struct.dirent = type { i8* }
define i32 @filtro(%struct.dirent* %0) {
%2 = alloca %struct.dirent*
%3 = alloca i32
store %struct.dirent* %0, %struct.dirent** %2
%4 = load %struct.dirent*, %struct.dirent** %2
%5 = getelementptr inbounds %struct.dirent, %struct.dirent* %4, i32 0, i32 0
%6 = load i8*, i8** %5
%7 = call i32 @strlen(i8* %6)
store i32 %7, i32* %3
%8 = load %struct.dirent*, %struct.dirent** %2
%9 = getelementptr inbounds %struct.dirent, %struct.dirent* %8, i32 0, i32 0
%10 = load i8*, i8** %9
%11 = load i32, i32* %3
%12 = sub nsw i32 %11, 1
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8, i8* %10, i64 %13
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp eq i32 %16, 88
br i1 %17, label %18, label %29
18: ; preds = %1
%19 = load %struct.dirent*, %struct.dirent** %2
%20 = getelementptr inbounds %struct.dirent, %struct.dirent* %19, i32 0, i32 0
%21 = load i8*, i8** %20
%22 = load i32, i32* %3
%23 = sub nsw i32 %22, 2
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %21, i64 %24
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = icmp eq i32 %27, 46
br label %29
29: ; preds = %18, %1
%30 = phi i1 [ false, %1 ], [ %28, %18 ]
%31 = zext i1 %30 to i32
ret i32 %31
}

LLVM IR (-O2):
%struct.dirent = type { i8* }
define i32 @filtro(%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 @strlen(i8* %3)
%5 = load i8*, i8** %2
%6 = add nsw i32 %4, -1
%7 = sext i32 %6 to i64
%8 = getelementptr inbounds i8, i8* %5, i64 %7
%9 = load i8, i8* %8
%10 = icmp eq i8 %9, 88
br i1 %10, label %11, label %18
11: ; preds = %1
%12 = add nsw i32 %4, -2
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8, i8* %5, i64 %13
%15 = load i8, i8* %14
%16 = icmp eq i8 %15, 46
%17 = zext i1 %16 to i32
br label %18
18: ; preds = %11, %1
%19 = phi i32 [ 0, %1 ], [ %17, %11 ]
ret i32 %19
}