#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 *,
           unsigned int *, unsigned int *);
int strlen(int /*<<< orphan*/);
int filter_interfaces(const struct dirent *de) {
  unsigned int d0, d1, d2, d3;
  return (strlen(de->d_name) >= 7 &&
          sscanf(de->d_name, "%u-%u:%u.%u", &d0, &d1, &d2, &d3) == 4);
}


x86 assembly (clang, -O0):
<filter_interfaces>:
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    $0x7,%ecx
mov    %al,-0x19(%rbp)
jl     1172 <filter_interfaces+0x52>
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
lea    0xeac(%rip),%rsi
lea    -0xc(%rbp),%rdx
lea    -0x10(%rbp),%rcx
lea    -0x14(%rbp),%r8
lea    -0x18(%rbp),%r9
call   1040 <sscanf@plt>
cmp    $0x4,%eax
sete   %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<filter_interfaces>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
mov    (%rdi),%edi
call   1030 <strlen@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x7,%ecx
jl     1162 <filter_interfaces+0x42>
mov    (%rbx),%edi
lea    0xebf(%rip),%rsi
lea    0xc(%rsp),%rdx
lea    0x8(%rsp),%rcx
lea    0x4(%rsp),%r8
mov    %rsp,%r9
call   1040 <sscanf@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x4,%ecx
sete   %al
add    $0x10,%rsp
pop    %rbx
ret

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

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