#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 */
typedef int /*<<< orphan*/ vendor;
typedef int /*<<< orphan*/ uint64_t;
typedef int uint32_t;
struct dirent {
  char *d_name;
};
typedef int /*<<< orphan*/ rev;
typedef int /*<<< orphan*/ path;
typedef int /*<<< orphan*/ npath;
typedef int /*<<< orphan*/ model;
typedef int /*<<< orphan*/ DIR;

/* Variables and functions */
int /*<<< orphan*/ closedir(int /*<<< orphan*/ *);
char *format_capstr(int /*<<< orphan*/, int);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ *opendir(char *);
int /*<<< orphan*/ printf(char *, unsigned int, char *, char *, int, char *,
                          char *, char *);
struct dirent *readdir(int /*<<< orphan*/ *);
int /*<<< orphan*/ sa_sys_read_line(char *, char *, char *, int);
int /*<<< orphan*/ sa_sys_read_u32(char *, char *, int *);
int /*<<< orphan*/ sa_sys_read_u64(char *, char *, int /*<<< orphan*/ *);
int snprintf(char *, int, char *, ...);
int strlen(char *);
int /*<<< orphan*/ strncat(char *, char *, int);
void show_short_lun_info(unsigned int hba, unsigned int port, unsigned int tgt,
                         unsigned int lun) {
  struct dirent *dp;
  char vendor[256];
  char path[1024];
  char npath[1024];
  char model[256];
  char rev[256];
  DIR *dir;
  uint32_t blksize = 0;
  char *capstr = "Unknown";
  char *osname = "Unknown";
  uint64_t size = 0;
  int rc;
  rc =
      snprintf(path, sizeof(path), "/sys/class/scsi_device/%u:%u:%u:%u/device/",
               hba, port, tgt, lun);
  if (rc < 0 || (size_t)rc >= sizeof(path))
    return;
  sa_sys_read_line(path, "rev", rev, sizeof(rev));
  sa_sys_read_line(path, "model", model, sizeof(model));
  sa_sys_read_line(path, "vendor", vendor, sizeof(vendor));
  strncat(path, "block", sizeof(path) - strlen(path) - 1);
  dir = opendir(path);
  if (!dir)
    return;
  while ((dp = readdir(dir)) != NULL) {
    if (dp->d_name[0] == '.' &&
        (dp->d_name[1] == '\0' ||
         (dp->d_name[1] == '.' && dp->d_name[2] == '\0')))
      continue;
    osname = dp->d_name;
    rc = snprintf(npath, sizeof(npath), "%s/%s/", path, osname);
    if (rc < 0 || (size_t)rc >= sizeof(npath))
      continue;
    sa_sys_read_u64(npath, "size", &size);
    rc = snprintf(npath, sizeof(npath), "%s/%s/queue/", path, osname);
    if (rc < 0 || (size_t)rc >= sizeof(npath))
      continue;
    sa_sys_read_u32(npath, "hw_sector_size", &blksize);
  }
  closedir(dir);
  capstr = format_capstr(size, blksize);
  printf("%10d  %-11s  %10s  %7d     %s %s (rev %s)\n", lun, osname, capstr,
         blksize, vendor, model, rev);
  free(capstr);
  return;
}


