#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 scalar_t__ uint64_t;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int sg_ll_read_long10(int, int, int, unsigned int, void *, int, int *, int,
                      int);
int sg_ll_read_long16(int, int, int, scalar_t__, void *, int, int *, int, int);
int /*<<< orphan*/ stderr;
int process_read_long(int sg_fd, int do_16, int pblock, int correct,
                      uint64_t llba, void *data_out, int xfer_len,
                      int verbose) {
  int offset, res;
  const char *ten_or;
  if (do_16)
    res = sg_ll_read_long16(sg_fd, pblock, correct, llba, data_out, xfer_len,
                            &offset, 1, verbose);
  else
    res = sg_ll_read_long10(sg_fd, pblock, correct, (unsigned int)llba,
                            data_out, xfer_len, &offset, 1, verbose);
  ten_or = do_16 ? "16" : "10";
  switch (res) {
  case 0:
    break;
  case 2:
    fprintf(stderr, "  SCSI READ LONG (%s) failed, device not ready\n", ten_or);
    break;
  case 6:
    fprintf(stderr, "  SCSI READ LONG (%s) failed, unit attention\n", ten_or);
    break;
  case 11:
    fprintf(stderr, "  SCSI READ LONG (%s) failed, aborted command\n", ten_or);
    break;
  case 9:
    fprintf(stderr, "  SCSI READ LONG (%s) command not supported\n", ten_or);
    break;
  case 5:
    fprintf(stderr, "  SCSI READ LONG (%s) command, bad field in cdb\n",
            ten_or);
    break;
  case 17:
    fprintf(stderr,
            "<<< device indicates 'xfer_len' should be %d "
            ">>>\n",
            xfer_len - offset);
    break;
  default:
    fprintf(stderr, "  SCSI READ LONG (%s) command error\n", ten_or);
    break;
  }
  return res;
}


