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

/* Variables and functions */
int /*<<< orphan*/ strcmp(char *, char *);
char *strrchr(int /*<<< orphan*/, char);
int filter(const struct dirent *dir) {
  if (dir) {
    char *last = strrchr(dir->d_name, '.');
    if (last) {
      if (!strcmp(last, ".jar")) {
        return 1;
      }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<filter>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1185 <filter+0x65>
mov    -0x10(%rbp),%rax
mov    (%rax),%edi
mov    $0x2e,%esi
call   1030 <strrchr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1180 <filter+0x60>
mov    -0x18(%rbp),%rdi
lea    0xe9f(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    117b <filter+0x5b>
movl   $0x1,-0x4(%rbp)
jmp    118c <filter+0x6c>
jmp    1180 <filter+0x60>
jmp    1185 <filter+0x65>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<filter>:
push   %rbx
xor    %ebx,%ebx
test   %rdi,%rdi
je     1151 <filter+0x31>
mov    (%rdi),%edi
mov    $0x2e,%esi
call   1030 <strrchr@plt>
test   %rax,%rax
je     1151 <filter+0x31>
lea    0xec0(%rip),%rsi
mov    %rax,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
jne    1151 <filter+0x31>
mov    $0x1,%ebx
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
%struct.dirent = type { i32 }
@.str = [5 x i8] c".jar\00"
define i32 @filter(%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 = icmp ne %struct.dirent* %5, null
br i1 %6, label %7, label %21
7: ; preds = %1
%8 = load %struct.dirent*, %struct.dirent** %3
%9 = getelementptr inbounds %struct.dirent, %struct.dirent* %8, i32 0, i32 0
%10 = load i32, i32* %9
%11 = call i8* @strrchr(i32 %10, i8 signext 46)
store i8* %11, i8** %4
%12 = load i8*, i8** %4
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %20
14: ; preds = %7
%15 = load i8*, i8** %4
%16 = call i32 @strcmp(i8* %15, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%17 = icmp ne i32 %16, 0
br i1 %17, label %19, label %18
18: ; preds = %14
store i32 1, i32* %2
br label %22
19: ; preds = %14
br label %20
20: ; preds = %19, %7
br label %21
21: ; preds = %20, %1
store i32 0, i32* %2
br label %22
22: ; preds = %21, %18
%23 = load i32, i32* %2
ret i32 %23
}

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