#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 {
  scalar_t__ d_type;
  int /*<<< orphan*/ *d_name;
};

/* Variables and functions */
scalar_t__ DT_DIR;
size_t strlen(int /*<<< orphan*/ *);
scalar_t__ strncmp(int /*<<< orphan*/ *, char *, int);
int config_filename_filter(const struct dirent *dirent) {
  size_t flen;
  if (dirent == NULL)
    return 0;
  if (dirent->d_type == DT_DIR)
    return 0;
  flen = strlen(dirent->d_name);
  if (flen <= 5)
    return 0;
  if (strncmp(&dirent->d_name[flen - 5], ".conf", 5) == 0)
    return 1;
  return 0;
}


x86 assembly (clang, -O0):
<config_filename_filter>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1143 <config_filename_filter+0x23>
movl   $0x0,-0x4(%rbp)
jmp    11d3 <config_filename_filter+0xb3>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    0x2e8f(%rip),%rcx
cmp    (%rcx),%rax
jne    1166 <config_filename_filter+0x46>
movl   $0x0,-0x4(%rbp)
jmp    11d3 <config_filename_filter+0xb3>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x5,-0x18(%rbp)
ja     118e <config_filename_filter+0x6e>
movl   $0x0,-0x4(%rbp)
jmp    11d3 <config_filename_filter+0xb3>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x18(%rbp),%rax
sub    $0x5,%rax
shl    $0x2,%rax
add    %rax,%rdi
lea    0xe54(%rip),%rsi
mov    $0x5,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    11cc <config_filename_filter+0xac>
movl   $0x1,-0x4(%rbp)
jmp    11d3 <config_filename_filter+0xb3>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<config_filename_filter>:
push   %r14
push   %rbx
push   %rax
xor    %ebx,%ebx
test   %rdi,%rdi
je     116d <config_filename_filter+0x4d>
mov    (%rdi),%rax
mov    0x2eab(%rip),%rcx
cmp    (%rcx),%rax
je     116d <config_filename_filter+0x4d>
mov    0x8(%rdi),%r14
mov    %r14,%rdi
call   1040 <strlen@plt>
cmp    $0x6,%rax
jb     116d <config_filename_filter+0x4d>
lea    (%r14,%rax,4),%rdi
add    $0xffffffffffffffec,%rdi
lea    0xea5(%rip),%rsi
mov    $0x5,%edx
call   1030 <strncmp@plt>
xor    %ebx,%ebx
test   %rax,%rax
sete   %bl
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.dirent = type { i64, i32* }
@DT_DIR = global i64 0
@.str = [6 x i8] c".conf\00"
define i32 @config_filename_filter(%struct.dirent* %0) {
%2 = alloca i32
%3 = alloca %struct.dirent*
%4 = alloca i64
store %struct.dirent* %0, %struct.dirent** %3
%5 = load %struct.dirent*, %struct.dirent** %3
%6 = icmp eq %struct.dirent* %5, null
br i1 %6, label %7, label %8
7: ; preds = %1
store i32 0, i32* %2
br label %34
8: ; preds = %1
%9 = load %struct.dirent*, %struct.dirent** %3
%10 = getelementptr inbounds %struct.dirent, %struct.dirent* %9, i32 0, i32 0
%11 = load i64, i64* %10
%12 = load i64, i64* @DT_DIR
%13 = icmp eq i64 %11, %12
br i1 %13, label %14, label %15
14: ; preds = %8
store i32 0, i32* %2
br label %34
15: ; preds = %8
%16 = load %struct.dirent*, %struct.dirent** %3
%17 = getelementptr inbounds %struct.dirent, %struct.dirent* %16, i32 0, i32 1
%18 = load i32*, i32** %17
%19 = call i64 @strlen(i32* %18)
store i64 %19, i64* %4
%20 = load i64, i64* %4
%21 = icmp ule i64 %20, 5
br i1 %21, label %22, label %23
22: ; preds = %15
store i32 0, i32* %2
br label %34
23: ; preds = %15
%24 = load %struct.dirent*, %struct.dirent** %3
%25 = getelementptr inbounds %struct.dirent, %struct.dirent* %24, i32 0, i32 1
%26 = load i32*, i32** %25
%27 = load i64, i64* %4
%28 = sub i64 %27, 5
%29 = getelementptr inbounds i32, i32* %26, i64 %28
%30 = call i64 @strncmp(i32* %29, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 5)
%31 = icmp eq i64 %30, 0
br i1 %31, label %32, label %33
32: ; preds = %23
store i32 1, i32* %2
br label %34
33: ; preds = %23
store i32 0, i32* %2
br label %34
34: ; preds = %33, %32, %22, %14, %7
%35 = load i32, i32* %2
ret i32 %35
}

LLVM IR (-O2):
%struct.dirent = type { i64, i32* }
@DT_DIR = global i64 0
@.str = [6 x i8] c".conf\00"
define i32 @config_filename_filter(%struct.dirent* %0) {
%2 = icmp eq %struct.dirent* %0, null
br i1 %2, label %19, label %3
3: ; preds = %1
%4 = getelementptr inbounds %struct.dirent, %struct.dirent* %0, i64 0, i32 0
%5 = load i64, i64* %4
%6 = load i64, i64* @DT_DIR
%7 = icmp eq i64 %5, %6
br i1 %7, label %19, label %8
8: ; preds = %3
%9 = getelementptr inbounds %struct.dirent, %struct.dirent* %0, i64 0, i32 1
%10 = load i32*, i32** %9
%11 = tail call i64 @strlen(i32* dereferenceable(1) %10)
%12 = icmp ult i64 %11, 6
br i1 %12, label %19, label %13
13: ; preds = %8
%14 = add i64 %11, -5
%15 = getelementptr inbounds i32, i32* %10, i64 %14
%16 = tail call i64 @strncmp(i32* %15, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 5)
%17 = icmp eq i64 %16, 0
%18 = zext i1 %17 to i32
br label %19
19: ; preds = %13, %8, %3, %1
%20 = phi i32 [ 0, %1 ], [ 0, %3 ], [ 0, %8 ], [ %18, %13 ]
ret i32 %20
}