char sa2i(char c) {
  if (c >= 'a' && c <= 'z')
    c += 'A' - 'a';
  switch (c) {
  case '.':
    return 0;
  case '-':
    return 0;
  case 'A':
    return 1;
  case 'B':
    return 2;
  case 'C':
    return 3;
  case 'D':
    return 4;
  case 'E':
    return 5;
  case 'F':
    return 6;
  case ' ':
    return -1;
  case '\t':
    return -1;
  case '\n':
    return -1;
  }
  return -2;
}


x86 assembly (clang, -O0):
<sa2i>:
push   %rbp
mov    %rsp,%rbp
mov    %dil,%al
mov    %al,-0x2(%rbp)
movsbl -0x2(%rbp),%eax
cmp    $0x61,%eax
jl     112e <sa2i+0x2e>
movsbl -0x2(%rbp),%eax
cmp    $0x7a,%eax
jg     112e <sa2i+0x2e>
movsbl -0x2(%rbp),%eax
add    $0xffffffe0,%eax
mov    %al,-0x2(%rbp)
movsbl -0x2(%rbp),%eax
add    $0xfffffff7,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x3d,%eax
ja     11bb <sa2i+0xbb>
mov    -0x10(%rbp),%rax
lea    0xeb1(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movb   $0x0,-0x1(%rbp)
jmp    11bf <sa2i+0xbf>
movb   $0x0,-0x1(%rbp)
jmp    11bf <sa2i+0xbf>
movb   $0x1,-0x1(%rbp)
jmp    11bf <sa2i+0xbf>
movb   $0x2,-0x1(%rbp)
jmp    11bf <sa2i+0xbf>
movb   $0x3,-0x1(%rbp)
jmp    11bf <sa2i+0xbf>
movb   $0x4,-0x1(%rbp)
jmp    11bf <sa2i+0xbf>
movb   $0x5,-0x1(%rbp)
jmp    11bf <sa2i+0xbf>
movb   $0x6,-0x1(%rbp)
jmp    11bf <sa2i+0xbf>
movb   $0xff,-0x1(%rbp)
jmp    11bf <sa2i+0xbf>
movb   $0xff,-0x1(%rbp)
jmp    11bf <sa2i+0xbf>
movb   $0xff,-0x1(%rbp)
jmp    11bf <sa2i+0xbf>
movb   $0xfe,-0x1(%rbp)
movsbl -0x1(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<sa2i>:
lea    -0x61(%rdi),%eax
lea    -0x20(%rdi),%ecx
cmp    $0x1a,%al
movzbl %cl,%eax
cmovae %edi,%eax
movsbl %al,%ecx
add    $0xfffffff7,%ecx
cmp    $0x3d,%ecx
ja     112e <sa2i+0x2e>
xor    %eax,%eax
lea    0xede(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
jmp    *%rcx
mov    $0xff,%al
ret
mov    $0xfe,%al
ret
mov    $0x1,%al
ret
mov    $0x2,%al
ret
mov    $0x3,%al
ret
mov    $0x4,%al
ret
mov    $0x5,%al
ret
mov    $0x6,%al
ret

LLVM IR (-O0):
define signext i8 @sa2i(i8 signext %0) {
%2 = alloca i8
%3 = alloca i8
store i8 %0, i8* %3
%4 = load i8, i8* %3
%5 = sext i8 %4 to i32
%6 = icmp sge i32 %5, 97
br i1 %6, label %7, label %16
7: ; preds = %1
%8 = load i8, i8* %3
%9 = sext i8 %8 to i32
%10 = icmp sle i32 %9, 122
br i1 %10, label %11, label %16
11: ; preds = %7
%12 = load i8, i8* %3
%13 = sext i8 %12 to i32
%14 = add nsw i32 %13, -32
%15 = trunc i32 %14 to i8
store i8 %15, i8* %3
br label %16
16: ; preds = %11, %7, %1
%17 = load i8, i8* %3
%18 = sext i8 %17 to i32
switch i32 %18, label %30 [
i32 46, label %19
i32 45, label %20
i32 65, label %21
i32 66, label %22
i32 67, label %23
i32 68, label %24
i32 69, label %25
i32 70, label %26
i32 32, label %27
i32 9, label %28
i32 10, label %29
]
19: ; preds = %16
store i8 0, i8* %2
br label %31
20: ; preds = %16
store i8 0, i8* %2
br label %31
21: ; preds = %16
store i8 1, i8* %2
br label %31
22: ; preds = %16
store i8 2, i8* %2
br label %31
23: ; preds = %16
store i8 3, i8* %2
br label %31
24: ; preds = %16
store i8 4, i8* %2
br label %31
25: ; preds = %16
store i8 5, i8* %2
br label %31
26: ; preds = %16
store i8 6, i8* %2
br label %31
27: ; preds = %16
store i8 -1, i8* %2
br label %31
28: ; preds = %16
store i8 -1, i8* %2
br label %31
29: ; preds = %16
store i8 -1, i8* %2
br label %31
30: ; preds = %16
store i8 -2, i8* %2
br label %31
31: ; preds = %30, %29, %28, %27, %26, %25, %24, %23, %22, %21, %20, %19
%32 = load i8, i8* %2
ret i8 %32
}

LLVM IR (-O2):
define signext i8 @sa2i(i8 signext %0) {
%2 = add i8 %0, -97
%3 = icmp ult i8 %2, 26
%4 = add i8 %0, -32
%5 = select i1 %3, i8 %4, i8 %0
%6 = sext i8 %5 to i32
switch i32 %6, label %16 [
i32 46, label %17
i32 45, label %17
i32 65, label %7
i32 66, label %8
i32 67, label %9
i32 68, label %10
i32 69, label %11
i32 70, label %12
i32 32, label %13
i32 9, label %14
i32 10, label %15
]
7: ; preds = %1
br label %17
8: ; preds = %1
br label %17
9: ; preds = %1
br label %17
10: ; preds = %1
br label %17
11: ; preds = %1
br label %17
12: ; preds = %1
br label %17
13: ; preds = %1
br label %17
14: ; preds = %1
br label %17
15: ; preds = %1
br label %17
16: ; preds = %1
br label %17
17: ; preds = %1, %1, %16, %15, %14, %13, %12, %11, %10, %9, %8, %7
%18 = phi i8 [ -2, %16 ], [ -1, %15 ], [ -1, %14 ], [ -1, %13 ], [ 6, %12 ], [ 5, %11 ], [ 4, %10 ], [ 3, %9 ], [ 2, %8 ], [ 1, %7 ], [ 0, %1 ], [ 0, %1 ]
ret i8 %18
}