#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;
  char *d_name;
};

/* Variables and functions */
scalar_t__ DT_LNK;
scalar_t__ DT_REG;
int /*<<< orphan*/ strcasecmp(char *, char *);
char *strrchr(char *, char);
int mameFilter(const struct dirent *d) {
  char *ptr;
  if (((d->d_type == DT_REG) || (d->d_type == DT_LNK)) &&
      (d->d_name[0] != '.') && (ptr = strrchr(d->d_name, '.')) &&
      !strcasecmp(ptr, ".zip")) {
    *ptr = 0;
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<mameFilter>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    0x2ea6(%rip),%rcx
cmp    (%rcx),%rax
je     115a <mameFilter+0x3a>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    0x2e87(%rip),%rcx
cmp    (%rcx),%rax
jne    11ba <mameFilter+0x9a>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
je     11ba <mameFilter+0x9a>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    $0x2e,%esi
call   1040 <strrchr@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     11ba <mameFilter+0x9a>
mov    -0x18(%rbp),%rdi
lea    0xe67(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%eax
jne    11ba <mameFilter+0x9a>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    11c1 <mameFilter+0xa1>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mameFilter>:
push   %r14
push   %rbx
push   %rax
mov    (%rdi),%rax
mov    0x2eb2(%rip),%rcx
xor    %ebx,%ebx
cmp    (%rcx),%rax
je     1141 <mameFilter+0x21>
mov    0x2e9c(%rip),%rcx
cmp    (%rcx),%rax
jne    1178 <mameFilter+0x58>
mov    0x8(%rdi),%rdi
cmpb   $0x2e,(%rdi)
je     1178 <mameFilter+0x58>
mov    $0x2e,%esi
call   1040 <strrchr@plt>
test   %rax,%rax
je     1178 <mameFilter+0x58>
mov    %rax,%r14
lea    0xe9d(%rip),%rsi
mov    %rax,%rdi
call   1030 <strcasecmp@plt>
test   %eax,%eax
jne    1178 <mameFilter+0x58>
movb   $0x0,(%r14)
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.dirent = type { i64, i8* }
@DT_REG = global i64 0
@DT_LNK = global i64 0
@.str = [5 x i8] c".zip\00"
define i32 @mameFilter(%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 = getelementptr inbounds %struct.dirent, %struct.dirent* %5, i32 0, i32 0
%7 = load i64, i64* %6
%8 = load i64, i64* @DT_REG
%9 = icmp eq i64 %7, %8
br i1 %9, label %16, label %10
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_LNK
%15 = icmp eq i64 %13, %14
br i1 %15, label %16, label %36
16: ; preds = %10, %1
%17 = load %struct.dirent*, %struct.dirent** %3
%18 = getelementptr inbounds %struct.dirent, %struct.dirent* %17, i32 0, i32 1
%19 = load i8*, i8** %18
%20 = getelementptr inbounds i8, i8* %19, i64 0
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp ne i32 %22, 46
br i1 %23, label %24, label %36
24: ; preds = %16
%25 = load %struct.dirent*, %struct.dirent** %3
%26 = getelementptr inbounds %struct.dirent, %struct.dirent* %25, i32 0, i32 1
%27 = load i8*, i8** %26
%28 = call i8* @strrchr(i8* %27, i8 signext 46)
store i8* %28, i8** %4
%29 = icmp ne i8* %28, null
br i1 %29, label %30, label %36
30: ; preds = %24
%31 = load i8*, i8** %4
%32 = call i32 @strcasecmp(i8* %31, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%33 = icmp ne i32 %32, 0
br i1 %33, label %36, label %34
34: ; preds = %30
%35 = load i8*, i8** %4
store i8 0, i8* %35
store i32 1, i32* %2
br label %37
36: ; preds = %30, %24, %16, %10
store i32 0, i32* %2
br label %37
37: ; preds = %36, %34
%38 = load i32, i32* %2
ret i32 %38
}

LLVM IR (-O2):
%struct.dirent = type { i64, i8* }
@DT_REG = global i64 0
@DT_LNK = global i64 0
@.str = [5 x i8] c".zip\00"
define i32 @mameFilter(%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_LNK
%7 = icmp eq i64 %3, %6
%8 = select i1 %5, i1 true, i1 %7
br i1 %8, label %9, label %21
9: ; preds = %1
%10 = getelementptr inbounds %struct.dirent, %struct.dirent* %0, i64 0, i32 1
%11 = load i8*, i8** %10
%12 = load i8, i8* %11
%13 = icmp eq i8 %12, 46
br i1 %13, label %21, label %14
14: ; preds = %9
%15 = tail call i8* @strrchr(i8* %11, i8 signext 46)
%16 = icmp eq i8* %15, null
br i1 %16, label %21, label %17
17: ; preds = %14
%18 = tail call i32 @strcasecmp(i8* %15, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %21
20: ; preds = %17
store i8 0, i8* %15
br label %21
21: ; preds = %9, %14, %17, %1, %20
%22 = phi i32 [ 1, %20 ], [ 0, %1 ], [ 0, %17 ], [ 0, %14 ], [ 0, %9 ]
ret i32 %22
}