#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;
typedef int uint32_t;
typedef int /*<<< orphan*/ command;

/* Variables and functions */
int /*<<< orphan*/ SG_DXFER_FROM_DEV;
int scsi_command(int, int /*<<< orphan*/, int const *, int, int *, int, int *,
                 int /*<<< orphan*/);
int kvss905c_read(int fd, uint8_t type, uint8_t q1, uint8_t q2, uint8_t *buffer,
                  uint32_t length, uint8_t *requestsense) {
  const uint8_t command[] = {0x28,         0,           type,   0, q1, q2,
                             length >> 16, length >> 8, length, 0};
  return scsi_command(fd, SG_DXFER_FROM_DEV, command, sizeof(command), buffer,
                      length, requestsense, 0);
}


x86 assembly (clang, -O0):
<kvss905c_read>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    0x10(%rbp),%rax
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    %r8,-0x18(%rbp)
mov    %r9d,-0x1c(%rbp)
movl   $0x28,-0x50(%rbp)
movl   $0x0,-0x4c(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x48(%rbp)
movl   $0x0,-0x44(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x40(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x1c(%rbp),%eax
sar    $0x10,%eax
mov    %eax,-0x38(%rbp)
mov    -0x1c(%rbp),%eax
sar    $0x8,%eax
mov    %eax,-0x34(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x30(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2e68(%rip),%rax
mov    (%rax),%esi
lea    -0x50(%rbp),%rdx
mov    -0x18(%rbp),%r8
mov    -0x1c(%rbp),%r9d
mov    0x10(%rbp),%rax
mov    $0x28,%ecx
xor    %r10d,%r10d
mov    %rax,(%rsp)
movl   $0x0,0x8(%rsp)
call   1030 <scsi_command@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<kvss905c_read>:
sub    $0x28,%rsp
mov    0x30(%rsp),%rax
movq   $0x28,(%rsp)
mov    %esi,0x8(%rsp)
movl   $0x0,0xc(%rsp)
mov    %edx,0x10(%rsp)
mov    %ecx,0x14(%rsp)
mov    %r9d,%ecx
sar    $0x10,%ecx
mov    %ecx,0x18(%rsp)
mov    %r9d,%ecx
sar    $0x8,%ecx
mov    %ecx,0x1c(%rsp)
mov    %r9d,0x20(%rsp)
movl   $0x0,0x24(%rsp)
mov    0x2e8b(%rip),%rcx
mov    (%rcx),%esi
mov    %rsp,%rdx
mov    $0x28,%ecx
push   $0x0
push   %rax
call   1030 <scsi_command@plt>
add    $0x38,%rsp
ret

LLVM IR (-O0):
@SG_DXFER_FROM_DEV = global i32 0
define i32 @kvss905c_read(i32 %0, i32 %1, i32 %2, i32 %3, i32* %4, i32 %5, i32* %6) {
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32*
%13 = alloca i32
%14 = alloca i32*
%15 = alloca [10 x i32]
store i32 %0, i32* %8
store i32 %1, i32* %9
store i32 %2, i32* %10
store i32 %3, i32* %11
store i32* %4, i32** %12
store i32 %5, i32* %13
store i32* %6, i32** %14
%16 = getelementptr inbounds [10 x i32], [10 x i32]* %15, i64 0, i64 0
store i32 40, i32* %16
%17 = getelementptr inbounds i32, i32* %16, i64 1
store i32 0, i32* %17
%18 = getelementptr inbounds i32, i32* %17, i64 1
%19 = load i32, i32* %9
store i32 %19, i32* %18
%20 = getelementptr inbounds i32, i32* %18, i64 1
store i32 0, i32* %20
%21 = getelementptr inbounds i32, i32* %20, i64 1
%22 = load i32, i32* %10
store i32 %22, i32* %21
%23 = getelementptr inbounds i32, i32* %21, i64 1
%24 = load i32, i32* %11
store i32 %24, i32* %23
%25 = getelementptr inbounds i32, i32* %23, i64 1
%26 = load i32, i32* %13
%27 = ashr i32 %26, 16
store i32 %27, i32* %25
%28 = getelementptr inbounds i32, i32* %25, i64 1
%29 = load i32, i32* %13
%30 = ashr i32 %29, 8
store i32 %30, i32* %28
%31 = getelementptr inbounds i32, i32* %28, i64 1
%32 = load i32, i32* %13
store i32 %32, i32* %31
%33 = getelementptr inbounds i32, i32* %31, i64 1
store i32 0, i32* %33
%34 = load i32, i32* %8
%35 = load i32, i32* @SG_DXFER_FROM_DEV
%36 = getelementptr inbounds [10 x i32], [10 x i32]* %15, i64 0, i64 0
%37 = load i32*, i32** %12
%38 = load i32, i32* %13
%39 = load i32*, i32** %14
%40 = call i32 @scsi_command(i32 %34, i32 %35, i32* %36, i32 40, i32* %37, i32 %38, i32* %39, i32 0)
ret i32 %40
}

LLVM IR (-O2):
@SG_DXFER_FROM_DEV = global i32 0
define i32 @kvss905c_read(i32 %0, i32 %1, i32 %2, i32 %3, i32* %4, i32 %5, i32* %6) {
%8 = alloca [10 x i32]
%9 = bitcast [10 x i32]* %8 to i8*
%10 = getelementptr inbounds [10 x i32], [10 x i32]* %8, i64 0, i64 0
store i32 40, i32* %10
%11 = getelementptr inbounds [10 x i32], [10 x i32]* %8, i64 0, i64 1
store i32 0, i32* %11
%12 = getelementptr inbounds [10 x i32], [10 x i32]* %8, i64 0, i64 2
store i32 %1, i32* %12
%13 = getelementptr inbounds [10 x i32], [10 x i32]* %8, i64 0, i64 3
store i32 0, i32* %13
%14 = getelementptr inbounds [10 x i32], [10 x i32]* %8, i64 0, i64 4
store i32 %2, i32* %14
%15 = getelementptr inbounds [10 x i32], [10 x i32]* %8, i64 0, i64 5
store i32 %3, i32* %15
%16 = getelementptr inbounds [10 x i32], [10 x i32]* %8, i64 0, i64 6
%17 = ashr i32 %5, 16
store i32 %17, i32* %16
%18 = getelementptr inbounds [10 x i32], [10 x i32]* %8, i64 0, i64 7
%19 = ashr i32 %5, 8
store i32 %19, i32* %18
%20 = getelementptr inbounds [10 x i32], [10 x i32]* %8, i64 0, i64 8
store i32 %5, i32* %20
%21 = getelementptr inbounds [10 x i32], [10 x i32]* %8, i64 0, i64 9
store i32 0, i32* %21
%22 = load i32, i32* @SG_DXFER_FROM_DEV
%23 = call i32 @scsi_command(i32 %0, i32 %22, i32* %10, i32 40, i32* %4, i32 %5, i32* %6, i32 0)
ret i32 %23
}