#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*/ *strcasestr(int /*<<< orphan*/, char *);
int /*<<< orphan*/ *strstr(int /*<<< orphan*/, char *);
int filter_by_string(const struct dirent *entry) {
  extern char *filter_string;
  extern char case_sensitive;
  if (filter_string != NULL) {
    if (case_sensitive) {
      if (strstr(entry->d_name, filter_string) == NULL) {
        return 0;
      }
    } else {
      if (strcasestr(entry->d_name, filter_string) == NULL) {
        return 0;
      }
    }
  }
  return 1;
}


x86 assembly (clang, -O0):
<filter_by_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
mov    0x2ebd(%rip),%rax
cmpq   $0x0,(%rax)
je     11b2 <filter_by_string+0x92>
mov    0x2e9c(%rip),%rax
cmpb   $0x0,(%rax)
je     117d <filter_by_string+0x5d>
mov    -0x10(%rbp),%rax
mov    (%rax),%edi
mov    0x2e96(%rip),%rax
mov    (%rax),%rsi
call   1040 <strstr@plt>
cmp    $0x0,%rax
jne    1178 <filter_by_string+0x58>
movl   $0x0,-0x4(%rbp)
jmp    11b9 <filter_by_string+0x99>
jmp    11ad <filter_by_string+0x8d>
mov    -0x10(%rbp),%rax
mov    (%rax),%edi
mov    0x2e66(%rip),%rax
mov    (%rax),%rsi
call   1030 <strcasestr@plt>
cmp    $0x0,%rax
jne    11a8 <filter_by_string+0x88>
movl   $0x0,-0x4(%rbp)
jmp    11b9 <filter_by_string+0x99>
jmp    11ad <filter_by_string+0x8d>
jmp    11b2 <filter_by_string+0x92>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<filter_by_string>:
push   %rax
mov    0x2ec8(%rip),%rax
mov    (%rax),%rsi
test   %rsi,%rsi
je     1148 <filter_by_string+0x28>
mov    0x2ea9(%rip),%rax
cmpb   $0x0,(%rax)
mov    (%rdi),%edi
je     114f <filter_by_string+0x2f>
call   1040 <strstr@plt>
test   %rax,%rax
je     1159 <filter_by_string+0x39>
mov    $0x1,%eax
pop    %rcx
ret
call   1030 <strcasestr@plt>
test   %rax,%rax
jne    1148 <filter_by_string+0x28>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
%struct.dirent = type { i32 }
@filter_string = external global i8*
@case_sensitive = external global i8
define i32 @filter_by_string(%struct.dirent* %0) {
%2 = alloca i32
%3 = alloca %struct.dirent*
store %struct.dirent* %0, %struct.dirent** %3
%4 = load i8*, i8** @filter_string
%5 = icmp ne i8* %4, null
br i1 %5, label %6, label %28
6: ; preds = %1
%7 = load i8, i8* @case_sensitive
%8 = icmp ne i8 %7, 0
br i1 %8, label %9, label %18
9: ; preds = %6
%10 = load %struct.dirent*, %struct.dirent** %3
%11 = getelementptr inbounds %struct.dirent, %struct.dirent* %10, i32 0, i32 0
%12 = load i32, i32* %11
%13 = load i8*, i8** @filter_string
%14 = call i32* @strstr(i32 %12, i8* %13)
%15 = icmp eq i32* %14, null
br i1 %15, label %16, label %17
16: ; preds = %9
store i32 0, i32* %2
br label %29
17: ; preds = %9
br label %27
18: ; preds = %6
%19 = load %struct.dirent*, %struct.dirent** %3
%20 = getelementptr inbounds %struct.dirent, %struct.dirent* %19, i32 0, i32 0
%21 = load i32, i32* %20
%22 = load i8*, i8** @filter_string
%23 = call i32* @strcasestr(i32 %21, i8* %22)
%24 = icmp eq i32* %23, null
br i1 %24, label %25, label %26
25: ; preds = %18
store i32 0, i32* %2
br label %29
26: ; preds = %18
br label %27
27: ; preds = %26, %17
br label %28
28: ; preds = %27, %1
store i32 1, i32* %2
br label %29
29: ; preds = %28, %25, %16
%30 = load i32, i32* %2
ret i32 %30
}

LLVM IR (-O2):
%struct.dirent = type { i32 }
@filter_string = external global i8*
@case_sensitive = external global i8
define i32 @filter_by_string(%struct.dirent* nocapture %0) {
%2 = load i8*, i8** @filter_string
%3 = icmp eq i8* %2, null
br i1 %3, label %15, label %4
4: ; preds = %1
%5 = load i8, i8* @case_sensitive
%6 = icmp eq i8 %5, 0
%7 = getelementptr inbounds %struct.dirent, %struct.dirent* %0, i64 0, i32 0
%8 = load i32, i32* %7
br i1 %6, label %12, label %9
9: ; preds = %4
%10 = tail call i32* @strstr(i32 %8, i8* %2)
%11 = icmp eq i32* %10, null
br i1 %11, label %16, label %15
12: ; preds = %4
%13 = tail call i32* @strcasestr(i32 %8, i8* %2)
%14 = icmp eq i32* %13, null
br i1 %14, label %16, label %15
15: ; preds = %9, %12, %1
br label %16
16: ; preds = %12, %9, %15
%17 = phi i32 [ 1, %15 ], [ 0, %9 ], [ 0, %12 ]
ret i32 %17
}