int xmlDecodeBase64(unsigned char *out, unsigned int olen, const char *in,
                    unsigned int ilen) {
  static const unsigned char b64[] = {
      66, 66, 66, 66, 66, 66, 66, 66, 66, 64, 64, 66, 66, 64, 66, 66, 66, 66,
      66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 64, 66, 66, 66,
      66, 66, 66, 66, 66, 66, 66, 62, 66, 66, 66, 63, 52, 53, 54, 55, 56, 57,
      58, 59, 60, 61, 66, 66, 66, 65, 66, 66, 66, 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, 66, 66, 66, 66, 66, 66, 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, 66, 66, 66,
      66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66,
      66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66,
      66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66,
      66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66,
      66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66,
      66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66,
      66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66,
      66, 66, 66, 66};
  unsigned long buf;
  int len;
  buf = 1;
  len = 0;
  while (ilen-- > 0) {
    unsigned char c;
    switch ((c = b64[*(unsigned char *)in++])) {
    case 66:
      return (-1);
    case 64:
      continue;
    case 65:
      ilen = 0;
      break;
    default:
      buf = buf << 6 | c;
      if (buf & 0x1000000) {
        if (olen >= 3) {
          *out++ = buf >> 16;
          *out++ = buf >> 8;
          *out++ = buf;
          olen -= 3;
        }
        len += 3;
        buf = 1;
      }
      break;
    }
  }
  if (buf & 0x40000) {
    if (olen >= 2) {
      *out++ = buf >> 10;
      *out++ = buf >> 2;
    }
    len += 2;
  } else if (buf & 0x1000) {
    if (olen >= 1)
      *out++ = buf >> 4;
    len++;
  }
  return (len);
}


