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

/* Variables and functions */
int sscanf(char *, char *, int *, int *);
scalar_t__ strstr(char *, char *);
int scan_ctrls_filter(const struct dirent *d) {
  int id, nsid;
  if (d->d_name[0] == '.')
    return 0;
  if (strstr(d->d_name, "nvme")) {
    if (sscanf(d->d_name, "nvme%dn%d", &id, &nsid) == 2)
      return 0;
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<scan_ctrls_filter>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
jne    114b <scan_ctrls_filter+0x2b>
movl   $0x0,-0x4(%rbp)
jmp    11ab <scan_ctrls_filter+0x8b>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xea7(%rip),%rsi
call   1040 <strstr@plt>
cmp    $0x0,%rax
je     11a4 <scan_ctrls_filter+0x84>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xe8f(%rip),%rsi
lea    -0x14(%rbp),%rdx
lea    -0x18(%rbp),%rcx
call   1030 <sscanf@plt>
cmp    $0x2,%eax
jne    1198 <scan_ctrls_filter+0x78>
movl   $0x0,-0x4(%rbp)
jmp    11ab <scan_ctrls_filter+0x8b>
movl   $0x1,-0x4(%rbp)
jmp    11ab <scan_ctrls_filter+0x8b>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<scan_ctrls_filter>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    (%rdi),%rdi
xor    %ebx,%ebx
cmpb   $0x2e,(%rdi)
je     1161 <scan_ctrls_filter+0x41>
lea    0xec8(%rip),%rsi
call   1040 <strstr@plt>
test   %rax,%rax
je     1161 <scan_ctrls_filter+0x41>
mov    (%r14),%rdi
lea    0xeb9(%rip),%rsi
lea    0x4(%rsp),%rdx
mov    %rsp,%rcx
call   1030 <sscanf@plt>
xor    %ebx,%ebx
cmp    $0x2,%eax
setne  %bl
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

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