x86 assembly (clang, -O0):
<show_short_lun_info>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb60,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
movl   $0x0,-0xb2c(%rbp)
lea    0xe18(%rip),%rax
mov    %rax,-0xb38(%rbp)
lea    0xe0a(%rip),%rax
mov    %rax,-0xb40(%rbp)
movl   $0x0,-0xb44(%rbp)
lea    -0x520(%rbp),%rdi
mov    -0x4(%rbp),%ecx
mov    -0x8(%rbp),%r8d
mov    -0xc(%rbp),%r9d
mov    -0x10(%rbp),%eax
mov    $0x400,%esi
lea    0xde0(%rip),%rdx
mov    %eax,(%rsp)
mov    $0x0,%al
call   1080 <snprintf@plt>
mov    %eax,-0xb48(%rbp)
cmpl   $0x0,-0xb48(%rbp)
jl     1258 <show_short_lun_info+0x98>
movslq -0xb48(%rbp),%rax
cmp    $0x400,%rax
jb     125d <show_short_lun_info+0x9d>
jmp    14f0 <show_short_lun_info+0x330>
lea    -0x520(%rbp),%rdi
lea    -0xb20(%rbp),%rdx
lea    0xdc1(%rip),%rsi
mov    $0x100,%ecx
call   1090 <sa_sys_read_line@plt>
lea    -0x520(%rbp),%rdi
lea    -0xa20(%rbp),%rdx
lea    0xda6(%rip),%rsi
mov    $0x100,%ecx
call   1090 <sa_sys_read_line@plt>
lea    -0x520(%rbp),%rdi
lea    -0x120(%rbp),%rdx
lea    0xd8d(%rip),%rsi
mov    $0x100,%ecx
call   1090 <sa_sys_read_line@plt>
lea    -0x520(%rbp),%rax
mov    %rax,-0xb50(%rbp)
lea    -0x520(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0xb50(%rbp),%rdi
movslq %eax,%rcx
mov    $0x400,%eax
sub    %rcx,%rax
sub    $0x1,%rax
mov    %eax,%edx
lea    0xd51(%rip),%rsi
call   10a0 <strncat@plt>
lea    -0x520(%rbp),%rdi
call   1040 <opendir@plt>
mov    %rax,-0xb28(%rbp)
cmpq   $0x0,-0xb28(%rbp)
jne    131e <show_short_lun_info+0x15e>
jmp    14f0 <show_short_lun_info+0x330>
jmp    1323 <show_short_lun_info+0x163>
mov    -0xb28(%rbp),%rdi
call   10e0 <readdir@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     147e <show_short_lun_info+0x2be>
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
jne    1391 <show_short_lun_info+0x1d1>
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
movsbl 0x1(%rax),%eax
cmp    $0x0,%eax
je     138c <show_short_lun_info+0x1cc>
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
movsbl 0x1(%rax),%eax
cmp    $0x2e,%eax
jne    1391 <show_short_lun_info+0x1d1>
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
movsbl 0x2(%rax),%eax
cmp    $0x0,%eax
jne    1391 <show_short_lun_info+0x1d1>
jmp    1323 <show_short_lun_info+0x163>
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0xb40(%rbp)
lea    -0x920(%rbp),%rdi
lea    -0x520(%rbp),%rcx
mov    -0xb40(%rbp),%r8
mov    $0x400,%esi
lea    0xc8a(%rip),%rdx
mov    $0x0,%al
call   1080 <snprintf@plt>
mov    %eax,-0xb48(%rbp)
cmpl   $0x0,-0xb48(%rbp)
jl     13ed <show_short_lun_info+0x22d>
movslq -0xb48(%rbp),%rax
cmp    $0x400,%rax
jb     13f2 <show_short_lun_info+0x232>
jmp    1323 <show_short_lun_info+0x163>
lea    -0x920(%rbp),%rdi
lea    0xc68(%rip),%rsi
lea    -0xb44(%rbp),%rdx
call   10d0 <sa_sys_read_u64@plt>
lea    -0x920(%rbp),%rdi
lea    -0x520(%rbp),%rcx
mov    -0xb40(%rbp),%r8
mov    $0x400,%esi
lea    0xc24(%rip),%rdx
mov    $0x0,%al
call   1080 <snprintf@plt>
mov    %eax,-0xb48(%rbp)
cmpl   $0x0,-0xb48(%rbp)
jl     145a <show_short_lun_info+0x29a>
movslq -0xb48(%rbp),%rax
cmp    $0x400,%rax
jb     145f <show_short_lun_info+0x29f>
jmp    1323 <show_short_lun_info+0x163>
lea    -0x920(%rbp),%rdi
lea    0xbf1(%rip),%rsi
lea    -0xb2c(%rbp),%rdx
call   10b0 <sa_sys_read_u32@plt>
jmp    1323 <show_short_lun_info+0x163>
mov    -0xb28(%rbp),%rdi
call   10c0 <closedir@plt>
mov    -0xb44(%rbp),%edi
mov    -0xb2c(%rbp),%esi
call   1060 <format_capstr@plt>
mov    %rax,-0xb38(%rbp)
mov    -0x10(%rbp),%esi
mov    -0xb40(%rbp),%rdx
mov    -0xb38(%rbp),%rcx
mov    -0xb2c(%rbp),%r8d
lea    -0x120(%rbp),%r9
lea    -0xa20(%rbp),%r10
lea    -0xb20(%rbp),%rax
lea    0xb97(%rip),%rdi
mov    %r10,(%rsp)
mov    %rax,0x8(%rsp)
call   1070 <printf@plt>
mov    -0xb38(%rbp),%rdi
call   1030 <free@plt>
add    $0xb60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<show_short_lun_info>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xb18,%rsp
mov    %ecx,%r12d
mov    %edx,%r9d
mov    %esi,%r8d
mov    %edi,%ecx
movl   $0x0,0x8(%rsp)
movl   $0x0,0xc(%rsp)
sub    $0x8,%rsp
lea    0xe11(%rip),%rdx
lea    0x318(%rsp),%rdi
mov    $0x400,%esi
xor    %eax,%eax
push   %r12
call   1080 <snprintf@plt>
add    $0x10,%rsp
cmp    $0x3ff,%eax
ja     13ed <show_short_lun_info+0x22d>
lea    0xe10(%rip),%rsi
lea    0x310(%rsp),%rbx
lea    0x210(%rsp),%r14
mov    %rbx,%rdi
mov    %r14,%rdx
mov    $0x100,%ecx
call   1090 <sa_sys_read_line@plt>
lea    0xded(%rip),%rsi
lea    0x10(%rsp),%rdx
mov    %rbx,%rdi
mov    $0x100,%ecx
call   1090 <sa_sys_read_line@plt>
lea    0xdda(%rip),%rsi
lea    0x110(%rsp),%rdx
mov    %rbx,%rdi
mov    $0x100,%ecx
call   1090 <sa_sys_read_line@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    $0x3ff,%edx
sub    %eax,%edx
lea    0xdb6(%rip),%rsi
mov    %rbx,%rdi
call   10a0 <strncat@plt>
mov    %rbx,%rdi
call   1040 <opendir@plt>
test   %rax,%rax
je     13ed <show_short_lun_info+0x22d>
mov    %rax,%r13
mov    %rax,%rdi
call   10e0 <readdir@plt>
lea    0xd47(%rip),%rbx
test   %rax,%rax
je     139f <show_short_lun_info+0x1df>
lea    0x710(%rsp),%rbp
jmp    12e1 <show_short_lun_info+0x121>
nopl   0x0(%rax)
mov    %r13,%rdi
call   10e0 <readdir@plt>
test   %rax,%rax
je     139f <show_short_lun_info+0x1df>
mov    %rbx,%r15
jmp    1301 <show_short_lun_info+0x141>
cs nopw 0x0(%rax,%rax,1)
mov    %r13,%rdi
call   10e0 <readdir@plt>
test   %rax,%rax
je     139c <show_short_lun_info+0x1dc>
mov    (%rax),%rbx
cmpb   $0x2e,(%rbx)
jne    131b <show_short_lun_info+0x15b>
movzbl 0x1(%rbx),%eax
test   %al,%al
je     12f0 <show_short_lun_info+0x130>
cmp    $0x2e,%al
jne    131b <show_short_lun_info+0x15b>
cmpb   $0x0,0x2(%rbx)
je     12f0 <show_short_lun_info+0x130>
mov    %rbp,%rdi
mov    $0x400,%esi
lea    0xd20(%rip),%rdx
lea    0x310(%rsp),%rcx
mov    %rbx,%r8
xor    %eax,%eax
call   1080 <snprintf@plt>
cmp    $0x400,%eax
jae    12d0 <show_short_lun_info+0x110>
mov    %rbp,%rdi
lea    0xd1b(%rip),%rsi
lea    0xc(%rsp),%rdx
call   10d0 <sa_sys_read_u64@plt>
mov    %rbp,%rdi
mov    $0x400,%esi
lea    0xceb(%rip),%rdx
lea    0x310(%rsp),%rcx
mov    %rbx,%r8
xor    %eax,%eax
call   1080 <snprintf@plt>
cmp    $0x3ff,%eax
ja     12d0 <show_short_lun_info+0x110>
mov    %rbp,%rdi
lea    0xcd1(%rip),%rsi
lea    0x8(%rsp),%rdx
call   10b0 <sa_sys_read_u32@plt>
jmp    12d0 <show_short_lun_info+0x110>
mov    %r15,%rbx
mov    %r13,%rdi
call   10c0 <closedir@plt>
mov    0xc(%rsp),%edi
mov    0x8(%rsp),%esi
call   1060 <format_capstr@plt>
mov    %rax,%rbp
mov    0x8(%rsp),%r8d
lea    0xcaa(%rip),%rdi
lea    0x110(%rsp),%r9
mov    %r12d,%esi
mov    %rbx,%rdx
mov    %rax,%rcx
push   %r14
lea    0x18(%rsp),%rax
push   %rax
call   1070 <printf@plt>
add    $0x10,%rsp
mov    %rbp,%rdi
call   1030 <free@plt>
add    $0xb18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.dirent = type { i8* }
@.str = [8 x i8] c"Unknown\00"
@.str.1 = [43 x i8] c"/sys/class/scsi_device/%u:%u:%u:%u/device/\00"
@.str.2 = [4 x i8] c"rev\00"
@.str.3 = [6 x i8] c"model\00"
@.str.4 = [7 x i8] c"vendor\00"
@.str.5 = [6 x i8] c"block\00"
@.str.6 = [7 x i8] c"%s/%s/\00"
@.str.7 = [5 x i8] c"size\00"
@.str.8 = [13 x i8] c"%s/%s/queue/\00"
@.str.9 = [15 x i8] c"hw_sector_size\00"
@.str.10 = [43 x i8] c"%10d %-11s %10s %7d %s %s (rev %s)\0A\00"
define void @show_short_lun_info(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca %struct.dirent*
%10 = alloca [256 x i8]
%11 = alloca [1024 x i8]
%12 = alloca [1024 x i8]
%13 = alloca [256 x i8]
%14 = alloca [256 x i8]
%15 = alloca i32*
%16 = alloca i32
%17 = alloca i8*
%18 = alloca i8*
%19 = alloca i32
%20 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
store i32 0, i32* %16
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8** %17
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8** %18
store i32 0, i32* %19
%21 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%22 = load i32, i32* %5
%23 = load i32, i32* %6
%24 = load i32, i32* %7
%25 = load i32, i32* %8
%26 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %21, i32 1024, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0), i32 %22, i32 %23, i32 %24, i32 %25)
store i32 %26, i32* %20
%27 = load i32, i32* %20
%28 = icmp slt i32 %27, 0
br i1 %28, label %33, label %29
29: ; preds = %4
%30 = load i32, i32* %20
%31 = sext i32 %30 to i64
%32 = icmp uge i64 %31, 1024
br i1 %32, label %33, label %34
33: ; preds = %29, %4
br label %143
34: ; preds = %29
%35 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%36 = getelementptr inbounds [256 x i8], [256 x i8]* %14, i64 0, i64 0
%37 = call i32 @sa_sys_read_line(i8* %35, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %36, i32 256)
%38 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%39 = getelementptr inbounds [256 x i8], [256 x i8]* %13, i64 0, i64 0
%40 = call i32 @sa_sys_read_line(i8* %38, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8* %39, i32 256)
%41 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%42 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%43 = call i32 @sa_sys_read_line(i8* %41, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i8* %42, i32 256)
%44 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%45 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%46 = call i32 @strlen(i8* %45)
%47 = sext i32 %46 to i64
%48 = sub i64 1024, %47
%49 = sub i64 %48, 1
%50 = trunc i64 %49 to i32
%51 = call i32 @strncat(i8* %44, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i32 %50)
%52 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%53 = call i32* @opendir(i8* %52)
store i32* %53, i32** %15
%54 = load i32*, i32** %15
%55 = icmp ne i32* %54, null
br i1 %55, label %57, label %56
56: ; preds = %34
br label %143
57: ; preds = %34
br label %58
58: ; preds = %124, %123, %109, %94, %57
%59 = load i32*, i32** %15
%60 = call %struct.dirent* @readdir(i32* %59)
store %struct.dirent* %60, %struct.dirent** %9
%61 = icmp ne %struct.dirent* %60, null
br i1 %61, label %62, label %127
62: ; preds = %58
%63 = load %struct.dirent*, %struct.dirent** %9
%64 = getelementptr inbounds %struct.dirent, %struct.dirent* %63, i32 0, i32 0
%65 = load i8*, i8** %64
%66 = getelementptr inbounds i8, i8* %65, i64 0
%67 = load i8, i8* %66
%68 = sext i8 %67 to i32
%69 = icmp eq i32 %68, 46
br i1 %69, label %70, label %95
70: ; preds = %62
%71 = load %struct.dirent*, %struct.dirent** %9
%72 = getelementptr inbounds %struct.dirent, %struct.dirent* %71, i32 0, i32 0
%73 = load i8*, i8** %72
%74 = getelementptr inbounds i8, i8* %73, i64 1
%75 = load i8, i8* %74
%76 = sext i8 %75 to i32
%77 = icmp eq i32 %76, 0
br i1 %77, label %94, label %78
78: ; preds = %70
%79 = load %struct.dirent*, %struct.dirent** %9
%80 = getelementptr inbounds %struct.dirent, %struct.dirent* %79, i32 0, i32 0
%81 = load i8*, i8** %80
%82 = getelementptr inbounds i8, i8* %81, i64 1
%83 = load i8, i8* %82
%84 = sext i8 %83 to i32
%85 = icmp eq i32 %84, 46
br i1 %85, label %86, label %95
86: ; preds = %78
%87 = load %struct.dirent*, %struct.dirent** %9
%88 = getelementptr inbounds %struct.dirent, %struct.dirent* %87, i32 0, i32 0
%89 = load i8*, i8** %88
%90 = getelementptr inbounds i8, i8* %89, i64 2
%91 = load i8, i8* %90
%92 = sext i8 %91 to i32
%93 = icmp eq i32 %92, 0
br i1 %93, label %94, label %95
94: ; preds = %86, %70
br label %58
95: ; preds = %86, %78, %62
%96 = load %struct.dirent*, %struct.dirent** %9
%97 = getelementptr inbounds %struct.dirent, %struct.dirent* %96, i32 0, i32 0
%98 = load i8*, i8** %97
store i8* %98, i8** %18
%99 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%100 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%101 = load i8*, i8** %18
%102 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %99, i32 1024, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i8* %100, i8* %101)
store i32 %102, i32* %20
%103 = load i32, i32* %20
%104 = icmp slt i32 %103, 0
br i1 %104, label %109, label %105
105: ; preds = %95
%106 = load i32, i32* %20
%107 = sext i32 %106 to i64
%108 = icmp uge i64 %107, 1024
br i1 %108, label %109, label %110
109: ; preds = %105, %95
br label %58
110: ; preds = %105
%111 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%112 = call i32 @sa_sys_read_u64(i8* %111, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i32* %19)
%113 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%114 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%115 = load i8*, i8** %18
%116 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %113, i32 1024, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0), i8* %114, i8* %115)
store i32 %116, i32* %20
%117 = load i32, i32* %20
%118 = icmp slt i32 %117, 0
br i1 %118, label %123, label %119
119: ; preds = %110
%120 = load i32, i32* %20
%121 = sext i32 %120 to i64
%122 = icmp uge i64 %121, 1024
br i1 %122, label %123, label %124
123: ; preds = %119, %110
br label %58
124: ; preds = %119
%125 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%126 = call i32 @sa_sys_read_u32(i8* %125, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.9, i64 0, i64 0), i32* %16)
br label %58
127: ; preds = %58
%128 = load i32*, i32** %15
%129 = call i32 @closedir(i32* %128)
%130 = load i32, i32* %19
%131 = load i32, i32* %16
%132 = call i8* @format_capstr(i32 %130, i32 %131)
store i8* %132, i8** %17
%133 = load i32, i32* %8
%134 = load i8*, i8** %18
%135 = load i8*, i8** %17
%136 = load i32, i32* %16
%137 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%138 = getelementptr inbounds [256 x i8], [256 x i8]* %13, i64 0, i64 0
%139 = getelementptr inbounds [256 x i8], [256 x i8]* %14, i64 0, i64 0
%140 = call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.10, i64 0, i64 0), i32 %133, i8* %134, i8* %135, i32 %136, i8* %137, i8* %138, i8* %139)
%141 = load i8*, i8** %17
%142 = call i32 @free(i8* %141)
br label %143
143: ; preds = %127, %56, %33
ret void
}

