#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 *);
int filter(const struct dirent *dir) {
  char *p = (char *)&dir->d_name;
  while (*++p)
    ;
  while (*--p != '.')
    ;
  return !strcmp(p, ".desktop");
}


x86 assembly (clang, -O0):
<filter>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
cmpb   $0x0,0x1(%rax)
je     1142 <filter+0x32>
jmp    1124 <filter+0x14>
jmp    1147 <filter+0x37>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x10(%rbp)
movsbl -0x1(%rax),%eax
cmp    $0x2e,%eax
je     1168 <filter+0x58>
jmp    1147 <filter+0x37>
mov    -0x10(%rbp),%rdi
lea    0xe8d(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<filter>:
push   %rax
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
cmpb   $0x0,0x1(%rdi)
lea    0x1(%rdi),%rdi
jne    1120 <filter+0x10>
nopw   0x0(%rax,%rax,1)
cmpb   $0x2e,-0x1(%rdi)
lea    -0x1(%rdi),%rdi
jne    1130 <filter+0x20>
lea    0xebf(%rip),%rsi
call   1030 <strcmp@plt>
xor    %ecx,%ecx
test   %eax,%eax
sete   %cl
mov    %ecx,%eax
pop    %rcx
ret

LLVM IR (-O0):
%struct.dirent = type { i32 }
@.str = [9 x i8] c".desktop\00"
define i32 @filter(%struct.dirent* %0) {
%2 = alloca %struct.dirent*
%3 = alloca i8*
store %struct.dirent* %0, %struct.dirent** %2
%4 = load %struct.dirent*, %struct.dirent** %2
%5 = getelementptr inbounds %struct.dirent, %struct.dirent* %4, i32 0, i32 0
%6 = bitcast i32* %5 to i8*
store i8* %6, i8** %3
br label %7
7: ; preds = %12, %1
%8 = load i8*, i8** %3
%9 = getelementptr inbounds i8, i8* %8, i32 1
store i8* %9, i8** %3
%10 = load i8, i8* %9
%11 = icmp ne i8 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %7
br label %7
13: ; preds = %7
br label %14
14: ; preds = %20, %13
%15 = load i8*, i8** %3
%16 = getelementptr inbounds i8, i8* %15, i32 -1
store i8* %16, i8** %3
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = icmp ne i32 %18, 46
br i1 %19, label %20, label %21
20: ; preds = %14
br label %14
21: ; preds = %14
%22 = load i8*, i8** %3
%23 = call i32 @strcmp(i8* %22, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%24 = icmp ne i32 %23, 0
%25 = xor i1 %24, true
%26 = zext i1 %25 to i32
ret i32 %26
}

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