int cases(char s) {
  switch (s) {
  case 0:
    return 48;
  case 1:
    return 49;
  case 2:
    return 50;
  case 3:
    return 51;
  case 4:
    return 52;
  case 5:
    return 53;
  case 6:
    return 54;
  case 7:
    return 55;
  case 8:
    return 56;
  case 9:
    return 57;
  case 10:
    return 65;
  case 11:
    return 66;
  case 12:
    return 67;
  case 13:
    return 68;
  case 14:
    return 69;
  case 15:
    return 70;
  default:
    break;
  }
  return 0;
}


x86 assembly (clang, -O0):
<cases>:
push   %rbp
mov    %rsp,%rbp
mov    %dil,%al
mov    %al,-0x5(%rbp)
movsbl -0x5(%rbp),%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0xf,%eax
ja     11f1 <cases+0xf1>
mov    -0x10(%rbp),%rax
lea    0xed8(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x30,-0x4(%rbp)
jmp    11fd <cases+0xfd>
movl   $0x31,-0x4(%rbp)
jmp    11fd <cases+0xfd>
movl   $0x32,-0x4(%rbp)
jmp    11fd <cases+0xfd>
movl   $0x33,-0x4(%rbp)
jmp    11fd <cases+0xfd>
movl   $0x34,-0x4(%rbp)
jmp    11fd <cases+0xfd>
movl   $0x35,-0x4(%rbp)
jmp    11fd <cases+0xfd>
movl   $0x36,-0x4(%rbp)
jmp    11fd <cases+0xfd>
movl   $0x37,-0x4(%rbp)
jmp    11fd <cases+0xfd>
movl   $0x38,-0x4(%rbp)
jmp    11fd <cases+0xfd>
movl   $0x39,-0x4(%rbp)
jmp    11fd <cases+0xfd>
movl   $0x41,-0x4(%rbp)
jmp    11fd <cases+0xfd>
movl   $0x42,-0x4(%rbp)
jmp    11fd <cases+0xfd>
movl   $0x43,-0x4(%rbp)
jmp    11fd <cases+0xfd>
movl   $0x44,-0x4(%rbp)
jmp    11fd <cases+0xfd>
movl   $0x45,-0x4(%rbp)
jmp    11fd <cases+0xfd>
movl   $0x46,-0x4(%rbp)
jmp    11fd <cases+0xfd>
jmp    11f6 <cases+0xf6>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<cases>:
xor    %eax,%eax
cmp    $0xf,%dil
ja     1116 <cases+0x16>
movsbq %dil,%rax
lea    0xeed(%rip),%rcx
mov    (%rcx,%rax,4),%eax
ret

LLVM IR (-O0):
define i32 @cases(i8 signext %0) {
%2 = alloca i32
%3 = alloca i8
store i8 %0, i8* %3
%4 = load i8, i8* %3
%5 = sext i8 %4 to i32
switch i32 %5, label %22 [
i32 0, label %6
i32 1, label %7
i32 2, label %8
i32 3, label %9
i32 4, label %10
i32 5, label %11
i32 6, label %12
i32 7, label %13
i32 8, label %14
i32 9, label %15
i32 10, label %16
i32 11, label %17
i32 12, label %18
i32 13, label %19
i32 14, label %20
i32 15, label %21
]
6: ; preds = %1
store i32 48, i32* %2
br label %24
7: ; preds = %1
store i32 49, i32* %2
br label %24
8: ; preds = %1
store i32 50, i32* %2
br label %24
9: ; preds = %1
store i32 51, i32* %2
br label %24
10: ; preds = %1
store i32 52, i32* %2
br label %24
11: ; preds = %1
store i32 53, i32* %2
br label %24
12: ; preds = %1
store i32 54, i32* %2
br label %24
13: ; preds = %1
store i32 55, i32* %2
br label %24
14: ; preds = %1
store i32 56, i32* %2
br label %24
15: ; preds = %1
store i32 57, i32* %2
br label %24
16: ; preds = %1
store i32 65, i32* %2
br label %24
17: ; preds = %1
store i32 66, i32* %2
br label %24
18: ; preds = %1
store i32 67, i32* %2
br label %24
19: ; preds = %1
store i32 68, i32* %2
br label %24
20: ; preds = %1
store i32 69, i32* %2
br label %24
21: ; preds = %1
store i32 70, i32* %2
br label %24
22: ; preds = %1
br label %23
23: ; preds = %22
store i32 0, i32* %2
br label %24
24: ; preds = %23, %21, %20, %19, %18, %17, %16, %15, %14, %13, %12, %11, %10, %9, %8, %7, %6
%25 = load i32, i32* %2
ret i32 %25
}

LLVM IR (-O2):
@switch.table.cases = [16 x i32] [i32 48, i32 49, i32 50, i32 51, i32 52, i32 53, i32 54, i32 55, i32 56, i32 57, i32 65, i32 66, i32 67, i32 68, i32 69, i32 70]
define i32 @cases(i8 signext %0) {
%2 = icmp ult i8 %0, 16
br i1 %2, label %3, label %7
3: ; preds = %1
%4 = sext i8 %0 to i64
%5 = getelementptr inbounds [16 x i32], [16 x i32]* @switch.table.cases, i64 0, i64 %4
%6 = load i32, i32* %5
br label %7
7: ; preds = %1, %3
%8 = phi i32 [ %6, %3 ], [ 0, %1 ]
ret i32 %8
}