int b64_to_value(unsigned char b64) {
  static char table[] = {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1,
                         -1, -1, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61,
                         -1, -1, -1, -1, -1, -1, -1, 0,  1,  2,  3,  4,  5,
                         6,  7,  8,  9,  10, 11, 12, 13, 14, 15, 16, 17, 18,
                         19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1, -1,
                         26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38,
                         39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51};
  if (b64 < 0x20)
    return -1;
  b64 -= 0x20;
  if (b64 >= sizeof(table))
    return -1;
  return table[b64];
}


x86 assembly (clang, -O0):
<b64_to_value>:
push   %rbp
mov    %rsp,%rbp
mov    %dil,%al
mov    %al,-0x5(%rbp)
movzbl -0x5(%rbp),%eax
cmp    $0x20,%eax
jge    1123 <b64_to_value+0x23>
movl   $0xffffffff,-0x4(%rbp)
jmp    115b <b64_to_value+0x5b>
movzbl -0x5(%rbp),%eax
sub    $0x20,%eax
mov    %al,-0x5(%rbp)
movzbl -0x5(%rbp),%eax
cmp    $0x5b,%rax
jb     1147 <b64_to_value+0x47>
movl   $0xffffffff,-0x4(%rbp)
jmp    115b <b64_to_value+0x5b>
movzbl -0x5(%rbp),%eax
mov    %eax,%ecx
lea    0x2edc(%rip),%rax
movsbl (%rax,%rcx,1),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<b64_to_value>:
mov    $0xffffffff,%eax
cmp    $0x20,%dil
jb     1124 <b64_to_value+0x24>
add    $0xe0,%dil
cmp    $0x5a,%dil
ja     1124 <b64_to_value+0x24>
movzbl %dil,%eax
lea    0xee0(%rip),%rcx
movsbl (%rax,%rcx,1),%eax
ret

LLVM IR (-O0):
@b64_to_value.table = internal global [91 x i8] c"\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF>\FF\FF\FF?456789:;<=\FF\FF\FF\FF\FF\FF\FF\00\01\02\03\04\05\06\07\08\09\0A\0B\0C\0D\0E\0F\10\11\12\13\14\15\16\17\18\19\FF\FF\FF\FF\FF\FF\1A\1B\1C\1D\1E\1F !\22#$%&'()*+,-./0123"
define i32 @b64_to_value(i8 zeroext %0) {
%2 = alloca i32
%3 = alloca i8
store i8 %0, i8* %3
%4 = load i8, i8* %3
%5 = zext i8 %4 to i32
%6 = icmp slt i32 %5, 32
br i1 %6, label %7, label %8
7: ; preds = %1
store i32 -1, i32* %2
br label %23
8: ; preds = %1
%9 = load i8, i8* %3
%10 = zext i8 %9 to i32
%11 = sub nsw i32 %10, 32
%12 = trunc i32 %11 to i8
store i8 %12, i8* %3
%13 = load i8, i8* %3
%14 = zext i8 %13 to i64
%15 = icmp uge i64 %14, 91
br i1 %15, label %16, label %17
16: ; preds = %8
store i32 -1, i32* %2
br label %23
17: ; preds = %8
%18 = load i8, i8* %3
%19 = zext i8 %18 to i64
%20 = getelementptr inbounds [91 x i8], [91 x i8]* @b64_to_value.table, i64 0, i64 %19
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
store i32 %22, i32* %2
br label %23
23: ; preds = %17, %16, %7
%24 = load i32, i32* %2
ret i32 %24
}

LLVM IR (-O2):
@b64_to_value.table = internal unnamed_addr constant [91 x i8] c"\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF>\FF\FF\FF?456789:;<=\FF\FF\FF\FF\FF\FF\FF\00\01\02\03\04\05\06\07\08\09\0A\0B\0C\0D\0E\0F\10\11\12\13\14\15\16\17\18\19\FF\FF\FF\FF\FF\FF\1A\1B\1C\1D\1E\1F !\22#$%&'()*+,-./0123"
define i32 @b64_to_value(i8 zeroext %0) {
%2 = icmp ult i8 %0, 32
br i1 %2, label %11, label %3
3: ; preds = %1
%4 = add i8 %0, -32
%5 = icmp ugt i8 %4, 90
br i1 %5, label %11, label %6
6: ; preds = %3
%7 = zext i8 %4 to i64
%8 = getelementptr inbounds [91 x i8], [91 x i8]* @b64_to_value.table, i64 0, i64 %7
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
br label %11
11: ; preds = %3, %1, %6
%12 = phi i32 [ %10, %6 ], [ -1, %1 ], [ -1, %3 ]
ret i32 %12
}