#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_name;
};

/* Variables and functions */
unsigned short _D_EXACT_NAMLEN(struct dirent const *);
int /*<<< orphan*/ strcmp(scalar_t__, char *);
int filter_files(const struct dirent *d) {
  unsigned short int len = _D_EXACT_NAMLEN(d);
  return (len > 2) && !strcmp(d->d_name + len - 3, ".so");
}


x86 assembly (clang, -O0):
<filter_files>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <_D_EXACT_NAMLEN@plt>
mov    %ax,-0xa(%rbp)
movzwl -0xa(%rbp),%ecx
xor    %eax,%eax
cmp    $0x2,%ecx
mov    %al,-0xb(%rbp)
jle    1174 <filter_files+0x54>
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
movzwl -0xa(%rbp),%eax
add    %rax,%rdi
sub    $0x3,%rdi
lea    0xe9c(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
mov    %al,-0xb(%rbp)
mov    -0xb(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<filter_files>:
push   %rbx
mov    %rdi,%rbx
call   1040 <_D_EXACT_NAMLEN@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x3,%cx
jb     1156 <filter_files+0x36>
mov    (%rbx),%rax
movzwl %cx,%ecx
lea    (%rcx,%rax,1),%rdi
add    $0xfffffffffffffffd,%rdi
lea    0xeb8(%rip),%rsi
call   1030 <strcmp@plt>
mov    %eax,%ecx
xor    %eax,%eax
test   %ecx,%ecx
sete   %al
pop    %rbx
ret

LLVM IR (-O0):
%struct.dirent = type { i64 }
@.str = [4 x i8] c".so\00"
define i32 @filter_files(%struct.dirent* %0) {
%2 = alloca %struct.dirent*
%3 = alloca i16
store %struct.dirent* %0, %struct.dirent** %2
%4 = load %struct.dirent*, %struct.dirent** %2
%5 = call zeroext i16 @_D_EXACT_NAMLEN(%struct.dirent* %4)
store i16 %5, i16* %3
%6 = load i16, i16* %3
%7 = zext i16 %6 to i32
%8 = icmp sgt i32 %7, 2
br i1 %8, label %9, label %20
9: ; preds = %1
%10 = load %struct.dirent*, %struct.dirent** %2
%11 = getelementptr inbounds %struct.dirent, %struct.dirent* %10, i32 0, i32 0
%12 = load i64, i64* %11
%13 = load i16, i16* %3
%14 = zext i16 %13 to i64
%15 = add nsw i64 %12, %14
%16 = sub nsw i64 %15, 3
%17 = call i32 @strcmp(i64 %16, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%18 = icmp ne i32 %17, 0
%19 = xor i1 %18, true
br label %20
20: ; preds = %9, %1
%21 = phi i1 [ false, %1 ], [ %19, %9 ]
%22 = zext i1 %21 to i32
ret i32 %22
}

LLVM IR (-O2):
%struct.dirent = type { i64 }
@.str = [4 x i8] c".so\00"
define i32 @filter_files(%struct.dirent* %0) {
%2 = tail call zeroext i16 @_D_EXACT_NAMLEN(%struct.dirent* %0)
%3 = icmp ugt i16 %2, 2
br i1 %3, label %4, label %13
4: ; preds = %1
%5 = getelementptr inbounds %struct.dirent, %struct.dirent* %0, i64 0, i32 0
%6 = load i64, i64* %5
%7 = zext i16 %2 to i64
%8 = add nsw i64 %7, -3
%9 = add i64 %8, %6
%10 = tail call i32 @strcmp(i64 %9, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%11 = icmp eq i32 %10, 0
%12 = zext i1 %11 to i32
br label %13
13: ; preds = %4, %1
%14 = phi i32 [ 0, %1 ], [ %12, %4 ]
ret i32 %14
}