#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 */
struct trace_seq {
  int dummy;
};

/* Variables and functions */
char const *scsi_trace_misc(struct trace_seq *, unsigned char *, int);
char const *scsi_trace_rw32(struct trace_seq *, unsigned char *, int);
const char *scsi_trace_varlen(struct trace_seq *p, unsigned char *cdb,
                              int len) {
  switch (((cdb[8] << 8) | cdb[9])) {
  case 0x09:
  case 0x0a:
  case 0x0b:
  case 0x0d:
    return scsi_trace_rw32(p, cdb, len);
  default:
    return scsi_trace_misc(p, cdb, len);
  }
}


x86 assembly (clang, -O0):
<scsi_trace_varlen>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
movzwl 0x8(%rax),%eax
shl    $0x10,%eax
bswap  %eax
mov    %eax,-0x20(%rbp)
add    $0xfffffff7,%eax
sub    $0x3,%eax
jb     1165 <scsi_trace_varlen+0x45>
jmp    1154 <scsi_trace_varlen+0x34>
mov    -0x20(%rbp),%eax
sub    $0xd,%eax
jne    117e <scsi_trace_varlen+0x5e>
jmp    1165 <scsi_trace_varlen+0x45>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1030 <scsi_trace_rw32@plt>
mov    %rax,-0x8(%rbp)
jmp    1192 <scsi_trace_varlen+0x72>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1040 <scsi_trace_misc@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<scsi_trace_varlen>:
movzwl 0x8(%rsi),%eax
rol    $0x8,%ax
cmp    $0xd,%ax
ja     113d <scsi_trace_varlen+0x1d>
mov    $0x2e00,%ecx
bt     %eax,%ecx
jae    113d <scsi_trace_varlen+0x1d>
jmp    1030 <scsi_trace_rw32@plt>
jmp    1040 <scsi_trace_misc@plt>

LLVM IR (-O0):
%struct.trace_seq = type { i32 }
define i8* @scsi_trace_varlen(%struct.trace_seq* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca %struct.trace_seq*
%6 = alloca i8*
%7 = alloca i32
store %struct.trace_seq* %0, %struct.trace_seq** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
%8 = load i8*, i8** %6
%9 = getelementptr inbounds i8, i8* %8, i64 8
%10 = load i8, i8* %9
%11 = zext i8 %10 to i32
%12 = shl i32 %11, 8
%13 = load i8*, i8** %6
%14 = getelementptr inbounds i8, i8* %13, i64 9
%15 = load i8, i8* %14
%16 = zext i8 %15 to i32
%17 = or i32 %12, %16
switch i32 %17, label %23 [
i32 9, label %18
i32 10, label %18
i32 11, label %18
i32 13, label %18
]
18: ; preds = %3, %3, %3, %3
%19 = load %struct.trace_seq*, %struct.trace_seq** %5
%20 = load i8*, i8** %6
%21 = load i32, i32* %7
%22 = call i8* @scsi_trace_rw32(%struct.trace_seq* %19, i8* %20, i32 %21)
store i8* %22, i8** %4
br label %28
23: ; preds = %3
%24 = load %struct.trace_seq*, %struct.trace_seq** %5
%25 = load i8*, i8** %6
%26 = load i32, i32* %7
%27 = call i8* @scsi_trace_misc(%struct.trace_seq* %24, i8* %25, i32 %26)
store i8* %27, i8** %4
br label %28
28: ; preds = %23, %18
%29 = load i8*, i8** %4
ret i8* %29
}

LLVM IR (-O2):
%struct.trace_seq = type { i32 }
define i8* @scsi_trace_varlen(%struct.trace_seq* %0, i8* %1, i32 %2) {
%4 = getelementptr inbounds i8, i8* %1, i64 8
%5 = load i8, i8* %4
%6 = zext i8 %5 to i16
%7 = shl nuw i16 %6, 8
%8 = getelementptr inbounds i8, i8* %1, i64 9
%9 = load i8, i8* %8
%10 = zext i8 %9 to i16
%11 = or i16 %7, %10
switch i16 %11, label %14 [
i16 9, label %12
i16 10, label %12
i16 11, label %12
i16 13, label %12
]
12: ; preds = %3, %3, %3, %3
%13 = tail call i8* @scsi_trace_rw32(%struct.trace_seq* %0, i8* %1, i32 %2)
br label %16
14: ; preds = %3
%15 = tail call i8* @scsi_trace_misc(%struct.trace_seq* %0, i8* %1, i32 %2)
br label %16
16: ; preds = %14, %12
%17 = phi i8* [ %15, %14 ], [ %13, %12 ]
ret i8* %17
}