LLVM IR (-O2):
%struct.dirent = type { i8* }
@.str = [8 x i8] c"Unknown\00"
@.str.1 = [43 x i8] c"/sys/class/scsi_device/%u:%u:%u:%u/device/\00"
@.str.2 = [4 x i8] c"rev\00"
@.str.3 = [6 x i8] c"model\00"
@.str.4 = [7 x i8] c"vendor\00"
@.str.5 = [6 x i8] c"block\00"
@.str.6 = [7 x i8] c"%s/%s/\00"
@.str.7 = [5 x i8] c"size\00"
@.str.8 = [13 x i8] c"%s/%s/queue/\00"
@.str.9 = [15 x i8] c"hw_sector_size\00"
@.str.10 = [43 x i8] c"%10d %-11s %10s %7d %s %s (rev %s)\0A\00"
define void @show_short_lun_info(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca [256 x i8]
%6 = alloca [1024 x i8]
%7 = alloca [1024 x i8]
%8 = alloca [256 x i8]
%9 = alloca [256 x i8]
%10 = alloca i32
%11 = alloca i32
%12 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%13 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%14 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%15 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%16 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 0
%17 = bitcast i32* %10 to i8*
store i32 0, i32* %10
%18 = bitcast i32* %11 to i8*
store i32 0, i32* %11
%19 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %13, i32 1024, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0), i32 %0, i32 %1, i32 %2, i32 %3)
%20 = icmp ugt i32 %19, 1023
br i1 %20, label %73, label %21
21: ; preds = %4
%22 = call i32 @sa_sys_read_line(i8* %13, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %16, i32 256)
%23 = call i32 @sa_sys_read_line(i8* %13, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8* %15, i32 256)
%24 = call i32 @sa_sys_read_line(i8* %13, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i8* %12, i32 256)
%25 = call i32 @strlen(i8* %13)
%26 = sub i32 1023, %25
%27 = call i32 @strncat(i8* %13, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i32 %26)
%28 = call i32* @opendir(i8* %13)
%29 = icmp eq i32* %28, null
br i1 %29, label %73, label %30
30: ; preds = %21
%31 = call %struct.dirent* @readdir(i32* %28)
%32 = icmp eq %struct.dirent* %31, null
br i1 %32, label %64, label %33
33: ; preds = %30, %55
%34 = phi %struct.dirent* [ %56, %55 ], [ %31, %30 ]
%35 = phi i8* [ %39, %55 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), %30 ]
br label %36
36: ; preds = %33, %49
%37 = phi %struct.dirent* [ %34, %33 ], [ %50, %49 ]
%38 = getelementptr inbounds %struct.dirent, %struct.dirent* %37, i64 0, i32 0
%39 = load i8*, i8** %38
%40 = load i8, i8* %39
%41 = icmp eq i8 %40, 46
br i1 %41, label %42, label %52
42: ; preds = %36
%43 = getelementptr inbounds i8, i8* %39, i64 1
%44 = load i8, i8* %43
switch i8 %44, label %52 [
i8 0, label %49
i8 46, label %45
]
45: ; preds = %42
%46 = getelementptr inbounds i8, i8* %39, i64 2
%47 = load i8, i8* %46
%48 = icmp eq i8 %47, 0
br i1 %48, label %49, label %52
49: ; preds = %42, %45
%50 = call %struct.dirent* @readdir(i32* %28)
%51 = icmp eq %struct.dirent* %50, null
br i1 %51, label %64, label %36
52: ; preds = %42, %45, %36
%53 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %14, i32 1024, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i8* %13, i8* %39)
%54 = icmp ugt i32 %53, 1023
br i1 %54, label %55, label %58
55: ; preds = %52, %58, %62
%56 = call %struct.dirent* @readdir(i32* %28)
%57 = icmp eq %struct.dirent* %56, null
br i1 %57, label %64, label %33
58: ; preds = %52
%59 = call i32 @sa_sys_read_u64(i8* %14, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i32* %11)
%60 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %14, i32 1024, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0), i8* %13, i8* %39)
%61 = icmp ugt i32 %60, 1023
br i1 %61, label %55, label %62
62: ; preds = %58
%63 = call i32 @sa_sys_read_u32(i8* %14, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.9, i64 0, i64 0), i32* %10)
br label %55
64: ; preds = %55, %49, %30
%65 = phi i8* [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), %30 ], [ %35, %49 ], [ %39, %55 ]
%66 = call i32 @closedir(i32* %28)
%67 = load i32, i32* %11
%68 = load i32, i32* %10
%69 = call i8* @format_capstr(i32 %67, i32 %68)
%70 = load i32, i32* %10
%71 = call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.10, i64 0, i64 0), i32 %3, i8* %65, i8* %69, i32 %70, i8* %12, i8* %15, i8* %16)
%72 = call i32 @free(i8* %69)
br label %73
73: ; preds = %21, %4, %64
ret void
}