const char *GetShiftTypeString(unsigned int type, unsigned int length) {
  switch (type) {
  case 0x0:
    return "LSL";
  case 0x1:
    return "LSR";
  case 0x2:
    return "ASR";
  case 0x3:
    return ((!length) ? "ROR" : "RRX");
  default:
    return "";
  }
}


x86 assembly (clang, -O0):
<GetShiftTypeString>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0xc(%rbp)
mov    %esi,-0x10(%rbp)
mov    -0xc(%rbp),%eax
mov    %rax,-0x18(%rbp)
sub    $0x3,%rax
ja     1187 <GetShiftTypeString+0x87>
mov    -0x18(%rbp),%rax
lea    0xeda(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xeda(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1192 <GetShiftTypeString+0x92>
lea    0xece(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1192 <GetShiftTypeString+0x92>
lea    0xec2(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1192 <GetShiftTypeString+0x92>
cmpl   $0x0,-0x10(%rbp)
setne  %dl
xor    $0xff,%dl
lea    0xeb0(%rip),%rax
lea    0xea5(%rip),%rcx
test   $0x1,%dl
cmovne %rcx,%rax
mov    %rax,-0x8(%rbp)
jmp    1192 <GetShiftTypeString+0x92>
lea    0xe85(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<GetShiftTypeString>:
cmp    $0x3,%edi
ja     1126 <GetShiftTypeString+0x26>
lea    0xf04(%rip),%rax
mov    %edi,%ecx
lea    0xeeb(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
jmp    *%rcx
lea    0xeef(%rip),%rax
ret
lea    0xee6(%rip),%rax
ret
lea    0xee3(%rip),%rax
ret
test   %esi,%esi
lea    0xedd(%rip),%rcx
lea    0xeda(%rip),%rax
cmove  %rcx,%rax
ret

LLVM IR (-O0):
@.str = [4 x i8] c"LSL\00"
@.str.1 = [4 x i8] c"LSR\00"
@.str.2 = [4 x i8] c"ASR\00"
@.str.3 = [4 x i8] c"ROR\00"
@.str.4 = [4 x i8] c"RRX\00"
@.str.5 = [1 x i8] zeroinitializer
define i8* @GetShiftTypeString(i32 %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
%6 = load i32, i32* %4
switch i32 %6, label %16 [
i32 0, label %7
i32 1, label %8
i32 2, label %9
i32 3, label %10
]
7: ; preds = %2
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8** %3
br label %17
8: ; preds = %2
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8** %3
br label %17
9: ; preds = %2
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8** %3
br label %17
10: ; preds = %2
%11 = load i32, i32* %5
%12 = icmp ne i32 %11, 0
%13 = xor i1 %12, true
%14 = zext i1 %13 to i64
%15 = select i1 %13, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0)
store i8* %15, i8** %3
br label %17
16: ; preds = %2
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.5, i64 0, i64 0), i8** %3
br label %17
17: ; preds = %16, %10, %9, %8, %7
%18 = load i8*, i8** %3
ret i8* %18
}

LLVM IR (-O2):
@.str = [4 x i8] c"LSL\00"
@.str.1 = [4 x i8] c"LSR\00"
@.str.2 = [4 x i8] c"ASR\00"
@.str.3 = [4 x i8] c"ROR\00"
@.str.4 = [4 x i8] c"RRX\00"
@.str.5 = [1 x i8] zeroinitializer
define i8* @GetShiftTypeString(i32 %0, i32 %1) {
switch i32 %0, label %8 [
i32 0, label %9
i32 1, label %3
i32 2, label %4
i32 3, label %5
]
3: ; preds = %2
br label %9
4: ; preds = %2
br label %9
5: ; preds = %2
%6 = icmp eq i32 %1, 0
%7 = select i1 %6, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0)
br label %9
8: ; preds = %2
br label %9
9: ; preds = %2, %8, %5, %4, %3
%10 = phi i8* [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str.5, i64 0, i64 0), %8 ], [ %7, %5 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), %4 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), %3 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), %2 ]
ret i8* %10
}