#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 */
size_t strlen(char const *);
char *strstr(char const *, char const *);
int accept_triggerfile(const struct dirent *entry) {
  const char *suffix = ".conf";
  const char *name = entry->d_name;
  char *end = strstr(name, suffix);
  if (end && end[strlen(suffix)] == '\0') {
    return 1;
  } else {
    return 0;
  }
}


x86 assembly (clang, -O0):
<accept_triggerfile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
lea    0xecd(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <strstr@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     118f <accept_triggerfile+0x6f>
mov    -0x28(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,%rcx
mov    -0x30(%rbp),%rax
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
jne    118f <accept_triggerfile+0x6f>
movl   $0x1,-0x4(%rbp)
jmp    1196 <accept_triggerfile+0x76>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<accept_triggerfile>:
push   %rax
mov    (%rdi),%rdi
lea    0xee5(%rip),%rsi
call   1030 <strstr@plt>
test   %rax,%rax
je     112b <accept_triggerfile+0x1b>
cmpb   $0x0,0x5(%rax)
je     112f <accept_triggerfile+0x1f>
xor    %eax,%eax
pop    %rcx
ret
mov    $0x1,%eax
pop    %rcx
ret

LLVM IR (-O0):
%struct.dirent = type { i8* }
@.str = [6 x i8] c".conf\00"
define i32 @accept_triggerfile(%struct.dirent* %0) {
%2 = alloca i32
%3 = alloca %struct.dirent*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
store %struct.dirent* %0, %struct.dirent** %3
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8** %4
%7 = load %struct.dirent*, %struct.dirent** %3
%8 = getelementptr inbounds %struct.dirent, %struct.dirent* %7, i32 0, i32 0
%9 = load i8*, i8** %8
store i8* %9, i8** %5
%10 = load i8*, i8** %5
%11 = load i8*, i8** %4
%12 = call i8* @strstr(i8* %10, i8* %11)
store i8* %12, i8** %6
%13 = load i8*, i8** %6
%14 = icmp ne i8* %13, null
br i1 %14, label %15, label %24
15: ; preds = %1
%16 = load i8*, i8** %6
%17 = load i8*, i8** %4
%18 = call i64 @strlen(i8* %17)
%19 = getelementptr inbounds i8, i8* %16, i64 %18
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %24
23: ; preds = %15
store i32 1, i32* %2
br label %25
24: ; preds = %15, %1
store i32 0, i32* %2
br label %25
25: ; preds = %24, %23
%26 = load i32, i32* %2
ret i32 %26
}

LLVM IR (-O2):
%struct.dirent = type { i8* }
@.str = [6 x i8] c".conf\00"
define i32 @accept_triggerfile(%struct.dirent* nocapture %0) {
%2 = getelementptr inbounds %struct.dirent, %struct.dirent* %0, i64 0, i32 0
%3 = load i8*, i8** %2
%4 = tail call i8* @strstr(i8* dereferenceable(1) %3, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i8* %4, null
br i1 %5, label %10, label %6
6: ; preds = %1
%7 = getelementptr inbounds i8, i8* %4, i64 5
%8 = load i8, i8* %7
%9 = icmp eq i8 %8, 0
br i1 %9, label %11, label %10
10: ; preds = %6, %1
br label %11
11: ; preds = %6, %10
%12 = phi i32 [ 0, %10 ], [ 1, %6 ]
ret i32 %12
}