#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_REG;
scalar_t__ DT_UNKNOWN;
scalar_t__ strcmp(int /*<<< orphan*/ *, char *);
size_t strlen(int /*<<< orphan*/ *);
int _keystore_info_file_filter(const struct dirent *dirent) {
  size_t len;
  if (dirent->d_type != DT_REG && dirent->d_type != DT_UNKNOWN)
    return 0;
  len = strlen(dirent->d_name);
  if (len > 5 && strcmp(&dirent->d_name[len - 5], ".info") == 0)
    return 1;
  return 0;
}


x86 assembly (clang, -O0):
<_keystore_info_file_filter>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    0x2e9e(%rip),%rcx
cmp    (%rcx),%rax
je     1166 <_keystore_info_file_filter+0x46>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    0x2e97(%rip),%rcx
cmp    (%rcx),%rax
je     1166 <_keystore_info_file_filter+0x46>
movl   $0x0,-0x4(%rbp)
jmp    11c2 <_keystore_info_file_filter+0xa2>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x5,-0x18(%rbp)
jbe    11bb <_keystore_info_file_filter+0x9b>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x18(%rbp),%rax
sub    $0x5,%rax
shl    $0x2,%rax
add    %rax,%rdi
lea    0xe60(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11bb <_keystore_info_file_filter+0x9b>
movl   $0x1,-0x4(%rbp)
jmp    11c2 <_keystore_info_file_filter+0xa2>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_keystore_info_file_filter>:
push   %rbp
push   %rbx
push   %rax
mov    (%rdi),%rax
mov    0x2eab(%rip),%rcx
xor    %ebp,%ebp
cmp    (%rcx),%rax
je     1140 <_keystore_info_file_filter+0x20>
mov    0x2ead(%rip),%rcx
cmp    (%rcx),%rax
jne    1170 <_keystore_info_file_filter+0x50>
mov    0x8(%rdi),%rbx
mov    %rbx,%rdi
call   1030 <strlen@plt>
cmp    $0x6,%rax
jb     1170 <_keystore_info_file_filter+0x50>
lea    (%rbx,%rax,4),%rdi
add    $0xffffffffffffffec,%rdi
lea    0xe9f(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
jne    1170 <_keystore_info_file_filter+0x50>
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.dirent = type { i64, i32* }
@DT_REG = global i64 0
@DT_UNKNOWN = global i64 0
@.str = [6 x i8] c".info\00"
define i32 @_keystore_info_file_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 = getelementptr inbounds %struct.dirent, %struct.dirent* %5, i32 0, i32 0
%7 = load i64, i64* %6
%8 = load i64, i64* @DT_REG
%9 = icmp ne i64 %7, %8
br i1 %9, label %10, label %17
10: ; preds = %1
%11 = load %struct.dirent*, %struct.dirent** %3
%12 = getelementptr inbounds %struct.dirent, %struct.dirent* %11, i32 0, i32 0
%13 = load i64, i64* %12
%14 = load i64, i64* @DT_UNKNOWN
%15 = icmp ne i64 %13, %14
br i1 %15, label %16, label %17
16: ; preds = %10
store i32 0, i32* %2
br label %35
17: ; preds = %10, %1
%18 = load %struct.dirent*, %struct.dirent** %3
%19 = getelementptr inbounds %struct.dirent, %struct.dirent* %18, i32 0, i32 1
%20 = load i32*, i32** %19
%21 = call i64 @strlen(i32* %20)
store i64 %21, i64* %4
%22 = load i64, i64* %4
%23 = icmp ugt i64 %22, 5
br i1 %23, label %24, label %34
24: ; preds = %17
%25 = load %struct.dirent*, %struct.dirent** %3
%26 = getelementptr inbounds %struct.dirent, %struct.dirent* %25, i32 0, i32 1
%27 = load i32*, i32** %26
%28 = load i64, i64* %4
%29 = sub i64 %28, 5
%30 = getelementptr inbounds i32, i32* %27, i64 %29
%31 = call i64 @strcmp(i32* %30, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%32 = icmp eq i64 %31, 0
br i1 %32, label %33, label %34
33: ; preds = %24
store i32 1, i32* %2
br label %35
34: ; preds = %24, %17
store i32 0, i32* %2
br label %35
35: ; preds = %34, %33, %16
%36 = load i32, i32* %2
ret i32 %36
}

LLVM IR (-O2):
%struct.dirent = type { i64, i32* }
@DT_REG = global i64 0
@DT_UNKNOWN = global i64 0
@.str = [6 x i8] c".info\00"
define i32 @_keystore_info_file_filter(%struct.dirent* nocapture %0) {
%2 = getelementptr inbounds %struct.dirent, %struct.dirent* %0, i64 0, i32 0
%3 = load i64, i64* %2
%4 = load i64, i64* @DT_REG
%5 = icmp eq i64 %3, %4
%6 = load i64, i64* @DT_UNKNOWN
%7 = icmp eq i64 %3, %6
%8 = select i1 %5, i1 true, i1 %7
br i1 %8, label %9, label %20
9: ; preds = %1
%10 = getelementptr inbounds %struct.dirent, %struct.dirent* %0, i64 0, i32 1
%11 = load i32*, i32** %10
%12 = tail call i64 @strlen(i32* dereferenceable(1) %11)
%13 = icmp ugt i64 %12, 5
br i1 %13, label %14, label %19
14: ; preds = %9
%15 = add i64 %12, -5
%16 = getelementptr inbounds i32, i32* %11, i64 %15
%17 = tail call i64 @strcmp(i32* %16, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %20, label %19
19: ; preds = %14, %9
br label %20
20: ; preds = %14, %1, %19
%21 = phi i32 [ 0, %19 ], [ 0, %1 ], [ 1, %14 ]
ret i32 %21
}