#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 */

/* Variables and functions */
char *_basename(char const *);
int /*<<< orphan*/ readvpd(char const *);
int /*<<< orphan*/ strcmp(char const *, char *);
int /*<<< orphan*/ vpd_fileattr(char *, char const *, int /*<<< orphan*/);
int scannetdev(const char *path, void *arg) {
  const char *vb;
  vb = _basename(path);
  if (!strcmp(vb, "vendor"))
    vpd_fileattr("MF", path, 0);
  if (!strcmp(vb, "device"))
    vpd_fileattr("PN", path, 0);
  if (!strcmp(vb, "vpd"))
    readvpd(path);
  return 0;
}


x86 assembly (clang, -O0):
<scannetdev>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <_basename@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe98(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    1188 <scannetdev+0x48>
mov    -0x8(%rbp),%rsi
lea    0xe86(%rip),%rdi
xor    %edx,%edx
call   1030 <vpd_fileattr@plt>
mov    -0x18(%rbp),%rdi
lea    0xe77(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    11b3 <scannetdev+0x73>
mov    -0x8(%rbp),%rsi
lea    0xe65(%rip),%rdi
xor    %edx,%edx
call   1030 <vpd_fileattr@plt>
mov    -0x18(%rbp),%rdi
lea    0xe56(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    11d5 <scannetdev+0x95>
mov    -0x8(%rbp),%rdi
call   1050 <readvpd@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<scannetdev>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
call   1060 <_basename@plt>
mov    %rax,%rbx
lea    0xeaa(%rip),%rsi
mov    %rax,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
jne    1173 <scannetdev+0x33>
lea    0xe9e(%rip),%rdi
mov    %r14,%rsi
xor    %edx,%edx
call   1030 <vpd_fileattr@plt>
lea    0xe90(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
jne    1197 <scannetdev+0x57>
lea    0xe84(%rip),%rdi
mov    %r14,%rsi
xor    %edx,%edx
call   1030 <vpd_fileattr@plt>
lea    0xe76(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
jne    11b2 <scannetdev+0x72>
mov    %r14,%rdi
call   1050 <readvpd@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [7 x i8] c"vendor\00"
@.str.1 = [3 x i8] c"MF\00"
@.str.2 = [7 x i8] c"device\00"
@.str.3 = [3 x i8] c"PN\00"
@.str.4 = [4 x i8] c"vpd\00"
define i32 @scannetdev(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%6 = load i8*, i8** %3
%7 = call i8* @_basename(i8* %6)
store i8* %7, i8** %5
%8 = load i8*, i8** %5
%9 = call i32 @strcmp(i8* %8, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%10 = icmp ne i32 %9, 0
br i1 %10, label %14, label %11
11: ; preds = %2
%12 = load i8*, i8** %3
%13 = call i32 @vpd_fileattr(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %12, i32 0)
br label %14
14: ; preds = %11, %2
%15 = load i8*, i8** %5
%16 = call i32 @strcmp(i8* %15, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%17 = icmp ne i32 %16, 0
br i1 %17, label %21, label %18
18: ; preds = %14
%19 = load i8*, i8** %3
%20 = call i32 @vpd_fileattr(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %19, i32 0)
br label %21
21: ; preds = %18, %14
%22 = load i8*, i8** %5
%23 = call i32 @strcmp(i8* %22, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%24 = icmp ne i32 %23, 0
br i1 %24, label %28, label %25
25: ; preds = %21
%26 = load i8*, i8** %3
%27 = call i32 @readvpd(i8* %26)
br label %28
28: ; preds = %25, %21
ret i32 0
}

LLVM IR (-O2):
@.str = [7 x i8] c"vendor\00"
@.str.1 = [3 x i8] c"MF\00"
@.str.2 = [7 x i8] c"device\00"
@.str.3 = [3 x i8] c"PN\00"
@.str.4 = [4 x i8] c"vpd\00"
define i32 @scannetdev(i8* %0, i8* nocapture readnone %1) {
%3 = tail call i8* @_basename(i8* %0)
%4 = tail call i32 @strcmp(i8* dereferenceable(1) %3, i8* dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = tail call i32 @vpd_fileattr(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %0, i32 0)
br label %8
8: ; preds = %6, %2
%9 = tail call i32 @strcmp(i8* dereferenceable(1) %3, i8* dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %8
%12 = tail call i32 @vpd_fileattr(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %0, i32 0)
br label %13
13: ; preds = %11, %8
%14 = tail call i32 @strcmp(i8* dereferenceable(1) %3, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %13
%17 = tail call i32 @readvpd(i8* %0)
br label %18
18: ; preds = %16, %13
ret i32 0
}