#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*/ fprintf(int /*<<< orphan*/, char *, char *);
int sg_ll_mode_sense10(int, int /*<<< orphan*/, int, int /*<<< orphan*/, int,
                       int /*<<< orphan*/, void *, int, int, int);
int sg_ll_mode_sense6(int, int, int /*<<< orphan*/, int, int /*<<< orphan*/,
                      void *, int, int, int);
int /*<<< orphan*/ stderr;
int do_modes_0a(int sg_fd, void *resp, int mx_resp_len, int noisy, int mode6,
                int verbose) {
  int res;
  if (mode6)
    res = sg_ll_mode_sense6(sg_fd, 1, 0, 0xa, 0, resp, mx_resp_len, noisy,
                            verbose);
  else
    res = sg_ll_mode_sense10(sg_fd, 0, 1, 0, 0xa, 0, resp, mx_resp_len, noisy,
                             verbose);
  if (9 == res)
    fprintf(stderr, "Mode sense (%s) command not supported\n",
            (mode6 ? "6" : "10"));
  else if (5 == res)
    fprintf(stderr, "bad field in Mode sense (%s) command\n",
            (mode6 ? "6" : "10"));
  else if (2 == res)
    fprintf(stderr, "Mode sense (%s) failed, device not ready\n",
            (mode6 ? "6" : "10"));
  else if (6 == res)
    fprintf(stderr, "Mode sense (%s) failed, unit attention\n",
            (mode6 ? "6" : "10"));
  else if (11 == res)
    fprintf(stderr, "Mode sense (%s) failed, aborted command\n",
            (mode6 ? "6" : "10"));
  return res;
}


