#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*/ cdb;

/* Variables and functions */
int /*<<< orphan*/ SG_DXFER_FROM_DEV;
int /*<<< orphan*/ print_sense_data(unsigned char *, unsigned int);
int /*<<< orphan*/ printf(char *, ...);
int scsi_io(int, unsigned char *, int, int /*<<< orphan*/, unsigned char *,
            unsigned int *, unsigned char *, unsigned int *);
int scsi_persistent_reserve_in_report_capabilities(int fd) {
  unsigned char cdb[] = {0x5e, 0, 0, 0, 0, 0, 0, 0, 0, 0};
  unsigned int data_size = 0x00ff;
  unsigned char data[data_size];
  unsigned int sense_len = 32;
  unsigned char sense[sense_len];
  unsigned char service_action = 2;
  int res;
  unsigned short length, type_mask;
  cdb[1] = service_action;
  cdb[7] = (data_size >> 8) & 0xff;
  cdb[8] = data_size & 0xff;
  printf("PERSISTENT RESERVE IN: REPORT CAPABILITIES\n");
  res = scsi_io(fd, cdb, sizeof(cdb), SG_DXFER_FROM_DEV, data, &data_size,
                sense, &sense_len);
  if (res) {
    printf("SCSI_IO failed\n");
    return -1;
  }
  if (sense_len) {
    print_sense_data(sense, sense_len);
    return -1;
  }
  length = data[0];
  length <<= 8;
  length |= data[1];
  printf("Length:%d\n", length);
  printf("CRH:%d SIP_C:%d ATP_C:%d PTPL_C:%d\n", !!(data[2] & 0x10),
         !!(data[2] & 0x08), !!(data[2] & 0x04), !!(data[2] & 0x01));
  printf("TMV:%d ALLOW_COMMANDS:%c%c%cb PTPL_A:%d\n", !!(data[3] & 0x80),
         '0' + (!!(data[3] & 0x40)), '0' + (!!(data[3] & 0x20)),
         '0' + (!!(data[3] & 0x10)), !!(data[3] & 0x01));
  type_mask = data[4];
  type_mask <<= 8;
  type_mask |= data[5];
  printf("Persistent Reservation Type Mask:0x%04x\n", type_mask);
  printf("WR_EX_AR:%d EX_AC_RO:%d WR_EX_RO:%d EX_AC:%d WR_EX:%d EX_AC_AR:%d\n",
         !!(data[4] & 0x80), !!(data[4] & 0x40), !!(data[4] & 0x20),
         !!(data[4] & 0x08), !!(data[4] & 0x02), !!(data[4] & 0x01));
  return 0;
}


