#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);
long strlen(unsigned char *);
scalar_t__ strstr(unsigned char *, char *);
unsigned char *base64_decode(unsigned char *code) {
  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 len;
  long str_len;
  unsigned char *res;
  int i, j;
  len = strlen(code);
  if (strstr(code, "=="))
    str_len = len / 4 * 3 - 2;
  else if (strstr(code, "="))
    str_len = len / 4 * 3 - 1;
  else
    str_len = len / 4;
  res = malloc(sizeof(unsigned char) * str_len + 1);
  res[str_len] = '\0';
  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]]);
  }
  return res;
}


x86 assembly (clang, -O0):
<base64_decode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x220,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x200(%rbp),%rdi
lea    0xea3(%rip),%rsi
mov    $0x1ec,%edx
call   1040 <memcpy@plt>
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x208(%rbp)
mov    -0x8(%rbp),%rdi
lea    0x106a(%rip),%rsi
call   1060 <strstr@plt>
cmp    $0x0,%rax
je     11b6 <base64_decode+0x76>
mov    -0x208(%rbp),%rax
mov    $0x4,%ecx
cqto
idiv   %rcx
imul   $0x3,%rax,%rax
sub    $0x2,%rax
mov    %rax,-0x210(%rbp)
jmp    1212 <base64_decode+0xd2>
mov    -0x8(%rbp),%rdi
lea    0x102c(%rip),%rsi
call   1060 <strstr@plt>
cmp    $0x0,%rax
je     11f5 <base64_decode+0xb5>
mov    -0x208(%rbp),%rax
mov    $0x4,%ecx
cqto
idiv   %rcx
imul   $0x3,%rax,%rax
sub    $0x1,%rax
mov    %rax,-0x210(%rbp)
jmp    120d <base64_decode+0xcd>
mov    -0x208(%rbp),%rax
mov    $0x4,%ecx
cqto
idiv   %rcx
mov    %rax,-0x210(%rbp)
jmp    1212 <base64_decode+0xd2>
mov    -0x210(%rbp),%rax
shl    $0x0,%rax
add    $0x1,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x218(%rbp)
mov    -0x218(%rbp),%rax
mov    -0x210(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
movl   $0x0,-0x21c(%rbp)
movl   $0x0,-0x220(%rbp)
movslq -0x21c(%rbp),%rax
mov    -0x208(%rbp),%rcx
sub    $0x2,%rcx
cmp    %rcx,%rax
jge    139a <base64_decode+0x25a>
mov    -0x8(%rbp),%rax
movslq -0x21c(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
mov    -0x200(%rbp,%rax,4),%eax
movzbl %al,%eax
shl    $0x2,%eax
mov    -0x8(%rbp),%rcx
mov    -0x21c(%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    -0x218(%rbp),%rax
movslq -0x220(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x8(%rbp),%rax
mov    -0x21c(%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    -0x21c(%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    -0x218(%rbp),%rax
mov    -0x220(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x8(%rbp),%rax
mov    -0x21c(%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    -0x21c(%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    -0x218(%rbp),%rax
mov    -0x220(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x220(%rbp),%eax
add    $0x3,%eax
mov    %eax,-0x220(%rbp)
mov    -0x21c(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0x21c(%rbp)
jmp    1255 <base64_decode+0x115>
mov    -0x218(%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    %rdi,%r12
call   1030 <strlen@plt>
mov    %rax,%r14
lea    0x10a2(%rip),%rsi
mov    %r12,%rdi
call   1050 <strstr@plt>
test   %rax,%rax
je     1170 <base64_decode+0x40>
lea    0x3(%r14),%rax
test   %r14,%r14
cmovns %r14,%rax
sar    $0x2,%rax
lea    (%rax,%rax,2),%r15
add    $0xfffffffffffffffe,%r15
jmp    119b <base64_decode+0x6b>
lea    0x1076(%rip),%rsi
mov    %r12,%rdi
call   1050 <strstr@plt>
lea    0x3(%r14),%r15
test   %r14,%r14
cmovns %r14,%r15
sar    $0x2,%r15
test   %rax,%rax
je     119b <base64_decode+0x6b>
lea    (%r15,%r15,2),%r15
add    $0xffffffffffffffff,%r15
lea    0x1(%r15),%edi
call   1040 <malloc@plt>
movb   $0x0,(%rax,%r15,1)
cmp    $0x3,%r14
jl     122c <base64_decode+0xfc>
add    $0xfffffffffffffffe,%r14
mov    %rax,%rcx
add    $0x2,%rcx
xor    %edx,%edx
lea    0xe3d(%rip),%r8
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
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     11d0 <base64_decode+0xa0>
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]
@.str = [3 x i8] c"==\00"
@.str.1 = [2 x i8] c"=\00"
define i8* @base64_decode(i8* %0) {
%2 = alloca i8*
%3 = alloca [123 x i32]
%4 = alloca i64
%5 = alloca i64
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %2
%9 = bitcast [123 x i32]* %3 to i8*
%10 = load i8*, i8** %2
%11 = call i64 @strlen(i8* %10)
store i64 %11, i64* %4
%12 = load i8*, i8** %2
%13 = call i64 @strstr(i8* %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %20
15: ; preds = %1
%16 = load i64, i64* %4
%17 = sdiv i64 %16, 4
%18 = mul nsw i64 %17, 3
%19 = sub nsw i64 %18, 2
store i64 %19, i64* %5
br label %33
20: ; preds = %1
%21 = load i8*, i8** %2
%22 = call i64 @strstr(i8* %21, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%23 = icmp ne i64 %22, 0
br i1 %23, label %24, label %29
24: ; preds = %20
%25 = load i64, i64* %4
%26 = sdiv i64 %25, 4
%27 = mul nsw i64 %26, 3
%28 = sub nsw i64 %27, 1
store i64 %28, i64* %5
br label %32
29: ; preds = %20
%30 = load i64, i64* %4
%31 = sdiv i64 %30, 4
store i64 %31, i64* %5
br label %32
32: ; preds = %29, %24
br label %33
33: ; preds = %32, %15
%34 = load i64, i64* %5
%35 = mul i64 1, %34
%36 = add i64 %35, 1
%37 = trunc i64 %36 to i32
%38 = call i8* @malloc(i32 %37)
store i8* %38, i8** %6
%39 = load i8*, i8** %6
%40 = load i64, i64* %5
%41 = getelementptr inbounds i8, i8* %39, i64 %40
store i8 0, i8* %41
store i32 0, i32* %7
store i32 0, i32* %8
br label %42
42: ; preds = %139, %33
%43 = load i32, i32* %7
%44 = sext i32 %43 to i64
%45 = load i64, i64* %4
%46 = sub nsw i64 %45, 2
%47 = icmp slt i64 %44, %46
br i1 %47, label %48, label %144
48: ; preds = %42
%49 = load i8*, i8** %2
%50 = load i32, i32* %7
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds i8, i8* %49, i64 %51
%53 = load i8, i8* %52
%54 = zext i8 %53 to i64
%55 = getelementptr inbounds [123 x i32], [123 x i32]* %3, i64 0, i64 %54
%56 = load i32, i32* %55
%57 = trunc i32 %56 to i8
%58 = zext i8 %57 to i32
%59 = shl i32 %58, 2
%60 = load i8*, i8** %2
%61 = load i32, i32* %7
%62 = add nsw i32 %61, 1
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds i8, i8* %60, i64 %63
%65 = load i8, i8* %64
%66 = zext i8 %65 to i64
%67 = getelementptr inbounds [123 x i32], [123 x i32]* %3, i64 0, i64 %66
%68 = load i32, i32* %67
%69 = trunc i32 %68 to i8
%70 = zext i8 %69 to i32
%71 = ashr i32 %70, 4
%72 = or i32 %59, %71
%73 = trunc i32 %72 to i8
%74 = load i8*, i8** %6
%75 = load i32, i32* %8
%76 = sext i32 %75 to i64
%77 = getelementptr inbounds i8, i8* %74, i64 %76
store i8 %73, i8* %77
%78 = load i8*, i8** %2
%79 = load i32, i32* %7
%80 = add nsw i32 %79, 1
%81 = sext i32 %80 to i64
%82 = getelementptr inbounds i8, i8* %78, i64 %81
%83 = load i8, i8* %82
%84 = zext i8 %83 to i64
%85 = getelementptr inbounds [123 x i32], [123 x i32]* %3, i64 0, i64 %84
%86 = load i32, i32* %85
%87 = trunc i32 %86 to i8
%88 = zext i8 %87 to i32
%89 = shl i32 %88, 4
%90 = load i8*, i8** %2
%91 = load i32, i32* %7
%92 = add nsw i32 %91, 2
%93 = sext i32 %92 to i64
%94 = getelementptr inbounds i8, i8* %90, i64 %93
%95 = load i8, i8* %94
%96 = zext i8 %95 to i64
%97 = getelementptr inbounds [123 x i32], [123 x i32]* %3, i64 0, i64 %96
%98 = load i32, i32* %97
%99 = trunc i32 %98 to i8
%100 = zext i8 %99 to i32
%101 = ashr i32 %100, 2
%102 = or i32 %89, %101
%103 = trunc i32 %102 to i8
%104 = load i8*, i8** %6
%105 = load i32, i32* %8
%106 = add nsw i32 %105, 1
%107 = sext i32 %106 to i64
%108 = getelementptr inbounds i8, i8* %104, i64 %107
store i8 %103, i8* %108
%109 = load i8*, i8** %2
%110 = load i32, i32* %7
%111 = add nsw i32 %110, 2
%112 = sext i32 %111 to i64
%113 = getelementptr inbounds i8, i8* %109, i64 %112
%114 = load i8, i8* %113
%115 = zext i8 %114 to i64
%116 = getelementptr inbounds [123 x i32], [123 x i32]* %3, i64 0, i64 %115
%117 = load i32, i32* %116
%118 = trunc i32 %117 to i8
%119 = zext i8 %118 to i32
%120 = shl i32 %119, 6
%121 = load i8*, i8** %2
%122 = load i32, i32* %7
%123 = add nsw i32 %122, 3
%124 = sext i32 %123 to i64
%125 = getelementptr inbounds i8, i8* %121, i64 %124
%126 = load i8, i8* %125
%127 = zext i8 %126 to i64
%128 = getelementptr inbounds [123 x i32], [123 x i32]* %3, i64 0, i64 %127
%129 = load i32, i32* %128
%130 = trunc i32 %129 to i8
%131 = zext i8 %130 to i32
%132 = or i32 %120, %131
%133 = trunc i32 %132 to i8
%134 = load i8*, i8** %6
%135 = load i32, i32* %8
%136 = add nsw i32 %135, 2
%137 = sext i32 %136 to i64
%138 = getelementptr inbounds i8, i8* %134, i64 %137
store i8 %133, i8* %138
br label %139
139: ; preds = %48
%140 = load i32, i32* %8
%141 = add nsw i32 %140, 3
store i32 %141, i32* %8
%142 = load i32, i32* %7
%143 = add nsw i32 %142, 4
store i32 %143, i32* %7
br label %42
144: ; preds = %42
%145 = load i8*, i8** %6
ret i8* %145
}

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