x86 assembly (clang, -O0):
<do_modes_0a>:
push   %rbp
mov    %rsp,%rbp
push   %rbx
sub    $0x48,%rsp
mov    %edi,-0xc(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %ecx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    %r9d,-0x28(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     1194 <do_modes_0a+0x64>
mov    -0xc(%rbp),%edi
mov    -0x18(%rbp),%r9
mov    -0x1c(%rbp),%r11d
mov    -0x20(%rbp),%r10d
mov    -0x28(%rbp),%eax
mov    $0x1,%esi
xor    %r8d,%r8d
mov    $0xa,%ecx
mov    %r8d,%edx
mov    %r11d,(%rsp)
mov    %r10d,0x8(%rsp)
mov    %eax,0x10(%rsp)
call   1050 <sg_ll_mode_sense6@plt>
mov    %eax,-0x2c(%rbp)
jmp    11d4 <do_modes_0a+0xa4>
mov    -0xc(%rbp),%edi
mov    -0x18(%rbp),%rbx
mov    -0x1c(%rbp),%r11d
mov    -0x20(%rbp),%r10d
mov    -0x28(%rbp),%eax
xor    %r9d,%r9d
mov    $0x1,%edx
mov    $0xa,%r8d
mov    %r9d,%esi
mov    %r9d,%ecx
mov    %rbx,(%rsp)
mov    %r11d,0x8(%rsp)
mov    %r10d,0x10(%rsp)
mov    %eax,0x18(%rsp)
call   1030 <sg_ll_mode_sense10@plt>
mov    %eax,-0x2c(%rbp)
mov    $0x9,%eax
cmp    -0x2c(%rbp),%eax
jne    1214 <do_modes_0a+0xe4>
mov    0x2df7(%rip),%rax
mov    (%rax),%edi
mov    -0x24(%rbp),%ecx
lea    0xe34(%rip),%rdx
lea    0xe2b(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rdx
lea    0xdf6(%rip),%rsi
call   1040 <fprintf@plt>
jmp    1323 <do_modes_0a+0x1f3>
mov    $0x5,%eax
cmp    -0x2c(%rbp),%eax
jne    1254 <do_modes_0a+0x124>
mov    0x2db7(%rip),%rax
mov    (%rax),%edi
mov    -0x24(%rbp),%ecx
lea    0xdf4(%rip),%rdx
lea    0xdeb(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rdx
lea    0xde2(%rip),%rsi
call   1040 <fprintf@plt>
jmp    131e <do_modes_0a+0x1ee>
mov    $0x2,%eax
cmp    -0x2c(%rbp),%eax
jne    1294 <do_modes_0a+0x164>
mov    0x2d77(%rip),%rax
mov    (%rax),%edi
mov    -0x24(%rbp),%ecx
lea    0xdb4(%rip),%rdx
lea    0xdab(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rdx
lea    0xdc8(%rip),%rsi
call   1040 <fprintf@plt>
jmp    1319 <do_modes_0a+0x1e9>
mov    $0x6,%eax
cmp    -0x2c(%rbp),%eax
jne    12d4 <do_modes_0a+0x1a4>
mov    0x2d37(%rip),%rax
mov    (%rax),%edi
mov    -0x24(%rbp),%ecx
lea    0xd74(%rip),%rdx
lea    0xd6b(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rdx
lea    0xdb2(%rip),%rsi
call   1040 <fprintf@plt>
jmp    1314 <do_modes_0a+0x1e4>
mov    $0xb,%eax
cmp    -0x2c(%rbp),%eax
jne    130f <do_modes_0a+0x1df>
mov    0x2cf7(%rip),%rax
mov    (%rax),%edi
mov    -0x24(%rbp),%ecx
lea    0xd34(%rip),%rdx
lea    0xd2b(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rdx
lea    0xd9a(%rip),%rsi
call   1040 <fprintf@plt>
jmp    1314 <do_modes_0a+0x1e4>
jmp    1319 <do_modes_0a+0x1e9>
jmp    131e <do_modes_0a+0x1ee>
jmp    1323 <do_modes_0a+0x1f3>
mov    -0x2c(%rbp),%eax
add    $0x48,%rsp
pop    %rbx
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_modes_0a>:
push   %rbp
push   %r14
push   %rbx
mov    %r9d,%eax
mov    %r8d,%r14d
mov    %ecx,%ebx
mov    %edx,%r10d
mov    %rsi,%rbp
test   %r8d,%r8d
je     1168 <do_modes_0a+0x38>
sub    $0x8,%rsp
mov    $0x1,%esi
xor    %edx,%edx
mov    $0xa,%ecx
xor    %r8d,%r8d
mov    %rbp,%r9
push   %rax
push   %rbx
push   %r10
call   1050 <sg_ll_mode_sense6@plt>
jmp    1184 <do_modes_0a+0x54>
xor    %esi,%esi
mov    $0x1,%edx
xor    %ecx,%ecx
mov    $0xa,%r8d
xor    %r9d,%r9d
push   %rax
push   %rbx
push   %r10
push   %rbp
call   1030 <sg_ll_mode_sense10@plt>
add    $0x20,%rsp
mov    %eax,%ebx
lea    -0x2(%rbx),%eax
cmp    $0x9,%eax
ja     11cf <do_modes_0a+0x9f>
mov    $0x299,%ecx
bt     %eax,%ecx
jae    11cf <do_modes_0a+0x9f>
cltq
lea    0xf2b(%rip),%rcx
movslq (%rcx,%rax,4),%rsi
add    %rcx,%rsi
test   %r14d,%r14d
mov    0x2e2a(%rip),%rax
mov    (%rax),%edi
lea    0xe6a(%rip),%rax
lea    0xe61(%rip),%rdx
cmove  %rax,%rdx
call   1040 <fprintf@plt>
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [39 x i8] c"Mode sense (%s) command not supported\0A\00"
@.str.1 = [2 x i8] c"6\00"
@.str.2 = [3 x i8] c"10\00"
@.str.3 = [38 x i8] c"bad field in Mode sense (%s) command\0A\00"
@.str.4 = [42 x i8] c"Mode sense (%s) failed, device not ready\0A\00"
@.str.5 = [40 x i8] c"Mode sense (%s) failed, unit attention\0A\00"
@.str.6 = [41 x i8] c"Mode sense (%s) failed, aborted command\0A\00"
define i32 @do_modes_0a(i32 %0, i8* %1, i32 %2, i32 %3, i32 %4, i32 %5) {
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
store i32 %0, i32* %7
store i8* %1, i8** %8
store i32 %2, i32* %9
store i32 %3, i32* %10
store i32 %4, i32* %11
store i32 %5, i32* %12
%14 = load i32, i32* %11
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %23
16: ; preds = %6
%17 = load i32, i32* %7
%18 = load i8*, i8** %8
%19 = load i32, i32* %9
%20 = load i32, i32* %10
%21 = load i32, i32* %12
%22 = call i32 @sg_ll_mode_sense6(i32 %17, i32 1, i32 0, i32 10, i32 0, i8* %18, i32 %19, i32 %20, i32 %21)
store i32 %22, i32* %13
br label %30
23: ; preds = %6
%24 = load i32, i32* %7
%25 = load i8*, i8** %8
%26 = load i32, i32* %9
%27 = load i32, i32* %10
%28 = load i32, i32* %12
%29 = call i32 @sg_ll_mode_sense10(i32 %24, i32 0, i32 1, i32 0, i32 10, i32 0, i8* %25, i32 %26, i32 %27, i32 %28)
store i32 %29, i32* %13
br label %30
30: ; preds = %23, %16
%31 = load i32, i32* %13
%32 = icmp eq i32 9, %31
br i1 %32, label %33, label %40
33: ; preds = %30
%34 = load i32, i32* @stderr
%35 = load i32, i32* %11
%36 = icmp ne i32 %35, 0
%37 = zext i1 %36 to i64
%38 = select i1 %36, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0)
%39 = call i32 @fprintf(i32 %34, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i8* %38)
br label %84
40: ; preds = %30
%41 = load i32, i32* %13
%42 = icmp eq i32 5, %41
br i1 %42, label %43, label %50
43: ; preds = %40
%44 = load i32, i32* @stderr
%45 = load i32, i32* %11
%46 = icmp ne i32 %45, 0
%47 = zext i1 %46 to i64
%48 = select i1 %46, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0)
%49 = call i32 @fprintf(i32 %44, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0), i8* %48)
br label %83
50: ; preds = %40
%51 = load i32, i32* %13
%52 = icmp eq i32 2, %51
br i1 %52, label %53, label %60
53: ; preds = %50
%54 = load i32, i32* @stderr
%55 = load i32, i32* %11
%56 = icmp ne i32 %55, 0
%57 = zext i1 %56 to i64
%58 = select i1 %56, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0)
%59 = call i32 @fprintf(i32 %54, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.4, i64 0, i64 0), i8* %58)
br label %82
60: ; preds = %50
%61 = load i32, i32* %13
%62 = icmp eq i32 6, %61
br i1 %62, label %63, label %70
63: ; preds = %60
%64 = load i32, i32* @stderr
%65 = load i32, i32* %11
%66 = icmp ne i32 %65, 0
%67 = zext i1 %66 to i64
%68 = select i1 %66, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0)
%69 = call i32 @fprintf(i32 %64, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.5, i64 0, i64 0), i8* %68)
br label %81
70: ; preds = %60
%71 = load i32, i32* %13
%72 = icmp eq i32 11, %71
br i1 %72, label %73, label %80
73: ; preds = %70
%74 = load i32, i32* @stderr
%75 = load i32, i32* %11
%76 = icmp ne i32 %75, 0
%77 = zext i1 %76 to i64
%78 = select i1 %76, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0)
%79 = call i32 @fprintf(i32 %74, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.6, i64 0, i64 0), i8* %78)
br label %80
80: ; preds = %73, %70
br label %81
81: ; preds = %80, %63
br label %82
82: ; preds = %81, %53
br label %83
83: ; preds = %82, %43
br label %84
84: ; preds = %83, %33
%85 = load i32, i32* %13
ret i32 %85
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [39 x i8] c"Mode sense (%s) command not supported\0A\00"
@.str.1 = [2 x i8] c"6\00"
@.str.2 = [3 x i8] c"10\00"
@.str.3 = [38 x i8] c"bad field in Mode sense (%s) command\0A\00"
@.str.4 = [42 x i8] c"Mode sense (%s) failed, device not ready\0A\00"
@.str.5 = [40 x i8] c"Mode sense (%s) failed, unit attention\0A\00"
@.str.6 = [41 x i8] c"Mode sense (%s) failed, aborted command\0A\00"
@reltable.do_modes_0a = [10 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([42 x i8]* @.str.4 to i64), i64 ptrtoint ([10 x i32]* @reltable.do_modes_0a to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([39 x i8]* @.str to i64), i64 ptrtoint ([10 x i32]* @reltable.do_modes_0a to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([39 x i8]* @.str to i64), i64 ptrtoint ([10 x i32]* @reltable.do_modes_0a to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([38 x i8]* @.str.3 to i64), i64 ptrtoint ([10 x i32]* @reltable.do_modes_0a to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([40 x i8]* @.str.5 to i64), i64 ptrtoint ([10 x i32]* @reltable.do_modes_0a to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([39 x i8]* @.str to i64), i64 ptrtoint ([10 x i32]* @reltable.do_modes_0a to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([39 x i8]* @.str to i64), i64 ptrtoint ([10 x i32]* @reltable.do_modes_0a to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([39 x i8]* @.str to i64), i64 ptrtoint ([10 x i32]* @reltable.do_modes_0a to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([39 x i8]* @.str to i64), i64 ptrtoint ([10 x i32]* @reltable.do_modes_0a to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([41 x i8]* @.str.6 to i64), i64 ptrtoint ([10 x i32]* @reltable.do_modes_0a to i64)) to i32)]
define i32 @do_modes_0a(i32 %0, i8* %1, i32 %2, i32 %3, i32 %4, i32 %5) {
%7 = icmp eq i32 %4, 0
br i1 %7, label %10, label %8
8: ; preds = %6
%9 = tail call i32 @sg_ll_mode_sense6(i32 %0, i32 1, i32 0, i32 10, i32 0, i8* %1, i32 %2, i32 %3, i32 %5)
br label %12
10: ; preds = %6
%11 = tail call i32 @sg_ll_mode_sense10(i32 %0, i32 0, i32 1, i32 0, i32 10, i32 0, i8* %1, i32 %2, i32 %3, i32 %5)
br label %12
12: ; preds = %10, %8
%13 = phi i32 [ %9, %8 ], [ %11, %10 ]
%14 = add i32 %13, -2
%15 = icmp ult i32 %14, 10
br i1 %15, label %16, label %28
16: ; preds = %12
%17 = trunc i32 %14 to i16
%18 = lshr i16 665, %17
%19 = and i16 %18, 1
%20 = icmp eq i16 %19, 0
br i1 %20, label %28, label %21
21: ; preds = %16
%22 = sext i32 %14 to i64
%23 = shl i64 %22, 2
%24 = call i8* @llvm.load.relative.i64(i8* bitcast ([10 x i32]* @reltable.do_modes_0a to i8*), i64 %23)
%25 = load i32, i32* @stderr
%26 = select i1 %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0)
%27 = tail call i32 @fprintf(i32 %25, i8* %24, i8* %26)
br label %28
28: ; preds = %16, %12, %21
ret i32 %13
}