int wdl_base64decode(const char *src, unsigned char *dest, int destsize) {
  static const char *tab =
      "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
      "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
      "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x3e\xff\xff\xff\x3f"
      "\x34\x35\x36\x37\x38\x39\x3a\x3b\x3c\x3d\xff\xff\xff\xff\xff\xff"
      "\xff\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e"
      "\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\xff\xff\xff\xff\xff"
      "\xff\x1a\x1b\x1c\x1d\x1e\x1f\x20\x21\x22\x23\x24\x25\x26\x27\x28"
      "\x29\x2a\x2b\x2c\x2d\x2e\x2f\x30\x31\x32\x33\xff\xff\xff\xff\xff"
      "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
      "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
      "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
      "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
      "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
      "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
      "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
      "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff";
  int accum = 0, nbits = 0, wpos = 0;
  if (destsize <= 0)
    return 0;
  for (;;) {
    const int v = (int)tab[*(unsigned char *)src++];
    if (v < 0)
      return wpos;
    accum += v;
    nbits += 6;
    if (nbits >= 8) {
      nbits -= 8;
      dest[wpos] = (accum >> nbits) & 0xff;
      if (++wpos >= destsize)
        return wpos;
    }
    accum <<= 6;
  }
}


x86 assembly (clang, -O0):
<wdl_base64decode>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jg     113a <wdl_base64decode+0x3a>
movl   $0x0,-0x4(%rbp)
jmp    11e3 <wdl_base64decode+0xe3>
jmp    113f <wdl_base64decode+0x3f>
mov    0x2eda(%rip),%rax
mov    -0x10(%rbp),%rcx
mov    %rcx,%rdx
add    $0x1,%rdx
mov    %rdx,-0x10(%rbp)
movzbl (%rcx),%ecx
movsbl (%rax,%rcx,1),%eax
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jge    1174 <wdl_base64decode+0x74>
mov    -0x28(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11e3 <wdl_base64decode+0xe3>
mov    -0x2c(%rbp),%eax
add    -0x20(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x24(%rbp),%eax
add    $0x6,%eax
mov    %eax,-0x24(%rbp)
cmpl   $0x8,-0x24(%rbp)
jl     11d5 <wdl_base64decode+0xd5>
mov    -0x24(%rbp),%eax
sub    $0x8,%eax
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%eax
mov    -0x24(%rbp),%ecx
sar    %cl,%eax
and    $0xff,%eax
mov    %al,%dl
mov    -0x18(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
cmp    -0x1c(%rbp),%eax
jl     11d0 <wdl_base64decode+0xd0>
mov    -0x28(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11e3 <wdl_base64decode+0xe3>
jmp    11d5 <wdl_base64decode+0xd5>
mov    -0x20(%rbp),%eax
shl    $0x6,%eax
mov    %eax,-0x20(%rbp)
jmp    113f <wdl_base64decode+0x3f>
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<wdl_base64decode>:
xor    %eax,%eax
test   %edx,%edx
jle    116e <wdl_base64decode+0x6e>
movzbl (%rdi),%ecx
lea    0xef0(%rip),%r8
mov    (%rcx,%r8,1),%r10b
test   %r10b,%r10b
js     116e <wdl_base64decode+0x6e>
add    $0x1,%rdi
xor    %eax,%eax
xor    %ecx,%ecx
xor    %r11d,%r11d
jmp    114c <wdl_base64decode+0x4c>
cs nopw 0x0(%rax,%rax,1)
add    $0x6,%ecx
shl    $0x6,%r9d
movzbl (%rdi),%r10d
movzbl (%r10,%r8,1),%r10d
add    $0x1,%rdi
mov    %r9d,%r11d
test   %r10b,%r10b
js     116e <wdl_base64decode+0x6e>
movzbl %r10b,%r9d
add    %r11d,%r9d
cmp    $0x2,%ecx
jl     1130 <wdl_base64decode+0x30>
add    $0xfffffffe,%ecx
mov    %r9d,%r10d
sar    %cl,%r10d
cltq
mov    %r10b,(%rsi,%rax,1)
add    $0x1,%eax
cmp    %edx,%eax
jl     1133 <wdl_base64decode+0x33>
ret

LLVM IR (-O0):
@wdl_base64decode.tab = internal global i8* getelementptr inbounds ([257 x i8], [257 x i8]* @.str, i32 0, i32 0)
@.str = [257 x i8] c"\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\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\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\00"
define i32 @wdl_base64decode(i8* %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
store i32 0, i32* %8
store i32 0, i32* %9
store i32 0, i32* %10
%12 = load i32, i32* %7
%13 = icmp sle i32 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %3
store i32 0, i32* %4
br label %59
15: ; preds = %3
br label %16
16: ; preds = %56, %15
%17 = load i8*, i8** @wdl_base64decode.tab
%18 = load i8*, i8** %5
%19 = getelementptr inbounds i8, i8* %18, i32 1
store i8* %19, i8** %5
%20 = load i8, i8* %18
%21 = zext i8 %20 to i64
%22 = getelementptr inbounds i8, i8* %17, i64 %21
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
store i32 %24, i32* %11
%25 = load i32, i32* %11
%26 = icmp slt i32 %25, 0
br i1 %26, label %27, label %29
27: ; preds = %16
%28 = load i32, i32* %10
store i32 %28, i32* %4
br label %59
29: ; preds = %16
%30 = load i32, i32* %11
%31 = load i32, i32* %8
%32 = add nsw i32 %31, %30
store i32 %32, i32* %8
%33 = load i32, i32* %9
%34 = add nsw i32 %33, 6
store i32 %34, i32* %9
%35 = load i32, i32* %9
%36 = icmp sge i32 %35, 8
br i1 %36, label %37, label %56
37: ; preds = %29
%38 = load i32, i32* %9
%39 = sub nsw i32 %38, 8
store i32 %39, i32* %9
%40 = load i32, i32* %8
%41 = load i32, i32* %9
%42 = ashr i32 %40, %41
%43 = and i32 %42, 255
%44 = trunc i32 %43 to i8
%45 = load i8*, i8** %6
%46 = load i32, i32* %10
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds i8, i8* %45, i64 %47
store i8 %44, i8* %48
%49 = load i32, i32* %10
%50 = add nsw i32 %49, 1
store i32 %50, i32* %10
%51 = load i32, i32* %7
%52 = icmp sge i32 %50, %51
br i1 %52, label %53, label %55
53: ; preds = %37
%54 = load i32, i32* %10
store i32 %54, i32* %4
br label %59
55: ; preds = %37
br label %56
56: ; preds = %55, %29
%57 = load i32, i32* %8
%58 = shl i32 %57, 6
store i32 %58, i32* %8
br label %16
59: ; preds = %53, %27, %14
%60 = load i32, i32* %4
ret i32 %60
}

LLVM IR (-O2):
@.str = [257 x i8] c"\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\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\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\FF\00"
define i32 @wdl_base64decode(i8* nocapture %0, i8* nocapture writeonly %1, i32 %2) {
%4 = icmp slt i32 %2, 1
br i1 %4, label %39, label %5
5: ; preds = %3
%6 = load i8, i8* %0
%7 = zext i8 %6 to i64
%8 = getelementptr inbounds [257 x i8], [257 x i8]* @.str, i64 0, i64 %7
%9 = load i8, i8* %8
%10 = icmp slt i8 %9, 0
br i1 %10, label %39, label %11
11: ; preds = %5, %30
%12 = phi i8 [ %37, %30 ], [ %9, %5 ]
%13 = phi i8* [ %17, %30 ], [ %0, %5 ]
%14 = phi i32 [ %32, %30 ], [ 0, %5 ]
%15 = phi i32 [ %31, %30 ], [ 0, %5 ]
%16 = phi i32 [ %33, %30 ], [ 0, %5 ]
%17 = getelementptr inbounds i8, i8* %13, i64 1
%18 = zext i8 %12 to i32
%19 = add nsw i32 %16, %18
%20 = add nsw i32 %15, 6
%21 = icmp sgt i32 %15, 1
br i1 %21, label %22, label %30
22: ; preds = %11
%23 = add nsw i32 %15, -2
%24 = ashr i32 %19, %23
%25 = trunc i32 %24 to i8
%26 = sext i32 %14 to i64
%27 = getelementptr inbounds i8, i8* %1, i64 %26
store i8 %25, i8* %27
%28 = add nsw i32 %14, 1
%29 = icmp slt i32 %28, %2
br i1 %29, label %30, label %39
30: ; preds = %11, %22
%31 = phi i32 [ %23, %22 ], [ %20, %11 ]
%32 = phi i32 [ %28, %22 ], [ %14, %11 ]
%33 = shl i32 %19, 6
%34 = load i8, i8* %17
%35 = zext i8 %34 to i64
%36 = getelementptr inbounds [257 x i8], [257 x i8]* @.str, i64 0, i64 %35
%37 = load i8, i8* %36
%38 = icmp slt i8 %37, 0
br i1 %38, label %39, label %11
39: ; preds = %30, %22, %5, %3
%40 = phi i32 [ 0, %3 ], [ 0, %5 ], [ %32, %30 ], [ %28, %22 ]
ret i32 %40
}