#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;
};
typedef int /*<<< orphan*/ DIR;

/* Variables and functions */
int DT_DIR;
int DT_LNK;
int DT_REG;
int PATH_MAX;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, char *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ printf(char *, char *);
char *realpath(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ snprintf(char *, int, char *, char *, char *, ...);
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ sysfsparser_closedir(int /*<<< orphan*/ *);
char *sysfsparser_getline(char *, char *);
int /*<<< orphan*/ sysfsparser_opendir(int /*<<< orphan*/ **, char *, ...);
struct dirent *sysfsparser_readfilename(int /*<<< orphan*/ *, int);
void fc_host_summary(signed char verbose) {
  DIR *dirp;
  struct dirent *dp;
  char *line, path[PATH_MAX];
  sysfsparser_opendir(&dirp, "/sys/class"
                             "/fc_host");
  while ((dp = sysfsparser_readfilename(dirp, DT_DIR | DT_LNK))) {
    DIR *dirp_host;
    struct dirent *dp_host;
    printf("Class Device = \"%s\"\n", dp->d_name);
    if (!verbose)
      continue;
    snprintf(path, PATH_MAX, "%s/%s/device",
             "/sys/class"
             "/fc_host",
             dp->d_name);
    char *cdevpath = realpath(path, NULL);
    printf("Class Device path = \"%s\"\n", cdevpath);
    sysfsparser_opendir(&dirp_host, "%s/%s",
                        "/sys/class"
                        "/fc_host",
                        dp->d_name);
    while ((dp_host = sysfsparser_readfilename(dirp_host, DT_REG))) {
      snprintf(path, PATH_MAX, "%s/%s/%s",
               "/sys/class"
               "/fc_host",
               dp->d_name, dp_host->d_name);
      if ((line = sysfsparser_getline("%s", path))) {
        fprintf(stdout, "%25s = \"%s\"\n", dp_host->d_name, line);
        free(line);
      }
    }
    fputs("\n", stdout);
    sysfsparser_closedir(dirp_host);
    free(cdevpath);
  }
  sysfsparser_closedir(dirp);
}


x86 assembly (clang, -O0):
<fc_host_summary>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
mov    0x2e3b(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x28(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x50(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x30(%rbp)
lea    -0x10(%rbp),%rdi
lea    0xe1b(%rip),%rsi
mov    $0x0,%al
call   10c0 <sysfsparser_opendir@plt>
mov    -0x10(%rbp),%rdi
mov    0x2dd9(%rip),%rax
mov    (%rax),%esi
mov    0x2dc0(%rip),%rax
or     (%rax),%esi
call   10b0 <sysfsparser_readfilename@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     1369 <fc_host_summary+0x1c9>
mov    -0x18(%rbp),%rax
mov    (%rax),%rsi
lea    0xdf0(%rip),%rdi
call   1050 <printf@plt>
cmpb   $0x0,-0x1(%rbp)
jne    1237 <fc_host_summary+0x97>
jmp    11ec <fc_host_summary+0x4c>
mov    -0x50(%rbp),%rdi
mov    0x2dae(%rip),%rax
mov    (%rax),%esi
mov    -0x18(%rbp),%rax
mov    (%rax),%r8
lea    0xdd6(%rip),%rdx
lea    0xda7(%rip),%rcx
mov    $0x0,%al
call   1060 <snprintf@plt>
mov    -0x50(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   10a0 <realpath@plt>
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rsi
lea    0xdb9(%rip),%rdi
call   1050 <printf@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%rcx
lea    -0x38(%rbp),%rdi
lea    0xdbf(%rip),%rsi
lea    0xd66(%rip),%rdx
mov    $0x0,%al
call   10c0 <sysfsparser_opendir@plt>
mov    -0x38(%rbp),%rdi
mov    0x2d2c(%rip),%rax
mov    (%rax),%esi
call   10b0 <sysfsparser_readfilename@plt>
mov    %rax,-0x40(%rbp)
cmp    $0x0,%rax
je     133d <fc_host_summary+0x19d>
mov    -0x50(%rbp),%rdi
mov    0x2d24(%rip),%rax
mov    (%rax),%esi
mov    -0x18(%rbp),%rax
mov    (%rax),%r8
mov    -0x40(%rbp),%rax
mov    (%rax),%r9
lea    0xd6c(%rip),%rdx
lea    0xd16(%rip),%rcx
mov    $0x0,%al
call   1060 <snprintf@plt>
mov    -0x50(%rbp),%rsi
lea    0xd59(%rip),%rdi
call   1080 <sysfsparser_getline@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     1338 <fc_host_summary+0x198>
mov    0x2cb2(%rip),%rax
mov    (%rax),%edi
mov    -0x40(%rbp),%rax
mov    (%rax),%rdx
mov    -0x20(%rbp),%rcx
lea    0xd2e(%rip),%rsi
call   1090 <fprintf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
jmp    12a1 <fc_host_summary+0x101>
mov    0x2c84(%rip),%rax
mov    (%rax),%esi
lea    0xcd9(%rip),%rdi
call   1070 <fputs@plt>
mov    -0x38(%rbp),%rdi
call   1040 <sysfsparser_closedir@plt>
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
jmp    11ec <fc_host_summary+0x4c>
mov    -0x10(%rbp),%rdi
call   1040 <sysfsparser_closedir@plt>
mov    -0x28(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fc_host_summary>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %edi,-0x3c(%rbp)
mov    %rsp,-0x48(%rbp)
mov    0x2e31(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rbx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
lea    0xe27(%rip),%rsi
lea    -0x38(%rbp),%rdi
xor    %eax,%eax
call   10c0 <sysfsparser_opendir@plt>
mov    -0x38(%rbp),%rdi
mov    0x2de1(%rip),%rax
mov    0x2dca(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
call   10b0 <sysfsparser_readfilename@plt>
test   %rax,%rax
je     137f <fc_host_summary+0x1df>
mov    %rax,%r14
lea    0xdee(%rip),%r13
jmp    126e <fc_host_summary+0xce>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    0x2da1(%rip),%rax
mov    (%rax),%esi
lea    0xdf6(%rip),%rdi
call   1070 <fputs@plt>
mov    -0x30(%rbp),%rdi
call   1040 <sysfsparser_closedir@plt>
mov    -0x50(%rbp),%rdi
call   1030 <free@plt>
mov    -0x38(%rbp),%rdi
mov    0x2d6e(%rip),%rax
mov    (%rax),%esi
mov    0x2d75(%rip),%rax
or     (%rax),%esi
call   10b0 <sysfsparser_readfilename@plt>
mov    %rax,%r14
test   %rax,%rax
je     137f <fc_host_summary+0x1df>
mov    (%r14),%rsi
lea    0xd9b(%rip),%rdi
call   1050 <printf@plt>
cmpb   $0x0,-0x3c(%rbp)
je     1247 <fc_host_summary+0xa7>
mov    0x2d66(%rip),%rax
mov    (%rax),%esi
mov    (%r14),%r8
mov    %rbx,%rdi
lea    0xd8f(%rip),%rdx
mov    %r13,%rcx
xor    %eax,%eax
call   1060 <snprintf@plt>
mov    %rbx,%rdi
xor    %esi,%esi
call   10a0 <realpath@plt>
lea    0xd81(%rip),%rdi
mov    %rax,-0x50(%rbp)
mov    %rax,%rsi
call   1050 <printf@plt>
mov    (%r14),%rcx
lea    -0x30(%rbp),%rdi
lea    0xd84(%rip),%rsi
mov    %r13,%rdx
xor    %eax,%eax
call   10c0 <sysfsparser_opendir@plt>
mov    -0x30(%rbp),%rdi
mov    0x2cf5(%rip),%rax
mov    (%rax),%esi
call   10b0 <sysfsparser_readfilename@plt>
test   %rax,%rax
je     1220 <fc_host_summary+0x80>
mov    %rax,%r12
jmp    131e <fc_host_summary+0x17e>
nopl   0x0(%rax,%rax,1)
mov    -0x30(%rbp),%rdi
mov    0x2ccd(%rip),%rax
mov    (%rax),%esi
call   10b0 <sysfsparser_readfilename@plt>
mov    %rax,%r12
test   %rax,%rax
je     1220 <fc_host_summary+0x80>
mov    0x2ccb(%rip),%rax
mov    (%rax),%esi
mov    (%r14),%r8
mov    (%r12),%r9
mov    %rbx,%rdi
lea    0xd17(%rip),%rdx
mov    %r13,%rcx
xor    %eax,%eax
call   1060 <snprintf@plt>
lea    0xd0c(%rip),%rdi
mov    %rbx,%rsi
call   1080 <sysfsparser_getline@plt>
test   %rax,%rax
je     1300 <fc_host_summary+0x160>
mov    %rax,%r15
mov    0x2c68(%rip),%rax
mov    (%rax),%edi
mov    (%r12),%rdx
lea    0xceb(%rip),%rsi
mov    %r15,%rcx
call   1090 <fprintf@plt>
mov    %r15,%rdi
call   1030 <free@plt>
jmp    1300 <fc_host_summary+0x160>
mov    -0x38(%rbp),%rdi
call   1040 <sysfsparser_closedir@plt>
mov    -0x48(%rbp),%rsp
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.dirent = type { i8* }
@PATH_MAX = global i32 0
@.str = [19 x i8] c"/sys/class/fc_host\00"
@DT_DIR = global i32 0
@DT_LNK = global i32 0
@.str.1 = [21 x i8] c"Class Device = \22%s\22\0A\00"
@.str.2 = [13 x i8] c"%s/%s/device\00"
@.str.3 = [26 x i8] c"Class Device path = \22%s\22\0A\00"
@.str.4 = [6 x i8] c"%s/%s\00"
@DT_REG = global i32 0
@.str.5 = [9 x i8] c"%s/%s/%s\00"
@.str.6 = [3 x i8] c"%s\00"
@stdout = global i32 0
@.str.7 = [13 x i8] c"%25s = \22%s\22\0A\00"
@.str.8 = [2 x i8] c"\0A\00"
define void @fc_host_summary(i8 signext %0) {
%2 = alloca i8
%3 = alloca i32*
%4 = alloca %struct.dirent*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i32*
%9 = alloca %struct.dirent*
%10 = alloca i8*
store i8 %0, i8* %2
%11 = load i32, i32* @PATH_MAX
%12 = zext i32 %11 to i64
%13 = call i8* @llvm.stacksave()
store i8* %13, i8** %6
%14 = alloca i8, i64 %12
store i64 %12, i64* %7
%15 = call i32 (i32**, i8*, ...) @sysfsparser_opendir(i32** %3, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
br label %16
16: ; preds = %70, %30, %1
%17 = load i32*, i32** %3
%18 = load i32, i32* @DT_DIR
%19 = load i32, i32* @DT_LNK
%20 = or i32 %18, %19
%21 = call %struct.dirent* @sysfsparser_readfilename(i32* %17, i32 %20)
store %struct.dirent* %21, %struct.dirent** %4
%22 = icmp ne %struct.dirent* %21, null
br i1 %22, label %23, label %77
23: ; preds = %16
%24 = load %struct.dirent*, %struct.dirent** %4
%25 = getelementptr inbounds %struct.dirent, %struct.dirent* %24, i32 0, i32 0
%26 = load i8*, i8** %25
%27 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* %26)
%28 = load i8, i8* %2
%29 = icmp ne i8 %28, 0
br i1 %29, label %31, label %30
30: ; preds = %23
br label %16
31: ; preds = %23
%32 = load i32, i32* @PATH_MAX
%33 = load %struct.dirent*, %struct.dirent** %4
%34 = getelementptr inbounds %struct.dirent, %struct.dirent* %33, i32 0, i32 0
%35 = load i8*, i8** %34
%36 = call i32 (i8*, i32, i8*, i8*, i8*, ...) @snprintf(i8* %14, i32 %32, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %35)
%37 = call i8* @realpath(i8* %14, i32* null)
store i8* %37, i8** %10
%38 = load i8*, i8** %10
%39 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i8* %38)
%40 = load %struct.dirent*, %struct.dirent** %4
%41 = getelementptr inbounds %struct.dirent, %struct.dirent* %40, i32 0, i32 0
%42 = load i8*, i8** %41
%43 = call i32 (i32**, i8*, ...) @sysfsparser_opendir(i32** %8, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %42)
br label %44
44: ; preds = %69, %31
%45 = load i32*, i32** %8
%46 = load i32, i32* @DT_REG
%47 = call %struct.dirent* @sysfsparser_readfilename(i32* %45, i32 %46)
store %struct.dirent* %47, %struct.dirent** %9
%48 = icmp ne %struct.dirent* %47, null
br i1 %48, label %49, label %70
49: ; preds = %44
%50 = load i32, i32* @PATH_MAX
%51 = load %struct.dirent*, %struct.dirent** %4
%52 = getelementptr inbounds %struct.dirent, %struct.dirent* %51, i32 0, i32 0
%53 = load i8*, i8** %52
%54 = load %struct.dirent*, %struct.dirent** %9
%55 = getelementptr inbounds %struct.dirent, %struct.dirent* %54, i32 0, i32 0
%56 = load i8*, i8** %55
%57 = call i32 (i8*, i32, i8*, i8*, i8*, ...) @snprintf(i8* %14, i32 %50, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %53, i8* %56)
%58 = call i8* @sysfsparser_getline(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* %14)
store i8* %58, i8** %5
%59 = icmp ne i8* %58, null
br i1 %59, label %60, label %69
60: ; preds = %49
%61 = load i32, i32* @stdout
%62 = load %struct.dirent*, %struct.dirent** %9
%63 = getelementptr inbounds %struct.dirent, %struct.dirent* %62, i32 0, i32 0
%64 = load i8*, i8** %63
%65 = load i8*, i8** %5
%66 = call i32 @fprintf(i32 %61, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0), i8* %64, i8* %65)
%67 = load i8*, i8** %5
%68 = call i32 @free(i8* %67)
br label %69
69: ; preds = %60, %49
br label %44
70: ; preds = %44
%71 = load i32, i32* @stdout
%72 = call i32 @fputs(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0), i32 %71)
%73 = load i32*, i32** %8
%74 = call i32 @sysfsparser_closedir(i32* %73)
%75 = load i8*, i8** %10
%76 = call i32 @free(i8* %75)
br label %16
77: ; preds = %16
%78 = load i32*, i32** %3
%79 = call i32 @sysfsparser_closedir(i32* %78)
%80 = load i8*, i8** %6
ret void
}

LLVM IR (-O2):
%struct.dirent = type { i8* }
@PATH_MAX = global i32 0
@.str = [19 x i8] c"/sys/class/fc_host\00"
@DT_DIR = global i32 0
@DT_LNK = global i32 0
@.str.1 = [21 x i8] c"Class Device = \22%s\22\0A\00"
@.str.2 = [13 x i8] c"%s/%s/device\00"
@.str.3 = [26 x i8] c"Class Device path = \22%s\22\0A\00"
@.str.4 = [6 x i8] c"%s/%s\00"
@DT_REG = global i32 0
@.str.5 = [9 x i8] c"%s/%s/%s\00"
@.str.6 = [3 x i8] c"%s\00"
@stdout = global i32 0
@.str.7 = [13 x i8] c"%25s = \22%s\22\0A\00"
@.str.8 = [2 x i8] c"\0A\00"
define void @fc_host_summary(i8 signext %0) {
%2 = alloca i32*
%3 = alloca i32*
%4 = bitcast i32** %2 to i8*
%5 = load i32, i32* @PATH_MAX
%6 = zext i32 %5 to i64
%7 = tail call i8* @llvm.stacksave()
%8 = alloca i8, i64 %6
%9 = call i32 (i32**, i8*, ...) @sysfsparser_opendir(i32** %2, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%10 = load i32*, i32** %2
%11 = load i32, i32* @DT_DIR
%12 = load i32, i32* @DT_LNK
%13 = or i32 %12, %11
%14 = call %struct.dirent* @sysfsparser_readfilename(i32* %10, i32 %13)
%15 = icmp eq %struct.dirent* %14, null
br i1 %15, label %68, label %16
16: ; preds = %1
%17 = bitcast i32** %3 to i8*
%18 = icmp eq i8 %0, 0
br label %19
19: ; preds = %16, %61
%20 = phi %struct.dirent* [ %14, %16 ], [ %66, %61 ]
%21 = getelementptr inbounds %struct.dirent, %struct.dirent* %20, i64 0, i32 0
%22 = load i8*, i8** %21
%23 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* %22)
br i1 %18, label %61, label %24
24: ; preds = %19
%25 = load i32, i32* @PATH_MAX
%26 = load i8*, i8** %21
%27 = call i32 (i8*, i32, i8*, i8*, i8*, ...) @snprintf(i8* %8, i32 %25, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %26)
%28 = call i8* @realpath(i8* %8, i32* null)
%29 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i8* %28)
%30 = load i8*, i8** %21
%31 = call i32 (i32**, i8*, ...) @sysfsparser_opendir(i32** %3, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %30)
%32 = load i32*, i32** %3
%33 = load i32, i32* @DT_REG
%34 = call %struct.dirent* @sysfsparser_readfilename(i32* %32, i32 %33)
%35 = icmp eq %struct.dirent* %34, null
br i1 %35, label %55, label %36
36: ; preds = %24, %50
%37 = phi %struct.dirent* [ %53, %50 ], [ %34, %24 ]
%38 = load i32, i32* @PATH_MAX
%39 = load i8*, i8** %21
%40 = getelementptr inbounds %struct.dirent, %struct.dirent* %37, i64 0, i32 0
%41 = load i8*, i8** %40
%42 = call i32 (i8*, i32, i8*, i8*, i8*, ...) @snprintf(i8* %8, i32 %38, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %39, i8* %41)
%43 = call i8* @sysfsparser_getline(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* %8)
%44 = icmp eq i8* %43, null
br i1 %44, label %50, label %45
45: ; preds = %36
%46 = load i32, i32* @stdout
%47 = load i8*, i8** %40
%48 = call i32 @fprintf(i32 %46, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0), i8* %47, i8* %43)
%49 = call i32 @free(i8* %43)
br label %50
50: ; preds = %45, %36
%51 = load i32*, i32** %3
%52 = load i32, i32* @DT_REG
%53 = call %struct.dirent* @sysfsparser_readfilename(i32* %51, i32 %52)
%54 = icmp eq %struct.dirent* %53, null
br i1 %54, label %55, label %36
55: ; preds = %50, %24
%56 = load i32, i32* @stdout
%57 = call i32 @fputs(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0), i32 %56)
%58 = load i32*, i32** %3
%59 = call i32 @sysfsparser_closedir(i32* %58)
%60 = call i32 @free(i8* %28)
br label %61
61: ; preds = %19, %55
%62 = load i32*, i32** %2
%63 = load i32, i32* @DT_DIR
%64 = load i32, i32* @DT_LNK
%65 = or i32 %64, %63
%66 = call %struct.dirent* @sysfsparser_readfilename(i32* %62, i32 %65)
%67 = icmp eq %struct.dirent* %66, null
br i1 %67, label %68, label %19
68: ; preds = %61, %1
%69 = load i32*, i32** %2
%70 = call i32 @sysfsparser_closedir(i32* %69)
ret void
}