int base64_char2id(char c) {
  static const char *table =
      "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
  int i;
  for (i = 0; table[i] != '\0'; i++) {
    if (table[i] == c)
      return i;
  }
  return -1;
}


x86 assembly (clang, -O0):
<base64_char2id>:
push   %rbp
mov    %rsp,%rbp
mov    %dil,%al
mov    %al,-0x5(%rbp)
movl   $0x0,-0xc(%rbp)
mov    0x2f08(%rip),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     1162 <base64_char2id+0x62>
mov    0x2ef0(%rip),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
movsbl -0x5(%rbp),%ecx
cmp    %ecx,%eax
jne    114f <base64_char2id+0x4f>
mov    -0xc(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1169 <base64_char2id+0x69>
jmp    1154 <base64_char2id+0x54>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1111 <base64_char2id+0x11>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<base64_char2id>:
xor    %eax,%eax
lea    0xef7(%rip),%rcx
nopl   0x0(%rax)
cmp    %dil,(%rax,%rcx,1)
je     1144 <base64_char2id+0x44>
cmp    %dil,0x1(%rax,%rcx,1)
je     113b <base64_char2id+0x3b>
cmp    %dil,0x2(%rax,%rcx,1)
je     1140 <base64_char2id+0x40>
cmp    %dil,0x3(%rax,%rcx,1)
je     1145 <base64_char2id+0x45>
add    $0x4,%rax
cmp    $0x40,%rax
jne    1110 <base64_char2id+0x10>
mov    $0xffffffff,%eax
ret
add    $0x1,%rax
ret
add    $0x2,%rax
ret
add    $0x3,%rax
ret

LLVM IR (-O0):
@base64_char2id.table = internal global i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i32 0, i32 0)
@.str = [65 x i8] c"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\00"
define i32 @base64_char2id(i8 signext %0) {
%2 = alloca i32
%3 = alloca i8
%4 = alloca i32
store i8 %0, i8* %3
store i32 0, i32* %4
br label %5
5: ; preds = %26, %1
%6 = load i8*, i8** @base64_char2id.table
%7 = load i32, i32* %4
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds i8, i8* %6, i64 %8
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %29
13: ; preds = %5
%14 = load i8*, i8** @base64_char2id.table
%15 = load i32, i32* %4
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8, i8* %14, i64 %16
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = load i8, i8* %3
%21 = sext i8 %20 to i32
%22 = icmp eq i32 %19, %21
br i1 %22, label %23, label %25
23: ; preds = %13
%24 = load i32, i32* %4
store i32 %24, i32* %2
br label %30
25: ; preds = %13
br label %26
26: ; preds = %25
%27 = load i32, i32* %4
%28 = add nsw i32 %27, 1
store i32 %28, i32* %4
br label %5
29: ; preds = %5
store i32 -1, i32* %2
br label %30
30: ; preds = %29, %23
%31 = load i32, i32* %2
ret i32 %31
}

LLVM IR (-O2):
@.str = [65 x i8] c"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\00"
define i32 @base64_char2id(i8 signext %0) {
br label %2
2: ; preds = %22, %1
%3 = phi i64 [ 0, %1 ], [ %23, %22 ]
%4 = getelementptr inbounds [65 x i8], [65 x i8]* @.str, i64 0, i64 %3
%5 = load i8, i8* %4
%6 = icmp eq i8 %5, %0
br i1 %6, label %25, label %7
7: ; preds = %2
%8 = or i64 %3, 1
%9 = getelementptr inbounds [65 x i8], [65 x i8]* @.str, i64 0, i64 %8
%10 = load i8, i8* %9
%11 = icmp eq i8 %10, %0
br i1 %11, label %25, label %12
12: ; preds = %7
%13 = or i64 %3, 2
%14 = getelementptr inbounds [65 x i8], [65 x i8]* @.str, i64 0, i64 %13
%15 = load i8, i8* %14
%16 = icmp eq i8 %15, %0
br i1 %16, label %25, label %17
17: ; preds = %12
%18 = or i64 %3, 3
%19 = getelementptr inbounds [65 x i8], [65 x i8]* @.str, i64 0, i64 %18
%20 = load i8, i8* %19
%21 = icmp eq i8 %20, %0
br i1 %21, label %25, label %22
22: ; preds = %17
%23 = add nuw nsw i64 %3, 4
%24 = icmp eq i64 %23, 64
br i1 %24, label %28, label %2
25: ; preds = %17, %12, %7, %2
%26 = phi i64 [ %3, %2 ], [ %8, %7 ], [ %13, %12 ], [ %18, %17 ]
%27 = trunc i64 %26 to i32
br label %28
28: ; preds = %22, %25
%29 = phi i32 [ %27, %25 ], [ -1, %22 ]
ret i32 %29
}