#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 uint8_t;
struct sg_io_v4 {
  char guard;
  int request_len;
  uintptr_t request;
  int max_response_len;
  uintptr_t response;
  size_t const din_xfer_len;
  uintptr_t din_xferp;
  int timeout;
  char interface_id;
  unsigned char *cmdp;
  int cmd_len;
  void *const dxferp;
  size_t const dxfer_len;
  int *sbp;
  int mx_sb_len;
  scalar_t__ status;
  scalar_t__ host_status;
  scalar_t__ driver_status;
  scalar_t__ device_status;
  scalar_t__ transport_status;
  int /*<<< orphan*/ dxfer_direction;
  int /*<<< orphan*/ subprotocol;
  int /*<<< orphan*/ protocol;
};
struct sg_io_hdr {
  char guard;
  int request_len;
  uintptr_t request;
  int max_response_len;
  uintptr_t response;
  size_t const din_xfer_len;
  uintptr_t din_xferp;
  int timeout;
  char interface_id;
  unsigned char *cmdp;
  int cmd_len;
  void *const dxferp;
  size_t const dxfer_len;
  int *sbp;
  int mx_sb_len;
  scalar_t__ status;
  scalar_t__ host_status;
  scalar_t__ driver_status;
  scalar_t__ device_status;
  scalar_t__ transport_status;
  int /*<<< orphan*/ dxfer_direction;
  int /*<<< orphan*/ subprotocol;
  int /*<<< orphan*/ protocol;
};
typedef int /*<<< orphan*/ sense;
typedef int /*<<< orphan*/ cdb;

