int httpd_decode_base64_code2value(unsigned char c) {
  if ((c >= 'A') && (c <= 'Z')) {
    return c - 'A';
  } else if ((c >= 'a') && (c <= 'z')) {
    return (c - 'a') + 26;
  } else if ((c >= '0') && (c <= '9')) {
    return (c - '0') + 52;
  } else if ('+' == c) {
    return 62;
  } else if ('/' == c) {
    return 63;
  } else if ('=' == c) {
    return 0;
  } else {
    return -1;
  }
}


x86 assembly (clang, -O0):
<httpd_decode_base64_code2value>:
push   %rbp
mov    %rsp,%rbp
mov    %dil,%al
mov    %al,-0x5(%rbp)
movzbl -0x5(%rbp),%eax
cmp    $0x41,%eax
jl     1133 <httpd_decode_base64_code2value+0x33>
movzbl -0x5(%rbp),%eax
cmp    $0x5a,%eax
jg     1133 <httpd_decode_base64_code2value+0x33>
movzbl -0x5(%rbp),%eax
sub    $0x41,%eax
mov    %eax,-0x4(%rbp)
jmp    11e9 <httpd_decode_base64_code2value+0xe9>
movzbl -0x5(%rbp),%eax
cmp    $0x61,%eax
jl     115f <httpd_decode_base64_code2value+0x5f>
movzbl -0x5(%rbp),%eax
cmp    $0x7a,%eax
jg     115f <httpd_decode_base64_code2value+0x5f>
movzbl -0x5(%rbp),%eax
sub    $0x61,%eax
add    $0x1a,%eax
mov    %eax,-0x4(%rbp)
jmp    11e9 <httpd_decode_base64_code2value+0xe9>
movzbl -0x5(%rbp),%eax
cmp    $0x30,%eax
jl     118b <httpd_decode_base64_code2value+0x8b>
movzbl -0x5(%rbp),%eax
cmp    $0x39,%eax
jg     118b <httpd_decode_base64_code2value+0x8b>
movzbl -0x5(%rbp),%eax
sub    $0x30,%eax
add    $0x34,%eax
mov    %eax,-0x4(%rbp)
jmp    11e9 <httpd_decode_base64_code2value+0xe9>
movzbl -0x5(%rbp),%ecx
mov    $0x2b,%eax
cmp    %ecx,%eax
jne    11a8 <httpd_decode_base64_code2value+0xa8>
movl   $0x3e,-0x4(%rbp)
jmp    11e9 <httpd_decode_base64_code2value+0xe9>
movzbl -0x5(%rbp),%ecx
mov    $0x2f,%eax
cmp    %ecx,%eax
jne    11c5 <httpd_decode_base64_code2value+0xc5>
movl   $0x3f,-0x4(%rbp)
jmp    11e9 <httpd_decode_base64_code2value+0xe9>
movzbl -0x5(%rbp),%ecx
mov    $0x3d,%eax
cmp    %ecx,%eax
jne    11e2 <httpd_decode_base64_code2value+0xe2>
movl   $0x0,-0x4(%rbp)
jmp    11e9 <httpd_decode_base64_code2value+0xe9>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<httpd_decode_base64_code2value>:
mov    %edi,%eax
lea    -0x41(%rax),%ecx
cmp    $0x19,%cl
ja     110e <httpd_decode_base64_code2value+0xe>
add    $0xffffffbf,%eax
ret
lea    -0x61(%rax),%ecx
cmp    $0x19,%cl
ja     111a <httpd_decode_base64_code2value+0x1a>
add    $0xffffffb9,%eax
ret
lea    -0x30(%rax),%ecx
cmp    $0x9,%cl
ja     1126 <httpd_decode_base64_code2value+0x26>
add    $0x4,%eax
ret
cmp    $0x2b,%al
je     1138 <httpd_decode_base64_code2value+0x38>
cmp    $0x3d,%al
je     113e <httpd_decode_base64_code2value+0x3e>
cmp    $0x2f,%al
jne    1141 <httpd_decode_base64_code2value+0x41>
mov    $0x3f,%eax
ret
mov    $0x3e,%eax
ret
xor    %eax,%eax
ret
mov    $0xffffffff,%eax
ret

