#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 */
scalar_t__ strncmp(int /*<<< orphan*/, char *, int);
int generic_select(const struct dirent *entry) {
  if (strncmp(entry->d_name, "sg", 2) == 0)
    return (1);
  if (strncmp(entry->d_name, "scsi_generic:", 13) == 0)
    return (1);
  return 0;
}


x86 assembly (clang, -O0):
<generic_select>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%edi
lea    0xed7(%rip),%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    1149 <generic_select+0x39>
movl   $0x1,-0x4(%rbp)
jmp    117d <generic_select+0x6d>
mov    -0x10(%rbp),%rax
mov    (%rax),%edi
lea    0xead(%rip),%rsi
mov    $0xd,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    1176 <generic_select+0x66>
movl   $0x1,-0x4(%rbp)
jmp    117d <generic_select+0x6d>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<generic_select>:
push   %rbx
mov    %rdi,%rbx
mov    (%rdi),%edi
lea    0xee3(%rip),%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     114c <generic_select+0x3c>
mov    (%rbx),%edi
lea    0xece(%rip),%rsi
mov    $0xd,%edx
call   1030 <strncmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
sete   %al
pop    %rbx
ret
mov    $0x1,%eax
pop    %rbx
ret

LLVM IR (-O0):
%struct.dirent = type { i32 }
@.str = [3 x i8] c"sg\00"
@.str.1 = [14 x i8] c"scsi_generic:\00"
define i32 @generic_select(%struct.dirent* %0) {
%2 = alloca i32
%3 = alloca %struct.dirent*
store %struct.dirent* %0, %struct.dirent** %3
%4 = load %struct.dirent*, %struct.dirent** %3
%5 = getelementptr inbounds %struct.dirent, %struct.dirent* %4, i32 0, i32 0
%6 = load i32, i32* %5
%7 = call i64 @strncmp(i32 %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 2)
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %10
9: ; preds = %1
store i32 1, i32* %2
br label %18
10: ; preds = %1
%11 = load %struct.dirent*, %struct.dirent** %3
%12 = getelementptr inbounds %struct.dirent, %struct.dirent* %11, i32 0, i32 0
%13 = load i32, i32* %12
%14 = call i64 @strncmp(i32 %13, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 13)
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %10
store i32 1, i32* %2
br label %18
17: ; preds = %10
store i32 0, i32* %2
br label %18
18: ; preds = %17, %16, %9
%19 = load i32, i32* %2
ret i32 %19
}

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