/* Variables and functions */
int /*<<< orphan*/ BSG_PROTOCOL_SCSI;
int /*<<< orphan*/ BSG_SUB_PROTOCOL_SCSI_CMD;
scalar_t__ EINVAL;
scalar_t__ EIO;
int /*<<< orphan*/ SG_DXFER_FROM_DEV;
int /*<<< orphan*/ SG_IO;
scalar_t__ errno;
int ioctl(int const, int /*<<< orphan*/, struct sg_io_v4 *);
int disk_scsi_inquiry_command(const int fd, void *const buf,
                              const size_t buf_len) {
  uint8_t cdb[6] = {
      [0] = 0x12,
      [3] = (buf_len >> 8),
      [4] = (buf_len & 0xff),
  };
  uint8_t sense[32] = {0};
  struct sg_io_v4 io_v4 = {
      .guard = 'Q',
      .protocol = BSG_PROTOCOL_SCSI,
      .subprotocol = BSG_SUB_PROTOCOL_SCSI_CMD,
      .request_len = sizeof(cdb),
      .request = (uintptr_t)cdb,
      .max_response_len = sizeof(sense),
      .response = (uintptr_t)sense,
      .din_xfer_len = buf_len,
      .din_xferp = (uintptr_t)buf,
      .timeout = (30 * 1000),
  };
  int ret;
  ret = ioctl(fd, SG_IO, &io_v4);
  if (ret != 0) {
    if (errno == EINVAL) {
      struct sg_io_hdr io_hdr = {
          .interface_id = 'S',
          .cmdp = (unsigned char *)cdb,
          .cmd_len = sizeof(cdb),
          .dxferp = buf,
          .dxfer_len = buf_len,
          .sbp = sense,
          .mx_sb_len = sizeof(sense),
          .dxfer_direction = SG_DXFER_FROM_DEV,
          .timeout = (30 * 1000),
      };
      ret = ioctl(fd, SG_IO, &io_hdr);
      if (ret != 0) {
        return ret;
      }
      if (!(io_hdr.status == 0 && io_hdr.host_status == 0 &&
            io_hdr.driver_status == 0)) {
        errno = EIO;
        return -1;
      }
    } else {
      return ret;
    }
  }
  if (!(io_v4.device_status == 0 && io_v4.transport_status == 0 &&
        io_v4.driver_status == 0)) {
    errno = EIO;
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<disk_scsi_inquiry_command>:
push   %rbp
mov    %rsp,%rbp
sub    $0x210,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
lea    -0x30(%rbp),%rcx
movl   $0x12,-0x30(%rbp)
mov    %rcx,%rax
add    $0x4,%rax
movl   $0x0,-0x2c(%rbp)
add    $0x4,%rax
movl   $0x0,-0x28(%rbp)
add    $0x4,%rax
mov    -0x18(%rbp),%rdx
shr    $0x8,%rdx
mov    %edx,-0x24(%rbp)
add    $0x4,%rax
mov    -0x18(%rbp),%rdx
and    $0xff,%rdx
mov    %edx,-0x20(%rbp)
add    $0x4,%rax
add    $0x18,%rcx
mov    %rcx,-0x208(%rbp)
mov    %rax,-0x200(%rbp)
mov    -0x200(%rbp),%rax
mov    -0x208(%rbp),%rcx
movl   $0x0,(%rax)
add    $0x4,%rax
mov    %rax,-0x210(%rbp)
cmp    %rcx,%rax
mov    %rax,-0x200(%rbp)
jne    1191 <disk_scsi_inquiry_command+0x71>
lea    -0xb0(%rbp),%rdi
xor    %esi,%esi
mov    $0x80,%edx
call   1030 <memset@plt>
movb   $0x51,-0x150(%rbp)
movl   $0x18,-0x14c(%rbp)
lea    -0x30(%rbp),%rax
mov    %rax,-0x148(%rbp)
movl   $0x80,-0x140(%rbp)
lea    -0xb0(%rbp),%rax
mov    %rax,-0x138(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x130(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x128(%rbp)
movl   $0x7530,-0x120(%rbp)
movb   $0x0,-0x11c(%rbp)
movq   $0x0,-0x118(%rbp)
movl   $0x0,-0x110(%rbp)
movq   $0x0,-0x108(%rbp)
movq   $0x0,-0x100(%rbp)
movq   $0x0,-0xf8(%rbp)
movl   $0x0,-0xf0(%rbp)
movq   $0x0,-0xe8(%rbp)
movq   $0x0,-0xe0(%rbp)
movq   $0x0,-0xd8(%rbp)
movq   $0x0,-0xd0(%rbp)
movq   $0x0,-0xc8(%rbp)
movl   $0x0,-0xc0(%rbp)
mov    0x2cfa(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xbc(%rbp)
mov    0x2d33(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xb8(%rbp)
mov    -0x8(%rbp),%edi
mov    0x2cf1(%rip),%rax
mov    (%rax),%esi
lea    -0x150(%rbp),%rdx
call   1040 <ioctl@plt>
mov    %eax,-0x154(%rbp)
cmpl   $0x0,-0x154(%rbp)
je     14a2 <disk_scsi_inquiry_command+0x382>
mov    0x2cc1(%rip),%rax
mov    (%rax),%rax
mov    0x2caf(%rip),%rcx
cmp    (%rcx),%rax
jne    148f <disk_scsi_inquiry_command+0x36f>
movb   $0x0,-0x1f8(%rbp)
movl   $0x0,-0x1f4(%rbp)
movq   $0x0,-0x1f0(%rbp)
movl   $0x0,-0x1e8(%rbp)
movq   $0x0,-0x1e0(%rbp)
movq   $0x0,-0x1d8(%rbp)
movq   $0x0,-0x1d0(%rbp)
movl   $0x7530,-0x1c8(%rbp)
movb   $0x53,-0x1c4(%rbp)
lea    -0x30(%rbp),%rax
mov    %rax,-0x1c0(%rbp)
movl   $0x18,-0x1b8(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x1b0(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x1a8(%rbp)
lea    -0xb0(%rbp),%rax
mov    %rax,-0x1a0(%rbp)
movl   $0x80,-0x198(%rbp)
movq   $0x0,-0x190(%rbp)
movq   $0x0,-0x188(%rbp)
movq   $0x0,-0x180(%rbp)
movq   $0x0,-0x178(%rbp)
movq   $0x0,-0x170(%rbp)
mov    0x2bf5(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x168(%rbp)
movl   $0x0,-0x164(%rbp)
movl   $0x0,-0x160(%rbp)
mov    -0x8(%rbp),%edi
mov    0x2bb7(%rip),%rax
mov    (%rax),%esi
lea    -0x1f8(%rbp),%rdx
call   1040 <ioctl@plt>
mov    %eax,-0x154(%rbp)
cmpl   $0x0,-0x154(%rbp)
je     1440 <disk_scsi_inquiry_command+0x320>
mov    -0x154(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    14f3 <disk_scsi_inquiry_command+0x3d3>
cmpq   $0x0,-0x190(%rbp)
jne    146a <disk_scsi_inquiry_command+0x34a>
cmpq   $0x0,-0x188(%rbp)
jne    146a <disk_scsi_inquiry_command+0x34a>
cmpq   $0x0,-0x180(%rbp)
je     148a <disk_scsi_inquiry_command+0x36a>
mov    0x2b5f(%rip),%rax
mov    (%rax),%rcx
mov    0x2b45(%rip),%rax
mov    %rcx,(%rax)
movl   $0xffffffff,-0x4(%rbp)
jmp    14f3 <disk_scsi_inquiry_command+0x3d3>
jmp    149d <disk_scsi_inquiry_command+0x37d>
mov    -0x154(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    14f3 <disk_scsi_inquiry_command+0x3d3>
jmp    14a2 <disk_scsi_inquiry_command+0x382>
cmpq   $0x0,-0xd0(%rbp)
jne    14cc <disk_scsi_inquiry_command+0x3ac>
cmpq   $0x0,-0xc8(%rbp)
jne    14cc <disk_scsi_inquiry_command+0x3ac>
cmpq   $0x0,-0xd8(%rbp)
je     14ec <disk_scsi_inquiry_command+0x3cc>
mov    0x2afd(%rip),%rax
mov    (%rax),%rcx
mov    0x2ae3(%rip),%rax
mov    %rcx,(%rax)
movl   $0xffffffff,-0x4(%rbp)
jmp    14f3 <disk_scsi_inquiry_command+0x3d3>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x210,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<disk_scsi_inquiry_command>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1e8,%rsp
mov    %rdx,%rbx
mov    %rsi,%rbp
mov    %edi,%r14d
movq   $0x12,(%rsp)
movl   $0x0,0x8(%rsp)
mov    %rdx,%rax
shr    $0x8,%rax
mov    %eax,0xc(%rsp)
movzbl %bl,%eax
mov    %eax,0x10(%rsp)
movl   $0x0,0x14(%rsp)
xorps  %xmm0,%xmm0
movaps %xmm0,0x1d0(%rsp)
movaps %xmm0,0x1c0(%rsp)
movaps %xmm0,0x1b0(%rsp)
movaps %xmm0,0x1a0(%rsp)
movaps %xmm0,0x190(%rsp)
movaps %xmm0,0x180(%rsp)
movaps %xmm0,0x170(%rsp)
movaps %xmm0,0x160(%rsp)
movb   $0x51,0x20(%rsp)
movl   $0x18,0x24(%rsp)
mov    %rsp,%r13
mov    %r13,0x28(%rsp)
movl   $0x80,0x30(%rsp)
lea    0x160(%rsp),%r12
mov    %r12,0x38(%rsp)
mov    %rdx,0x40(%rsp)
mov    %rsi,0x48(%rsp)
movl   $0x7530,0x50(%rsp)
movb   $0x0,0x54(%rsp)
movq   $0x0,0x58(%rsp)
movl   $0x0,0x60(%rsp)
movups %xmm0,0x68(%rsp)
movups %xmm0,0x74(%rsp)
movups %xmm0,0x88(%rsp)
movups %xmm0,0x98(%rsp)
movups %xmm0,0xa4(%rsp)
mov    0x2d9e(%rip),%rax
mov    (%rax),%eax
mov    %eax,0xb4(%rsp)
mov    0x2dd6(%rip),%rax
mov    (%rax),%eax
mov    %eax,0xb8(%rsp)
mov    0x2d96(%rip),%r15
mov    (%r15),%esi
lea    0x20(%rsp),%rdx
call   1030 <ioctl@plt>
test   %eax,%eax
je     1341 <disk_scsi_inquiry_command+0x231>
mov    0x2d72(%rip),%rcx
mov    (%rcx),%rcx
mov    0x2d60(%rip),%rdx
cmp    (%rdx),%rcx
jne    137d <disk_scsi_inquiry_command+0x26d>
movb   $0x0,0xc0(%rsp)
xorps  %xmm0,%xmm0
movups %xmm0,0xc4(%rsp)
movups %xmm0,0xd8(%rsp)
movq   $0x0,0xe8(%rsp)
movl   $0x7530,0xf0(%rsp)
movb   $0x53,0xf4(%rsp)
53
mov    %r13,0xf8(%rsp)
movl   $0x18,0x100(%rsp)
mov    %rbp,0x108(%rsp)
mov    %rbx,0x110(%rsp)
mov    %r12,0x118(%rsp)
movl   $0x80,0x120(%rsp)
movups %xmm0,0x128(%rsp)
movups %xmm0,0x138(%rsp)
movq   $0x0,0x148(%rsp)
mov    0x2cec(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x150(%rsp)
movq   $0x0,0x154(%rsp)
mov    (%r15),%esi
lea    0xc0(%rsp),%rdx
mov    %r14d,%edi
call   1030 <ioctl@plt>
test   %eax,%eax
jne    137d <disk_scsi_inquiry_command+0x26d>
cmpq   $0x0,0x128(%rsp)
jne    1364 <disk_scsi_inquiry_command+0x254>
cmpq   $0x0,0x130(%rsp)
jne    1364 <disk_scsi_inquiry_command+0x254>
cmpq   $0x0,0x138(%rsp)
jne    1364 <disk_scsi_inquiry_command+0x254>
cmpq   $0x0,0xa0(%rsp)
jne    1364 <disk_scsi_inquiry_command+0x254>
cmpq   $0x0,0xa8(%rsp)
jne    1364 <disk_scsi_inquiry_command+0x254>
xor    %eax,%eax
cmpq   $0x0,0x98(%rsp)
je     137d <disk_scsi_inquiry_command+0x26d>
mov    0x2c65(%rip),%rax
mov    (%rax),%rax
mov    0x2c4b(%rip),%rcx
mov    %rax,(%rcx)
mov    $0xffffffff,%eax
add    $0x1e8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.sg_io_v4 = type { i8, i32, i64, i32, i64, i64, i64, i32, i8, i8*, i32, i8*, i64, i32*, i32, i64, i64, i64, i64, i64, i32, i32, i32 }
%struct.sg_io_hdr = type { i8, i32, i64, i32, i64, i64, i64, i32, i8, i8*, i32, i8*, i64, i32*, i32, i64, i64, i64, i64, i64, i32, i32, i32 }
@BSG_SUB_PROTOCOL_SCSI_CMD = global i32 0
@BSG_PROTOCOL_SCSI = global i32 0
@SG_IO = global i32 0
@errno = global i64 0
@EINVAL = global i64 0
@SG_DXFER_FROM_DEV = global i32 0
@EIO = global i64 0
define i32 @disk_scsi_inquiry_command(i32 %0, i8* %1, i64 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i64
%8 = alloca [6 x i32]
%9 = alloca [32 x i32]
%10 = alloca %struct.sg_io_v4
%11 = alloca i32
%12 = alloca %struct.sg_io_hdr
store i32 %0, i32* %5
store i8* %1, i8** %6
store i64 %2, i64* %7
%13 = getelementptr inbounds [6 x i32], [6 x i32]* %8, i64 0, i64 0
store i32 18, i32* %13
%14 = getelementptr inbounds i32, i32* %13, i64 1
store i32 0, i32* %14
%15 = getelementptr inbounds i32, i32* %14, i64 1
store i32 0, i32* %15
%16 = getelementptr inbounds i32, i32* %15, i64 1
%17 = load i64, i64* %7
%18 = lshr i64 %17, 8
%19 = trunc i64 %18 to i32
store i32 %19, i32* %16
%20 = getelementptr inbounds i32, i32* %16, i64 1
%21 = load i64, i64* %7
%22 = and i64 %21, 255
%23 = trunc i64 %22 to i32
store i32 %23, i32* %20
%24 = getelementptr inbounds i32, i32* %20, i64 1
%25 = getelementptr inbounds i32, i32* %13, i64 6
br label %26
26: ; preds = %26, %3
%27 = phi i32* [ %24, %3 ], [ %28, %26 ]
store i32 0, i32* %27
%28 = getelementptr inbounds i32, i32* %27, i64 1
%29 = icmp eq i32* %28, %25
br i1 %29, label %30, label %26
30: ; preds = %26
%31 = bitcast [32 x i32]* %9 to i8*
%32 = getelementptr inbounds %struct.sg_io_v4, %struct.sg_io_v4* %10, i32 0, i32 0
store i8 81, i8* %32
%33 = getelementptr inbounds %struct.sg_io_v4, %struct.sg_io_v4* %10, i32 0, i32 1
store i32 24, i32* %33
%34 = getelementptr inbounds %struct.sg_io_v4, %struct.sg_io_v4* %10, i32 0, i32 2
%35 = getelementptr inbounds [6 x i32], [6 x i32]* %8, i64 0, i64 0
%36 = ptrtoint i32* %35 to i64
store i64 %36, i64* %34
%37 = getelementptr inbounds %struct.sg_io_v4, %struct.sg_io_v4* %10, i32 0, i32 3
store i32 128, i32* %37
%38 = getelementptr inbounds %struct.sg_io_v4, %struct.sg_io_v4* %10, i32 0, i32 4
%39 = getelementptr inbounds [32 x i32], [32 x i32]* %9, i64 0, i64 0
%40 = ptrtoint i32* %39 to i64
store i64 %40, i64* %38
%41 = getelementptr inbounds %struct.sg_io_v4, %struct.sg_io_v4* %10, i32 0, i32 5
%42 = load i64, i64* %7
store i64 %42, i64* %41
%43 = getelementptr inbounds %struct.sg_io_v4, %struct.sg_io_v4* %10, i32 0, i32 6
%44 = load i8*, i8** %6
%45 = ptrtoint i8* %44 to i64
store i64 %45, i64* %43
%46 = getelementptr inbounds %struct.sg_io_v4, %struct.sg_io_v4* %10, i32 0, i32 7
store i32 30000, i32* %46
%47 = getelementptr inbounds %struct.sg_io_v4, %struct.sg_io_v4* %10, i32 0, i32 8
store i8 0, i8* %47
%48 = getelementptr inbounds %struct.sg_io_v4, %struct.sg_io_v4* %10, i32 0, i32 9
store i8* null, i8** %48
%49 = getelementptr inbounds %struct.sg_io_v4, %struct.sg_io_v4* %10, i32 0, i32 10
store i32 0, i32* %49
%50 = getelementptr inbounds %struct.sg_io_v4, %struct.sg_io_v4* %10, i32 0, i32 11
store i8* null, i8** %50
%51 = getelementptr inbounds %struct.sg_io_v4, %struct.sg_io_v4* %10, i32 0, i32 12
store i64 0, i64* %51
%52 = getelementptr inbounds %struct.sg_io_v4, %struct.sg_io_v4* %10, i32 0, i32 13
store i32* null, i32** %52
%53 = getelementptr inbounds %struct.sg_io_v4, %struct.sg_io_v4* %10, i32 0, i32 14
store i32 0, i32* %53
%54 = getelementptr inbounds %struct.sg_io_v4, %struct.sg_io_v4* %10, i32 0, i32 15
store i64 0, i64* %54
%55 = getelementptr inbounds %struct.sg_io_v4, %struct.sg_io_v4* %10, i32 0, i32 16
store i64 0, i64* %55
%56 = getelementptr inbounds %struct.sg_io_v4, %struct.sg_io_v4* %10, i32 0, i32 17
store i64 0, i64* %56
%57 = getelementptr inbounds %struct.sg_io_v4, %struct.sg_io_v4* %10, i32 0, i32 18
store i64 0, i64* %57
%58 = getelementptr inbounds %struct.sg_io_v4, %struct.sg_io_v4* %10, i32 0, i32 19
store i64 0, i64* %58
%59 = getelementptr inbounds %struct.sg_io_v4, %struct.sg_io_v4* %10, i32 0, i32 20
store i32 0, i32* %59
%60 = getelementptr inbounds %struct.sg_io_v4, %struct.sg_io_v4* %10, i32 0, i32 21
%61 = load i32, i32* @BSG_SUB_PROTOCOL_SCSI_CMD
store i32 %61, i32* %60
%62 = getelementptr inbounds %struct.sg_io_v4, %struct.sg_io_v4* %10, i32 0, i32 22
%63 = load i32, i32* @BSG_PROTOCOL_SCSI
store i32 %63, i32* %62
%64 = load i32, i32* %5
%65 = load i32, i32* @SG_IO
%66 = call i32 @ioctl(i32 %64, i32 %65, %struct.sg_io_v4* %10)
store i32 %66, i32* %11
%67 = load i32, i32* %11
%68 = icmp ne i32 %67, 0
br i1 %68, label %69, label %129
69: ; preds = %30
%70 = load i64, i64* @errno
%71 = load i64, i64* @EINVAL
%72 = icmp eq i64 %70, %71
br i1 %72, label %73, label %126
73: ; preds = %69
%74 = getelementptr inbounds %struct.sg_io_hdr, %struct.sg_io_hdr* %12, i32 0, i32 0
store i8 0, i8* %74
%75 = getelementptr inbounds %struct.sg_io_hdr, %struct.sg_io_hdr* %12, i32 0, i32 1
store i32 0, i32* %75
%76 = getelementptr inbounds %struct.sg_io_hdr, %struct.sg_io_hdr* %12, i32 0, i32 2
store i64 0, i64* %76
%77 = getelementptr inbounds %struct.sg_io_hdr, %struct.sg_io_hdr* %12, i32 0, i32 3
store i32 0, i32* %77
%78 = getelementptr inbounds %struct.sg_io_hdr, %struct.sg_io_hdr* %12, i32 0, i32 4
store i64 0, i64* %78
%79 = getelementptr inbounds %struct.sg_io_hdr, %struct.sg_io_hdr* %12, i32 0, i32 5
store i64 0, i64* %79
%80 = getelementptr inbounds %struct.sg_io_hdr, %struct.sg_io_hdr* %12, i32 0, i32 6
store i64 0, i64* %80
%81 = getelementptr inbounds %struct.sg_io_hdr, %struct.sg_io_hdr* %12, i32 0, i32 7
store i32 30000, i32* %81
%82 = getelementptr inbounds %struct.sg_io_hdr, %struct.sg_io_hdr* %12, i32 0, i32 8
store i8 83, i8* %82
%83 = getelementptr inbounds %struct.sg_io_hdr, %struct.sg_io_hdr* %12, i32 0, i32 9
%84 = getelementptr inbounds [6 x i32], [6 x i32]* %8, i64 0, i64 0
%85 = bitcast i32* %84 to i8*
store i8* %85, i8** %83
%86 = getelementptr inbounds %struct.sg_io_hdr, %struct.sg_io_hdr* %12, i32 0, i32 10
store i32 24, i32* %86
%87 = getelementptr inbounds %struct.sg_io_hdr, %struct.sg_io_hdr* %12, i32 0, i32 11
%88 = load i8*, i8** %6
store i8* %88, i8** %87
%89 = getelementptr inbounds %struct.sg_io_hdr, %struct.sg_io_hdr* %12, i32 0, i32 12
%90 = load i64, i64* %7
store i64 %90, i64* %89
%91 = getelementptr inbounds %struct.sg_io_hdr, %struct.sg_io_hdr* %12, i32 0, i32 13
%92 = getelementptr inbounds [32 x i32], [32 x i32]* %9, i64 0, i64 0
store i32* %92, i32** %91
%93 = getelementptr inbounds %struct.sg_io_hdr, %struct.sg_io_hdr* %12, i32 0, i32 14
store i32 128, i32* %93
%94 = getelementptr inbounds %struct.sg_io_hdr, %struct.sg_io_hdr* %12, i32 0, i32 15
store i64 0, i64* %94
%95 = getelementptr inbounds %struct.sg_io_hdr, %struct.sg_io_hdr* %12, i32 0, i32 16
store i64 0, i64* %95
%96 = getelementptr inbounds %struct.sg_io_hdr, %struct.sg_io_hdr* %12, i32 0, i32 17
store i64 0, i64* %96
%97 = getelementptr inbounds %struct.sg_io_hdr, %struct.sg_io_hdr* %12, i32 0, i32 18
store i64 0, i64* %97
%98 = getelementptr inbounds %struct.sg_io_hdr, %struct.sg_io_hdr* %12, i32 0, i32 19
store i64 0, i64* %98
%99 = getelementptr inbounds %struct.sg_io_hdr, %struct.sg_io_hdr* %12, i32 0, i32 20
%100 = load i32, i32* @SG_DXFER_FROM_DEV
store i32 %100, i32* %99
%101 = getelementptr inbounds %struct.sg_io_hdr, %struct.sg_io_hdr* %12, i32 0, i32 21
store i32 0, i32* %101
%102 = getelementptr inbounds %struct.sg_io_hdr, %struct.sg_io_hdr* %12, i32 0, i32 22
store i32 0, i32* %102
%103 = load i32, i32* %5
%104 = load i32, i32* @SG_IO
%105 = bitcast %struct.sg_io_hdr* %12 to %struct.sg_io_v4*
%106 = call i32 @ioctl(i32 %103, i32 %104, %struct.sg_io_v4* %105)
store i32 %106, i32* %11
%107 = load i32, i32* %11
%108 = icmp ne i32 %107, 0
br i1 %108, label %109, label %111
109: ; preds = %73
%110 = load i32, i32* %11
store i32 %110, i32* %4
br label %144
111: ; preds = %73
%112 = getelementptr inbounds %struct.sg_io_hdr, %struct.sg_io_hdr* %12, i32 0, i32 15
%113 = load i64, i64* %112
%114 = icmp eq i64 %113, 0
br i1 %114, label %115, label %123
115: ; preds = %111
%116 = getelementptr inbounds %struct.sg_io_hdr, %struct.sg_io_hdr* %12, i32 0, i32 16
%117 = load i64, i64* %116
%118 = icmp eq i64 %117, 0
br i1 %118, label %119, label %123
119: ; preds = %115
%120 = getelementptr inbounds %struct.sg_io_hdr, %struct.sg_io_hdr* %12, i32 0, i32 17
%121 = load i64, i64* %120
%122 = icmp eq i64 %121, 0
br i1 %122, label %125, label %123
123: ; preds = %119, %115, %111
%124 = load i64, i64* @EIO
store i64 %124, i64* @errno
store i32 -1, i32* %4
br label %144
125: ; preds = %119
br label %128
126: ; preds = %69
%127 = load i32, i32* %11
store i32 %127, i32* %4
br label %144
128: ; preds = %125
br label %129
129: ; preds = %128, %30
%130 = getelementptr inbounds %struct.sg_io_v4, %struct.sg_io_v4* %10, i32 0, i32 18
%131 = load i64, i64* %130
%132 = icmp eq i64 %131, 0
br i1 %132, label %133, label %141
133: ; preds = %129
%134 = getelementptr inbounds %struct.sg_io_v4, %struct.sg_io_v4* %10, i32 0, i32 19
%135 = load i64, i64* %134
%136 = icmp eq i64 %135, 0
br i1 %136, label %137, label %141
137: ; preds = %133
%138 = getelementptr inbounds %struct.sg_io_v4, %struct.sg_io_v4* %10, i32 0, i32 17
%139 = load i64, i64* %138
%140 = icmp eq i64 %139, 0
br i1 %140, label %143, label %141
141: ; preds = %137, %133, %129
%142 = load i64, i64* @EIO
store i64 %142, i64* @errno
store i32 -1, i32* %4
br label %144
143: ; preds = %137
store i32 0, i32* %4
br label %144
144: ; preds = %143, %141, %126, %123, %109
%145 = load i32, i32* %4
ret i32 %145
}

LLVM IR (-O2):
%struct.sg_io_v4 = type { i8, i32, i64, i32, i64, i64, i64, i32, i8, i8*, i32, i8*, i64, i32*, i32, i64, i64, i64, i64, i64, i32, i32, i32 }
%struct.sg_io_hdr = type { i8, i32, i64, i32, i64, i64, i64, i32, i8, i8*, i32, i8*, i64, i32*, i32, i64, i64, i64, i64, i64, i32, i32, i32 }
@BSG_SUB_PROTOCOL_SCSI_CMD = global i32 0
@BSG_PROTOCOL_SCSI = global i32 0
@SG_IO = global i32 0
@errno = global i64 0
@EINVAL = global i64 0
@SG_DXFER_FROM_DEV = global i32 0
@EIO = global i64 0
define i32 @disk_scsi_inquiry_command(i32 %0, i8* %1, i64 %2) {
%4 = alloca [6 x i32]
%5 = alloca [32 x i32]
%6 = alloca %struct.sg_io_v4
%7 = alloca %struct.sg_io_hdr
%8 = bitcast [6 x i32]* %4 to i8*
%9 = getelementptr inbounds [6 x i32], [6 x i32]* %4, i64 0, i64 0
store i32 18, i32* %9
%10 = getelementptr inbounds [6 x i32], [6 x i32]* %4, i64 0, i64 1
store i32 0, i32* %10
%11 = getelementptr inbounds [6 x i32], [6 x i32]* %4, i64 0, i64 2
store i32 0, i32* %11
%12 = getelementptr inbounds [6 x i32], [6 x i32]* %4, i64 0, i64 3
%13 = lshr i64 %2, 8
%14 = trunc i64 %13 to i32
store i32 %14, i32* %12
%15 = getelementptr inbounds [6 x i32], [6 x i32]* %4, i64 0, i64 4
%16 = trunc i64 %2 to i32
%17 = and i32 %16, 255
store i32 %17, i32* %15
%18 = getelementptr inbounds [6 x i32], [6 x i32]* %4, i64 0, i64 5
store i32 0, i32* %18
%19 = bitcast [32 x i32]* %5 to i8*
%20 = getelementptr inbounds %struct.sg_io_v4, %struct.sg_io_v4* %6, i64 0, i32 0
store i8 81, i8* %20
%21 = getelementptr inbounds %struct.sg_io_v4, %struct.sg_io_v4* %6, i64 0, i32 1
store i32 24, i32* %21
%22 = getelementptr inbounds %struct.sg_io_v4, %struct.sg_io_v4* %6, i64 0, i32 2
%23 = ptrtoint [6 x i32]* %4 to i64
store i64 %23, i64* %22
%24 = getelementptr inbounds %struct.sg_io_v4, %struct.sg_io_v4* %6, i64 0, i32 3
store i32 128, i32* %24
%25 = getelementptr inbounds %struct.sg_io_v4, %struct.sg_io_v4* %6, i64 0, i32 4
%26 = getelementptr inbounds [32 x i32], [32 x i32]* %5, i64 0, i64 0
%27 = ptrtoint [32 x i32]* %5 to i64
store i64 %27, i64* %25
%28 = getelementptr inbounds %struct.sg_io_v4, %struct.sg_io_v4* %6, i64 0, i32 5
store i64 %2, i64* %28
%29 = getelementptr inbounds %struct.sg_io_v4, %struct.sg_io_v4* %6, i64 0, i32 6
%30 = ptrtoint i8* %1 to i64
store i64 %30, i64* %29
%31 = getelementptr inbounds %struct.sg_io_v4, %struct.sg_io_v4* %6, i64 0, i32 7
store i32 30000, i32* %31
%32 = getelementptr inbounds %struct.sg_io_v4, %struct.sg_io_v4* %6, i64 0, i32 8
store i8 0, i8* %32
%33 = getelementptr inbounds %struct.sg_io_v4, %struct.sg_io_v4* %6, i64 0, i32 9
store i8* null, i8** %33
%34 = getelementptr inbounds %struct.sg_io_v4, %struct.sg_io_v4* %6, i64 0, i32 10
store i32 0, i32* %34
%35 = getelementptr inbounds %struct.sg_io_v4, %struct.sg_io_v4* %6, i64 0, i32 11
%36 = getelementptr inbounds %struct.sg_io_v4, %struct.sg_io_v4* %6, i64 0, i32 15
%37 = getelementptr inbounds %struct.sg_io_v4, %struct.sg_io_v4* %6, i64 0, i32 17
%38 = getelementptr inbounds %struct.sg_io_v4, %struct.sg_io_v4* %6, i64 0, i32 18
%39 = getelementptr inbounds %struct.sg_io_v4, %struct.sg_io_v4* %6, i64 0, i32 19
%40 = getelementptr inbounds %struct.sg_io_v4, %struct.sg_io_v4* %6, i64 0, i32 21
%41 = bitcast i8** %35 to i8*
%42 = bitcast i64* %36 to i8*
%43 = load i32, i32* @BSG_SUB_PROTOCOL_SCSI_CMD
store i32 %43, i32* %40
%44 = getelementptr inbounds %struct.sg_io_v4, %struct.sg_io_v4* %6, i64 0, i32 22
%45 = load i32, i32* @BSG_PROTOCOL_SCSI
store i32 %45, i32* %44
%46 = load i32, i32* @SG_IO
%47 = call i32 @ioctl(i32 %0, i32 %46, %struct.sg_io_v4* %6)
%48 = icmp eq i32 %47, 0
br i1 %48, label %94, label %49
49: ; preds = %3
%50 = load i64, i64* @errno
%51 = load i64, i64* @EINVAL
%52 = icmp eq i64 %50, %51
br i1 %52, label %53, label %105
53: ; preds = %49
%54 = getelementptr inbounds %struct.sg_io_hdr, %struct.sg_io_hdr* %7, i64 0, i32 0
store i8 0, i8* %54
%55 = getelementptr inbounds %struct.sg_io_hdr, %struct.sg_io_hdr* %7, i64 0, i32 1
%56 = getelementptr inbounds %struct.sg_io_hdr, %struct.sg_io_hdr* %7, i64 0, i32 4
%57 = getelementptr inbounds %struct.sg_io_hdr, %struct.sg_io_hdr* %7, i64 0, i32 7
%58 = bitcast i32* %55 to i8*
%59 = bitcast i64* %56 to i8*
store i32 30000, i32* %57
%60 = getelementptr inbounds %struct.sg_io_hdr, %struct.sg_io_hdr* %7, i64 0, i32 8
store i8 83, i8* %60
%61 = getelementptr inbounds %struct.sg_io_hdr, %struct.sg_io_hdr* %7, i64 0, i32 9
%62 = bitcast i8** %61 to [6 x i32]**
store [6 x i32]* %4, [6 x i32]** %62
%63 = getelementptr inbounds %struct.sg_io_hdr, %struct.sg_io_hdr* %7, i64 0, i32 10
store i32 24, i32* %63
%64 = getelementptr inbounds %struct.sg_io_hdr, %struct.sg_io_hdr* %7, i64 0, i32 11
store i8* %1, i8** %64
%65 = getelementptr inbounds %struct.sg_io_hdr, %struct.sg_io_hdr* %7, i64 0, i32 12
store i64 %2, i64* %65
%66 = getelementptr inbounds %struct.sg_io_hdr, %struct.sg_io_hdr* %7, i64 0, i32 13
store i32* %26, i32** %66
%67 = getelementptr inbounds %struct.sg_io_hdr, %struct.sg_io_hdr* %7, i64 0, i32 14
store i32 128, i32* %67
%68 = getelementptr inbounds %struct.sg_io_hdr, %struct.sg_io_hdr* %7, i64 0, i32 15
%69 = getelementptr inbounds %struct.sg_io_hdr, %struct.sg_io_hdr* %7, i64 0, i32 20
%70 = bitcast i64* %68 to i8*
%71 = load i32, i32* @SG_DXFER_FROM_DEV
store i32 %71, i32* %69
%72 = getelementptr inbounds %struct.sg_io_hdr, %struct.sg_io_hdr* %7, i64 0, i32 21
store i32 0, i32* %72
%73 = getelementptr inbounds %struct.sg_io_hdr, %struct.sg_io_hdr* %7, i64 0, i32 22
store i32 0, i32* %73
%74 = load i32, i32* @SG_IO
%75 = bitcast %struct.sg_io_hdr* %7 to %struct.sg_io_v4*
%76 = call i32 @ioctl(i32 %0, i32 %74, %struct.sg_io_v4* %75)
%77 = icmp eq i32 %76, 0
br i1 %77, label %78, label %91
78: ; preds = %53
%79 = getelementptr inbounds %struct.sg_io_hdr, %struct.sg_io_hdr* %7, i64 0, i32 17
%80 = getelementptr inbounds %struct.sg_io_hdr, %struct.sg_io_hdr* %7, i64 0, i32 16
%81 = load i64, i64* %68
%82 = icmp eq i64 %81, 0
%83 = load i64, i64* %80
%84 = icmp eq i64 %83, 0
%85 = select i1 %82, i1 %84, i1 false
%86 = load i64, i64* %79
%87 = icmp eq i64 %86, 0
%88 = select i1 %85, i1 %87, i1 false
br i1 %88, label %93, label %89
89: ; preds = %78
%90 = load i64, i64* @EIO
store i64 %90, i64* @errno
br label %91
91: ; preds = %89, %53
%92 = phi i32 [ %76, %53 ], [ -1, %89 ]
br label %105
93: ; preds = %78
br label %94
94: ; preds = %93, %3
%95 = load i64, i64* %38
%96 = icmp eq i64 %95, 0
%97 = load i64, i64* %39
%98 = icmp eq i64 %97, 0
%99 = select i1 %96, i1 %98, i1 false
%100 = load i64, i64* %37
%101 = icmp eq i64 %100, 0
%102 = select i1 %99, i1 %101, i1 false
br i1 %102, label %105, label %103
103: ; preds = %94
%104 = load i64, i64* @EIO
store i64 %104, i64* @errno
br label %105
105: ; preds = %91, %94, %49, %103
%106 = phi i32 [ -1, %103 ], [ %47, %49 ], [ 0, %94 ], [ %92, %91 ]
ret i32 %106
}