#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 *);
scalar_t__ strncmp(char *, char *, int);
int collect_testcases_filter(const struct dirent *a) {
  int l;
  if (a->d_name[0] == '.')
    return 0;
  l = strlen(a->d_name);
  if (l > 2 && strncmp(a->d_name + l - 3, ".sh", 3) == 0)
    return 1;
  return 0;
}


x86 assembly (clang, -O0):
<collect_testcases_filter>:
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 <collect_testcases_filter+0x2b>
movl   $0x0,-0x4(%rbp)
jmp    11a4 <collect_testcases_filter+0x84>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x2,-0x14(%rbp)
jle    119d <collect_testcases_filter+0x7d>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
movslq -0x14(%rbp),%rax
add    %rax,%rdi
add    $0xfffffffffffffffd,%rdi
lea    0xe83(%rip),%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    119d <collect_testcases_filter+0x7d>
movl   $0x1,-0x4(%rbp)
jmp    11a4 <collect_testcases_filter+0x84>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<collect_testcases_filter>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    (%rdi),%rdi
xor    %ebp,%ebp
cmpb   $0x2e,(%rdi)
je     1162 <collect_testcases_filter+0x42>
call   1040 <strlen@plt>
cmp    $0x3,%eax
jl     1162 <collect_testcases_filter+0x42>
mov    (%rbx),%rcx
mov    %eax,%eax
lea    (%rcx,%rax,1),%rdi
add    $0xfffffffffffffffd,%rdi
lea    0xeb2(%rip),%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
jne    1162 <collect_testcases_filter+0x42>
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.dirent = type { i8* }
@.str = [4 x i8] c".sh\00"
define i32 @collect_testcases_filter(%struct.dirent* %0) {
%2 = alloca i32
%3 = alloca %struct.dirent*
%4 = alloca i32
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 %32
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 i32 @strlen(i8* %16)
store i32 %17, i32* %4
%18 = load i32, i32* %4
%19 = icmp sgt i32 %18, 2
br i1 %19, label %20, label %31
20: ; preds = %13
%21 = load %struct.dirent*, %struct.dirent** %3
%22 = getelementptr inbounds %struct.dirent, %struct.dirent* %21, i32 0, i32 0
%23 = load i8*, i8** %22
%24 = load i32, i32* %4
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %23, i64 %25
%27 = getelementptr inbounds i8, i8* %26, i64 -3
%28 = call i64 @strncmp(i8* %27, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 3)
%29 = icmp eq i64 %28, 0
br i1 %29, label %30, label %31
30: ; preds = %20
store i32 1, i32* %2
br label %32
31: ; preds = %20, %13
store i32 0, i32* %2
br label %32
32: ; preds = %31, %30, %12
%33 = load i32, i32* %2
ret i32 %33
}

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