#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 get_sysfs_int(char *);
int /*<<< orphan*/ snprintf(char *, int, char *, char *);
scalar_t__ strcmp(char *, char *);
int enet_select(const struct dirent *entry) {
  char buffer[256];
  if ((strcmp(entry->d_name, ".") == 0) || (strcmp(entry->d_name, "..") == 0))
    return (0);
  snprintf(buffer, 255, "/sys/class/net/%s/addr_len", entry->d_name);
  if (get_sysfs_int(buffer) != 6)
    return (0);
  return (1);
}


x86 assembly (clang, -O0):
<enet_select>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xeb4(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
je     1179 <enet_select+0x49>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xe96(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1185 <enet_select+0x55>
movl   $0x0,-0x4(%rbp)
jmp    11cc <enet_select+0x9c>
lea    -0x110(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rcx
mov    $0xff,%esi
lea    0xe64(%rip),%rdx
call   1030 <snprintf@plt>
lea    -0x110(%rbp),%rdi
call   1050 <get_sysfs_int@plt>
cmp    $0x6,%eax
je     11c5 <enet_select+0x95>
movl   $0x0,-0x4(%rbp)
jmp    11cc <enet_select+0x9c>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<enet_select>:
push   %r14
push   %rbx
sub    $0x108,%rsp
mov    %rdi,%r14
mov    (%rdi),%rdi
lea    0xeba(%rip),%rsi
call   1040 <strcmp@plt>
xor    %ebx,%ebx
test   %rax,%rax
je     1191 <enet_select+0x61>
mov    (%r14),%rdi
lea    0xea3(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1191 <enet_select+0x61>
mov    (%r14),%rcx
lea    0xe92(%rip),%rdx
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0xff,%esi
call   1030 <snprintf@plt>
mov    %rbx,%rdi
call   1050 <get_sysfs_int@plt>
xor    %ebx,%ebx
cmp    $0x6,%eax
sete   %bl
mov    %ebx,%eax
add    $0x108,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.dirent = type { i8* }
@.str = [2 x i8] c".\00"
@.str.1 = [3 x i8] c"..\00"
@.str.2 = [27 x i8] c"/sys/class/net/%s/addr_len\00"
define i32 @enet_select(%struct.dirent* %0) {
%2 = alloca i32
%3 = alloca %struct.dirent*
%4 = alloca [256 x i8]
store %struct.dirent* %0, %struct.dirent** %3
%5 = load %struct.dirent*, %struct.dirent** %3
%6 = getelementptr inbounds %struct.dirent, %struct.dirent* %5, i32 0, i32 0
%7 = load i8*, i8** %6
%8 = call i64 @strcmp(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
br i1 %9, label %16, label %10
10: ; preds = %1
%11 = load %struct.dirent*, %struct.dirent** %3
%12 = getelementptr inbounds %struct.dirent, %struct.dirent* %11, i32 0, i32 0
%13 = load i8*, i8** %12
%14 = call i64 @strcmp(i8* %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %10, %1
store i32 0, i32* %2
br label %28
17: ; preds = %10
%18 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%19 = load %struct.dirent*, %struct.dirent** %3
%20 = getelementptr inbounds %struct.dirent, %struct.dirent* %19, i32 0, i32 0
%21 = load i8*, i8** %20
%22 = call i32 @snprintf(i8* %18, i32 255, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i8* %21)
%23 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%24 = call i32 @get_sysfs_int(i8* %23)
%25 = icmp ne i32 %24, 6
br i1 %25, label %26, label %27
26: ; preds = %17
store i32 0, i32* %2
br label %28
27: ; preds = %17
store i32 1, i32* %2
br label %28
28: ; preds = %27, %26, %16
%29 = load i32, i32* %2
ret i32 %29
}

LLVM IR (-O2):
%struct.dirent = type { i8* }
@.str = [2 x i8] c".\00"
@.str.1 = [3 x i8] c"..\00"
@.str.2 = [27 x i8] c"/sys/class/net/%s/addr_len\00"
define i32 @enet_select(%struct.dirent* nocapture %0) {
%2 = alloca [256 x i8]
%3 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%4 = getelementptr inbounds %struct.dirent, %struct.dirent* %0, i64 0, i32 0
%5 = load i8*, i8** %4
%6 = tail call i64 @strcmp(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i64 %6, 0
br i1 %7, label %18, label %8
8: ; preds = %1
%9 = load i8*, i8** %4
%10 = tail call i64 @strcmp(i8* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
br i1 %11, label %18, label %12
12: ; preds = %8
%13 = load i8*, i8** %4
%14 = call i32 @snprintf(i8* %3, i32 255, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i8* %13)
%15 = call i32 @get_sysfs_int(i8* %3)
%16 = icmp eq i32 %15, 6
%17 = zext i1 %16 to i32
br label %18
18: ; preds = %12, %1, %8
%19 = phi i32 [ 0, %8 ], [ 0, %1 ], [ %17, %12 ]
ret i32 %19
}