#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 scsi_request(char *, unsigned char *, int *, int, int /*<<< orphan*/, int,
                 int, int /*<<< orphan*/, int, int /*<<< orphan*/,
                 int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/,
                 unsigned char, unsigned char, int /*<<< orphan*/);
int mode_sense10(unsigned char *buf, int *buflen) {
  int len = *buflen;
  if (len > 65000)
    len = 65000;
  return scsi_request("mode_sense(10)", buf, buflen, 10, 0, 0x01, 0x5A, 0, 0x01,
                      0, 0, 0, 0, ((unsigned char)(((len)) >> 8)),
                      ((unsigned char)(len)), 0);
}


x86 assembly (clang, -O0):
<mode_sense10>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
cmpl   $0xfde8,-0x14(%rbp)
jle    113d <mode_sense10+0x2d>
movl   $0xfde8,-0x14(%rbp)
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
mov    -0x14(%rbp),%eax
sar    $0x8,%eax
mov    %al,%r10b
mov    -0x14(%rbp),%eax
lea    0xea8(%rip),%rdi
mov    $0xa,%ecx
xor    %r8d,%r8d
mov    $0x1,%r9d
movl   $0x5a,(%rsp)
movl   $0x0,0x8(%rsp)
movl   $0x1,0x10(%rsp)
movl   $0x0,0x18(%rsp)
movl   $0x0,0x20(%rsp)
movl   $0x0,0x28(%rsp)
movl   $0x0,0x30(%rsp)
movzbl %r10b,%r10d
mov    %r10d,0x38(%rsp)
movzbl %al,%eax
mov    %eax,0x40(%rsp)
movl   $0x0,0x48(%rsp)
call   1030 <scsi_request@plt>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mode_sense10>:
push   %rax
mov    %rsi,%rdx
mov    %rdi,%rsi
mov    (%rdx),%eax
cmp    $0xfde8,%eax
mov    $0xfde8,%ecx
cmovl  %eax,%ecx
movzbl %cl,%r10d
movzbl %ch,%eax
lea    0xecc(%rip),%rdi
mov    $0xa,%ecx
xor    %r8d,%r8d
mov    $0x1,%r9d
push   $0x0
push   %r10
push   %rax
push   $0x0
push   $0x0
push   $0x0
push   $0x0
push   $0x1
push   $0x0
push   $0x5a
call   1030 <scsi_request@plt>
add    $0x50,%rsp
pop    %rcx
ret

LLVM IR (-O0):
@.str = [15 x i8] c"mode_sense(10)\00"
define i32 @mode_sense10(i8* %0, i32* %1) {
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca i32
store i8* %0, i8** %3
store i32* %1, i32** %4
%6 = load i32*, i32** %4
%7 = load i32, i32* %6
store i32 %7, i32* %5
%8 = load i32, i32* %5
%9 = icmp sgt i32 %8, 65000
br i1 %9, label %10, label %11
10: ; preds = %2
store i32 65000, i32* %5
br label %11
11: ; preds = %10, %2
%12 = load i8*, i8** %3
%13 = load i32*, i32** %4
%14 = load i32, i32* %5
%15 = ashr i32 %14, 8
%16 = trunc i32 %15 to i8
%17 = load i32, i32* %5
%18 = trunc i32 %17 to i8
%19 = call i32 @scsi_request(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %12, i32* %13, i32 10, i32 0, i32 1, i32 90, i32 0, i32 1, i32 0, i32 0, i32 0, i32 0, i8 zeroext %16, i8 zeroext %18, i32 0)
ret i32 %19
}

LLVM IR (-O2):
@.str = [15 x i8] c"mode_sense(10)\00"
define i32 @mode_sense10(i8* %0, i32* %1) {
%3 = load i32, i32* %1
%4 = icmp slt i32 %3, 65000
%5 = select i1 %4, i32 %3, i32 65000
%6 = lshr i32 %5, 8
%7 = trunc i32 %6 to i8
%8 = trunc i32 %5 to i8
%9 = tail call i32 @scsi_request(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %0, i32* %1, i32 10, i32 0, i32 1, i32 90, i32 0, i32 1, i32 0, i32 0, i32 0, i32 0, i8 zeroext %7, i8 zeroext %8, i32 0)
ret i32 %9
}