char get_piece_type(int pieceValue) {
  if (!(pieceValue >= 1 && pieceValue <= 0xC)) {
    return ' ';
  }
  char pieceType;
  switch (pieceValue) {
  case 1:
  case 7:
    pieceType = 'P';
    break;
  case 2:
  case 8:
    pieceType = 'N';
    break;
  case 3:
  case 9:
    pieceType = 'B';
    break;
  case 4:
  case 10:
    pieceType = 'R';
    break;
  case 5:
  case 11:
    pieceType = 'Q';
    break;
  case 6:
  case 12:
    pieceType = 'K';
    break;
  }
  return pieceType;
}


x86 assembly (clang, -O0):
<get_piece_type>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
cmpl   $0x1,-0x8(%rbp)
jl     111b <get_piece_type+0x1b>
cmpl   $0xc,-0x8(%rbp)
jle    1124 <get_piece_type+0x24>
movb   $0x20,-0x1(%rbp)
jmp    1184 <get_piece_type+0x84>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0xb,%eax
ja     117e <get_piece_type+0x7e>
mov    -0x18(%rbp),%rax
lea    0xebc(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movb   $0x50,-0x9(%rbp)
jmp    117e <get_piece_type+0x7e>
movb   $0x4e,-0x9(%rbp)
jmp    117e <get_piece_type+0x7e>
movb   $0x42,-0x9(%rbp)
jmp    117e <get_piece_type+0x7e>
movb   $0x52,-0x9(%rbp)
jmp    117e <get_piece_type+0x7e>
movb   $0x51,-0x9(%rbp)
jmp    117e <get_piece_type+0x7e>
movb   $0x4b,-0x9(%rbp)
mov    -0x9(%rbp),%al
mov    %al,-0x1(%rbp)
movsbl -0x1(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_piece_type>:
lea    -0x1(%rdi),%ecx
mov    $0x20,%al
cmp    $0xb,%ecx
ja     1121 <get_piece_type+0x21>
add    $0xfffffffe,%edi
mov    $0x50,%al
cmp    $0xa,%edi
ja     1121 <get_piece_type+0x21>
movslq %edi,%rax
lea    0xee2(%rip),%rcx
mov    (%rax,%rcx,1),%al
ret

LLVM IR (-O0):
define signext i8 @get_piece_type(i32 %0) {
%2 = alloca i8
%3 = alloca i32
%4 = alloca i8
store i32 %0, i32* %3
%5 = load i32, i32* %3
%6 = icmp sge i32 %5, 1
br i1 %6, label %7, label %10
7: ; preds = %1
%8 = load i32, i32* %3
%9 = icmp sle i32 %8, 12
br i1 %9, label %11, label %10
10: ; preds = %7, %1
store i8 32, i8* %2
br label %21
11: ; preds = %7
%12 = load i32, i32* %3
switch i32 %12, label %19 [
i32 1, label %13
i32 7, label %13
i32 2, label %14
i32 8, label %14
i32 3, label %15
i32 9, label %15
i32 4, label %16
i32 10, label %16
i32 5, label %17
i32 11, label %17
i32 6, label %18
i32 12, label %18
]
13: ; preds = %11, %11
store i8 80, i8* %4
br label %19
14: ; preds = %11, %11
store i8 78, i8* %4
br label %19
15: ; preds = %11, %11
store i8 66, i8* %4
br label %19
16: ; preds = %11, %11
store i8 82, i8* %4
br label %19
17: ; preds = %11, %11
store i8 81, i8* %4
br label %19
18: ; preds = %11, %11
store i8 75, i8* %4
br label %19
19: ; preds = %11, %18, %17, %16, %15, %14, %13
%20 = load i8, i8* %4
store i8 %20, i8* %2
br label %21
21: ; preds = %19, %10
%22 = load i8, i8* %2
ret i8 %22
}

LLVM IR (-O2):
@switch.table.get_piece_type = [11 x i8] c"NBRQKPNBRQK"
define signext i8 @get_piece_type(i32 %0) {
%2 = add i32 %0, -1
%3 = icmp ult i32 %2, 12
br i1 %3, label %4, label %11
4: ; preds = %1
%5 = add i32 %0, -2
%6 = icmp ult i32 %5, 11
br i1 %6, label %7, label %11
7: ; preds = %4
%8 = sext i32 %5 to i64
%9 = getelementptr inbounds [11 x i8], [11 x i8]* @switch.table.get_piece_type, i64 0, i64 %8
%10 = load i8, i8* %9
br label %11
11: ; preds = %7, %4, %1
%12 = phi i8 [ 32, %1 ], [ 80, %4 ], [ %10, %7 ]
ret i8 %12
}