#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 /*<<< orphan*/);
int /*<<< orphan*/ dWordHex(unsigned short const *, int, int /*<<< orphan*/,
                            int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ memcpy(char *, unsigned char *, int);
int /*<<< orphan*/ printf(char *, ...);
int sg_ata_get_chars(unsigned short const *, int, int, int, char *);
int sg_is_big_endian();
int /*<<< orphan*/ stderr;
void decode_ata_info_vpd(unsigned char *buff, int len, int do_long,
                         int do_hex) {
  char b[80];
  int num, is_be;
  const char *cp;
  if (len < 36) {
    fprintf(stderr,
            "ATA information VPD page length too "
            "short=%d\n",
            len);
    return;
  }
  if (do_hex && (2 != do_hex)) {
    dStrHex((const char *)buff, len, 0);
    return;
  }
  memcpy(b, buff + 8, 8);
  b[8] = '\0';
  printf("  SAT Vendor identification: %s\n", b);
  memcpy(b, buff + 16, 16);
  b[16] = '\0';
  printf("  SAT Product identification: %s\n", b);
  memcpy(b, buff + 32, 4);
  b[4] = '\0';
  printf("  SAT Product revision level: %s\n", b);
  if (len < 56)
    return;
  if (do_long) {
    printf("  Signature (Device to host FIS):\n");
    dStrHex((const char *)buff + 36, 20, 0);
  }
  if (len < 60)
    return;
  is_be = sg_is_big_endian();
  if ((0xec == buff[56]) || (0xa1 == buff[56])) {
    cp = (0xa1 == buff[56]) ? "PACKET " : "";
    printf("  ATA command IDENTIFY %sDEVICE response summary:\n", cp);
    num =
        sg_ata_get_chars((const unsigned short *)(buff + 60), 27, 20, is_be, b);
    b[num] = '\0';
    printf("    model: %s\n", b);
    num =
        sg_ata_get_chars((const unsigned short *)(buff + 60), 10, 10, is_be, b);
    b[num] = '\0';
    printf("    serial number: %s\n", b);
    num =
        sg_ata_get_chars((const unsigned short *)(buff + 60), 23, 4, is_be, b);
    b[num] = '\0';
    printf("    firmware revision: %s\n", b);
    if (do_long)
      printf("  ATA command IDENTIFY %sDEVICE response in hex:\n", cp);
  } else if (do_long)
    printf("  ATA command 0x%x got following response:\n",
           (unsigned int)buff[56]);
  if (len < 572)
    return;
  if (2 == do_hex)
    dStrHex((const char *)(buff + 60), 512, 0);
  else if (do_long)
    dWordHex((const unsigned short *)(buff + 60), 256, 0, is_be);
}


x86 assembly (clang, -O0):
<decode_ata_info_vpd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
cmpl   $0x24,-0xc(%rbp)
jge    11af <decode_ata_info_vpd+0x3f>
mov    0x2e47(%rip),%rax
mov    (%rax),%edi
mov    -0xc(%rbp),%edx
lea    0xe5b(%rip),%rsi
call   1060 <fprintf@plt>
jmp    1469 <decode_ata_info_vpd+0x2f9>
cmpl   $0x0,-0x14(%rbp)
je     11da <decode_ata_info_vpd+0x6a>
mov    $0x2,%eax
cmp    -0x14(%rbp),%eax
je     11da <decode_ata_info_vpd+0x6a>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
xor    %edx,%edx
call   1030 <dStrHex@plt>
jmp    1469 <decode_ata_info_vpd+0x2f9>
lea    -0x70(%rbp),%rdi
mov    -0x8(%rbp),%rsi
add    $0x8,%rsi
mov    $0x8,%edx
call   1070 <memcpy@plt>
movb   $0x0,-0x68(%rbp)
lea    -0x70(%rbp),%rsi
lea    0xe2f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x70(%rbp),%rdi
mov    -0x8(%rbp),%rsi
add    $0x10,%rsi
mov    $0x10,%edx
call   1070 <memcpy@plt>
movb   $0x0,-0x60(%rbp)
lea    -0x70(%rbp),%rsi
lea    0xe24(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x70(%rbp),%rdi
mov    -0x8(%rbp),%rsi
add    $0x20,%rsi
mov    $0x4,%edx
call   1070 <memcpy@plt>
movb   $0x0,-0x6c(%rbp)
lea    -0x70(%rbp),%rsi
lea    0xe1a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
cmpl   $0x38,-0xc(%rbp)
jge    126d <decode_ata_info_vpd+0xfd>
jmp    1469 <decode_ata_info_vpd+0x2f9>
cmpl   $0x0,-0x10(%rbp)
je     1299 <decode_ata_info_vpd+0x129>
lea    0xe15(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x8(%rbp),%rdi
add    $0x24,%rdi
mov    $0x14,%esi
xor    %edx,%edx
call   1030 <dStrHex@plt>
cmpl   $0x3c,-0xc(%rbp)
jge    12a8 <decode_ata_info_vpd+0x138>
jmp    1469 <decode_ata_info_vpd+0x2f9>
mov    $0x0,%al
call   1080 <sg_is_big_endian@plt>
mov    %eax,-0x78(%rbp)
mov    -0x8(%rbp),%rax
movzbl 0x38(%rax),%ecx
mov    $0xec,%eax
cmp    %ecx,%eax
je     12dc <decode_ata_info_vpd+0x16c>
mov    -0x8(%rbp),%rax
movzbl 0x38(%rax),%ecx
mov    $0xa1,%eax
cmp    %ecx,%eax
jne    13e5 <decode_ata_info_vpd+0x275>
mov    -0x8(%rbp),%rax
movzbl 0x38(%rax),%esi
mov    $0xa1,%edx
lea    0xdc5(%rip),%rax
lea    0xdbf(%rip),%rcx
cmp    %esi,%edx
cmove  %rcx,%rax
mov    %rax,-0x80(%rbp)
mov    -0x80(%rbp),%rsi
lea    0xdb2(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x8(%rbp),%rdi
add    $0x3c,%rdi
mov    -0x78(%rbp),%ecx
lea    -0x70(%rbp),%r8
mov    $0x1b,%esi
mov    $0x14,%edx
call   1090 <sg_ata_get_chars@plt>
mov    %eax,-0x74(%rbp)
movslq -0x74(%rbp),%rax
movb   $0x0,-0x70(%rbp,%rax,1)
lea    -0x70(%rbp),%rsi
lea    0xda9(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x8(%rbp),%rdi
add    $0x3c,%rdi
mov    -0x78(%rbp),%ecx
lea    -0x70(%rbp),%r8
mov    $0xa,%edx
mov    %edx,%esi
call   1090 <sg_ata_get_chars@plt>
mov    %eax,-0x74(%rbp)
movslq -0x74(%rbp),%rax
movb   $0x0,-0x70(%rbp,%rax,1)
lea    -0x70(%rbp),%rsi
lea    0xd7f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x8(%rbp),%rdi
add    $0x3c,%rdi
mov    -0x78(%rbp),%ecx
lea    -0x70(%rbp),%r8
mov    $0x17,%esi
mov    $0x4,%edx
call   1090 <sg_ata_get_chars@plt>
mov    %eax,-0x74(%rbp)
movslq -0x74(%rbp),%rax
movb   $0x0,-0x70(%rbp,%rax,1)
lea    -0x70(%rbp),%rsi
lea    0xd5a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
cmpl   $0x0,-0x10(%rbp)
je     13e0 <decode_ata_info_vpd+0x270>
mov    -0x80(%rbp),%rsi
lea    0xd59(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    140a <decode_ata_info_vpd+0x29a>
cmpl   $0x0,-0x10(%rbp)
je     1405 <decode_ata_info_vpd+0x295>
mov    -0x8(%rbp),%rax
movzbl 0x38(%rax),%esi
lea    0xd66(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    140a <decode_ata_info_vpd+0x29a>
cmpl   $0x23c,-0xc(%rbp)
jge    141c <decode_ata_info_vpd+0x2ac>
jmp    1469 <decode_ata_info_vpd+0x2f9>
mov    $0x2,%eax
cmp    -0x14(%rbp),%eax
jne    1443 <decode_ata_info_vpd+0x2d3>
mov    -0x8(%rbp),%rdi
add    $0x3c,%rdi
mov    $0x200,%esi
xor    %edx,%edx
call   1030 <dStrHex@plt>
jmp    1469 <decode_ata_info_vpd+0x2f9>
cmpl   $0x0,-0x10(%rbp)
je     1464 <decode_ata_info_vpd+0x2f4>
mov    -0x8(%rbp),%rdi
add    $0x3c,%rdi
mov    -0x78(%rbp),%ecx
mov    $0x100,%esi
xor    %edx,%edx
call   1040 <dWordHex@plt>
jmp    1469 <decode_ata_info_vpd+0x2f9>
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<decode_ata_info_vpd>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
mov    %esi,%ebp
cmp    $0x23,%esi
jg     11ba <decode_ata_info_vpd+0x3a>
mov    0x2e44(%rip),%rax
mov    (%rax),%edi
lea    0xe5b(%rip),%rsi
mov    %ebp,%edx
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1070 <fprintf@plt>
mov    %ecx,%r15d
mov    %rdi,%r13
test   $0xfffffffd,%ecx
je     11e2 <decode_ata_info_vpd+0x62>
mov    %r13,%rdi
mov    %ebp,%esi
xor    %edx,%edx
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <dStrHex@plt>
mov    %edx,%r14d
lea    0x8(%r13),%rsi
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x8,%edx
call   1080 <memcpy@plt>
movb   $0x0,0x18(%rsp)
lea    0xe27(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0x10(%r13),%rsi
mov    %rbx,%rdi
mov    $0x10,%edx
call   1080 <memcpy@plt>
movb   $0x0,0x20(%rsp)
lea    0xe21(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0x20(%r13),%rsi
mov    %rbx,%rdi
mov    $0x4,%edx
call   1080 <memcpy@plt>
movb   $0x0,0x14(%rsp)
lea    0xe1c(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
cmp    $0x38,%ebp
jb     13ef <decode_ata_info_vpd+0x26f>
test   %r14d,%r14d
je     1289 <decode_ata_info_vpd+0x109>
lea    0xef9(%rip),%rdi
call   1030 <puts@plt>
lea    0x24(%r13),%rdi
mov    $0x14,%esi
xor    %edx,%edx
call   1040 <dStrHex@plt>
cmp    $0x3c,%ebp
jb     13ef <decode_ata_info_vpd+0x26f>
xor    %eax,%eax
call   1090 <sg_is_big_endian@plt>
mov    %eax,0x4(%rsp)
movzbl 0x38(%r13),%esi
cmp    $0xec,%esi
je     12b4 <decode_ata_info_vpd+0x134>
cmp    $0xa1,%sil
jne    139d <decode_ata_info_vpd+0x21d>
cmp    $0xa1,%sil
lea    0xdd4(%rip),%rax
lea    0xea6(%rip),%rsi
cmove  %rax,%rsi
lea    0xdca(%rip),%rdi
mov    %rsi,0x8(%rsp)
xor    %eax,%eax
call   1060 <printf@plt>
lea    0x3c(%r13),%rbx
lea    0x10(%rsp),%r8
mov    %rbx,%rdi
mov    $0x1b,%esi
mov    $0x14,%edx
mov    0x4(%rsp),%r12d
mov    %r12d,%ecx
call   10a0 <sg_ata_get_chars@plt>
cltq
movb   $0x0,0x10(%rsp,%rax,1)
lea    0xdc0(%rip),%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
mov    $0xa,%esi
mov    $0xa,%edx
mov    %r12d,%ecx
lea    0x10(%rsp),%r8
call   10a0 <sg_ata_get_chars@plt>
cltq
movb   $0x0,0x10(%rsp,%rax,1)
lea    0xd9b(%rip),%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
mov    $0x17,%esi
mov    $0x4,%edx
mov    %r12d,%ecx
lea    0x10(%rsp),%r8
mov    %r8,%rbx
call   10a0 <sg_ata_get_chars@plt>
cltq
movb   $0x0,0x10(%rsp,%rax,1)
lea    0xd7b(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
test   %r14d,%r14d
je     13b0 <decode_ata_info_vpd+0x230>
lea    0xd80(%rip),%rdi
mov    0x8(%rsp),%rsi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    13b0 <decode_ata_info_vpd+0x230>
test   %r14d,%r14d
je     13b0 <decode_ata_info_vpd+0x230>
lea    0xd98(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
cmp    $0x23c,%ebp
jb     13ef <decode_ata_info_vpd+0x26f>
cmp    $0x2,%r15d
jne    13d3 <decode_ata_info_vpd+0x253>
add    $0x3c,%r13
mov    %r13,%rdi
mov    $0x200,%esi
xor    %edx,%edx
call   1040 <dStrHex@plt>
jmp    13ef <decode_ata_info_vpd+0x26f>
test   %r14d,%r14d
je     13ef <decode_ata_info_vpd+0x26f>
add    $0x3c,%r13
mov    %r13,%rdi
mov    $0x100,%esi
xor    %edx,%edx
mov    0x4(%rsp),%ecx
call   1050 <dWordHex@plt>
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [46 x i8] c"ATA information VPD page length too short=%d\0A\00"
@.str.1 = [33 x i8] c" SAT Vendor identification: %s\0A\00"
@.str.2 = [34 x i8] c" SAT Product identification: %s\0A\00"
@.str.3 = [34 x i8] c" SAT Product revision level: %s\0A\00"
@.str.4 = [35 x i8] c" Signature (Device to host FIS):\0A\00"
@.str.5 = [8 x i8] c"PACKET \00"
@.str.6 = [1 x i8] zeroinitializer
@.str.7 = [51 x i8] c" ATA command IDENTIFY %sDEVICE response summary:\0A\00"
@.str.8 = [15 x i8] c" model: %s\0A\00"
@.str.9 = [23 x i8] c" serial number: %s\0A\00"
@.str.10 = [27 x i8] c" firmware revision: %s\0A\00"
@.str.11 = [50 x i8] c" ATA command IDENTIFY %sDEVICE response in hex:\0A\00"
@.str.12 = [44 x i8] c" ATA command 0x%x got following response:\0A\00"
define void @decode_ata_info_vpd(i8* %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca [80 x i8]
%10 = alloca i32
%11 = alloca i32
%12 = alloca i8*
store i8* %0, i8** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%13 = load i32, i32* %6
%14 = icmp slt i32 %13, 36
br i1 %14, label %15, label %19
15: ; preds = %4
%16 = load i32, i32* @stderr
%17 = load i32, i32* %6
%18 = call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0), i32 %17)
br label %159
19: ; preds = %4
%20 = load i32, i32* %8
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %29
22: ; preds = %19
%23 = load i32, i32* %8
%24 = icmp ne i32 2, %23
br i1 %24, label %25, label %29
25: ; preds = %22
%26 = load i8*, i8** %5
%27 = load i32, i32* %6
%28 = call i32 @dStrHex(i8* %26, i32 %27, i32 0)
br label %159
29: ; preds = %22, %19
%30 = getelementptr inbounds [80 x i8], [80 x i8]* %9, i64 0, i64 0
%31 = load i8*, i8** %5
%32 = getelementptr inbounds i8, i8* %31, i64 8
%33 = call i32 @memcpy(i8* %30, i8* %32, i32 8)
%34 = getelementptr inbounds [80 x i8], [80 x i8]* %9, i64 0, i64 8
store i8 0, i8* %34
%35 = getelementptr inbounds [80 x i8], [80 x i8]* %9, i64 0, i64 0
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i8* %35)
%37 = getelementptr inbounds [80 x i8], [80 x i8]* %9, i64 0, i64 0
%38 = load i8*, i8** %5
%39 = getelementptr inbounds i8, i8* %38, i64 16
%40 = call i32 @memcpy(i8* %37, i8* %39, i32 16)
%41 = getelementptr inbounds [80 x i8], [80 x i8]* %9, i64 0, i64 16
store i8 0, i8* %41
%42 = getelementptr inbounds [80 x i8], [80 x i8]* %9, i64 0, i64 0
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i8* %42)
%44 = getelementptr inbounds [80 x i8], [80 x i8]* %9, i64 0, i64 0
%45 = load i8*, i8** %5
%46 = getelementptr inbounds i8, i8* %45, i64 32
%47 = call i32 @memcpy(i8* %44, i8* %46, i32 4)
%48 = getelementptr inbounds [80 x i8], [80 x i8]* %9, i64 0, i64 4
store i8 0, i8* %48
%49 = getelementptr inbounds [80 x i8], [80 x i8]* %9, i64 0, i64 0
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0), i8* %49)
%51 = load i32, i32* %6
%52 = icmp slt i32 %51, 56
br i1 %52, label %53, label %54
53: ; preds = %29
br label %159
54: ; preds = %29
%55 = load i32, i32* %7
%56 = icmp ne i32 %55, 0
br i1 %56, label %57, label %62
57: ; preds = %54
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.4, i64 0, i64 0))
%59 = load i8*, i8** %5
%60 = getelementptr inbounds i8, i8* %59, i64 36
%61 = call i32 @dStrHex(i8* %60, i32 20, i32 0)
br label %62
62: ; preds = %57, %54
%63 = load i32, i32* %6
%64 = icmp slt i32 %63, 60
br i1 %64, label %65, label %66
65: ; preds = %62
br label %159
66: ; preds = %62
%67 = call i32 (...) @sg_is_big_endian()
store i32 %67, i32* %11
%68 = load i8*, i8** %5
%69 = getelementptr inbounds i8, i8* %68, i64 56
%70 = load i8, i8* %69
%71 = zext i8 %70 to i32
%72 = icmp eq i32 236, %71
br i1 %72, label %79, label %73
73: ; preds = %66
%74 = load i8*, i8** %5
%75 = getelementptr inbounds i8, i8* %74, i64 56
%76 = load i8, i8* %75
%77 = zext i8 %76 to i32
%78 = icmp eq i32 161, %77
br i1 %78, label %79, label %128
79: ; preds = %73, %66
%80 = load i8*, i8** %5
%81 = getelementptr inbounds i8, i8* %80, i64 56
%82 = load i8, i8* %81
%83 = zext i8 %82 to i32
%84 = icmp eq i32 161, %83
%85 = zext i1 %84 to i64
%86 = select i1 %84, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.6, i64 0, i64 0)
store i8* %86, i8** %12
%87 = load i8*, i8** %12
%88 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.7, i64 0, i64 0), i8* %87)
%89 = load i8*, i8** %5
%90 = getelementptr inbounds i8, i8* %89, i64 60
%91 = bitcast i8* %90 to i16*
%92 = load i32, i32* %11
%93 = getelementptr inbounds [80 x i8], [80 x i8]* %9, i64 0, i64 0
%94 = call i32 @sg_ata_get_chars(i16* %91, i32 27, i32 20, i32 %92, i8* %93)
store i32 %94, i32* %10
%95 = load i32, i32* %10
%96 = sext i32 %95 to i64
%97 = getelementptr inbounds [80 x i8], [80 x i8]* %9, i64 0, i64 %96
store i8 0, i8* %97
%98 = getelementptr inbounds [80 x i8], [80 x i8]* %9, i64 0, i64 0
%99 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0), i8* %98)
%100 = load i8*, i8** %5
%101 = getelementptr inbounds i8, i8* %100, i64 60
%102 = bitcast i8* %101 to i16*
%103 = load i32, i32* %11
%104 = getelementptr inbounds [80 x i8], [80 x i8]* %9, i64 0, i64 0
%105 = call i32 @sg_ata_get_chars(i16* %102, i32 10, i32 10, i32 %103, i8* %104)
store i32 %105, i32* %10
%106 = load i32, i32* %10
%107 = sext i32 %106 to i64
%108 = getelementptr inbounds [80 x i8], [80 x i8]* %9, i64 0, i64 %107
store i8 0, i8* %108
%109 = getelementptr inbounds [80 x i8], [80 x i8]* %9, i64 0, i64 0
%110 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.9, i64 0, i64 0), i8* %109)
%111 = load i8*, i8** %5
%112 = getelementptr inbounds i8, i8* %111, i64 60
%113 = bitcast i8* %112 to i16*
%114 = load i32, i32* %11
%115 = getelementptr inbounds [80 x i8], [80 x i8]* %9, i64 0, i64 0
%116 = call i32 @sg_ata_get_chars(i16* %113, i32 23, i32 4, i32 %114, i8* %115)
store i32 %116, i32* %10
%117 = load i32, i32* %10
%118 = sext i32 %117 to i64
%119 = getelementptr inbounds [80 x i8], [80 x i8]* %9, i64 0, i64 %118
store i8 0, i8* %119
%120 = getelementptr inbounds [80 x i8], [80 x i8]* %9, i64 0, i64 0
%121 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.10, i64 0, i64 0), i8* %120)
%122 = load i32, i32* %7
%123 = icmp ne i32 %122, 0
br i1 %123, label %124, label %127
124: ; preds = %79
%125 = load i8*, i8** %12
%126 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.11, i64 0, i64 0), i8* %125)
br label %127
127: ; preds = %124, %79
br label %138
128: ; preds = %73
%129 = load i32, i32* %7
%130 = icmp ne i32 %129, 0
br i1 %130, label %131, label %137
131: ; preds = %128
%132 = load i8*, i8** %5
%133 = getelementptr inbounds i8, i8* %132, i64 56
%134 = load i8, i8* %133
%135 = zext i8 %134 to i32
%136 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.12, i64 0, i64 0), i32 %135)
br label %137
137: ; preds = %131, %128
br label %138
138: ; preds = %137, %127
%139 = load i32, i32* %6
%140 = icmp slt i32 %139, 572
br i1 %140, label %141, label %142
141: ; preds = %138
br label %159
142: ; preds = %138
%143 = load i32, i32* %8
%144 = icmp eq i32 2, %143
br i1 %144, label %145, label %149
145: ; preds = %142
%146 = load i8*, i8** %5
%147 = getelementptr inbounds i8, i8* %146, i64 60
%148 = call i32 @dStrHex(i8* %147, i32 512, i32 0)
br label %159
149: ; preds = %142
%150 = load i32, i32* %7
%151 = icmp ne i32 %150, 0
br i1 %151, label %152, label %158
152: ; preds = %149
%153 = load i8*, i8** %5
%154 = getelementptr inbounds i8, i8* %153, i64 60
%155 = bitcast i8* %154 to i16*
%156 = load i32, i32* %11
%157 = call i32 @dWordHex(i16* %155, i32 256, i32 0, i32 %156)
br label %158
158: ; preds = %152, %149
br label %159
159: ; preds = %15, %25, %53, %65, %141, %158, %145
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [46 x i8] c"ATA information VPD page length too short=%d\0A\00"
@.str.1 = [33 x i8] c" SAT Vendor identification: %s\0A\00"
@.str.2 = [34 x i8] c" SAT Product identification: %s\0A\00"
@.str.3 = [34 x i8] c" SAT Product revision level: %s\0A\00"
@.str.5 = [8 x i8] c"PACKET \00"
@.str.6 = [1 x i8] zeroinitializer
@.str.7 = [51 x i8] c" ATA command IDENTIFY %sDEVICE response summary:\0A\00"
@.str.8 = [15 x i8] c" model: %s\0A\00"
@.str.9 = [23 x i8] c" serial number: %s\0A\00"
@.str.10 = [27 x i8] c" firmware revision: %s\0A\00"
@.str.11 = [50 x i8] c" ATA command IDENTIFY %sDEVICE response in hex:\0A\00"
@.str.12 = [44 x i8] c" ATA command 0x%x got following response:\0A\00"
@str = [34 x i8] c" Signature (Device to host FIS):\00"
define void @decode_ata_info_vpd(i8* %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca [80 x i8]
%6 = getelementptr inbounds [80 x i8], [80 x i8]* %5, i64 0, i64 0
%7 = icmp slt i32 %1, 36
br i1 %7, label %8, label %11
8: ; preds = %4
%9 = load i32, i32* @stderr
%10 = tail call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0), i32 %1)
br label %78
11: ; preds = %4
%12 = and i32 %3, -3
%13 = icmp eq i32 %12, 0
br i1 %13, label %16, label %14
14: ; preds = %11
%15 = tail call i32 @dStrHex(i8* %0, i32 %1, i32 0)
br label %78
16: ; preds = %11
%17 = getelementptr inbounds i8, i8* %0, i64 8
%18 = call i32 @memcpy(i8* %6, i8* %17, i32 8)
%19 = getelementptr inbounds [80 x i8], [80 x i8]* %5, i64 0, i64 8
store i8 0, i8* %19
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i8* %6)
%21 = getelementptr inbounds i8, i8* %0, i64 16
%22 = call i32 @memcpy(i8* %6, i8* %21, i32 16)
%23 = getelementptr inbounds [80 x i8], [80 x i8]* %5, i64 0, i64 16
store i8 0, i8* %23
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i8* %6)
%25 = getelementptr inbounds i8, i8* %0, i64 32
%26 = call i32 @memcpy(i8* %6, i8* %25, i32 4)
%27 = getelementptr inbounds [80 x i8], [80 x i8]* %5, i64 0, i64 4
store i8 0, i8* %27
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0), i8* %6)
%29 = icmp ult i32 %1, 56
br i1 %29, label %78, label %30
30: ; preds = %16
%31 = icmp eq i32 %2, 0
br i1 %31, label %36, label %32
32: ; preds = %30
%33 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str, i64 0, i64 0))
%34 = getelementptr inbounds i8, i8* %0, i64 36
%35 = call i32 @dStrHex(i8* %34, i32 20, i32 0)
br label %36
36: ; preds = %32, %30
%37 = icmp ult i32 %1, 60
br i1 %37, label %78, label %38
38: ; preds = %36
%39 = call i32 (...) @sg_is_big_endian()
%40 = getelementptr inbounds i8, i8* %0, i64 56
%41 = load i8, i8* %40
%42 = zext i8 %41 to i32
switch i8 %41, label %63 [
i8 -20, label %43
i8 -95, label %43
]
43: ; preds = %38, %38
%44 = icmp eq i8 %41, -95
%45 = select i1 %44, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.6, i64 0, i64 0)
%46 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @.str.7, i64 0, i64 0), i8* %45)
%47 = getelementptr inbounds i8, i8* %0, i64 60
%48 = bitcast i8* %47 to i16*
%49 = call i32 @sg_ata_get_chars(i16* %48, i32 27, i32 20, i32 %39, i8* %6)
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds [80 x i8], [80 x i8]* %5, i64 0, i64 %50
store i8 0, i8* %51
%52 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0), i8* %6)
%53 = call i32 @sg_ata_get_chars(i16* %48, i32 10, i32 10, i32 %39, i8* %6)
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds [80 x i8], [80 x i8]* %5, i64 0, i64 %54
store i8 0, i8* %55
%56 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.9, i64 0, i64 0), i8* %6)
%57 = call i32 @sg_ata_get_chars(i16* %48, i32 23, i32 4, i32 %39, i8* %6)
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds [80 x i8], [80 x i8]* %5, i64 0, i64 %58
store i8 0, i8* %59
%60 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.10, i64 0, i64 0), i8* %6)
br i1 %31, label %66, label %61
61: ; preds = %43
%62 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @.str.11, i64 0, i64 0), i8* %45)
br label %66
63: ; preds = %38
br i1 %31, label %66, label %64
64: ; preds = %63
%65 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.12, i64 0, i64 0), i32 %42)
br label %66
66: ; preds = %63, %64, %43, %61
%67 = icmp ult i32 %1, 572
br i1 %67, label %78, label %68
68: ; preds = %66
%69 = icmp eq i32 %3, 2
br i1 %69, label %70, label %73
70: ; preds = %68
%71 = getelementptr inbounds i8, i8* %0, i64 60
%72 = call i32 @dStrHex(i8* %71, i32 512, i32 0)
br label %78
73: ; preds = %68
br i1 %31, label %78, label %74
74: ; preds = %73
%75 = getelementptr inbounds i8, i8* %0, i64 60
%76 = bitcast i8* %75 to i16*
%77 = call i32 @dWordHex(i16* %76, i32 256, i32 0, i32 %39)
br label %78
78: ; preds = %70, %74, %73, %66, %36, %16, %14, %8
ret void
}