#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*/ strcmp(char const *, char *);
int /*<<< orphan*/ vpd_fileattr(char *, char const *, int);
int scanblockdev(const char *path, void *arg) {
  const char *vb;
  vb = _basename(path);
  if (!strcmp(vb, "vendor"))
    vpd_fileattr("MF", path, 0);
  if (!strcmp(vb, "model"))
    vpd_fileattr("PN", path, 0);
  if (!strcmp(vb, "vpd_pg80"))
    vpd_fileattr("SN", path, 4);
  if (!strcmp(vb, "rev"))
    vpd_fileattr("FW", path, 0);
  return 0;
}


x86 assembly (clang, -O0):
<scanblockdev>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <_basename@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xea8(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    1178 <scanblockdev+0x48>
mov    -0x8(%rbp),%rsi
lea    0xe96(%rip),%rdi
xor    %edx,%edx
call   1030 <vpd_fileattr@plt>
mov    -0x18(%rbp),%rdi
lea    0xe87(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    11a3 <scanblockdev+0x73>
mov    -0x8(%rbp),%rsi
lea    0xe74(%rip),%rdi
xor    %edx,%edx
call   1030 <vpd_fileattr@plt>
mov    -0x18(%rbp),%rdi
lea    0xe65(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    11d1 <scanblockdev+0xa1>
mov    -0x8(%rbp),%rsi
lea    0xe55(%rip),%rdi
mov    $0x4,%edx
call   1030 <vpd_fileattr@plt>
mov    -0x18(%rbp),%rdi
lea    0xe43(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    11fc <scanblockdev+0xcc>
mov    -0x8(%rbp),%rsi
lea    0xe2e(%rip),%rdi
xor    %edx,%edx
call   1030 <vpd_fileattr@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<scanblockdev>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
call   1050 <_basename@plt>
mov    %rax,%rbx
lea    0xeba(%rip),%rsi
mov    %rax,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
jne    1163 <scanblockdev+0x33>
lea    0xeae(%rip),%rdi
mov    %r14,%rsi
xor    %edx,%edx
call   1030 <vpd_fileattr@plt>
lea    0xea0(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
jne    1187 <scanblockdev+0x57>
lea    0xe93(%rip),%rdi
mov    %r14,%rsi
xor    %edx,%edx
call   1030 <vpd_fileattr@plt>
lea    0xe85(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
jne    11ae <scanblockdev+0x7e>
lea    0xe7b(%rip),%rdi
mov    %r14,%rsi
mov    $0x4,%edx
call   1030 <vpd_fileattr@plt>
lea    0xe6a(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
jne    11d2 <scanblockdev+0xa2>
lea    0xe5b(%rip),%rdi
mov    %r14,%rsi
xor    %edx,%edx
call   1030 <vpd_fileattr@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 = [6 x i8] c"model\00"
@.str.3 = [3 x i8] c"PN\00"
@.str.4 = [9 x i8] c"vpd_pg80\00"
@.str.5 = [3 x i8] c"SN\00"
@.str.6 = [4 x i8] c"rev\00"
@.str.7 = [3 x i8] c"FW\00"
define i32 @scanblockdev(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 ([6 x i8], [6 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 ([9 x i8], [9 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 @vpd_fileattr(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* %26, i32 4)
br label %28
28: ; preds = %25, %21
%29 = load i8*, i8** %5
%30 = call i32 @strcmp(i8* %29, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%31 = icmp ne i32 %30, 0
br i1 %31, label %35, label %32
32: ; preds = %28
%33 = load i8*, i8** %3
%34 = call i32 @vpd_fileattr(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i8* %33, i32 0)
br label %35
35: ; preds = %32, %28
ret i32 0
}

LLVM IR (-O2):
@.str = [7 x i8] c"vendor\00"
@.str.1 = [3 x i8] c"MF\00"
@.str.2 = [6 x i8] c"model\00"
@.str.3 = [3 x i8] c"PN\00"
@.str.4 = [9 x i8] c"vpd_pg80\00"
@.str.5 = [3 x i8] c"SN\00"
@.str.6 = [4 x i8] c"rev\00"
@.str.7 = [3 x i8] c"FW\00"
define i32 @scanblockdev(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(6) getelementptr inbounds ([6 x i8], [6 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(9) getelementptr inbounds ([9 x i8], [9 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 @vpd_fileattr(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* %0, i32 4)
br label %18
18: ; preds = %16, %13
%19 = tail call i32 @strcmp(i8* dereferenceable(1) %3, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %18
%22 = tail call i32 @vpd_fileattr(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i8* %0, i32 0)
br label %23
23: ; preds = %21, %18
ret i32 0
}