x86 assembly (clang, -O0):
<scsi_persistent_reserve_in_report_capabilities>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %edi,-0x8(%rbp)
mov    0xec6(%rip),%ax
mov    %ax,-0x10(%rbp)
mov    0xeb3(%rip),%rax
mov    %rax,-0x18(%rbp)
movl   $0xff,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x28(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x60(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x30(%rbp)
movl   $0x20,-0x34(%rbp)
mov    -0x34(%rbp),%eax
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x58(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x40(%rbp)
movb   $0x2,-0x41(%rbp)
mov    -0x41(%rbp),%al
mov    %al,-0x17(%rbp)
mov    -0x1c(%rbp),%eax
shr    $0x8,%eax
and    $0xff,%eax
mov    %al,-0x11(%rbp)
mov    -0x1c(%rbp),%eax
and    $0xff,%eax
mov    %al,-0x10(%rbp)
lea    0xe3c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x60(%rbp),%r8
mov    -0x58(%rbp),%r10
mov    -0x8(%rbp),%edi
lea    -0x18(%rbp),%rsi
mov    0x2dfd(%rip),%rax
mov    (%rax),%ecx
mov    $0xa,%edx
lea    -0x1c(%rbp),%r9
lea    -0x34(%rbp),%rax
sub    $0x10,%rsp
mov    %r10,(%rsp)
mov    %rax,0x8(%rsp)
call   1040 <scsi_io@plt>
add    $0x10,%rsp
mov    %eax,-0x48(%rbp)
cmpl   $0x0,-0x48(%rbp)
je     123e <scsi_persistent_reserve_in_report_capabilities+0x10e>
lea    0xe12(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x50(%rbp)
jmp    14b2 <scsi_persistent_reserve_in_report_capabilities+0x382>
cmpl   $0x0,-0x34(%rbp)
je     1267 <scsi_persistent_reserve_in_report_capabilities+0x137>
mov    -0x58(%rbp),%rdi
mov    -0x34(%rbp),%esi
call   1050 <print_sense_data@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x50(%rbp)
jmp    14b2 <scsi_persistent_reserve_in_report_capabilities+0x382>
mov    -0x60(%rbp),%rax
movzbl (%rax),%ecx
mov    %cx,-0x4a(%rbp)
movzwl -0x4a(%rbp),%ecx
shl    $0x8,%ecx
mov    %cx,-0x4a(%rbp)
movzbl 0x1(%rax),%ecx
movzwl -0x4a(%rbp),%eax
or     %ecx,%eax
mov    %ax,-0x4a(%rbp)
movzwl -0x4a(%rbp),%esi
lea    0xdb0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x60(%rbp),%rax
movzbl 0x2(%rax),%ecx
and    $0x10,%ecx
cmp    $0x0,%ecx
setne  %cl
xor    $0xff,%cl
xor    $0xff,%cl
and    $0x1,%cl
movzbl %cl,%esi
movzbl 0x2(%rax),%ecx
and    $0x8,%ecx
cmp    $0x0,%ecx
setne  %cl
xor    $0xff,%cl
xor    $0xff,%cl
and    $0x1,%cl
movzbl %cl,%edx
movzbl 0x2(%rax),%ecx
and    $0x4,%ecx
cmp    $0x0,%ecx
setne  %cl
xor    $0xff,%cl
xor    $0xff,%cl
and    $0x1,%cl
movzbl %cl,%ecx
movzbl 0x2(%rax),%eax
and    $0x1,%eax
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%r8d
lea    0xd47(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x60(%rbp),%rax
movzbl 0x3(%rax),%ecx
and    $0x80,%ecx
cmp    $0x0,%ecx
setne  %cl
xor    $0xff,%cl
xor    $0xff,%cl
and    $0x1,%cl
movzbl %cl,%esi
movzbl 0x3(%rax),%ecx
and    $0x40,%ecx
cmp    $0x0,%ecx
setne  %cl
xor    $0xff,%cl
xor    $0xff,%cl
and    $0x1,%cl
movzbl %cl,%edx
add    $0x30,%edx
movzbl 0x3(%rax),%ecx
and    $0x20,%ecx
cmp    $0x0,%ecx
setne  %cl
xor    $0xff,%cl
xor    $0xff,%cl
and    $0x1,%cl
movzbl %cl,%ecx
add    $0x30,%ecx
movzbl 0x3(%rax),%edi
and    $0x10,%edi
cmp    $0x0,%edi
setne  %dil
xor    $0xff,%dil
xor    $0xff,%dil
and    $0x1,%dil
movzbl %dil,%r8d
add    $0x30,%r8d
movzbl 0x3(%rax),%eax
and    $0x1,%eax
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%r9d
lea    0xccc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x60(%rbp),%rax
movzbl 0x4(%rax),%ecx
mov    %cx,-0x4c(%rbp)
movzwl -0x4c(%rbp),%ecx
shl    $0x8,%ecx
mov    %cx,-0x4c(%rbp)
movzbl 0x5(%rax),%ecx
movzwl -0x4c(%rbp),%eax
or     %ecx,%eax
mov    %ax,-0x4c(%rbp)
movzwl -0x4c(%rbp),%esi
lea    0xcbe(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x60(%rbp),%rax
movzbl 0x4(%rax),%ecx
and    $0x80,%ecx
cmp    $0x0,%ecx
setne  %cl
xor    $0xff,%cl
xor    $0xff,%cl
and    $0x1,%cl
movzbl %cl,%esi
movzbl 0x4(%rax),%ecx
and    $0x40,%ecx
cmp    $0x0,%ecx
setne  %cl
xor    $0xff,%cl
xor    $0xff,%cl
and    $0x1,%cl
movzbl %cl,%edx
movzbl 0x4(%rax),%ecx
and    $0x20,%ecx
cmp    $0x0,%ecx
setne  %cl
xor    $0xff,%cl
xor    $0xff,%cl
and    $0x1,%cl
movzbl %cl,%ecx
movzbl 0x4(%rax),%edi
and    $0x8,%edi
cmp    $0x0,%edi
setne  %dil
xor    $0xff,%dil
xor    $0xff,%dil
and    $0x1,%dil
movzbl %dil,%r8d
movzbl 0x4(%rax),%edi
and    $0x2,%edi
cmp    $0x0,%edi
setne  %dil
xor    $0xff,%dil
xor    $0xff,%dil
and    $0x1,%dil
movzbl %dil,%r9d
movzbl 0x4(%rax),%eax
and    $0x1,%eax
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
lea    0xc35(%rip),%rdi
sub    $0x10,%rsp
mov    %eax,(%rsp)
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x50(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<scsi_persistent_reserve_in_report_capabilities>:
push   %rbp
push   %r14
push   %rbx
sub    $0x140,%rsp
mov    %edi,%ebx
mov    %rsp,%r14
movzwl 0xeb1(%rip),%eax
mov    %ax,0x18(%rsp)
mov    0xe9d(%rip),%rax
mov    %rax,0x10(%rsp)
movl   $0xff,0x1c(%rsp)
movl   $0x20,0xc(%rsp)
movb   $0x2,0x11(%rsp)
movw   $0xff00,0x17(%rsp)
lea    0xf43(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e51(%rip),%rax
mov    (%rax),%ecx
lea    0xc(%rsp),%rax
lea    0x20(%rsp),%rbp
lea    0x10(%rsp),%rsi
lea    0x40(%rsp),%r8
lea    0x1c(%rsp),%r9
mov    %ebx,%edi
mov    $0xa,%edx
push   %rax
push   %rbp
call   1050 <scsi_io@plt>
add    $0x10,%rsp
test   %eax,%eax
je     11de <scsi_persistent_reserve_in_report_capabilities+0x9e>
lea    0xf2a(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%ebp
jmp    12ed <scsi_persistent_reserve_in_report_capabilities+0x1ad>
mov    0xc(%rsp),%esi
test   %esi,%esi
je     11fa <scsi_persistent_reserve_in_report_capabilities+0xba>
lea    0x20(%rsp),%rdi
call   1060 <print_sense_data@plt>
mov    $0xffffffff,%ebp
jmp    12ed <scsi_persistent_reserve_in_report_capabilities+0x1ad>
movzwl 0x40(%rsp),%esi
shl    $0x10,%esi
bswap  %esi
lea    0xdff(%rip),%rdi
xor    %ebp,%ebp
xor    %eax,%eax
call   1040 <printf@plt>
movzbl 0x42(%rsp),%r8d
mov    %r8d,%esi
shr    $0x4,%esi
and    $0x1,%esi
mov    %r8d,%edx
shr    $0x3,%edx
and    $0x1,%edx
mov    %r8d,%ecx
shr    $0x2,%ecx
and    $0x1,%ecx
and    $0x1,%r8d
lea    0xdd5(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movzbl 0x43(%rsp),%r9d
mov    %r9d,%esi
shr    $0x7,%esi
mov    %r9d,%edx
shr    $0x6,%edx
and    $0x1,%edx
or     $0x30,%edx
mov    %r9d,%ecx
shr    $0x5,%ecx
and    $0x1,%ecx
or     $0x30,%ecx
mov    %r9d,%r8d
shr    $0x4,%r8d
and    $0x1,%r8d
or     $0x30,%r8d
and    $0x1,%r9d
lea    0xdb4(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movzwl 0x44(%rsp),%esi
shl    $0x10,%esi
bswap  %esi
lea    0xdc5(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movzbl 0x44(%rsp),%ebx
mov    %ebx,%esi
shr    $0x7,%esi
mov    %ebx,%edx
shr    $0x6,%edx
and    $0x1,%edx
mov    %ebx,%ecx
shr    $0x5,%ecx
and    $0x1,%ecx
mov    %ebx,%r8d
shr    $0x3,%r8d
and    $0x1,%r8d
mov    %ebx,%r9d
shr    %r9d
and    $0x1,%r9d
and    $0x1,%ebx
sub    $0x8,%rsp
lea    0xdaa(%rip),%rdi
xor    %eax,%eax
push   %rbx
call   1040 <printf@plt>
add    $0x10,%rsp
mov    %r14,%rsp
mov    %ebp,%eax
add    $0x140,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@__const.scsi_persistent_reserve_in_report_capabilities.cdb = <{ i8, [9 x i8] }> <{ i8 94, [9 x i8] zeroinitializer }>
@.str = [44 x i8] c"PERSISTENT RESERVE IN: REPORT CAPABILITIES\0A\00"
@SG_DXFER_FROM_DEV = global i32 0
@.str.1 = [16 x i8] c"SCSI_IO failed\0A\00"
@.str.2 = [11 x i8] c"Length:%d\0A\00"
@.str.3 = [36 x i8] c"CRH:%d SIP_C:%d ATP_C:%d PTPL_C:%d\0A\00"
@.str.4 = [41 x i8] c"TMV:%d ALLOW_COMMANDS:%c%c%cb PTPL_A:%d\0A\00"
@.str.5 = [41 x i8] c"Persistent Reservation Type Mask:0x%04x\0A\00"
@.str.6 = [67 x i8] c"WR_EX_AR:%d EX_AC_RO:%d WR_EX_RO:%d EX_AC:%d WR_EX:%d EX_AC_AR:%d\0A\00"
define i32 @scsi_persistent_reserve_in_report_capabilities(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca [10 x i8]
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i32
%9 = alloca i64
%10 = alloca i8
%11 = alloca i32
%12 = alloca i16
%13 = alloca i16
%14 = alloca i32
store i32 %0, i32* %3
%15 = bitcast [10 x i8]* %4 to i8*
store i32 255, i32* %5
%16 = load i32, i32* %5
%17 = zext i32 %16 to i64
%18 = call i8* @llvm.stacksave()
store i8* %18, i8** %6
%19 = alloca i8, i64 %17
store i64 %17, i64* %7
store i32 32, i32* %8
%20 = load i32, i32* %8
%21 = zext i32 %20 to i64
%22 = alloca i8, i64 %21
store i64 %21, i64* %9
store i8 2, i8* %10
%23 = load i8, i8* %10
%24 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 1
store i8 %23, i8* %24
%25 = load i32, i32* %5
%26 = lshr i32 %25, 8
%27 = and i32 %26, 255
%28 = trunc i32 %27 to i8
%29 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 7
store i8 %28, i8* %29
%30 = load i32, i32* %5
%31 = and i32 %30, 255
%32 = trunc i32 %31 to i8
%33 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 8
store i8 %32, i8* %33
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0))
%35 = load i32, i32* %3
%36 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 0
%37 = load i32, i32* @SG_DXFER_FROM_DEV
%38 = call i32 @scsi_io(i32 %35, i8* %36, i32 10, i32 %37, i8* %19, i32* %5, i8* %22, i32* %8)
store i32 %38, i32* %11
%39 = load i32, i32* %11
%40 = icmp ne i32 %39, 0
br i1 %40, label %41, label %43
41: ; preds = %1
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %2
store i32 1, i32* %14
br label %210
43: ; preds = %1
%44 = load i32, i32* %8
%45 = icmp ne i32 %44, 0
br i1 %45, label %46, label %49
46: ; preds = %43
%47 = load i32, i32* %8
%48 = call i32 @print_sense_data(i8* %22, i32 %47)
store i32 -1, i32* %2
store i32 1, i32* %14
br label %210
49: ; preds = %43
%50 = getelementptr inbounds i8, i8* %19, i64 0
%51 = load i8, i8* %50
%52 = zext i8 %51 to i16
store i16 %52, i16* %12
%53 = load i16, i16* %12
%54 = zext i16 %53 to i32
%55 = shl i32 %54, 8
%56 = trunc i32 %55 to i16
store i16 %56, i16* %12
%57 = getelementptr inbounds i8, i8* %19, i64 1
%58 = load i8, i8* %57
%59 = zext i8 %58 to i32
%60 = load i16, i16* %12
%61 = zext i16 %60 to i32
%62 = or i32 %61, %59
%63 = trunc i32 %62 to i16
store i16 %63, i16* %12
%64 = load i16, i16* %12
%65 = zext i16 %64 to i32
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %65)
%67 = getelementptr inbounds i8, i8* %19, i64 2
%68 = load i8, i8* %67
%69 = zext i8 %68 to i32
%70 = and i32 %69, 16
%71 = icmp ne i32 %70, 0
%72 = xor i1 %71, true
%73 = xor i1 %72, true
%74 = zext i1 %73 to i32
%75 = getelementptr inbounds i8, i8* %19, i64 2
%76 = load i8, i8* %75
%77 = zext i8 %76 to i32
%78 = and i32 %77, 8
%79 = icmp ne i32 %78, 0
%80 = xor i1 %79, true
%81 = xor i1 %80, true
%82 = zext i1 %81 to i32
%83 = getelementptr inbounds i8, i8* %19, i64 2
%84 = load i8, i8* %83
%85 = zext i8 %84 to i32
%86 = and i32 %85, 4
%87 = icmp ne i32 %86, 0
%88 = xor i1 %87, true
%89 = xor i1 %88, true
%90 = zext i1 %89 to i32
%91 = getelementptr inbounds i8, i8* %19, i64 2
%92 = load i8, i8* %91
%93 = zext i8 %92 to i32
%94 = and i32 %93, 1
%95 = icmp ne i32 %94, 0
%96 = xor i1 %95, true
%97 = xor i1 %96, true
%98 = zext i1 %97 to i32
%99 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0), i32 %74, i32 %82, i32 %90, i32 %98)
%100 = getelementptr inbounds i8, i8* %19, i64 3
%101 = load i8, i8* %100
%102 = zext i8 %101 to i32
%103 = and i32 %102, 128
%104 = icmp ne i32 %103, 0
%105 = xor i1 %104, true
%106 = xor i1 %105, true
%107 = zext i1 %106 to i32
%108 = getelementptr inbounds i8, i8* %19, i64 3
%109 = load i8, i8* %108
%110 = zext i8 %109 to i32
%111 = and i32 %110, 64
%112 = icmp ne i32 %111, 0
%113 = xor i1 %112, true
%114 = xor i1 %113, true
%115 = zext i1 %114 to i32
%116 = add nsw i32 48, %115
%117 = getelementptr inbounds i8, i8* %19, i64 3
%118 = load i8, i8* %117
%119 = zext i8 %118 to i32
%120 = and i32 %119, 32
%121 = icmp ne i32 %120, 0
%122 = xor i1 %121, true
%123 = xor i1 %122, true
%124 = zext i1 %123 to i32
%125 = add nsw i32 48, %124
%126 = getelementptr inbounds i8, i8* %19, i64 3
%127 = load i8, i8* %126
%128 = zext i8 %127 to i32
%129 = and i32 %128, 16
%130 = icmp ne i32 %129, 0
%131 = xor i1 %130, true
%132 = xor i1 %131, true
%133 = zext i1 %132 to i32
%134 = add nsw i32 48, %133
%135 = getelementptr inbounds i8, i8* %19, i64 3
%136 = load i8, i8* %135
%137 = zext i8 %136 to i32
%138 = and i32 %137, 1
%139 = icmp ne i32 %138, 0
%140 = xor i1 %139, true
%141 = xor i1 %140, true
%142 = zext i1 %141 to i32
%143 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.4, i64 0, i64 0), i32 %107, i32 %116, i32 %125, i32 %134, i32 %142)
%144 = getelementptr inbounds i8, i8* %19, i64 4
%145 = load i8, i8* %144
%146 = zext i8 %145 to i16
store i16 %146, i16* %13
%147 = load i16, i16* %13
%148 = zext i16 %147 to i32
%149 = shl i32 %148, 8
%150 = trunc i32 %149 to i16
store i16 %150, i16* %13
%151 = getelementptr inbounds i8, i8* %19, i64 5
%152 = load i8, i8* %151
%153 = zext i8 %152 to i32
%154 = load i16, i16* %13
%155 = zext i16 %154 to i32
%156 = or i32 %155, %153
%157 = trunc i32 %156 to i16
store i16 %157, i16* %13
%158 = load i16, i16* %13
%159 = zext i16 %158 to i32
%160 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.5, i64 0, i64 0), i32 %159)
%161 = getelementptr inbounds i8, i8* %19, i64 4
%162 = load i8, i8* %161
%163 = zext i8 %162 to i32
%164 = and i32 %163, 128
%165 = icmp ne i32 %164, 0
%166 = xor i1 %165, true
%167 = xor i1 %166, true
%168 = zext i1 %167 to i32
%169 = getelementptr inbounds i8, i8* %19, i64 4
%170 = load i8, i8* %169
%171 = zext i8 %170 to i32
%172 = and i32 %171, 64
%173 = icmp ne i32 %172, 0
%174 = xor i1 %173, true
%175 = xor i1 %174, true
%176 = zext i1 %175 to i32
%177 = getelementptr inbounds i8, i8* %19, i64 4
%178 = load i8, i8* %177
%179 = zext i8 %178 to i32
%180 = and i32 %179, 32
%181 = icmp ne i32 %180, 0
%182 = xor i1 %181, true
%183 = xor i1 %182, true
%184 = zext i1 %183 to i32
%185 = getelementptr inbounds i8, i8* %19, i64 4
%186 = load i8, i8* %185
%187 = zext i8 %186 to i32
%188 = and i32 %187, 8
%189 = icmp ne i32 %188, 0
%190 = xor i1 %189, true
%191 = xor i1 %190, true
%192 = zext i1 %191 to i32
%193 = getelementptr inbounds i8, i8* %19, i64 4
%194 = load i8, i8* %193
%195 = zext i8 %194 to i32
%196 = and i32 %195, 2
%197 = icmp ne i32 %196, 0
%198 = xor i1 %197, true
%199 = xor i1 %198, true
%200 = zext i1 %199 to i32
%201 = getelementptr inbounds i8, i8* %19, i64 4
%202 = load i8, i8* %201
%203 = zext i8 %202 to i32
%204 = and i32 %203, 1
%205 = icmp ne i32 %204, 0
%206 = xor i1 %205, true
%207 = xor i1 %206, true
%208 = zext i1 %207 to i32
%209 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str.6, i64 0, i64 0), i32 %168, i32 %176, i32 %184, i32 %192, i32 %200, i32 %208)
store i32 0, i32* %2
store i32 1, i32* %14
br label %210
210: ; preds = %49, %46, %41
%211 = load i8*, i8** %6
%212 = load i32, i32* %2
ret i32 %212
}

LLVM IR (-O2):
@__const.scsi_persistent_reserve_in_report_capabilities.cdb = <{ i8, [9 x i8] }> <{ i8 94, [9 x i8] zeroinitializer }>
@SG_DXFER_FROM_DEV = global i32 0
@.str.2 = [11 x i8] c"Length:%d\0A\00"
@.str.3 = [36 x i8] c"CRH:%d SIP_C:%d ATP_C:%d PTPL_C:%d\0A\00"
@.str.4 = [41 x i8] c"TMV:%d ALLOW_COMMANDS:%c%c%cb PTPL_A:%d\0A\00"
@.str.5 = [41 x i8] c"Persistent Reservation Type Mask:0x%04x\0A\00"
@.str.6 = [67 x i8] c"WR_EX_AR:%d EX_AC_RO:%d WR_EX_RO:%d EX_AC:%d WR_EX:%d EX_AC_AR:%d\0A\00"
@str = [43 x i8] c"PERSISTENT RESERVE IN: REPORT CAPABILITIES\00"
@str.7 = [15 x i8] c"SCSI_IO failed\00"
define i32 @scsi_persistent_reserve_in_report_capabilities(i32 %0) {
%2 = alloca [10 x i8]
%3 = alloca i32
%4 = alloca i32
%5 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%6 = bitcast i32* %3 to i8*
store i32 255, i32* %3
%7 = tail call i8* @llvm.stacksave()
%8 = alloca [255 x i8]
%9 = getelementptr inbounds [255 x i8], [255 x i8]* %8, i64 0, i64 0
%10 = bitcast i32* %4 to i8*
store i32 32, i32* %4
%11 = alloca [32 x i8]
%12 = getelementptr inbounds [32 x i8], [32 x i8]* %11, i64 0, i64 0
%13 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 1
store i8 2, i8* %13
%14 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 7
store i8 0, i8* %14
%15 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 8
store i8 -1, i8* %15
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @str, i64 0, i64 0))
%17 = load i32, i32* @SG_DXFER_FROM_DEV
%18 = call i32 @scsi_io(i32 %0, i8* %5, i32 10, i32 %17, i8* %9, i32* %3, i8* %12, i32* %4)
%19 = icmp eq i32 %18, 0
br i1 %19, label %22, label %20
20: ; preds = %1
%21 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.7, i64 0, i64 0))
br label %84
22: ; preds = %1
%23 = load i32, i32* %4
%24 = icmp eq i32 %23, 0
br i1 %24, label %27, label %25
25: ; preds = %22
%26 = call i32 @print_sense_data(i8* %12, i32 %23)
br label %84
27: ; preds = %22
%28 = load i8, i8* %9
%29 = zext i8 %28 to i32
%30 = shl nuw nsw i32 %29, 8
%31 = getelementptr inbounds [255 x i8], [255 x i8]* %8, i64 0, i64 1
%32 = load i8, i8* %31
%33 = zext i8 %32 to i32
%34 = or i32 %30, %33
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %34)
%36 = getelementptr inbounds [255 x i8], [255 x i8]* %8, i64 0, i64 2
%37 = load i8, i8* %36
%38 = zext i8 %37 to i32
%39 = lshr i32 %38, 4
%40 = and i32 %39, 1
%41 = lshr i32 %38, 3
%42 = and i32 %41, 1
%43 = lshr i32 %38, 2
%44 = and i32 %43, 1
%45 = and i32 %38, 1
%46 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0), i32 %40, i32 %42, i32 %44, i32 %45)
%47 = getelementptr inbounds [255 x i8], [255 x i8]* %8, i64 0, i64 3
%48 = load i8, i8* %47
%49 = zext i8 %48 to i32
%50 = lshr i32 %49, 7
%51 = lshr i32 %49, 6
%52 = and i32 %51, 1
%53 = or i32 %52, 48
%54 = lshr i32 %49, 5
%55 = and i32 %54, 1
%56 = or i32 %55, 48
%57 = lshr i32 %49, 4
%58 = and i32 %57, 1
%59 = or i32 %58, 48
%60 = and i32 %49, 1
%61 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.4, i64 0, i64 0), i32 %50, i32 %53, i32 %56, i32 %59, i32 %60)
%62 = getelementptr inbounds [255 x i8], [255 x i8]* %8, i64 0, i64 4
%63 = load i8, i8* %62
%64 = zext i8 %63 to i32
%65 = shl nuw nsw i32 %64, 8
%66 = getelementptr inbounds [255 x i8], [255 x i8]* %8, i64 0, i64 5
%67 = load i8, i8* %66
%68 = zext i8 %67 to i32
%69 = or i32 %65, %68
%70 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.5, i64 0, i64 0), i32 %69)
%71 = load i8, i8* %62
%72 = zext i8 %71 to i32
%73 = lshr i32 %72, 7
%74 = lshr i32 %72, 6
%75 = and i32 %74, 1
%76 = lshr i32 %72, 5
%77 = and i32 %76, 1
%78 = lshr i32 %72, 3
%79 = and i32 %78, 1
%80 = lshr i32 %72, 1
%81 = and i32 %80, 1
%82 = and i32 %72, 1
%83 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([67 x i8], [67 x i8]* @.str.6, i64 0, i64 0), i32 %73, i32 %75, i32 %77, i32 %79, i32 %81, i32 %82)
br label %84
84: ; preds = %27, %25, %20
%85 = phi i32 [ -1, %20 ], [ -1, %25 ], [ 0, %27 ]
ret i32 %85
}