LLVM IR (-O0):
define i32 @httpd_decode_base64_code2value(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 sge i32 %5, 65
br i1 %6, label %7, label %15
7: ; preds = %1
%8 = load i8, i8* %3
%9 = zext i8 %8 to i32
%10 = icmp sle i32 %9, 90
br i1 %10, label %11, label %15
11: ; preds = %7
%12 = load i8, i8* %3
%13 = zext i8 %12 to i32
%14 = sub nsw i32 %13, 65
store i32 %14, i32* %2
br label %57
15: ; preds = %7, %1
%16 = load i8, i8* %3
%17 = zext i8 %16 to i32
%18 = icmp sge i32 %17, 97
br i1 %18, label %19, label %28
19: ; preds = %15
%20 = load i8, i8* %3
%21 = zext i8 %20 to i32
%22 = icmp sle i32 %21, 122
br i1 %22, label %23, label %28
23: ; preds = %19
%24 = load i8, i8* %3
%25 = zext i8 %24 to i32
%26 = sub nsw i32 %25, 97
%27 = add nsw i32 %26, 26
store i32 %27, i32* %2
br label %57
28: ; preds = %19, %15
%29 = load i8, i8* %3
%30 = zext i8 %29 to i32
%31 = icmp sge i32 %30, 48
br i1 %31, label %32, label %41
32: ; preds = %28
%33 = load i8, i8* %3
%34 = zext i8 %33 to i32
%35 = icmp sle i32 %34, 57
br i1 %35, label %36, label %41
36: ; preds = %32
%37 = load i8, i8* %3
%38 = zext i8 %37 to i32
%39 = sub nsw i32 %38, 48
%40 = add nsw i32 %39, 52
store i32 %40, i32* %2
br label %57
41: ; preds = %32, %28
%42 = load i8, i8* %3
%43 = zext i8 %42 to i32
%44 = icmp eq i32 43, %43
br i1 %44, label %45, label %46
45: ; preds = %41
store i32 62, i32* %2
br label %57
46: ; preds = %41
%47 = load i8, i8* %3
%48 = zext i8 %47 to i32
%49 = icmp eq i32 47, %48
br i1 %49, label %50, label %51
50: ; preds = %46
store i32 63, i32* %2
br label %57
51: ; preds = %46
%52 = load i8, i8* %3
%53 = zext i8 %52 to i32
%54 = icmp eq i32 61, %53
br i1 %54, label %55, label %56
55: ; preds = %51
store i32 0, i32* %2
br label %57
56: ; preds = %51
store i32 -1, i32* %2
br label %57
57: ; preds = %56, %55, %50, %45, %36, %23, %11
%58 = load i32, i32* %2
ret i32 %58
}

LLVM IR (-O2):
define i32 @httpd_decode_base64_code2value(i8 zeroext %0) {
%2 = zext i8 %0 to i32
%3 = add i8 %0, -65
%4 = icmp ult i8 %3, 26
br i1 %4, label %5, label %7
5: ; preds = %1
%6 = add nsw i32 %2, -65
br label %21
7: ; preds = %1
%8 = add i8 %0, -97
%9 = icmp ult i8 %8, 26
br i1 %9, label %10, label %12
10: ; preds = %7
%11 = add nsw i32 %2, -71
br label %21
12: ; preds = %7
%13 = add i8 %0, -48
%14 = icmp ult i8 %13, 10
br i1 %14, label %15, label %17
15: ; preds = %12
%16 = add nuw nsw i32 %2, 4
br label %21
17: ; preds = %12
switch i8 %0, label %20 [
i8 43, label %21
i8 47, label %18
i8 61, label %19
]
18: ; preds = %17
br label %21
19: ; preds = %17
br label %21
20: ; preds = %17
br label %21
21: ; preds = %17, %20, %19, %18, %15, %10, %5
%22 = phi i32 [ %6, %5 ], [ %11, %10 ], [ %16, %15 ], [ 63, %18 ], [ 0, %19 ], [ -1, %20 ], [ 62, %17 ]
ret i32 %22
}