#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 */
int /*<<< orphan*/ dStrHex(char const *, int, int);
int /*<<< orphan*/ decode_dev_ids(char *, unsigned char *, int, int, int, int,
                                  int, int);
int /*<<< orphan*/ decode_transport_id(char *, unsigned char *, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int, ...);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
void decode_scsi_ports_vpd(unsigned char *buff, int len, int do_hex,
                           int do_long, int do_quiet) {
  int k, bump, rel_port, ip_tid_len, tpd_len;
  unsigned char *ucp;
  if (1 == do_hex) {
    dStrHex((const char *)buff, len, 1);
    return;
  }
  if (len < 4) {
    fprintf(stderr, "SCSI Ports VPD page length too short=%d\n", len);
    return;
  }
  len -= 4;
  ucp = buff + 4;
  for (k = 0; k < len; k += bump, ucp += bump) {
    rel_port = (ucp[2] << 8) + ucp[3];
    printf("Relative port=%d\n", rel_port);
    ip_tid_len = (ucp[6] << 8) + ucp[7];
    bump = 8 + ip_tid_len;
    if ((k + bump) > len) {
      fprintf(stderr,
              "SCSI Ports VPD page, short descriptor "
              "length=%d, left=%d\n",
              bump, (len - k));
      return;
    }
    if (ip_tid_len > 0) {
      if (do_hex > 1) {
        printf(" Initiator port transport id:\n");
        dStrHex((const char *)(ucp + 8), ip_tid_len, 1);
      } else
        decode_transport_id(" ", ucp + 8, ip_tid_len);
    }
    tpd_len = (ucp[bump + 2] << 8) + ucp[bump + 3];
    if ((k + bump + tpd_len + 4) > len) {
      fprintf(stderr,
              "SCSI Ports VPD page, short descriptor(tgt) "
              "length=%d, left=%d\n",
              bump, (len - k));
      return;
    }
    if (tpd_len > 0) {
      if (do_hex > 1) {
        printf(" Target port descriptor(s):\n");
        dStrHex((const char *)(ucp + bump + 4), tpd_len, 1);
      } else {
        if ((0 == do_quiet) || (ip_tid_len > 0))
          printf(" Target port descriptor(s):\n");
        decode_dev_ids("SCSI Ports", ucp + bump + 4, tpd_len, 1, -1, -1,
                       do_long, do_quiet);
      }
    }
    bump += tpd_len + 4;
  }
}


