#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
unsigned char *malloc(int);
unsigned char *base64_decode(unsigned char *code, long len) {
  int table[] = {0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
                 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
                 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  62, 0,  0,  0,  63,
                 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 0,  0,  0,  0,  0,  0,
                 0,  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, 0,  0,  0,  0,  0,
                 0,  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};
  long str_len;
  unsigned char *res;
  int i, j;
  str_len = len / 4 * 3;
  res = malloc(sizeof(unsigned char) * (str_len + 1));
  for (i = 0, j = 0; i < len - 2; j += 3, i += 4) {
    res[j] = ((unsigned char)table[code[i]]) << 2 |
             (((unsigned char)table[code[i + 1]]) >> 4);
    res[j + 1] = (((unsigned char)table[code[i + 1]]) << 4) |
                 (((unsigned char)table[code[i + 2]]) >> 2);
    res[j + 2] = (((unsigned char)table[code[i + 2]]) << 6) |
                 ((unsigned char)table[code[i + 3]]);
  }
  res[str_len] = '\0';
  return res;
}


x86 assembly (clang, -O0):
<base64_decode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x220,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x200(%rbp),%rdi
lea    0xebf(%rip),%rsi
mov    $0x1ec,%edx
call   1030 <memcpy@plt>
mov    -0x10(%rbp),%rax
mov    $0x4,%ecx
cqto
idiv   %rcx
imul   $0x3,%rax,%rax
mov    %rax,-0x208(%rbp)
mov    -0x208(%rbp),%rax
add    $0x1,%rax
shl    $0x0,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x210(%rbp)
movl   $0x0,-0x214(%rbp)
movl   $0x0,-0x218(%rbp)
movslq -0x214(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    $0x2,%rcx
cmp    %rcx,%rax
jge    12d7 <base64_decode+0x1b7>
mov    -0x8(%rbp),%rax
movslq -0x214(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
mov    -0x200(%rbp,%rax,4),%eax
movzbl %al,%eax
shl    $0x2,%eax
mov    -0x8(%rbp),%rcx
mov    -0x214(%rbp),%edx
add    $0x1,%edx
movslq %edx,%rdx
movzbl (%rcx,%rdx,1),%ecx
mov    -0x200(%rbp,%rcx,4),%ecx
movzbl %cl,%ecx
sar    $0x4,%ecx
or     %ecx,%eax
mov    %al,%dl
mov    -0x210(%rbp),%rax
movslq -0x218(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x8(%rbp),%rax
mov    -0x214(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movzbl (%rax,%rcx,1),%eax
mov    -0x200(%rbp,%rax,4),%eax
movzbl %al,%eax
shl    $0x4,%eax
mov    -0x8(%rbp),%rcx
mov    -0x214(%rbp),%edx
add    $0x2,%edx
movslq %edx,%rdx
movzbl (%rcx,%rdx,1),%ecx
mov    -0x200(%rbp,%rcx,4),%ecx
movzbl %cl,%ecx
sar    $0x2,%ecx
or     %ecx,%eax
mov    %al,%dl
mov    -0x210(%rbp),%rax
mov    -0x218(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x8(%rbp),%rax
mov    -0x214(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
movzbl (%rax,%rcx,1),%eax
mov    -0x200(%rbp,%rax,4),%eax
movzbl %al,%eax
shl    $0x6,%eax
mov    -0x8(%rbp),%rcx
mov    -0x214(%rbp),%edx
add    $0x3,%edx
movslq %edx,%rdx
movzbl (%rcx,%rdx,1),%ecx
mov    -0x200(%rbp,%rcx,4),%ecx
movzbl %cl,%ecx
or     %ecx,%eax
mov    %al,%dl
mov    -0x210(%rbp),%rax
mov    -0x218(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x218(%rbp),%eax
add    $0x3,%eax
mov    %eax,-0x218(%rbp)
mov    -0x214(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0x214(%rbp)
jmp    1195 <base64_decode+0x75>
mov    -0x210(%rbp),%rax
mov    -0x208(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x210(%rbp),%rax
add    $0x220,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<base64_decode>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
lea    0x3(%rsi),%rax
test   %rsi,%rsi
cmovns %rsi,%rax
mov    %rdi,%r12
sar    $0x2,%rax
lea    (%rax,%rax,2),%r15
lea    0x1(%r15),%edi
call   1030 <malloc@plt>
cmp    $0x3,%r14
jl     11bc <base64_decode+0xac>
add    $0xfffffffffffffffe,%r14
mov    %rax,%rcx
add    $0x2,%rcx
xor    %edx,%edx
lea    0xeac(%rip),%r8
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movzbl (%r12,%rdx,1),%edi
mov    (%r8,%rdi,4),%edi
shl    $0x2,%edi
movzbl 0x1(%r12,%rdx,1),%esi
mov    (%r8,%rsi,4),%ebx
mov    %ebx,%esi
shr    $0x4,%esi
and    $0xf,%esi
or     %edi,%esi
mov    %sil,-0x2(%rcx)
shl    $0x4,%ebx
movzbl 0x2(%r12,%rdx,1),%esi
mov    (%r8,%rsi,4),%esi
mov    %esi,%edi
shr    $0x2,%edi
and    $0x3f,%edi
or     %ebx,%edi
mov    %dil,-0x1(%rcx)
shl    $0x6,%esi
movzbl 0x3(%r12,%rdx,1),%edi
or     (%r8,%rdi,4),%esi
mov    %sil,(%rcx)
add    $0x4,%rdx
add    $0x3,%rcx
cmp    %rdx,%r14
jg     1160 <base64_decode+0x50>
movb   $0x0,(%rax,%r15,1)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.base64_decode.table = [123 x i32] [i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 62, i32 0, i32 0, i32 0, i32 63, i32 52, i32 53, i32 54, i32 55, i32 56, i32 57, i32 58, i32 59, i32 60, i32 61, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 16, i32 17, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23, i32 24, i32 25, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 26, i32 27, i32 28, i32 29, i32 30, i32 31, i32 32, i32 33, i32 34, i32 35, i32 36, i32 37, i32 38, i32 39, i32 40, i32 41, i32 42, i32 43, i32 44, i32 45, i32 46, i32 47, i32 48, i32 49, i32 50, i32 51]
define i8* @base64_decode(i8* %0, i64 %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = alloca [123 x i32]
%6 = alloca i64
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
store i8* %0, i8** %3
store i64 %1, i64* %4
%10 = bitcast [123 x i32]* %5 to i8*
%11 = load i64, i64* %4
%12 = sdiv i64 %11, 4
%13 = mul nsw i64 %12, 3
store i64 %13, i64* %6
%14 = load i64, i64* %6
%15 = add nsw i64 %14, 1
%16 = mul i64 1, %15
%17 = trunc i64 %16 to i32
%18 = call i8* @malloc(i32 %17)
store i8* %18, i8** %7
store i32 0, i32* %8
store i32 0, i32* %9
br label %19
19: ; preds = %116, %2
%20 = load i32, i32* %8
%21 = sext i32 %20 to i64
%22 = load i64, i64* %4
%23 = sub nsw i64 %22, 2
%24 = icmp slt i64 %21, %23
br i1 %24, label %25, label %121
25: ; preds = %19
%26 = load i8*, i8** %3
%27 = load i32, i32* %8
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8, i8* %26, i64 %28
%30 = load i8, i8* %29
%31 = zext i8 %30 to i64
%32 = getelementptr inbounds [123 x i32], [123 x i32]* %5, i64 0, i64 %31
%33 = load i32, i32* %32
%34 = trunc i32 %33 to i8
%35 = zext i8 %34 to i32
%36 = shl i32 %35, 2
%37 = load i8*, i8** %3
%38 = load i32, i32* %8
%39 = add nsw i32 %38, 1
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i8, i8* %37, i64 %40
%42 = load i8, i8* %41
%43 = zext i8 %42 to i64
%44 = getelementptr inbounds [123 x i32], [123 x i32]* %5, i64 0, i64 %43
%45 = load i32, i32* %44
%46 = trunc i32 %45 to i8
%47 = zext i8 %46 to i32
%48 = ashr i32 %47, 4
%49 = or i32 %36, %48
%50 = trunc i32 %49 to i8
%51 = load i8*, i8** %7
%52 = load i32, i32* %9
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds i8, i8* %51, i64 %53
store i8 %50, i8* %54
%55 = load i8*, i8** %3
%56 = load i32, i32* %8
%57 = add nsw i32 %56, 1
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds i8, i8* %55, i64 %58
%60 = load i8, i8* %59
%61 = zext i8 %60 to i64
%62 = getelementptr inbounds [123 x i32], [123 x i32]* %5, i64 0, i64 %61
%63 = load i32, i32* %62
%64 = trunc i32 %63 to i8
%65 = zext i8 %64 to i32
%66 = shl i32 %65, 4
%67 = load i8*, i8** %3
%68 = load i32, i32* %8
%69 = add nsw i32 %68, 2
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds i8, i8* %67, i64 %70
%72 = load i8, i8* %71
%73 = zext i8 %72 to i64
%74 = getelementptr inbounds [123 x i32], [123 x i32]* %5, i64 0, i64 %73
%75 = load i32, i32* %74
%76 = trunc i32 %75 to i8
%77 = zext i8 %76 to i32
%78 = ashr i32 %77, 2
%79 = or i32 %66, %78
%80 = trunc i32 %79 to i8
%81 = load i8*, i8** %7
%82 = load i32, i32* %9
%83 = add nsw i32 %82, 1
%84 = sext i32 %83 to i64
%85 = getelementptr inbounds i8, i8* %81, i64 %84
store i8 %80, i8* %85
%86 = load i8*, i8** %3
%87 = load i32, i32* %8
%88 = add nsw i32 %87, 2
%89 = sext i32 %88 to i64
%90 = getelementptr inbounds i8, i8* %86, i64 %89
%91 = load i8, i8* %90
%92 = zext i8 %91 to i64
%93 = getelementptr inbounds [123 x i32], [123 x i32]* %5, i64 0, i64 %92
%94 = load i32, i32* %93
%95 = trunc i32 %94 to i8
%96 = zext i8 %95 to i32
%97 = shl i32 %96, 6
%98 = load i8*, i8** %3
%99 = load i32, i32* %8
%100 = add nsw i32 %99, 3
%101 = sext i32 %100 to i64
%102 = getelementptr inbounds i8, i8* %98, i64 %101
%103 = load i8, i8* %102
%104 = zext i8 %103 to i64
%105 = getelementptr inbounds [123 x i32], [123 x i32]* %5, i64 0, i64 %104
%106 = load i32, i32* %105
%107 = trunc i32 %106 to i8
%108 = zext i8 %107 to i32
%109 = or i32 %97, %108
%110 = trunc i32 %109 to i8
%111 = load i8*, i8** %7
%112 = load i32, i32* %9
%113 = add nsw i32 %112, 2
%114 = sext i32 %113 to i64
%115 = getelementptr inbounds i8, i8* %111, i64 %114
store i8 %110, i8* %115
br label %116
116: ; preds = %25
%117 = load i32, i32* %9
%118 = add nsw i32 %117, 3
store i32 %118, i32* %9
%119 = load i32, i32* %8
%120 = add nsw i32 %119, 4
store i32 %120, i32* %8
br label %19
121: ; preds = %19
%122 = load i8*, i8** %7
%123 = load i64, i64* %6
%124 = getelementptr inbounds i8, i8* %122, i64 %123
store i8 0, i8* %124
%125 = load i8*, i8** %7
ret i8* %125
}

LLVM IR (-O2):
@__const.base64_decode.table = [123 x i32] [i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 62, i32 0, i32 0, i32 0, i32 63, i32 52, i32 53, i32 54, i32 55, i32 56, i32 57, i32 58, i32 59, i32 60, i32 61, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 16, i32 17, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23, i32 24, i32 25, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 26, i32 27, i32 28, i32 29, i32 30, i32 31, i32 32, i32 33, i32 34, i32 35, i32 36, i32 37, i32 38, i32 39, i32 40, i32 41, i32 42, i32 43, i32 44, i32 45, i32 46, i32 47, i32 48, i32 49, i32 50, i32 51]
define noalias i8* @base64_decode(i8* nocapture %0, i64 %1) {
%3 = sdiv i64 %1, 4
%4 = mul nsw i64 %3, 3
%5 = trunc i64 %4 to i32
%6 = add i32 %5, 1
%7 = tail call i8* @malloc(i32 %6)
%8 = add nsw i64 %1, -2
%9 = icmp sgt i64 %1, 2
br i1 %9, label %10, label %57
10: ; preds = %2, %10
%11 = phi i64 [ %55, %10 ], [ 0, %2 ]
%12 = phi i64 [ %54, %10 ], [ 0, %2 ]
%13 = getelementptr inbounds i8, i8* %0, i64 %11
%14 = load i8, i8* %13
%15 = zext i8 %14 to i64
%16 = getelementptr inbounds [123 x i32], [123 x i32]* @__const.base64_decode.table, i64 0, i64 %15
%17 = load i32, i32* %16
%18 = shl i32 %17, 2
%19 = or i64 %11, 1
%20 = getelementptr inbounds i8, i8* %0, i64 %19
%21 = load i8, i8* %20
%22 = zext i8 %21 to i64
%23 = getelementptr inbounds [123 x i32], [123 x i32]* @__const.base64_decode.table, i64 0, i64 %22
%24 = load i32, i32* %23
%25 = lshr i32 %24, 4
%26 = and i32 %25, 15
%27 = or i32 %26, %18
%28 = trunc i32 %27 to i8
%29 = getelementptr inbounds i8, i8* %7, i64 %12
store i8 %28, i8* %29
%30 = shl i32 %24, 4
%31 = or i64 %11, 2
%32 = getelementptr inbounds i8, i8* %0, i64 %31
%33 = load i8, i8* %32
%34 = zext i8 %33 to i64
%35 = getelementptr inbounds [123 x i32], [123 x i32]* @__const.base64_decode.table, i64 0, i64 %34
%36 = load i32, i32* %35
%37 = lshr i32 %36, 2
%38 = and i32 %37, 63
%39 = or i32 %38, %30
%40 = trunc i32 %39 to i8
%41 = add nuw nsw i64 %12, 1
%42 = getelementptr inbounds i8, i8* %7, i64 %41
store i8 %40, i8* %42
%43 = shl i32 %36, 6
%44 = or i64 %11, 3
%45 = getelementptr inbounds i8, i8* %0, i64 %44
%46 = load i8, i8* %45
%47 = zext i8 %46 to i64
%48 = getelementptr inbounds [123 x i32], [123 x i32]* @__const.base64_decode.table, i64 0, i64 %47
%49 = load i32, i32* %48
%50 = or i32 %49, %43
%51 = trunc i32 %50 to i8
%52 = add nuw nsw i64 %12, 2
%53 = getelementptr inbounds i8, i8* %7, i64 %52
store i8 %51, i8* %53
%54 = add nuw nsw i64 %12, 3
%55 = add nuw nsw i64 %11, 4
%56 = icmp sgt i64 %8, %55
br i1 %56, label %10, label %57
57: ; preds = %10, %2
%58 = getelementptr inbounds i8, i8* %7, i64 %4
store i8 0, i8* %58
ret i8* %7
}