#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 */
size_t qbase64_decode(char *str) {
  const char B64MAPTBL[16 * 16] = {
      64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
      64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
      64, 64, 64, 64, 64, 64, 64, 62, 64, 64, 64, 63, 52, 53, 54, 55, 56, 57,
      58, 59, 60, 61, 64, 64, 64, 64, 64, 64, 64, 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, 64, 64, 64, 64, 64, 64, 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, 64, 64, 64,
      64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
      64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
      64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
      64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
      64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
      64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
      64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
      64, 64, 64, 64};
  char *pEncPt, *pBinPt = str;
  int nIdxOfFour = 0;
  char cLastByte = 0;
  for (pEncPt = str; *pEncPt != '\0'; pEncPt++) {
    char cByte = B64MAPTBL[(unsigned char)(*pEncPt)];
    if (cByte == 64)
      continue;
    if (nIdxOfFour == 0) {
      nIdxOfFour++;
    } else if (nIdxOfFour == 1) {
      *pBinPt++ = ((cLastByte << 2) | (cByte >> 4));
      nIdxOfFour++;
    } else if (nIdxOfFour == 2) {
      *pBinPt++ = ((cLastByte << 4) | (cByte >> 2));
      nIdxOfFour++;
    } else {
      *pBinPt++ = ((cLastByte << 6) | cByte);
      nIdxOfFour = 0;
    }
    cLastByte = cByte;
  }
  *pBinPt = '\0';
  return (pBinPt - str);
}