x86 assembly (clang, -O0):
<decode_scsi_ports_vpd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8d,-0x18(%rbp)
mov    $0x1,%eax
cmp    -0x10(%rbp),%eax
jne    118d <decode_scsi_ports_vpd+0x3d>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    $0x1,%edx
call   1030 <dStrHex@plt>
jmp    13e9 <decode_scsi_ports_vpd+0x299>
cmpl   $0x4,-0xc(%rbp)
jge    11b6 <decode_scsi_ports_vpd+0x66>
mov    0x2e42(%rip),%rax
mov    (%rax),%edi
mov    -0xc(%rbp),%edx
lea    0xe56(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
jmp    13e9 <decode_scsi_ports_vpd+0x299>
mov    -0xc(%rbp),%eax
sub    $0x4,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x38(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    13e9 <decode_scsi_ports_vpd+0x299>
mov    -0x38(%rbp),%rax
movzbl 0x2(%rax),%eax
shl    $0x8,%eax
mov    -0x38(%rbp),%rcx
movzbl 0x3(%rcx),%ecx
add    %ecx,%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%esi
lea    0xe29(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x38(%rbp),%rax
movzbl 0x6(%rax),%eax
shl    $0x8,%eax
mov    -0x38(%rbp),%rcx
movzbl 0x7(%rcx),%ecx
add    %ecx,%eax
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%eax
add    $0x8,%eax
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%eax
add    -0x20(%rbp),%eax
cmp    -0xc(%rbp),%eax
jle    125c <decode_scsi_ports_vpd+0x10c>
mov    0x2da2(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%edx
mov    -0xc(%rbp),%ecx
sub    -0x1c(%rbp),%ecx
lea    0xdeb(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
jmp    13e9 <decode_scsi_ports_vpd+0x299>
cmpl   $0x0,-0x28(%rbp)
jle    12b4 <decode_scsi_ports_vpd+0x164>
cmpl   $0x1,-0x10(%rbp)
jle    1298 <decode_scsi_ports_vpd+0x148>
lea    0xdfe(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x38(%rbp),%rdi
add    $0x8,%rdi
mov    -0x28(%rbp),%esi
mov    $0x1,%edx
call   1030 <dStrHex@plt>
jmp    12af <decode_scsi_ports_vpd+0x15f>
mov    -0x38(%rbp),%rsi
add    $0x8,%rsi
mov    -0x28(%rbp),%edx
lea    0xdea(%rip),%rdi
call   1040 <decode_transport_id@plt>
jmp    12b4 <decode_scsi_ports_vpd+0x164>
mov    -0x38(%rbp),%rax
mov    -0x20(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
movzbl (%rax,%rcx,1),%eax
shl    $0x8,%eax
mov    -0x38(%rbp),%rcx
mov    -0x20(%rbp),%edx
add    $0x3,%edx
movslq %edx,%rdx
movzbl (%rcx,%rdx,1),%ecx
add    %ecx,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x1c(%rbp),%eax
add    -0x20(%rbp),%eax
add    -0x2c(%rbp),%eax
add    $0x4,%eax
cmp    -0xc(%rbp),%eax
jle    1318 <decode_scsi_ports_vpd+0x1c8>
mov    0x2ce6(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%edx
mov    -0xc(%rbp),%ecx
sub    -0x1c(%rbp),%ecx
lea    0xd8a(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
jmp    13e9 <decode_scsi_ports_vpd+0x299>
cmpl   $0x0,-0x2c(%rbp)
jle    13be <decode_scsi_ports_vpd+0x26e>
cmpl   $0x1,-0x10(%rbp)
jle    135b <decode_scsi_ports_vpd+0x20b>
lea    0xda2(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x38(%rbp),%rdi
movslq -0x20(%rbp),%rax
add    %rax,%rdi
add    $0x4,%rdi
mov    -0x2c(%rbp),%esi
mov    $0x1,%edx
call   1030 <dStrHex@plt>
jmp    13b9 <decode_scsi_ports_vpd+0x269>
xor    %eax,%eax
cmp    -0x18(%rbp),%eax
je     1370 <decode_scsi_ports_vpd+0x220>
cmpl   $0x0,-0x28(%rbp)
jle    137e <decode_scsi_ports_vpd+0x22e>
lea    0xd5e(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x38(%rbp),%rsi
movslq -0x20(%rbp),%rax
add    %rax,%rsi
add    $0x4,%rsi
mov    -0x2c(%rbp),%edx
mov    -0x14(%rbp),%r10d
mov    -0x18(%rbp),%eax
lea    0xd54(%rip),%rdi
mov    $0x1,%ecx
mov    $0xffffffff,%r9d
mov    %r9d,%r8d
mov    %r10d,(%rsp)
mov    %eax,0x8(%rsp)
call   1070 <decode_dev_ids@plt>
jmp    13be <decode_scsi_ports_vpd+0x26e>
mov    -0x2c(%rbp),%eax
add    $0x4,%eax
add    -0x20(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
add    -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x20(%rbp),%ecx
mov    -0x38(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x38(%rbp)
jmp    11d2 <decode_scsi_ports_vpd+0x82>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<decode_scsi_ports_vpd>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %esi,%ebp
mov    %rdi,%rbx
mov    %edx,0xc(%rsp)
cmp    $0x1,%edx
jne    1199 <decode_scsi_ports_vpd+0x39>
mov    %rbx,%rdi
mov    %ebp,%esi
mov    $0x1,%edx
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <dStrHex@plt>
cmp    $0x3,%ebp
jg     11c5 <decode_scsi_ports_vpd+0x65>
mov    0x2e3b(%rip),%rax
mov    (%rax),%edi
lea    0xe52(%rip),%rsi
mov    %ebp,%edx
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1070 <fprintf@plt>
mov    %rcx,0x18(%rsp)
mov    %r8,0x10(%rsp)
cmp    $0x4,%ebp
jne    11e3 <decode_scsi_ports_vpd+0x83>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
add    $0xfffffffc,%ebp
add    $0x4,%rbx
xor    %r12d,%r12d
mov    %ebp,0x8(%rsp)
jmp    1239 <decode_scsi_ports_vpd+0xd9>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
lea    0xeba(%rip),%rdi
mov    %rdx,%r15
call   1030 <puts@plt>
lea    (%rbx,%r13,1),%rdi
add    $0x4,%rdi
mov    %r14d,%esi
mov    $0x1,%edx
call   1040 <dStrHex@plt>
mov    %r15,%rdx
add    %rdx,%rbp
add    %ebp,%r12d
add    %rbp,%rbx
mov    0x8(%rsp),%ebp
cmp    %r12d,%ebp
jle    11d4 <decode_scsi_ports_vpd+0x74>
movzwl 0x2(%rbx),%esi
shl    $0x10,%esi
bswap  %esi
lea    0xde0(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
movzwl 0x6(%rbx),%r15d
shl    $0x30,%r15
bswap  %r15
lea    0x8(%r15),%rdx
lea    (%rdx,%r12,1),%r13d
cmp    %ebp,%r13d
jg     134e <decode_scsi_ports_vpd+0x1ee>
test   %r15d,%r15d
je     12b9 <decode_scsi_ports_vpd+0x159>
cmpl   $0x2,0xc(%rsp)
jl     12a0 <decode_scsi_ports_vpd+0x140>
lea    0xe5d(%rip),%rdi
mov    %rdx,%rbp
call   1030 <puts@plt>
lea    0x8(%rbx),%rdi
mov    %r15d,%esi
mov    $0x1,%edx
call   1040 <dStrHex@plt>
jmp    12b6 <decode_scsi_ports_vpd+0x156>
nopl   0x0(%rax,%rax,1)
lea    0x8(%rbx),%rsi
lea    0xdca(%rip),%rdi
mov    %rdx,%rbp
mov    %r15d,%edx
call   1050 <decode_transport_id@plt>
mov    %rbp,%rdx
movzwl 0xa(%r15,%rbx,1),%r14d
shl    $0x30,%r14
bswap  %r14
lea    0x4(%r14),%rbp
add    %ebp,%r13d
cmp    0x8(%rsp),%r13d
jg     1365 <decode_scsi_ports_vpd+0x205>
test   %r14d,%r14d
je     1227 <decode_scsi_ports_vpd+0xc7>
mov    %edx,%r13d
cmpl   $0x2,0xc(%rsp)
jge    1200 <decode_scsi_ports_vpd+0xa0>
mov    %rdx,0x20(%rsp)
mov    0x10(%rsp),%rax
test   %eax,%eax
je     1302 <decode_scsi_ports_vpd+0x1a2>
test   %r15d,%r15d
je     1313 <decode_scsi_ports_vpd+0x1b3>
lea    0xdb8(%rip),%rdi
call   1030 <puts@plt>
mov    0x10(%rsp),%rax
lea    (%rbx,%r13,1),%rsi
add    $0x4,%rsi
lea    0xd94(%rip),%rdi
mov    %r14d,%edx
mov    $0x1,%ecx
mov    $0xffffffff,%r8d
mov    $0xffffffff,%r9d
push   %rax
push   0x20(%rsp)
call   1080 <decode_dev_ids@plt>
add    $0x10,%rsp
mov    0x20(%rsp),%rdx
jmp    1227 <decode_scsi_ports_vpd+0xc7>
mov    0x2c8b(%rip),%rax
mov    (%rax),%edi
sub    %r12d,%ebp
lea    0xcda(%rip),%rsi
mov    %ebp,%ecx
jmp    137c <decode_scsi_ports_vpd+0x21c>
mov    0x2c74(%rip),%rax
mov    (%rax),%edi
mov    0x8(%rsp),%ecx
sub    %r12d,%ecx
lea    0xcfb(%rip),%rsi
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1070 <fprintf@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [41 x i8] c"SCSI Ports VPD page length too short=%d\0A\00"
@.str.1 = [18 x i8] c"Relative port=%d\0A\00"
@.str.2 = [58 x i8] c"SCSI Ports VPD page, short descriptor length=%d, left=%d\0A\00"
@.str.3 = [31 x i8] c" Initiator port transport id:\0A\00"
@.str.4 = [2 x i8] c" \00"
@.str.5 = [63 x i8] c"SCSI Ports VPD page, short descriptor(tgt) length=%d, left=%d\0A\00"
@.str.6 = [29 x i8] c" Target port descriptor(s):\0A\00"
@.str.7 = [11 x i8] c"SCSI Ports\00"
define void @decode_scsi_ports_vpd(i8* %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i8*
store i8* %0, i8** %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i32 %4, i32* %10
%17 = load i32, i32* %8
%18 = icmp eq i32 1, %17
br i1 %18, label %19, label %23
19: ; preds = %5
%20 = load i8*, i8** %6
%21 = load i32, i32* %7
%22 = call i32 @dStrHex(i8* %20, i32 %21, i32 1)
br label %173
23: ; preds = %5
%24 = load i32, i32* %7
%25 = icmp slt i32 %24, 4
br i1 %25, label %26, label %30
26: ; preds = %23
%27 = load i32, i32* @stderr
%28 = load i32, i32* %7
%29 = call i32 (i32, i8*, i32, ...) @fprintf(i32 %27, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i32 %28)
br label %173
30: ; preds = %23
%31 = load i32, i32* %7
%32 = sub nsw i32 %31, 4
store i32 %32, i32* %7
%33 = load i8*, i8** %6
%34 = getelementptr inbounds i8, i8* %33, i64 4
store i8* %34, i8** %16
store i32 0, i32* %11
br label %35
35: ; preds = %165, %30
%36 = load i32, i32* %11
%37 = load i32, i32* %7
%38 = icmp slt i32 %36, %37
br i1 %38, label %39, label %173
39: ; preds = %35
%40 = load i8*, i8** %16
%41 = getelementptr inbounds i8, i8* %40, i64 2
%42 = load i8, i8* %41
%43 = zext i8 %42 to i32
%44 = shl i32 %43, 8
%45 = load i8*, i8** %16
%46 = getelementptr inbounds i8, i8* %45, i64 3
%47 = load i8, i8* %46
%48 = zext i8 %47 to i32
%49 = add nsw i32 %44, %48
store i32 %49, i32* %13
%50 = load i32, i32* %13
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 %50)
%52 = load i8*, i8** %16
%53 = getelementptr inbounds i8, i8* %52, i64 6
%54 = load i8, i8* %53
%55 = zext i8 %54 to i32
%56 = shl i32 %55, 8
%57 = load i8*, i8** %16
%58 = getelementptr inbounds i8, i8* %57, i64 7
%59 = load i8, i8* %58
%60 = zext i8 %59 to i32
%61 = add nsw i32 %56, %60
store i32 %61, i32* %14
%62 = load i32, i32* %14
%63 = add nsw i32 8, %62
store i32 %63, i32* %12
%64 = load i32, i32* %11
%65 = load i32, i32* %12
%66 = add nsw i32 %64, %65
%67 = load i32, i32* %7
%68 = icmp sgt i32 %66, %67
br i1 %68, label %69, label %76
69: ; preds = %39
%70 = load i32, i32* @stderr
%71 = load i32, i32* %12
%72 = load i32, i32* %7
%73 = load i32, i32* %11
%74 = sub nsw i32 %72, %73
%75 = call i32 (i32, i8*, i32, ...) @fprintf(i32 %70, i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.2, i64 0, i64 0), i32 %71, i32 %74)
br label %173
76: ; preds = %39
%77 = load i32, i32* %14
%78 = icmp sgt i32 %77, 0
br i1 %78, label %79, label %94
79: ; preds = %76
%80 = load i32, i32* %8
%81 = icmp sgt i32 %80, 1
br i1 %81, label %82, label %88
82: ; preds = %79
%83 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0))
%84 = load i8*, i8** %16
%85 = getelementptr inbounds i8, i8* %84, i64 8
%86 = load i32, i32* %14
%87 = call i32 @dStrHex(i8* %85, i32 %86, i32 1)
br label %93
88: ; preds = %79
%89 = load i8*, i8** %16
%90 = getelementptr inbounds i8, i8* %89, i64 8
%91 = load i32, i32* %14
%92 = call i32 @decode_transport_id(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i8* %90, i32 %91)
br label %93
93: ; preds = %88, %82
br label %94
94: ; preds = %93, %76
%95 = load i8*, i8** %16
%96 = load i32, i32* %12
%97 = add nsw i32 %96, 2
%98 = sext i32 %97 to i64
%99 = getelementptr inbounds i8, i8* %95, i64 %98
%100 = load i8, i8* %99
%101 = zext i8 %100 to i32
%102 = shl i32 %101, 8
%103 = load i8*, i8** %16
%104 = load i32, i32* %12
%105 = add nsw i32 %104, 3
%106 = sext i32 %105 to i64
%107 = getelementptr inbounds i8, i8* %103, i64 %106
%108 = load i8, i8* %107
%109 = zext i8 %108 to i32
%110 = add nsw i32 %102, %109
store i32 %110, i32* %15
%111 = load i32, i32* %11
%112 = load i32, i32* %12
%113 = add nsw i32 %111, %112
%114 = load i32, i32* %15
%115 = add nsw i32 %113, %114
%116 = add nsw i32 %115, 4
%117 = load i32, i32* %7
%118 = icmp sgt i32 %116, %117
br i1 %118, label %119, label %126
119: ; preds = %94
%120 = load i32, i32* @stderr
%121 = load i32, i32* %12
%122 = load i32, i32* %7
%123 = load i32, i32* %11
%124 = sub nsw i32 %122, %123
%125 = call i32 (i32, i8*, i32, ...) @fprintf(i32 %120, i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.5, i64 0, i64 0), i32 %121, i32 %124)
br label %173
126: ; preds = %94
%127 = load i32, i32* %15
%128 = icmp sgt i32 %127, 0
br i1 %128, label %129, label %160
129: ; preds = %126
%130 = load i32, i32* %8
%131 = icmp sgt i32 %130, 1
br i1 %131, label %132, label %141
132: ; preds = %129
%133 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.6, i64 0, i64 0))
%134 = load i8*, i8** %16
%135 = load i32, i32* %12
%136 = sext i32 %135 to i64
%137 = getelementptr inbounds i8, i8* %134, i64 %136
%138 = getelementptr inbounds i8, i8* %137, i64 4
%139 = load i32, i32* %15
%140 = call i32 @dStrHex(i8* %138, i32 %139, i32 1)
br label %159
141: ; preds = %129
%142 = load i32, i32* %10
%143 = icmp eq i32 0, %142
br i1 %143, label %147, label %144
144: ; preds = %141
%145 = load i32, i32* %14
%146 = icmp sgt i32 %145, 0
br i1 %146, label %147, label %149
147: ; preds = %144, %141
%148 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.6, i64 0, i64 0))
br label %149
149: ; preds = %147, %144
%150 = load i8*, i8** %16
%151 = load i32, i32* %12
%152 = sext i32 %151 to i64
%153 = getelementptr inbounds i8, i8* %150, i64 %152
%154 = getelementptr inbounds i8, i8* %153, i64 4
%155 = load i32, i32* %15
%156 = load i32, i32* %9
%157 = load i32, i32* %10
%158 = call i32 @decode_dev_ids(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0), i8* %154, i32 %155, i32 1, i32 -1, i32 -1, i32 %156, i32 %157)
br label %159
159: ; preds = %149, %132
br label %160
160: ; preds = %159, %126
%161 = load i32, i32* %15
%162 = add nsw i32 %161, 4
%163 = load i32, i32* %12
%164 = add nsw i32 %163, %162
store i32 %164, i32* %12
br label %165
165: ; preds = %160
%166 = load i32, i32* %12
%167 = load i32, i32* %11
%168 = add nsw i32 %167, %166
store i32 %168, i32* %11
%169 = load i32, i32* %12
%170 = load i8*, i8** %16
%171 = sext i32 %169 to i64
%172 = getelementptr inbounds i8, i8* %170, i64 %171
store i8* %172, i8** %16
br label %35
173: ; preds = %19, %26, %69, %119, %35
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [41 x i8] c"SCSI Ports VPD page length too short=%d\0A\00"
@.str.1 = [18 x i8] c"Relative port=%d\0A\00"
@.str.2 = [58 x i8] c"SCSI Ports VPD page, short descriptor length=%d, left=%d\0A\00"
@.str.4 = [2 x i8] c" \00"
@.str.5 = [63 x i8] c"SCSI Ports VPD page, short descriptor(tgt) length=%d, left=%d\0A\00"
@.str.7 = [11 x i8] c"SCSI Ports\00"
@str.8 = [28 x i8] c" Target port descriptor(s):\00"
@str.9 = [30 x i8] c" Initiator port transport id:\00"
define void @decode_scsi_ports_vpd(i8* %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = icmp eq i32 %2, 1
br i1 %6, label %7, label %9
7: ; preds = %5
%8 = tail call i32 @dStrHex(i8* %0, i32 %1, i32 1)
br label %102
9: ; preds = %5
%10 = icmp slt i32 %1, 4
br i1 %10, label %11, label %14
11: ; preds = %9
%12 = load i32, i32* @stderr
%13 = tail call i32 (i32, i8*, i32, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i32 %1)
br label %102
14: ; preds = %9
%15 = add nsw i32 %1, -4
%16 = icmp eq i32 %1, 4
br i1 %16, label %102, label %17
17: ; preds = %14
%18 = getelementptr inbounds i8, i8* %0, i64 4
%19 = icmp sgt i32 %2, 1
%20 = icmp eq i32 %4, 0
br label %21
21: ; preds = %17, %96
%22 = phi i8* [ %18, %17 ], [ %100, %96 ]
%23 = phi i32 [ 0, %17 ], [ %98, %96 ]
%24 = getelementptr inbounds i8, i8* %22, i64 2
%25 = load i8, i8* %24
%26 = zext i8 %25 to i32
%27 = shl nuw nsw i32 %26, 8
%28 = getelementptr inbounds i8, i8* %22, i64 3
%29 = load i8, i8* %28
%30 = zext i8 %29 to i32
%31 = or i32 %27, %30
%32 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 %31)
%33 = getelementptr inbounds i8, i8* %22, i64 6
%34 = load i8, i8* %33
%35 = zext i8 %34 to i32
%36 = shl nuw nsw i32 %35, 8
%37 = getelementptr inbounds i8, i8* %22, i64 7
%38 = load i8, i8* %37
%39 = zext i8 %38 to i32
%40 = or i32 %36, %39
%41 = add nuw nsw i32 %40, 8
%42 = add nuw nsw i32 %41, %23
%43 = icmp sgt i32 %42, %15
br i1 %43, label %44, label %48
44: ; preds = %21
%45 = load i32, i32* @stderr
%46 = sub nsw i32 %15, %23
%47 = tail call i32 (i32, i8*, i32, ...) @fprintf(i32 %45, i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.2, i64 0, i64 0), i32 %41, i32 %46)
br label %102
48: ; preds = %21
%49 = icmp ne i32 %40, 0
br i1 %49, label %50, label %58
50: ; preds = %48
br i1 %19, label %51, label %55
51: ; preds = %50
%52 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str.9, i64 0, i64 0))
%53 = getelementptr inbounds i8, i8* %22, i64 8
%54 = tail call i32 @dStrHex(i8* %53, i32 %40, i32 1)
br label %58
55: ; preds = %50
%56 = getelementptr inbounds i8, i8* %22, i64 8
%57 = tail call i32 @decode_transport_id(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i8* %56, i32 %40)
br label %58
58: ; preds = %51, %55, %48
%59 = add nuw nsw i32 %40, 10
%60 = zext i32 %59 to i64
%61 = getelementptr inbounds i8, i8* %22, i64 %60
%62 = load i8, i8* %61
%63 = zext i8 %62 to i32
%64 = shl nuw nsw i32 %63, 8
%65 = add nuw nsw i32 %40, 11
%66 = zext i32 %65 to i64
%67 = getelementptr inbounds i8, i8* %22, i64 %66
%68 = load i8, i8* %67
%69 = zext i8 %68 to i32
%70 = or i32 %64, %69
%71 = add nuw nsw i32 %70, 4
%72 = add i32 %71, %42
%73 = icmp sgt i32 %72, %15
br i1 %73, label %74, label %78
74: ; preds = %58
%75 = load i32, i32* @stderr
%76 = sub nsw i32 %15, %23
%77 = tail call i32 (i32, i8*, i32, ...) @fprintf(i32 %75, i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.5, i64 0, i64 0), i32 %41, i32 %76)
br label %102
78: ; preds = %58
%79 = icmp eq i32 %70, 0
br i1 %79, label %96, label %80
80: ; preds = %78
br i1 %19, label %81, label %87
81: ; preds = %80
%82 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.8, i64 0, i64 0))
%83 = zext i32 %41 to i64
%84 = getelementptr inbounds i8, i8* %22, i64 4
%85 = getelementptr inbounds i8, i8* %84, i64 %83
%86 = tail call i32 @dStrHex(i8* %85, i32 %70, i32 1)
br label %96
87: ; preds = %80
%88 = select i1 %20, i1 true, i1 %49
br i1 %88, label %89, label %91
89: ; preds = %87
%90 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.8, i64 0, i64 0))
br label %91
91: ; preds = %87, %89
%92 = zext i32 %41 to i64
%93 = getelementptr inbounds i8, i8* %22, i64 4
%94 = getelementptr inbounds i8, i8* %93, i64 %92
%95 = tail call i32 @decode_dev_ids(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0), i8* %94, i32 %70, i32 1, i32 -1, i32 -1, i32 %3, i32 %4)
br label %96
96: ; preds = %81, %91, %78
%97 = add nuw nsw i32 %71, %41
%98 = add nuw nsw i32 %97, %23
%99 = zext i32 %97 to i64
%100 = getelementptr inbounds i8, i8* %22, i64 %99
%101 = icmp sgt i32 %15, %98
br i1 %101, label %21, label %102
102: ; preds = %96, %14, %74, %44, %11, %7
ret void
}