#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 *);
char *strstr(char *, char *);
int fingerprint_filematch(const struct dirent *e) {
  if (e->d_name[0] == '.')
    return 0;
  char *s = strstr(e->d_name, ".raw");
  if (!s)
    return 0;
  if (e->d_name + strlen(e->d_name) - s == 4)
    return 1;
  return 0;
}


x86 assembly (clang, -O0):
<fingerprint_filematch>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
jne    114b <fingerprint_filematch+0x2b>
movl   $0x0,-0x4(%rbp)
jmp    11c0 <fingerprint_filematch+0xa0>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xea7(%rip),%rsi
call   1040 <strstr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1179 <fingerprint_filematch+0x59>
movl   $0x0,-0x4(%rbp)
jmp    11c0 <fingerprint_filematch+0xa0>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    -0x18(%rbp),%rcx
sub    %rcx,%rax
cmp    $0x4,%rax
jne    11b9 <fingerprint_filematch+0x99>
movl   $0x1,-0x4(%rbp)
jmp    11c0 <fingerprint_filematch+0xa0>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fingerprint_filematch>:
push   %rbp
push   %r14
push   %rbx
mov    (%rdi),%rbx
xor    %ebp,%ebp
cmpb   $0x2e,(%rbx)
je     115f <fingerprint_filematch+0x3f>
lea    0xecb(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strstr@plt>
test   %rax,%rax
je     115f <fingerprint_filematch+0x3f>
mov    %rax,%r14
mov    %rbx,%rdi
call   1030 <strlen@plt>
cltq
add    %rbx,%rax
sub    %r14,%rax
xor    %ebp,%ebp
cmp    $0x4,%rax
sete   %bpl
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.dirent = type { i8* }
@.str = [5 x i8] c".raw\00"
define i32 @fingerprint_filematch(%struct.dirent* %0) {
%2 = alloca i32
%3 = alloca %struct.dirent*
%4 = alloca i8*
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 %12, label %13
12: ; preds = %1
store i32 0, i32* %2
br label %38
13: ; preds = %1
%14 = load %struct.dirent*, %struct.dirent** %3
%15 = getelementptr inbounds %struct.dirent, %struct.dirent* %14, i32 0, i32 0
%16 = load i8*, i8** %15
%17 = call i8* @strstr(i8* %16, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i8* %17, i8** %4
%18 = load i8*, i8** %4
%19 = icmp ne i8* %18, null
br i1 %19, label %21, label %20
20: ; preds = %13
store i32 0, i32* %2
br label %38
21: ; preds = %13
%22 = load %struct.dirent*, %struct.dirent** %3
%23 = getelementptr inbounds %struct.dirent, %struct.dirent* %22, i32 0, i32 0
%24 = load i8*, i8** %23
%25 = load %struct.dirent*, %struct.dirent** %3
%26 = getelementptr inbounds %struct.dirent, %struct.dirent* %25, i32 0, i32 0
%27 = load i8*, i8** %26
%28 = call i32 @strlen(i8* %27)
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8, i8* %24, i64 %29
%31 = load i8*, i8** %4
%32 = ptrtoint i8* %30 to i64
%33 = ptrtoint i8* %31 to i64
%34 = sub i64 %32, %33
%35 = icmp eq i64 %34, 4
br i1 %35, label %36, label %37
36: ; preds = %21
store i32 1, i32* %2
br label %38
37: ; preds = %21
store i32 0, i32* %2
br label %38
38: ; preds = %37, %36, %20, %12
%39 = load i32, i32* %2
ret i32 %39
}

LLVM IR (-O2):
%struct.dirent = type { i8* }
@.str = [5 x i8] c".raw\00"
define i32 @fingerprint_filematch(%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 %18, label %6
6: ; preds = %1
%7 = tail call i8* @strstr(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i8* %7, null
br i1 %8, label %18, label %9
9: ; preds = %6
%10 = tail call i32 @strlen(i8* %3)
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds i8, i8* %3, i64 %11
%13 = ptrtoint i8* %12 to i64
%14 = ptrtoint i8* %7 to i64
%15 = sub i64 %13, %14
%16 = icmp eq i64 %15, 4
%17 = zext i1 %16 to i32
br label %18
18: ; preds = %6, %9, %1
%19 = phi i32 [ 0, %1 ], [ 0, %6 ], [ %17, %9 ]
ret i32 %19
}