#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 sscanf(int /*<<< orphan*/, char *, unsigned int *, unsigned int *);
int /*<<< orphan*/ *strchr(int /*<<< orphan*/, char);
int strlen(int /*<<< orphan*/);
int filter_devices(const struct dirent *de) {
  unsigned int d0, d1;
  return (strlen(de->d_name) >= 3 && strchr(de->d_name, ':') == NULL &&
          sscanf(de->d_name, "%u-%u", &d0, &d1) == 2);
}


x86 assembly (clang, -O0):
<filter_devices>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
call   1030 <strlen@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x3,%ecx
mov    %al,-0x11(%rbp)
jl     119c <filter_devices+0x6c>
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
mov    $0x3a,%esi
call   1040 <strchr@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x11(%rbp)
jne    119c <filter_devices+0x6c>
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
lea    0xe7a(%rip),%rsi
lea    -0xc(%rbp),%rdx
lea    -0x10(%rbp),%rcx
call   1050 <sscanf@plt>
cmp    $0x2,%eax
sete   %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<filter_devices>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    (%rdi),%edi
call   1030 <strlen@plt>
xor    %ebp,%ebp
cmp    $0x3,%eax
jl     1174 <filter_devices+0x44>
mov    (%rbx),%edi
mov    $0x3a,%esi
call   1040 <strchr@plt>
test   %rax,%rax
jne    1174 <filter_devices+0x44>
mov    (%rbx),%edi
lea    0xea2(%rip),%rsi
lea    0x4(%rsp),%rdx
mov    %rsp,%rcx
call   1050 <sscanf@plt>
xor    %ebp,%ebp
cmp    $0x2,%eax
sete   %bpl
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.dirent = type { i32 }
@.str = [6 x i8] c"%u-%u\00"
define i32 @filter_devices(%struct.dirent* %0) {
%2 = alloca %struct.dirent*
%3 = alloca i32
%4 = alloca i32
store %struct.dirent* %0, %struct.dirent** %2
%5 = load %struct.dirent*, %struct.dirent** %2
%6 = getelementptr inbounds %struct.dirent, %struct.dirent* %5, i32 0, i32 0
%7 = load i32, i32* %6
%8 = call i32 @strlen(i32 %7)
%9 = icmp sge i32 %8, 3
br i1 %9, label %10, label %22
10: ; preds = %1
%11 = load %struct.dirent*, %struct.dirent** %2
%12 = getelementptr inbounds %struct.dirent, %struct.dirent* %11, i32 0, i32 0
%13 = load i32, i32* %12
%14 = call i32* @strchr(i32 %13, i8 signext 58)
%15 = icmp eq i32* %14, null
br i1 %15, label %16, label %22
16: ; preds = %10
%17 = load %struct.dirent*, %struct.dirent** %2
%18 = getelementptr inbounds %struct.dirent, %struct.dirent* %17, i32 0, i32 0
%19 = load i32, i32* %18
%20 = call i32 @sscanf(i32 %19, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %3, i32* %4)
%21 = icmp eq i32 %20, 2
br label %22
22: ; preds = %16, %10, %1
%23 = phi i1 [ false, %10 ], [ false, %1 ], [ %21, %16 ]
%24 = zext i1 %23 to i32
ret i32 %24
}

LLVM IR (-O2):
%struct.dirent = type { i32 }
@.str = [6 x i8] c"%u-%u\00"
define i32 @filter_devices(%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 i32, i32* %6
%8 = tail call i32 @strlen(i32 %7)
%9 = icmp sgt i32 %8, 2
br i1 %9, label %10, label %19
10: ; preds = %1
%11 = load i32, i32* %6
%12 = tail call i32* @strchr(i32 %11, i8 signext 58)
%13 = icmp eq i32* %12, null
br i1 %13, label %14, label %19
14: ; preds = %10
%15 = load i32, i32* %6
%16 = call i32 @sscanf(i32 %15, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %2, i32* %3)
%17 = icmp eq i32 %16, 2
%18 = zext i1 %17 to i32
br label %19
19: ; preds = %14, %10, %1
%20 = phi i32 [ 0, %10 ], [ 0, %1 ], [ %18, %14 ]
ret i32 %20
}