x86 assembly (clang, -O0):
<process_read_long>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    0x18(%rbp),%eax
mov    0x10(%rbp),%eax
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    %r8,-0x18(%rbp)
mov    %r9,-0x20(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     1195 <process_read_long+0x65>
mov    -0x4(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x18(%rbp),%rcx
mov    -0x20(%rbp),%r8
mov    0x10(%rbp),%r9d
mov    0x18(%rbp),%eax
lea    -0x24(%rbp),%r10
mov    %r10,(%rsp)
movl   $0x1,0x8(%rsp)
mov    %eax,0x10(%rsp)
call   1050 <sg_ll_read_long16@plt>
mov    %eax,-0x28(%rbp)
jmp    11cb <process_read_long+0x9b>
mov    -0x4(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x18(%rbp),%rax
mov    %eax,%ecx
mov    -0x20(%rbp),%r8
mov    0x10(%rbp),%r9d
mov    0x18(%rbp),%eax
lea    -0x24(%rbp),%r10
mov    %r10,(%rsp)
movl   $0x1,0x8(%rsp)
mov    %eax,0x10(%rsp)
call   1040 <sg_ll_read_long10@plt>
mov    %eax,-0x28(%rbp)
mov    -0x8(%rbp),%eax
test   %eax,%eax
lea    0xe71(%rip),%rcx
lea    0xe6d(%rip),%rax
cmovne %rcx,%rax
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%eax
mov    %rax,-0x38(%rbp)
sub    $0x11,%rax
ja     12d2 <process_read_long+0x1a2>
mov    -0x38(%rbp),%rax
lea    0xdfe(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
jmp    12ed <process_read_long+0x1bd>
mov    0x2dc9(%rip),%rax
mov    (%rax),%edi
mov    -0x30(%rbp),%rdx
lea    0xe2a(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    12ed <process_read_long+0x1bd>
mov    0x2da9(%rip),%rax
mov    (%rax),%edi
mov    -0x30(%rbp),%rdx
lea    0xe3a(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    12ed <process_read_long+0x1bd>
mov    0x2d89(%rip),%rax
mov    (%rax),%edi
mov    -0x30(%rbp),%rdx
lea    0xe48(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    12ed <process_read_long+0x1bd>
mov    0x2d69(%rip),%rax
mov    (%rax),%edi
mov    -0x30(%rbp),%rdx
lea    0xe57(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    12ed <process_read_long+0x1bd>
mov    0x2d49(%rip),%rax
mov    (%rax),%edi
mov    -0x30(%rbp),%rdx
lea    0xe64(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    12ed <process_read_long+0x1bd>
mov    0x2d29(%rip),%rax
mov    (%rax),%edi
mov    0x10(%rbp),%edx
sub    -0x24(%rbp),%edx
lea    0xe73(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    12ed <process_read_long+0x1bd>
mov    0x2d07(%rip),%rax
mov    (%rax),%edi
mov    -0x30(%rbp),%rdx
lea    0xe85(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x28(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<process_read_long>:
push   %rbp
push   %rbx
push   %rax
mov    0x28(%rsp),%eax
mov    0x20(%rsp),%ebp
sub    $0x8,%rsp
test   %esi,%esi
je     1172 <process_read_long+0x42>
lea    0xc(%rsp),%rbx
mov    %edx,%esi
mov    %ecx,%edx
mov    %r8,%rcx
mov    %r9,%r8
mov    %ebp,%r9d
push   %rax
push   $0x1
push   %rbx
call   1050 <sg_ll_read_long16@plt>
add    $0x20,%rsp
mov    %eax,%ebx
lea    0xedd(%rip),%rdx
cmp    $0x11,%ebx
jbe    119f <process_read_long+0x6f>
jmp    11c3 <process_read_long+0x93>
lea    0xc(%rsp),%rbx
mov    %edx,%esi
mov    %ecx,%edx
mov    %r8d,%ecx
mov    %r9,%r8
mov    %ebp,%r9d
push   %rax
push   $0x1
push   %rbx
call   1040 <sg_ll_read_long10@plt>
add    $0x20,%rsp
mov    %eax,%ebx
lea    0xeb1(%rip),%rdx
cmp    $0x11,%ebx
ja     11c3 <process_read_long+0x93>
mov    %ebx,%eax
lea    0xe58(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    0x2e28(%rip),%rax
mov    (%rax),%edi
lea    0xe8d(%rip),%rsi
jmp    123a <process_read_long+0x10a>
mov    0x2e16(%rip),%rax
mov    (%rax),%edi
lea    0xf98(%rip),%rsi
jmp    123a <process_read_long+0x10a>
mov    0x2e04(%rip),%rax
mov    (%rax),%edi
lea    0xf23(%rip),%rsi
jmp    123a <process_read_long+0x10a>
mov    0x2df2(%rip),%rax
mov    (%rax),%edi
lea    0xe87(%rip),%rsi
jmp    123a <process_read_long+0x10a>
mov    0x2de0(%rip),%rax
mov    (%rax),%edi
lea    0xea3(%rip),%rsi
jmp    123a <process_read_long+0x10a>
mov    0x2dce(%rip),%rax
mov    (%rax),%edi
sub    0x4(%rsp),%ebp
lea    0xf1a(%rip),%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   1030 <fprintf@plt>
jmp    1241 <process_read_long+0x111>
mov    0x2daf(%rip),%rax
mov    (%rax),%edi
lea    0xea1(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"16\00"
@.str.1 = [3 x i8] c"10\00"
@stderr = global i32 0
@.str.2 = [48 x i8] c" SCSI READ LONG (%s) failed, device not ready\0A\00"
@.str.3 = [46 x i8] c" SCSI READ LONG (%s) failed, unit attention\0A\00"
@.str.4 = [47 x i8] c" SCSI READ LONG (%s) failed, aborted command\0A\00"
@.str.5 = [45 x i8] c" SCSI READ LONG (%s) command not supported\0A\00"
@.str.6 = [49 x i8] c" SCSI READ LONG (%s) command, bad field in cdb\0A\00"
@.str.7 = [50 x i8] c"<<< device indicates 'xfer_len' should be %d >>>\0A\00"
@.str.8 = [37 x i8] c" SCSI READ LONG (%s) command error\0A\00"
define i32 @process_read_long(i32 %0, i32 %1, i32 %2, i32 %3, i64 %4, i8* %5, i32 %6, i32 %7) {
%9 = alloca i32
%10 = bitcast i32* %9 to i8*
%11 = icmp eq i32 %1, 0
br i1 %11, label %14, label %12
12: ; preds = %8
%13 = call i32 @sg_ll_read_long16(i32 %0, i32 %2, i32 %3, i64 %4, i8* %5, i32 %6, i32* %9, i32 1, i32 %7)
br label %17
14: ; preds = %8
%15 = trunc i64 %4 to i32
%16 = call i32 @sg_ll_read_long10(i32 %0, i32 %2, i32 %3, i32 %15, i8* %5, i32 %6, i32* %9, i32 1, i32 %7)
br label %17
17: ; preds = %14, %12
%18 = phi i8* [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), %14 ], [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), %12 ]
%19 = phi i32 [ %16, %14 ], [ %13, %12 ]
switch i32 %19, label %40 [
i32 0, label %43
i32 2, label %20
i32 6, label %23
i32 11, label %26
i32 9, label %29
i32 5, label %32
i32 17, label %35
]
20: ; preds = %17
%21 = load i32, i32* @stderr
%22 = call i32 (i32, i8*, ...) @fprintf(i32 %21, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0), i8* %18)
br label %43
23: ; preds = %17
%24 = load i32, i32* @stderr
%25 = call i32 (i32, i8*, ...) @fprintf(i32 %24, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.3, i64 0, i64 0), i8* %18)
br label %43
26: ; preds = %17
%27 = load i32, i32* @stderr
%28 = call i32 (i32, i8*, ...) @fprintf(i32 %27, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.4, i64 0, i64 0), i8* %18)
br label %43
29: ; preds = %17
%30 = load i32, i32* @stderr
%31 = call i32 (i32, i8*, ...) @fprintf(i32 %30, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.5, i64 0, i64 0), i8* %18)
br label %43
32: ; preds = %17
%33 = load i32, i32* @stderr
%34 = call i32 (i32, i8*, ...) @fprintf(i32 %33, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.6, i64 0, i64 0), i8* %18)
br label %43
35: ; preds = %17
%36 = load i32, i32* @stderr
%37 = load i32, i32* %9
%38 = sub nsw i32 %6, %37
%39 = call i32 (i32, i8*, ...) @fprintf(i32 %36, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.7, i64 0, i64 0), i32 %38)
br label %43
40: ; preds = %17
%41 = load i32, i32* @stderr
%42 = call i32 (i32, i8*, ...) @fprintf(i32 %41, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.8, i64 0, i64 0), i8* %18)
br label %43
43: ; preds = %40, %35, %32, %29, %26, %23, %20, %17
ret i32 %19
}