x86 assembly (clang, -O0):
<xmlDecodeBase64>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
movq   $0x1,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x24(%rbp)
cmp    $0x0,%eax
jbe    1249 <xmlDecodeBase64+0x149>
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x20(%rbp)
movzbl (%rax),%eax
lea    0xeb2(%rip),%rcx
movzbl (%rax,%rcx,1),%ecx
mov    %ecx,-0x3c(%rbp)
mov    %cl,%al
sub    $0x40,%ecx
mov    %al,-0x35(%rbp)
je     1196 <xmlDecodeBase64+0x96>
jmp    1168 <xmlDecodeBase64+0x68>
mov    -0x3c(%rbp),%eax
sub    $0x41,%eax
je     119b <xmlDecodeBase64+0x9b>
jmp    1179 <xmlDecodeBase64+0x79>
mov    -0x3c(%rbp),%eax
sub    $0x42,%eax
jne    11a7 <xmlDecodeBase64+0xa7>
jmp    118a <xmlDecodeBase64+0x8a>
movl   $0xffffffff,-0x4(%rbp)
jmp    12f8 <xmlDecodeBase64+0x1f8>
jmp    1121 <xmlDecodeBase64+0x21>
movl   $0x0,-0x24(%rbp)
jmp    1244 <xmlDecodeBase64+0x144>
mov    -0x30(%rbp),%rax
shl    $0x6,%rax
movzbl -0x35(%rbp),%ecx
or     %rcx,%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
and    $0x1000000,%rax
cmp    $0x0,%rax
je     123f <xmlDecodeBase64+0x13f>
cmpl   $0x3,-0x14(%rbp)
jb     122e <xmlDecodeBase64+0x12e>
mov    -0x30(%rbp),%rax
shr    $0x10,%rax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x10(%rbp)
mov    %cl,(%rax)
mov    -0x30(%rbp),%rax
shr    $0x8,%rax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x10(%rbp)
mov    %cl,(%rax)
mov    -0x30(%rbp),%rax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x10(%rbp)
mov    %cl,(%rax)
mov    -0x14(%rbp),%eax
sub    $0x3,%eax
mov    %eax,-0x14(%rbp)
mov    -0x34(%rbp),%eax
add    $0x3,%eax
mov    %eax,-0x34(%rbp)
movq   $0x1,-0x30(%rbp)
jmp    1244 <xmlDecodeBase64+0x144>
jmp    1121 <xmlDecodeBase64+0x21>
mov    -0x30(%rbp),%rax
and    $0x40000,%rax
cmp    $0x0,%rax
je     12ab <xmlDecodeBase64+0x1ab>
cmpl   $0x2,-0x14(%rbp)
jb     129d <xmlDecodeBase64+0x19d>
mov    -0x30(%rbp),%rax
shr    $0xa,%rax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x10(%rbp)
mov    %cl,(%rax)
mov    -0x30(%rbp),%rax
shr    $0x2,%rax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x10(%rbp)
mov    %cl,(%rax)
mov    -0x34(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x34(%rbp)
jmp    12f2 <xmlDecodeBase64+0x1f2>
mov    -0x30(%rbp),%rax
and    $0x1000,%rax
cmp    $0x0,%rax
je     12ed <xmlDecodeBase64+0x1ed>
cmpl   $0x1,-0x14(%rbp)
jb     12e4 <xmlDecodeBase64+0x1e4>
mov    -0x30(%rbp),%rax
shr    $0x4,%rax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x10(%rbp)
mov    %cl,(%rax)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    12f2 <xmlDecodeBase64+0x1f2>
mov    -0x34(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<xmlDecodeBase64>:
push   %rbx
test   %ecx,%ecx
je     11ae <xmlDecodeBase64+0xae>
mov    $0x1,%r9d
xor    %r11d,%r11d
lea    0xee7(%rip),%r8
jmp    112a <xmlDecodeBase64+0x2a>
nopl   0x0(%rax,%rax,1)
xor    %ecx,%ecx
add    $0x1,%rdx
test   %ecx,%ecx
je     118b <xmlDecodeBase64+0x8b>
add    $0xffffffff,%ecx
movzbl (%rdx),%ebx
movzbl (%rbx,%r8,1),%r10d
cmp    $0x40,%r10
je     1122 <xmlDecodeBase64+0x22>
cmp    $0x41,%r10b
je     1120 <xmlDecodeBase64+0x20>
cmp    $0x42,%r10b
je     11cf <xmlDecodeBase64+0xcf>
mov    %r9,%rax
shl    $0x6,%rax
or     %rax,%r10
test   $0x40000,%r9d
jne    1163 <xmlDecodeBase64+0x63>
mov    %r10,%r9
jmp    1122 <xmlDecodeBase64+0x22>
cmp    $0x3,%esi
jb     117f <xmlDecodeBase64+0x7f>
mov    %rax,%rbx
shr    $0x10,%rbx
mov    %bl,(%rdi)
mov    %ah,0x1(%rdi)
mov    %r10b,0x2(%rdi)
add    $0x3,%rdi
add    $0xfffffffd,%esi
add    $0x3,%r11d
mov    $0x1,%r9d
jmp    1122 <xmlDecodeBase64+0x22>
test   $0x40000,%r9d
jne    11b3 <xmlDecodeBase64+0xb3>
test   $0x1000,%r9d
je     11d5 <xmlDecodeBase64+0xd5>
test   %esi,%esi
je     11a8 <xmlDecodeBase64+0xa8>
shr    $0x4,%r9
mov    %r9b,(%rdi)
add    $0x1,%r11d
jmp    11d5 <xmlDecodeBase64+0xd5>
xor    %r11d,%r11d
jmp    11d5 <xmlDecodeBase64+0xd5>
cmp    $0x2,%esi
jb     11c9 <xmlDecodeBase64+0xc9>
mov    %r9,%rax
shr    $0xa,%rax
mov    %al,(%rdi)
shr    $0x2,%r9
mov    %r9b,0x1(%rdi)
add    $0x2,%r11d
jmp    11d5 <xmlDecodeBase64+0xd5>
mov    $0xffffffff,%r11d
mov    %r11d,%eax
pop    %rbx
ret

LLVM IR (-O0):
@xmlDecodeBase64.b64 = internal constant [256 x i8] c"BBBBBBBBB@@BB@BBBBBBBBBBBBBBBBBB@BBBBBBBBBB>BBB?456789:;<=BBBABBB\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\19BBBBBB\1A\1B\1C\1D\1E\1F !\22#$%&'()*+,-./0123BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"
define i32 @xmlDecodeBase64(i8* %0, i32 %1, i8* %2, i32 %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i64
%11 = alloca i32
%12 = alloca i8
store i8* %0, i8** %6
store i32 %1, i32* %7
store i8* %2, i8** %8
store i32 %3, i32* %9
store i64 1, i64* %10
store i32 0, i32* %11
br label %13
13: ; preds = %61, %26, %4
%14 = load i32, i32* %9
%15 = add i32 %14, -1
store i32 %15, i32* %9
%16 = icmp ugt i32 %14, 0
br i1 %16, label %17, label %62
17: ; preds = %13
%18 = load i8*, i8** %8
%19 = getelementptr inbounds i8, i8* %18, i32 1
store i8* %19, i8** %8
%20 = load i8, i8* %18
%21 = zext i8 %20 to i64
%22 = getelementptr inbounds [256 x i8], [256 x i8]* @xmlDecodeBase64.b64, i64 0, i64 %21
%23 = load i8, i8* %22
store i8 %23, i8* %12
%24 = zext i8 %23 to i32
switch i32 %24, label %28 [
i32 66, label %25
i32 64, label %26
i32 65, label %27
]
25: ; preds = %17
store i32 -1, i32* %5
br label %102
26: ; preds = %17
br label %13
27: ; preds = %17
store i32 0, i32* %9
br label %61
28: ; preds = %17
%29 = load i64, i64* %10
%30 = shl i64 %29, 6
%31 = load i8, i8* %12
%32 = zext i8 %31 to i64
%33 = or i64 %30, %32
store i64 %33, i64* %10
%34 = load i64, i64* %10
%35 = and i64 %34, 16777216
%36 = icmp ne i64 %35, 0
br i1 %36, label %37, label %60
37: ; preds = %28
%38 = load i32, i32* %7
%39 = icmp uge i32 %38, 3
br i1 %39, label %40, label %57
40: ; preds = %37
%41 = load i64, i64* %10
%42 = lshr i64 %41, 16
%43 = trunc i64 %42 to i8
%44 = load i8*, i8** %6
%45 = getelementptr inbounds i8, i8* %44, i32 1
store i8* %45, i8** %6
store i8 %43, i8* %44
%46 = load i64, i64* %10
%47 = lshr i64 %46, 8
%48 = trunc i64 %47 to i8
%49 = load i8*, i8** %6
%50 = getelementptr inbounds i8, i8* %49, i32 1
store i8* %50, i8** %6
store i8 %48, i8* %49
%51 = load i64, i64* %10
%52 = trunc i64 %51 to i8
%53 = load i8*, i8** %6
%54 = getelementptr inbounds i8, i8* %53, i32 1
store i8* %54, i8** %6
store i8 %52, i8* %53
%55 = load i32, i32* %7
%56 = sub i32 %55, 3
store i32 %56, i32* %7
br label %57
57: ; preds = %40, %37
%58 = load i32, i32* %11
%59 = add nsw i32 %58, 3
store i32 %59, i32* %11
store i64 1, i64* %10
br label %60
60: ; preds = %57, %28
br label %61
61: ; preds = %60, %27
br label %13
62: ; preds = %13
%63 = load i64, i64* %10
%64 = and i64 %63, 262144
%65 = icmp ne i64 %64, 0
br i1 %65, label %66, label %83
66: ; preds = %62
%67 = load i32, i32* %7
%68 = icmp uge i32 %67, 2
br i1 %68, label %69, label %80
69: ; preds = %66
%70 = load i64, i64* %10
%71 = lshr i64 %70, 10
%72 = trunc i64 %71 to i8
%73 = load i8*, i8** %6
%74 = getelementptr inbounds i8, i8* %73, i32 1
store i8* %74, i8** %6
store i8 %72, i8* %73
%75 = load i64, i64* %10
%76 = lshr i64 %75, 2
%77 = trunc i64 %76 to i8
%78 = load i8*, i8** %6
%79 = getelementptr inbounds i8, i8* %78, i32 1
store i8* %79, i8** %6
store i8 %77, i8* %78
br label %80
80: ; preds = %69, %66
%81 = load i32, i32* %11
%82 = add nsw i32 %81, 2
store i32 %82, i32* %11
br label %100
83: ; preds = %62
%84 = load i64, i64* %10
%85 = and i64 %84, 4096
%86 = icmp ne i64 %85, 0
br i1 %86, label %87, label %99
87: ; preds = %83
%88 = load i32, i32* %7
%89 = icmp uge i32 %88, 1
br i1 %89, label %90, label %96
90: ; preds = %87
%91 = load i64, i64* %10
%92 = lshr i64 %91, 4
%93 = trunc i64 %92 to i8
%94 = load i8*, i8** %6
%95 = getelementptr inbounds i8, i8* %94, i32 1
store i8* %95, i8** %6
store i8 %93, i8* %94
br label %96
96: ; preds = %90, %87
%97 = load i32, i32* %11
%98 = add nsw i32 %97, 1
store i32 %98, i32* %11
br label %99
99: ; preds = %96, %83
br label %100
100: ; preds = %99, %80
%101 = load i32, i32* %11
store i32 %101, i32* %5
br label %102
102: ; preds = %100, %25
%103 = load i32, i32* %5
ret i32 %103
}

LLVM IR (-O2):
@xmlDecodeBase64.b64 = internal unnamed_addr constant [256 x i8] c"BBBBBBBBB@@BB@BBBBBBBBBBBBBBBBBB@BBBBBBBBBB>BBB?456789:;<=BBBABBB\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\19BBBBBB\1A\1B\1C\1D\1E\1F !\22#$%&'()*+,-./0123BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"
define i32 @xmlDecodeBase64(i8* nocapture writeonly %0, i32 %1, i8* nocapture %2, i32 %3) {
%5 = icmp eq i32 %3, 0
br i1 %5, label %77, label %6
6: ; preds = %4, %47
%7 = phi i32 [ %50, %47 ], [ %3, %4 ]
%8 = phi i32 [ %52, %47 ], [ 0, %4 ]
%9 = phi i64 [ %51, %47 ], [ 1, %4 ]
%10 = phi i8* [ %14, %47 ], [ %2, %4 ]
%11 = phi i32 [ %49, %47 ], [ %1, %4 ]
%12 = phi i8* [ %48, %47 ], [ %0, %4 ]
%13 = add i32 %7, -1
%14 = getelementptr inbounds i8, i8* %10, i64 1
%15 = load i8, i8* %10
%16 = zext i8 %15 to i64
%17 = getelementptr inbounds [256 x i8], [256 x i8]* @xmlDecodeBase64.b64, i64 0, i64 %16
%18 = load i8, i8* %17
switch i8 %18, label %19 [
i8 66, label %77
i8 64, label %47
i8 65, label %41
]
19: ; preds = %6
%20 = shl i64 %9, 6
%21 = zext i8 %18 to i64
%22 = or i64 %20, %21
%23 = and i64 %9, 262144
%24 = icmp eq i64 %23, 0
br i1 %24, label %41, label %25
25: ; preds = %19
%26 = icmp ugt i32 %11, 2
br i1 %26, label %27, label %37
27: ; preds = %25
%28 = lshr i64 %20, 16
%29 = trunc i64 %28 to i8
%30 = getelementptr inbounds i8, i8* %12, i64 1
store i8 %29, i8* %12
%31 = lshr i64 %20, 8
%32 = trunc i64 %31 to i8
%33 = getelementptr inbounds i8, i8* %12, i64 2
store i8 %32, i8* %30
%34 = trunc i64 %22 to i8
%35 = getelementptr inbounds i8, i8* %12, i64 3
store i8 %34, i8* %33
%36 = add i32 %11, -3
br label %37
37: ; preds = %27, %25
%38 = phi i8* [ %35, %27 ], [ %12, %25 ]
%39 = phi i32 [ %36, %27 ], [ %11, %25 ]
%40 = add nsw i32 %8, 3
br label %41
41: ; preds = %6, %19, %37
%42 = phi i8* [ %38, %37 ], [ %12, %19 ], [ %12, %6 ]
%43 = phi i32 [ %39, %37 ], [ %11, %19 ], [ %11, %6 ]
%44 = phi i32 [ %13, %37 ], [ %13, %19 ], [ 0, %6 ]
%45 = phi i64 [ 1, %37 ], [ %22, %19 ], [ %9, %6 ]
%46 = phi i32 [ %40, %37 ], [ %8, %19 ], [ %8, %6 ]
br label %47
47: ; preds = %6, %41
%48 = phi i8* [ %42, %41 ], [ %12, %6 ]
%49 = phi i32 [ %43, %41 ], [ %11, %6 ]
%50 = phi i32 [ %44, %41 ], [ %13, %6 ]
%51 = phi i64 [ %45, %41 ], [ %9, %6 ]
%52 = phi i32 [ %46, %41 ], [ %8, %6 ]
%53 = icmp eq i32 %50, 0
br i1 %53, label %54, label %6
54: ; preds = %47
%55 = and i64 %51, 262144
%56 = icmp eq i64 %55, 0
br i1 %56, label %67, label %57
57: ; preds = %54
%58 = icmp ugt i32 %49, 1
br i1 %58, label %59, label %65
59: ; preds = %57
%60 = lshr i64 %51, 10
%61 = trunc i64 %60 to i8
%62 = getelementptr inbounds i8, i8* %48, i64 1
store i8 %61, i8* %48
%63 = lshr i64 %51, 2
%64 = trunc i64 %63 to i8
store i8 %64, i8* %62
br label %65
65: ; preds = %59, %57
%66 = add nsw i32 %52, 2
br label %77
67: ; preds = %54
%68 = and i64 %51, 4096
%69 = icmp eq i64 %68, 0
br i1 %69, label %77, label %70
70: ; preds = %67
%71 = icmp eq i32 %49, 0
br i1 %71, label %75, label %72
72: ; preds = %70
%73 = lshr i64 %51, 4
%74 = trunc i64 %73 to i8
store i8 %74, i8* %48
br label %75
75: ; preds = %72, %70
%76 = add nsw i32 %52, 1
br label %77
77: ; preds = %6, %4, %65, %75, %67
%78 = phi i32 [ %66, %65 ], [ %76, %75 ], [ %52, %67 ], [ 0, %4 ], [ -1, %6 ]
ret i32 %78
}