x86 assembly (clang, -O0):
<qbase64_decode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x110(%rbp),%rdi
lea    0xed3(%rip),%rsi
mov    $0x100,%edx
call   1030 <memcpy@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x120(%rbp)
movl   $0x0,-0x124(%rbp)
movb   $0x0,-0x125(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x118(%rbp)
mov    -0x118(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     12c1 <qbase64_decode+0x1b1>
mov    -0x118(%rbp),%rax
movzbl (%rax),%eax
mov    -0x110(%rbp,%rax,1),%al
mov    %al,-0x126(%rbp)
movsbl -0x126(%rbp),%eax
cmp    $0x40,%eax
jne    119d <qbase64_decode+0x8d>
jmp    12aa <qbase64_decode+0x19a>
cmpl   $0x0,-0x124(%rbp)
jne    11be <qbase64_decode+0xae>
mov    -0x124(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x124(%rbp)
jmp    129e <qbase64_decode+0x18e>
cmpl   $0x1,-0x124(%rbp)
jne    120e <qbase64_decode+0xfe>
movsbl -0x125(%rbp),%eax
shl    $0x2,%eax
movsbl -0x126(%rbp),%ecx
sar    $0x4,%ecx
or     %ecx,%eax
mov    %al,%cl
mov    -0x120(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x120(%rbp)
mov    %cl,(%rax)
mov    -0x124(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x124(%rbp)
jmp    1299 <qbase64_decode+0x189>
cmpl   $0x2,-0x124(%rbp)
jne    125e <qbase64_decode+0x14e>
movsbl -0x125(%rbp),%eax
shl    $0x4,%eax
movsbl -0x126(%rbp),%ecx
sar    $0x2,%ecx
or     %ecx,%eax
mov    %al,%cl
mov    -0x120(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x120(%rbp)
mov    %cl,(%rax)
mov    -0x124(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x124(%rbp)
jmp    1294 <qbase64_decode+0x184>
movsbl -0x125(%rbp),%eax
shl    $0x6,%eax
movsbl -0x126(%rbp),%ecx
or     %ecx,%eax
mov    %al,%cl
mov    -0x120(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x120(%rbp)
mov    %cl,(%rax)
movl   $0x0,-0x124(%rbp)
jmp    1299 <qbase64_decode+0x189>
jmp    129e <qbase64_decode+0x18e>
mov    -0x126(%rbp),%al
mov    %al,-0x125(%rbp)
mov    -0x118(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x118(%rbp)
jmp    115e <qbase64_decode+0x4e>
mov    -0x120(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x120(%rbp),%rax
mov    -0x8(%rbp),%rcx
sub    %rcx,%rax
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<qbase64_decode>:
mov    (%rdi),%dl
mov    %rdi,%rax
test   %dl,%dl
je     11a6 <qbase64_decode+0xa6>
lea    0x1(%rdi),%rcx
xor    %esi,%esi
lea    0xee6(%rip),%r8
xor    %r9d,%r9d
mov    %rdi,%rax
jmp    1141 <qbase64_decode+0x41>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %esi,%r10d
movzbl (%rcx),%edx
add    $0x1,%rcx
mov    %r10d,%esi
test   %dl,%dl
je     11a6 <qbase64_decode+0xa6>
movzbl %dl,%edx
movzbl (%rdx,%r8,1),%r10d
cmp    $0x40,%r10b
je     1130 <qbase64_decode+0x30>
test   %r9d,%r9d
je     118a <qbase64_decode+0x8a>
cmp    $0x2,%r9d
je     1175 <qbase64_decode+0x75>
cmp    $0x1,%r9d
jne    1192 <qbase64_decode+0x92>
shl    $0x2,%sil
mov    %r10d,%edx
sar    $0x4,%dl
or     %sil,%dl
mov    $0x2,%r9d
jmp    119e <qbase64_decode+0x9e>
shl    $0x4,%sil
mov    %r10d,%edx
sar    $0x2,%dl
or     %sil,%dl
mov    $0x3,%r9d
jmp    119e <qbase64_decode+0x9e>
mov    $0x1,%r9d
jmp    1133 <qbase64_decode+0x33>
shl    $0x6,%sil
or     %r10b,%sil
xor    %r9d,%r9d
mov    %esi,%edx
mov    %dl,(%rax)
add    $0x1,%rax
jmp    1133 <qbase64_decode+0x33>
movb   $0x0,(%rax)
sub    %rdi,%rax
ret

LLVM IR (-O0):
@__const.qbase64_decode.B64MAPTBL = [256 x i8] c"@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@>@@@?456789:;<=@@@@@@@\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@@@@@@\1A\1B\1C\1D\1E\1F !\22#$%&'()*+,-./0123@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
define i64 @qbase64_decode(i8* %0) {
%2 = alloca i8*
%3 = alloca [256 x i8]
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8
%8 = alloca i8
store i8* %0, i8** %2
%9 = bitcast [256 x i8]* %3 to i8*
%10 = load i8*, i8** %2
store i8* %10, i8** %5
store i32 0, i32* %6
store i8 0, i8* %7
%11 = load i8*, i8** %2
store i8* %11, i8** %4
br label %12
12: ; preds = %79, %1
%13 = load i8*, i8** %4
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %82
17: ; preds = %12
%18 = load i8*, i8** %4
%19 = load i8, i8* %18
%20 = zext i8 %19 to i64
%21 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 %20
%22 = load i8, i8* %21
store i8 %22, i8* %8
%23 = load i8, i8* %8
%24 = sext i8 %23 to i32
%25 = icmp eq i32 %24, 64
br i1 %25, label %26, label %27
26: ; preds = %17
br label %79
27: ; preds = %17
%28 = load i32, i32* %6
%29 = icmp eq i32 %28, 0
br i1 %29, label %30, label %33
30: ; preds = %27
%31 = load i32, i32* %6
%32 = add nsw i32 %31, 1
store i32 %32, i32* %6
br label %77
33: ; preds = %27
%34 = load i32, i32* %6
%35 = icmp eq i32 %34, 1
br i1 %35, label %36, label %49
36: ; preds = %33
%37 = load i8, i8* %7
%38 = sext i8 %37 to i32
%39 = shl i32 %38, 2
%40 = load i8, i8* %8
%41 = sext i8 %40 to i32
%42 = ashr i32 %41, 4
%43 = or i32 %39, %42
%44 = trunc i32 %43 to i8
%45 = load i8*, i8** %5
%46 = getelementptr inbounds i8, i8* %45, i32 1
store i8* %46, i8** %5
store i8 %44, i8* %45
%47 = load i32, i32* %6
%48 = add nsw i32 %47, 1
store i32 %48, i32* %6
br label %76
49: ; preds = %33
%50 = load i32, i32* %6
%51 = icmp eq i32 %50, 2
br i1 %51, label %52, label %65
52: ; preds = %49
%53 = load i8, i8* %7
%54 = sext i8 %53 to i32
%55 = shl i32 %54, 4
%56 = load i8, i8* %8
%57 = sext i8 %56 to i32
%58 = ashr i32 %57, 2
%59 = or i32 %55, %58
%60 = trunc i32 %59 to i8
%61 = load i8*, i8** %5
%62 = getelementptr inbounds i8, i8* %61, i32 1
store i8* %62, i8** %5
store i8 %60, i8* %61
%63 = load i32, i32* %6
%64 = add nsw i32 %63, 1
store i32 %64, i32* %6
br label %75
65: ; preds = %49
%66 = load i8, i8* %7
%67 = sext i8 %66 to i32
%68 = shl i32 %67, 6
%69 = load i8, i8* %8
%70 = sext i8 %69 to i32
%71 = or i32 %68, %70
%72 = trunc i32 %71 to i8
%73 = load i8*, i8** %5
%74 = getelementptr inbounds i8, i8* %73, i32 1
store i8* %74, i8** %5
store i8 %72, i8* %73
store i32 0, i32* %6
br label %75
75: ; preds = %65, %52
br label %76
76: ; preds = %75, %36
br label %77
77: ; preds = %76, %30
%78 = load i8, i8* %8
store i8 %78, i8* %7
br label %79
79: ; preds = %77, %26
%80 = load i8*, i8** %4
%81 = getelementptr inbounds i8, i8* %80, i32 1
store i8* %81, i8** %4
br label %12
82: ; preds = %12
%83 = load i8*, i8** %5
store i8 0, i8* %83
%84 = load i8*, i8** %5
%85 = load i8*, i8** %2
%86 = ptrtoint i8* %84 to i64
%87 = ptrtoint i8* %85 to i64
%88 = sub i64 %86, %87
ret i64 %88
}

LLVM IR (-O2):
@__const.qbase64_decode.B64MAPTBL = [256 x i8] c"@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@>@@@?456789:;<=@@@@@@@\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@@@@@@\1A\1B\1C\1D\1E\1F !\22#$%&'()*+,-./0123@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
define i64 @qbase64_decode(i8* %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %37, label %4
4: ; preds = %1, %30
%5 = phi i8 [ %35, %30 ], [ %2, %1 ]
%6 = phi i8* [ %34, %30 ], [ %0, %1 ]
%7 = phi i8 [ %33, %30 ], [ 0, %1 ]
%8 = phi i32 [ %32, %30 ], [ 0, %1 ]
%9 = phi i8* [ %31, %30 ], [ %0, %1 ]
%10 = zext i8 %5 to i64
%11 = getelementptr inbounds [256 x i8], [256 x i8]* @__const.qbase64_decode.B64MAPTBL, i64 0, i64 %10
%12 = load i8, i8* %11
%13 = icmp eq i8 %12, 64
br i1 %13, label %30, label %14
14: ; preds = %4
switch i32 %8, label %23 [
i32 0, label %30
i32 1, label %15
i32 2, label %19
]
15: ; preds = %14
%16 = shl i8 %7, 2
%17 = ashr i8 %12, 4
%18 = or i8 %17, %16
br label %26
19: ; preds = %14
%20 = shl i8 %7, 4
%21 = ashr i8 %12, 2
%22 = or i8 %21, %20
br label %26
23: ; preds = %14
%24 = shl i8 %7, 6
%25 = or i8 %12, %24
br label %26
26: ; preds = %15, %23, %19
%27 = phi i8 [ %22, %19 ], [ %25, %23 ], [ %18, %15 ]
%28 = phi i32 [ 3, %19 ], [ 0, %23 ], [ 2, %15 ]
%29 = getelementptr inbounds i8, i8* %9, i64 1
store i8 %27, i8* %9
br label %30
30: ; preds = %26, %14, %4
%31 = phi i8* [ %9, %4 ], [ %9, %14 ], [ %29, %26 ]
%32 = phi i32 [ %8, %4 ], [ 1, %14 ], [ %28, %26 ]
%33 = phi i8 [ %7, %4 ], [ %12, %14 ], [ %12, %26 ]
%34 = getelementptr inbounds i8, i8* %6, i64 1
%35 = load i8, i8* %34
%36 = icmp eq i8 %35, 0
br i1 %36, label %37, label %4
37: ; preds = %30, %1
%38 = phi i8* [ %0, %1 ], [ %31, %30 ]
store i8 0, i8* %38
%39 = ptrtoint i8* %38 to i64
%40 = ptrtoint i8* %0 to i64
%41 = sub i64 %39, %40
ret i64 %41
}