#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int b64read(unsigned char *, char, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ free(unsigned char *);
unsigned char *malloc(int);
int /*<<< orphan*/ memset(unsigned char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int b64dec(FILE *fp) {
  int i, n = 0;
  int padFlag = 0;
  int space;
  unsigned char *inbuf = malloc(4);
  unsigned char *outbuf = malloc(3);
  while (!feof(fp)) {
    memset(inbuf, 0, 4);
    memset(outbuf, 0, 3);
    n = b64read(inbuf, 'd', 4, fp);
    if (n == -1) {
      fprintf(stderr, "ERR: b64dec illegal char detected\n");
      free(inbuf);
      free(outbuf);
      fclose(fp);
      exit(-1);
    } else if (n == 0) {
      break;
    } else if (n < 4) {
      fprintf(stderr, "ERR: b64dec illegal file format\n");
      free(inbuf);
      free(outbuf);
      fclose(fp);
      exit(-1);
    }
    if ((inbuf[0] == 61) || (inbuf[1] == 61) || (padFlag == 1)) {
      fprintf(stderr, "ERR: b64dec illegal padding position\n");
      free(inbuf);
      free(outbuf);
      fclose(fp);
      exit(-1);
    }
    space = 0;
    if ((inbuf[2] == 61) && (inbuf[3] == 61)) {
      inbuf[2] = 0;
      inbuf[3] = 0;
      space = 2;
      padFlag = 1;
    } else if (inbuf[3] == 61) {
      inbuf[3] = 0;
      space = 1;
    }
    for (i = 0; i < (4 - space); i++) {
      if (inbuf[i] >= 65 && inbuf[i] <= 90) {
        inbuf[i] = inbuf[i] - 65;
      } else if (inbuf[i] >= 97 && inbuf[i] <= 122) {
        inbuf[i] = inbuf[i] - 71;
      } else if (inbuf[i] >= 48 && inbuf[i] <= 57) {
        inbuf[i] = inbuf[i] + 4;
      } else if (inbuf[i] == 43) {
        inbuf[i] = 62;
      } else if (inbuf[i] == 47) {
        inbuf[i] = 63;
      }
    }
    outbuf[0] = ((inbuf[0] << 2) | (inbuf[1] >> 4));
    outbuf[1] = ((inbuf[1] & 15) << 4) | (inbuf[2] >> 2);
    outbuf[2] = ((inbuf[2] & 3) << 6) | inbuf[3];
    for (i = 0; i < (3 - space); i++) {
      fprintf(stdout, "%c", outbuf[i]);
    }
  }
  free(inbuf);
  free(outbuf);
  fclose(fp);
  return 1;
}


x86 assembly (clang, -O0):
<b64dec>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    $0x4,%edi
call   1080 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    $0x3,%edi
call   1080 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
call   1070 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11d4 <b64dec+0x54>
jmp    15a8 <b64dec+0x428>
mov    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1050 <memset@plt>
mov    -0x28(%rbp),%rdi
xor    %esi,%esi
mov    $0x3,%edx
call   1050 <memset@plt>
mov    -0x20(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    $0x64,%esi
mov    $0x4,%edx
call   1090 <b64read@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0xffffffff,-0x10(%rbp)
jne    1254 <b64dec+0xd4>
mov    0x2dc1(%rip),%rax
mov    (%rax),%edi
lea    0xdd8(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x8(%rbp),%rdi
call   1040 <fclose@plt>
mov    $0xffffffff,%edi
call   10a0 <exit@plt>
cmpl   $0x0,-0x10(%rbp)
jne    1263 <b64dec+0xe3>
jmp    15a8 <b64dec+0x428>
cmpl   $0x4,-0x10(%rbp)
jge    12a9 <b64dec+0x129>
mov    0x2d6c(%rip),%rax
mov    (%rax),%edi
lea    0xda6(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x8(%rbp),%rdi
call   1040 <fclose@plt>
mov    $0xffffffff,%edi
call   10a0 <exit@plt>
jmp    12ae <b64dec+0x12e>
jmp    12b3 <b64dec+0x133>
mov    -0x20(%rbp),%rax
movzbl (%rax),%eax
cmp    $0x3d,%eax
je     12de <b64dec+0x15e>
mov    -0x20(%rbp),%rax
movzbl 0x1(%rax),%eax
cmp    $0x3d,%eax
je     12de <b64dec+0x15e>
cmpl   $0x1,-0x14(%rbp)
jne    131a <b64dec+0x19a>
mov    0x2cfb(%rip),%rax
mov    (%rax),%edi
lea    0xd56(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x8(%rbp),%rdi
call   1040 <fclose@plt>
mov    $0xffffffff,%edi
call   10a0 <exit@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x20(%rbp),%rax
movzbl 0x2(%rax),%eax
cmp    $0x3d,%eax
jne    1366 <b64dec+0x1e6>
mov    -0x20(%rbp),%rax
movzbl 0x3(%rax),%eax
cmp    $0x3d,%eax
jne    1366 <b64dec+0x1e6>
mov    -0x20(%rbp),%rax
movb   $0x0,0x2(%rax)
mov    -0x20(%rbp),%rax
movb   $0x0,0x3(%rax)
movl   $0x2,-0x18(%rbp)
movl   $0x1,-0x14(%rbp)
jmp    138b <b64dec+0x20b>
mov    -0x20(%rbp),%rax
movzbl 0x3(%rax),%eax
cmp    $0x3d,%eax
jne    1386 <b64dec+0x206>
mov    -0x20(%rbp),%rax
movb   $0x0,0x3(%rax)
movl   $0x1,-0x18(%rbp)
jmp    138b <b64dec+0x20b>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x4,%ecx
sub    -0x18(%rbp),%ecx
cmp    %ecx,%eax
jge    14f4 <b64dec+0x374>
mov    -0x20(%rbp),%rax
movslq -0xc(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
cmp    $0x41,%eax
jl     13f0 <b64dec+0x270>
mov    -0x20(%rbp),%rax
movslq -0xc(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
cmp    $0x5a,%eax
jg     13f0 <b64dec+0x270>
mov    -0x20(%rbp),%rax
movslq -0xc(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
sub    $0x41,%eax
mov    %al,%dl
mov    -0x20(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
jmp    14e1 <b64dec+0x361>
mov    -0x20(%rbp),%rax
movslq -0xc(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
cmp    $0x61,%eax
jl     143b <b64dec+0x2bb>
mov    -0x20(%rbp),%rax
movslq -0xc(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
cmp    $0x7a,%eax
jg     143b <b64dec+0x2bb>
mov    -0x20(%rbp),%rax
movslq -0xc(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
sub    $0x47,%eax
mov    %al,%dl
mov    -0x20(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
jmp    14dc <b64dec+0x35c>
mov    -0x20(%rbp),%rax
movslq -0xc(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
cmp    $0x30,%eax
jl     1486 <b64dec+0x306>
mov    -0x20(%rbp),%rax
movslq -0xc(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
cmp    $0x39,%eax
jg     1486 <b64dec+0x306>
mov    -0x20(%rbp),%rax
movslq -0xc(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
add    $0x4,%eax
mov    %al,%dl
mov    -0x20(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
jmp    14d7 <b64dec+0x357>
mov    -0x20(%rbp),%rax
movslq -0xc(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
cmp    $0x2b,%eax
jne    14ac <b64dec+0x32c>
mov    -0x20(%rbp),%rax
movslq -0xc(%rbp),%rcx
movb   $0x3e,(%rax,%rcx,1)
jmp    14d2 <b64dec+0x352>
mov    -0x20(%rbp),%rax
movslq -0xc(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
cmp    $0x2f,%eax
jne    14cd <b64dec+0x34d>
mov    -0x20(%rbp),%rax
movslq -0xc(%rbp),%rcx
movb   $0x3f,(%rax,%rcx,1)
jmp    14d2 <b64dec+0x352>
jmp    14d7 <b64dec+0x357>
jmp    14dc <b64dec+0x35c>
jmp    14e1 <b64dec+0x361>
jmp    14e6 <b64dec+0x366>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1392 <b64dec+0x212>
mov    -0x20(%rbp),%rax
movzbl (%rax),%eax
shl    $0x2,%eax
mov    -0x20(%rbp),%rcx
movzbl 0x1(%rcx),%ecx
sar    $0x4,%ecx
or     %ecx,%eax
mov    %al,%cl
mov    -0x28(%rbp),%rax
mov    %cl,(%rax)
mov    -0x20(%rbp),%rax
movzbl 0x1(%rax),%eax
and    $0xf,%eax
shl    $0x4,%eax
mov    -0x20(%rbp),%rcx
movzbl 0x2(%rcx),%ecx
sar    $0x2,%ecx
or     %ecx,%eax
mov    %al,%cl
mov    -0x28(%rbp),%rax
mov    %cl,0x1(%rax)
mov    -0x20(%rbp),%rax
movzbl 0x2(%rax),%eax
and    $0x3,%eax
shl    $0x6,%eax
mov    -0x20(%rbp),%rcx
movzbl 0x3(%rcx),%ecx
or     %ecx,%eax
mov    %al,%cl
mov    -0x28(%rbp),%rax
mov    %cl,0x2(%rax)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x3,%ecx
sub    -0x18(%rbp),%ecx
cmp    %ecx,%eax
jge    15a3 <b64dec+0x423>
mov    0x2a5f(%rip),%rax
mov    (%rax),%edi
mov    -0x28(%rbp),%rax
movslq -0xc(%rbp),%rcx
movzbl (%rax,%rcx,1),%edx
lea    0xadc(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    155f <b64dec+0x3df>
jmp    11b6 <b64dec+0x36>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x8(%rbp),%rdi
call   1040 <fclose@plt>
mov    $0x1,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<b64dec>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%r12
mov    $0x4,%edi
call   1080 <malloc@plt>
mov    %rax,%r13
mov    $0x3,%edi
call   1080 <malloc@plt>
mov    %rax,%r15
mov    %r12,%rdi
call   1070 <feof@plt>
test   %eax,%eax
je     11e3 <b64dec+0x63>
mov    %r13,%rdi
call   1030 <free@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    %r12,%rdi
call   1040 <fclose@plt>
mov    $0x1,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2dee(%rip),%rbp
lea    0xe79(%rip),%r14
xor    %ebx,%ebx
mov    %r12,0x10(%rsp)
jmp    121b <b64dec+0x9b>
nopw   0x0(%rax,%rax,1)
mov    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   1070 <feof@plt>
test   %eax,%eax
mov    %r12,%rbp
mov    %rbx,%r12
mov    0xc(%rsp),%ebx
jne    11b7 <b64dec+0x37>
mov    %r13,%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1050 <memset@plt>
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x3,%edx
call   1050 <memset@plt>
mov    %r13,%rdi
mov    $0x64,%esi
mov    $0x4,%edx
mov    %r12,%rcx
call   1090 <b64read@plt>
test   %eax,%eax
je     11b7 <b64dec+0x37>
cmp    $0xffffffff,%eax
je     148b <b64dec+0x30b>
cmp    $0x3,%eax
jle    149d <b64dec+0x31d>
mov    0x0(%r13),%al
cmp    $0x3d,%al
je     1479 <b64dec+0x2f9>
cmp    $0x1,%ebx
je     1479 <b64dec+0x2f9>
cmpb   $0x3d,0x1(%r13)
je     1479 <b64dec+0x2f9>
mov    %rbp,%rdi
mov    0x3(%r13),%dl
cmpb   $0x3d,0x2(%r13)
jne    12c0 <b64dec+0x140>
xor    %esi,%esi
mov    $0x0,%ebp
cmp    $0x3d,%dl
jne    12d8 <b64dec+0x158>
movb   $0x0,0x2(%r13)
mov    $0x2,%ecx
mov    $0x1,%esi
jmp    12d1 <b64dec+0x151>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    $0x1,%ecx
xor    %esi,%esi
mov    $0x0,%ebp
cmp    $0x3d,%dl
jne    12d8 <b64dec+0x158>
movb   $0x0,0x3(%r13)
mov    %ecx,%ebp
lea    -0x41(%rax),%ecx
cmp    $0x1a,%cl
jb     1310 <b64dec+0x190>
lea    -0x61(%rax),%ecx
cmp    $0x19,%cl
ja     12f0 <b64dec+0x170>
add    $0xb9,%al
mov    %eax,%ecx
jmp    1310 <b64dec+0x190>
xchg   %ax,%ax
lea    -0x30(%rax),%ecx
cmp    $0x9,%cl
ja     12fe <b64dec+0x17e>
add    $0x4,%al
mov    %eax,%ecx
jmp    1310 <b64dec+0x190>
cmp    $0x2b,%al
je     130a <b64dec+0x18a>
cmp    $0x2f,%al
jne    1314 <b64dec+0x194>
mov    $0x3f,%cl
jmp    1310 <b64dec+0x190>
mov    $0x3e,%cl
nopl   0x0(%rax)
mov    %cl,0x0(%r13)
mov    0x1(%r13),%al
lea    -0x41(%rax),%ecx
cmp    $0x1a,%cl
jb     133c <b64dec+0x1bc>
lea    -0x61(%rax),%ecx
cmp    $0x1a,%cl
jae    1330 <b64dec+0x1b0>
add    $0xb9,%al
jmp    133a <b64dec+0x1ba>
nopl   0x0(%rax)
lea    -0x30(%rax),%ecx
cmp    $0xa,%cl
jae    135d <b64dec+0x1dd>
add    $0x4,%al
mov    %eax,%ecx
mov    %cl,0x1(%r13)
cmp    $0x2,%ebp
je     13be <b64dec+0x23e>
mov    0x2(%r13),%al
lea    -0x41(%rax),%ecx
cmp    $0x1a,%cl
jb     1379 <b64dec+0x1f9>
lea    -0x61(%rax),%ecx
cmp    $0x1a,%cl
jae    136d <b64dec+0x1ed>
add    $0xb9,%al
jmp    1377 <b64dec+0x1f7>
cmp    $0x2b,%al
je     1451 <b64dec+0x2d1>
cmp    $0x2f,%al
jne    1340 <b64dec+0x1c0>
mov    $0x3f,%cl
jmp    133c <b64dec+0x1bc>
lea    -0x30(%rax),%ecx
cmp    $0xa,%cl
jae    139a <b64dec+0x21a>
add    $0x4,%al
mov    %eax,%ecx
mov    %cl,0x2(%r13)
cmp    $0x1,%ebp
je     13be <b64dec+0x23e>
mov    0x3(%r13),%al
lea    -0x41(%rax),%ecx
cmp    $0x1a,%cl
jb     13ba <b64dec+0x23a>
lea    -0x61(%rax),%ecx
cmp    $0x1a,%cl
jae    13aa <b64dec+0x22a>
add    $0xb9,%al
jmp    13b8 <b64dec+0x238>
cmp    $0x2b,%al
je     146b <b64dec+0x2eb>
cmp    $0x2f,%al
jne    137d <b64dec+0x1fd>
mov    $0x3f,%cl
jmp    1379 <b64dec+0x1f9>
lea    -0x30(%rax),%ecx
cmp    $0xa,%cl
jae    1458 <b64dec+0x2d8>
add    $0x4,%al
mov    %eax,%ecx
mov    %cl,0x3(%r13)
mov    %esi,0xc(%rsp)
mov    0x0(%r13),%sil
mov    0x1(%r13),%dl
mov    0x2(%r13),%bl
shl    $0x2,%sil
mov    %edx,%eax
shr    $0x4,%al
mov    %ebx,%ecx
shl    $0x6,%cl
or     0x3(%r13),%cl
or     %sil,%al
mov    %al,(%r15)
shl    $0x4,%dl
shr    $0x2,%bl
or     %dl,%bl
mov    %bl,0x1(%r15)
mov    %cl,0x2(%r15)
cmp    $0x3,%ebp
mov    %rdi,%r12
je     1200 <b64dec+0x80>
xor    $0x3,%ebp
mov    (%r12),%edi
movzbl %al,%edx
mov    %r14,%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
cmp    $0x1,%ebp
je     1200 <b64dec+0x80>
mov    %ebp,%ebp
mov    $0x1,%ebx
cs nopw 0x0(%rax,%rax,1)
movzbl (%r15,%rbx,1),%edx
mov    (%r12),%edi
mov    %r14,%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1430 <b64dec+0x2b0>
jmp    1200 <b64dec+0x80>
mov    $0x3e,%cl
jmp    133c <b64dec+0x1bc>
cmp    $0x2b,%al
je     1472 <b64dec+0x2f2>
cmp    $0x2f,%al
jne    13be <b64dec+0x23e>
mov    $0x3f,%cl
jmp    13ba <b64dec+0x23a>
mov    $0x3e,%cl
jmp    1379 <b64dec+0x1f9>
mov    $0x3e,%cl
jmp    13ba <b64dec+0x23a>
mov    0x2b60(%rip),%rax
mov    (%rax),%edi
lea    0xbbb(%rip),%rsi
jmp    14ad <b64dec+0x32d>
mov    0x2b4e(%rip),%rax
mov    (%rax),%edi
lea    0xb65(%rip),%rsi
jmp    14ad <b64dec+0x32d>
mov    0x2b3c(%rip),%rax
mov    (%rax),%edi
lea    0xb76(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    %r13,%rdi
call   1030 <free@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    %r12,%rdi
call   1040 <fclose@plt>
mov    $0xffffffff,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [35 x i8] c"ERR: b64dec illegal char detected\0A\00"
@.str.1 = [33 x i8] c"ERR: b64dec illegal file format\0A\00"
@.str.2 = [38 x i8] c"ERR: b64dec illegal padding position\0A\00"
@stdout = global i32 0
@.str.3 = [3 x i8] c"%c\00"
define i32 @b64dec(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
store i32* %0, i32** %2
store i32 0, i32* %4
store i32 0, i32* %5
%9 = call i8* @malloc(i32 4)
store i8* %9, i8** %7
%10 = call i8* @malloc(i32 3)
store i8* %10, i8** %8
br label %11
11: ; preds = %295, %1
%12 = load i32*, i32** %2
%13 = call i32 @feof(i32* %12)
%14 = icmp ne i32 %13, 0
%15 = xor i1 %14, true
br i1 %15, label %16, label %296
16: ; preds = %11
%17 = load i8*, i8** %7
%18 = call i32 @memset(i8* %17, i32 0, i32 4)
%19 = load i8*, i8** %8
%20 = call i32 @memset(i8* %19, i32 0, i32 3)
%21 = load i8*, i8** %7
%22 = load i32*, i32** %2
%23 = call i32 @b64read(i8* %21, i8 signext 100, i32 4, i32* %22)
store i32 %23, i32* %4
%24 = load i32, i32* %4
%25 = icmp eq i32 %24, -1
br i1 %25, label %26, label %36
26: ; preds = %16
%27 = load i32, i32* @stderr
%28 = call i32 (i32, i8*, ...) @fprintf(i32 %27, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
%29 = load i8*, i8** %7
%30 = call i32 @free(i8* %29)
%31 = load i8*, i8** %8
%32 = call i32 @free(i8* %31)
%33 = load i32*, i32** %2
%34 = call i32 @fclose(i32* %33)
%35 = call i32 @exit(i32 -1)
unreachable
36: ; preds = %16
%37 = load i32, i32* %4
%38 = icmp eq i32 %37, 0
br i1 %38, label %39, label %40
39: ; preds = %36
br label %296
40: ; preds = %36
%41 = load i32, i32* %4
%42 = icmp slt i32 %41, 4
br i1 %42, label %43, label %53
43: ; preds = %40
%44 = load i32, i32* @stderr
%45 = call i32 (i32, i8*, ...) @fprintf(i32 %44, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0))
%46 = load i8*, i8** %7
%47 = call i32 @free(i8* %46)
%48 = load i8*, i8** %8
%49 = call i32 @free(i8* %48)
%50 = load i32*, i32** %2
%51 = call i32 @fclose(i32* %50)
%52 = call i32 @exit(i32 -1)
unreachable
53: ; preds = %40
br label %54
54: ; preds = %53
br label %55
55: ; preds = %54
%56 = load i8*, i8** %7
%57 = getelementptr inbounds i8, i8* %56, i64 0
%58 = load i8, i8* %57
%59 = zext i8 %58 to i32
%60 = icmp eq i32 %59, 61
br i1 %60, label %70, label %61
61: ; preds = %55
%62 = load i8*, i8** %7
%63 = getelementptr inbounds i8, i8* %62, i64 1
%64 = load i8, i8* %63
%65 = zext i8 %64 to i32
%66 = icmp eq i32 %65, 61
br i1 %66, label %70, label %67
67: ; preds = %61
%68 = load i32, i32* %5
%69 = icmp eq i32 %68, 1
br i1 %69, label %70, label %80
70: ; preds = %67, %61, %55
%71 = load i32, i32* @stderr
%72 = call i32 (i32, i8*, ...) @fprintf(i32 %71, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0))
%73 = load i8*, i8** %7
%74 = call i32 @free(i8* %73)
%75 = load i8*, i8** %8
%76 = call i32 @free(i8* %75)
%77 = load i32*, i32** %2
%78 = call i32 @fclose(i32* %77)
%79 = call i32 @exit(i32 -1)
unreachable
80: ; preds = %67
store i32 0, i32* %6
%81 = load i8*, i8** %7
%82 = getelementptr inbounds i8, i8* %81, i64 2
%83 = load i8, i8* %82
%84 = zext i8 %83 to i32
%85 = icmp eq i32 %84, 61
br i1 %85, label %86, label %97
86: ; preds = %80
%87 = load i8*, i8** %7
%88 = getelementptr inbounds i8, i8* %87, i64 3
%89 = load i8, i8* %88
%90 = zext i8 %89 to i32
%91 = icmp eq i32 %90, 61
br i1 %91, label %92, label %97
92: ; preds = %86
%93 = load i8*, i8** %7
%94 = getelementptr inbounds i8, i8* %93, i64 2
store i8 0, i8* %94
%95 = load i8*, i8** %7
%96 = getelementptr inbounds i8, i8* %95, i64 3
store i8 0, i8* %96
store i32 2, i32* %6
store i32 1, i32* %5
br label %107
97: ; preds = %86, %80
%98 = load i8*, i8** %7
%99 = getelementptr inbounds i8, i8* %98, i64 3
%100 = load i8, i8* %99
%101 = zext i8 %100 to i32
%102 = icmp eq i32 %101, 61
br i1 %102, label %103, label %106
103: ; preds = %97
%104 = load i8*, i8** %7
%105 = getelementptr inbounds i8, i8* %104, i64 3
store i8 0, i8* %105
store i32 1, i32* %6
br label %106
106: ; preds = %103, %97
br label %107
107: ; preds = %106, %92
store i32 0, i32* %3
br label %108
108: ; preds = %231, %107
%109 = load i32, i32* %3
%110 = load i32, i32* %6
%111 = sub nsw i32 4, %110
%112 = icmp slt i32 %109, %111
br i1 %112, label %113, label %234
113: ; preds = %108
%114 = load i8*, i8** %7
%115 = load i32, i32* %3
%116 = sext i32 %115 to i64
%117 = getelementptr inbounds i8, i8* %114, i64 %116
%118 = load i8, i8* %117
%119 = zext i8 %118 to i32
%120 = icmp sge i32 %119, 65
br i1 %120, label %121, label %142
121: ; preds = %113
%122 = load i8*, i8** %7
%123 = load i32, i32* %3
%124 = sext i32 %123 to i64
%125 = getelementptr inbounds i8, i8* %122, i64 %124
%126 = load i8, i8* %125
%127 = zext i8 %126 to i32
%128 = icmp sle i32 %127, 90
br i1 %128, label %129, label %142
129: ; preds = %121
%130 = load i8*, i8** %7
%131 = load i32, i32* %3
%132 = sext i32 %131 to i64
%133 = getelementptr inbounds i8, i8* %130, i64 %132
%134 = load i8, i8* %133
%135 = zext i8 %134 to i32
%136 = sub nsw i32 %135, 65
%137 = trunc i32 %136 to i8
%138 = load i8*, i8** %7
%139 = load i32, i32* %3
%140 = sext i32 %139 to i64
%141 = getelementptr inbounds i8, i8* %138, i64 %140
store i8 %137, i8* %141
br label %230
142: ; preds = %121, %113
%143 = load i8*, i8** %7
%144 = load i32, i32* %3
%145 = sext i32 %144 to i64
%146 = getelementptr inbounds i8, i8* %143, i64 %145
%147 = load i8, i8* %146
%148 = zext i8 %147 to i32
%149 = icmp sge i32 %148, 97
br i1 %149, label %150, label %171
150: ; preds = %142
%151 = load i8*, i8** %7
%152 = load i32, i32* %3
%153 = sext i32 %152 to i64
%154 = getelementptr inbounds i8, i8* %151, i64 %153
%155 = load i8, i8* %154
%156 = zext i8 %155 to i32
%157 = icmp sle i32 %156, 122
br i1 %157, label %158, label %171
158: ; preds = %150
%159 = load i8*, i8** %7
%160 = load i32, i32* %3
%161 = sext i32 %160 to i64
%162 = getelementptr inbounds i8, i8* %159, i64 %161
%163 = load i8, i8* %162
%164 = zext i8 %163 to i32
%165 = sub nsw i32 %164, 71
%166 = trunc i32 %165 to i8
%167 = load i8*, i8** %7
%168 = load i32, i32* %3
%169 = sext i32 %168 to i64
%170 = getelementptr inbounds i8, i8* %167, i64 %169
store i8 %166, i8* %170
br label %229
171: ; preds = %150, %142
%172 = load i8*, i8** %7
%173 = load i32, i32* %3
%174 = sext i32 %173 to i64
%175 = getelementptr inbounds i8, i8* %172, i64 %174
%176 = load i8, i8* %175
%177 = zext i8 %176 to i32
%178 = icmp sge i32 %177, 48
br i1 %178, label %179, label %200
179: ; preds = %171
%180 = load i8*, i8** %7
%181 = load i32, i32* %3
%182 = sext i32 %181 to i64
%183 = getelementptr inbounds i8, i8* %180, i64 %182
%184 = load i8, i8* %183
%185 = zext i8 %184 to i32
%186 = icmp sle i32 %185, 57
br i1 %186, label %187, label %200
187: ; preds = %179
%188 = load i8*, i8** %7
%189 = load i32, i32* %3
%190 = sext i32 %189 to i64
%191 = getelementptr inbounds i8, i8* %188, i64 %190
%192 = load i8, i8* %191
%193 = zext i8 %192 to i32
%194 = add nsw i32 %193, 4
%195 = trunc i32 %194 to i8
%196 = load i8*, i8** %7
%197 = load i32, i32* %3
%198 = sext i32 %197 to i64
%199 = getelementptr inbounds i8, i8* %196, i64 %198
store i8 %195, i8* %199
br label %228
200: ; preds = %179, %171
%201 = load i8*, i8** %7
%202 = load i32, i32* %3
%203 = sext i32 %202 to i64
%204 = getelementptr inbounds i8, i8* %201, i64 %203
%205 = load i8, i8* %204
%206 = zext i8 %205 to i32
%207 = icmp eq i32 %206, 43
br i1 %207, label %208, label %213
208: ; preds = %200
%209 = load i8*, i8** %7
%210 = load i32, i32* %3
%211 = sext i32 %210 to i64
%212 = getelementptr inbounds i8, i8* %209, i64 %211
store i8 62, i8* %212
br label %227
213: ; preds = %200
%214 = load i8*, i8** %7
%215 = load i32, i32* %3
%216 = sext i32 %215 to i64
%217 = getelementptr inbounds i8, i8* %214, i64 %216
%218 = load i8, i8* %217
%219 = zext i8 %218 to i32
%220 = icmp eq i32 %219, 47
br i1 %220, label %221, label %226
221: ; preds = %213
%222 = load i8*, i8** %7
%223 = load i32, i32* %3
%224 = sext i32 %223 to i64
%225 = getelementptr inbounds i8, i8* %222, i64 %224
store i8 63, i8* %225
br label %226
226: ; preds = %221, %213
br label %227
227: ; preds = %226, %208
br label %228
228: ; preds = %227, %187
br label %229
229: ; preds = %228, %158
br label %230
230: ; preds = %229, %129
br label %231
231: ; preds = %230
%232 = load i32, i32* %3
%233 = add nsw i32 %232, 1
store i32 %233, i32* %3
br label %108
234: ; preds = %108
%235 = load i8*, i8** %7
%236 = getelementptr inbounds i8, i8* %235, i64 0
%237 = load i8, i8* %236
%238 = zext i8 %237 to i32
%239 = shl i32 %238, 2
%240 = load i8*, i8** %7
%241 = getelementptr inbounds i8, i8* %240, i64 1
%242 = load i8, i8* %241
%243 = zext i8 %242 to i32
%244 = ashr i32 %243, 4
%245 = or i32 %239, %244
%246 = trunc i32 %245 to i8
%247 = load i8*, i8** %8
%248 = getelementptr inbounds i8, i8* %247, i64 0
store i8 %246, i8* %248
%249 = load i8*, i8** %7
%250 = getelementptr inbounds i8, i8* %249, i64 1
%251 = load i8, i8* %250
%252 = zext i8 %251 to i32
%253 = and i32 %252, 15
%254 = shl i32 %253, 4
%255 = load i8*, i8** %7
%256 = getelementptr inbounds i8, i8* %255, i64 2
%257 = load i8, i8* %256
%258 = zext i8 %257 to i32
%259 = ashr i32 %258, 2
%260 = or i32 %254, %259
%261 = trunc i32 %260 to i8
%262 = load i8*, i8** %8
%263 = getelementptr inbounds i8, i8* %262, i64 1
store i8 %261, i8* %263
%264 = load i8*, i8** %7
%265 = getelementptr inbounds i8, i8* %264, i64 2
%266 = load i8, i8* %265
%267 = zext i8 %266 to i32
%268 = and i32 %267, 3
%269 = shl i32 %268, 6
%270 = load i8*, i8** %7
%271 = getelementptr inbounds i8, i8* %270, i64 3
%272 = load i8, i8* %271
%273 = zext i8 %272 to i32
%274 = or i32 %269, %273
%275 = trunc i32 %274 to i8
%276 = load i8*, i8** %8
%277 = getelementptr inbounds i8, i8* %276, i64 2
store i8 %275, i8* %277
store i32 0, i32* %3
br label %278
278: ; preds = %292, %234
%279 = load i32, i32* %3
%280 = load i32, i32* %6
%281 = sub nsw i32 3, %280
%282 = icmp slt i32 %279, %281
br i1 %282, label %283, label %295
283: ; preds = %278
%284 = load i32, i32* @stdout
%285 = load i8*, i8** %8
%286 = load i32, i32* %3
%287 = sext i32 %286 to i64
%288 = getelementptr inbounds i8, i8* %285, i64 %287
%289 = load i8, i8* %288
%290 = zext i8 %289 to i32
%291 = call i32 (i32, i8*, ...) @fprintf(i32 %284, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %290)
br label %292
292: ; preds = %283
%293 = load i32, i32* %3
%294 = add nsw i32 %293, 1
store i32 %294, i32* %3
br label %278
295: ; preds = %278
br label %11
296: ; preds = %39, %11
%297 = load i8*, i8** %7
%298 = call i32 @free(i8* %297)
%299 = load i8*, i8** %8
%300 = call i32 @free(i8* %299)
%301 = load i32*, i32** %2
%302 = call i32 @fclose(i32* %301)
ret i32 1
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [35 x i8] c"ERR: b64dec illegal char detected\0A\00"
@.str.1 = [33 x i8] c"ERR: b64dec illegal file format\0A\00"
@.str.2 = [38 x i8] c"ERR: b64dec illegal padding position\0A\00"
@stdout = global i32 0
@.str.3 = [3 x i8] c"%c\00"
define i32 @b64dec(i32* %0) {
%2 = tail call dereferenceable_or_null(4) i8* @malloc(i32 4)
%3 = tail call dereferenceable_or_null(3) i8* @malloc(i32 3)
%4 = tail call i32 @feof(i32* %0)
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %177
6: ; preds = %1
%7 = getelementptr inbounds i8, i8* %2, i64 1
%8 = getelementptr inbounds i8, i8* %2, i64 2
%9 = getelementptr inbounds i8, i8* %2, i64 3
%10 = getelementptr inbounds i8, i8* %3, i64 1
%11 = getelementptr inbounds i8, i8* %3, i64 2
%12 = getelementptr inbounds i8, i8* %2, i64 1
%13 = getelementptr inbounds i8, i8* %2, i64 1
%14 = getelementptr inbounds i8, i8* %2, i64 2
%15 = getelementptr inbounds i8, i8* %2, i64 2
%16 = getelementptr inbounds i8, i8* %2, i64 3
%17 = getelementptr inbounds i8, i8* %2, i64 3
br label %21
18: ; preds = %168, %162, %147
%19 = tail call i32 @feof(i32* %0)
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %177
21: ; preds = %6, %18
%22 = phi i32 [ 0, %6 ], [ %69, %18 ]
%23 = tail call i32 @memset(i8* %2, i32 0, i32 4)
%24 = tail call i32 @memset(i8* %3, i32 0, i32 3)
%25 = tail call i32 @b64read(i8* %2, i8 signext 100, i32 4, i32* %0)
switch i32 %25, label %33 [
i32 -1, label %26
i32 0, label %177
]
26: ; preds = %21
%27 = load i32, i32* @stderr
%28 = tail call i32 (i32, i8*, ...) @fprintf(i32 %27, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
%29 = tail call i32 @free(i8* %2)
%30 = tail call i32 @free(i8* %3)
%31 = tail call i32 @fclose(i32* %0)
%32 = tail call i32 @exit(i32 -1)
unreachable
33: ; preds = %21
%34 = icmp slt i32 %25, 4
br i1 %34, label %35, label %42
35: ; preds = %33
%36 = load i32, i32* @stderr
%37 = tail call i32 (i32, i8*, ...) @fprintf(i32 %36, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0))
%38 = tail call i32 @free(i8* %2)
%39 = tail call i32 @free(i8* %3)
%40 = tail call i32 @fclose(i32* %0)
%41 = tail call i32 @exit(i32 -1)
unreachable
42: ; preds = %33
%43 = load i8, i8* %2
%44 = icmp eq i8 %43, 61
br i1 %44, label %50, label %45
45: ; preds = %42
%46 = load i8, i8* %7
%47 = icmp eq i8 %46, 61
%48 = icmp eq i32 %22, 1
%49 = or i1 %48, %47
br i1 %49, label %50, label %57
50: ; preds = %45, %42
%51 = load i32, i32* @stderr
%52 = tail call i32 (i32, i8*, ...) @fprintf(i32 %51, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0))
%53 = tail call i32 @free(i8* %2)
%54 = tail call i32 @free(i8* %3)
%55 = tail call i32 @fclose(i32* %0)
%56 = tail call i32 @exit(i32 -1)
unreachable
57: ; preds = %45
%58 = load i8, i8* %8
%59 = icmp eq i8 %58, 61
%60 = load i8, i8* %9
%61 = icmp eq i8 %60, 61
br i1 %59, label %62, label %64
62: ; preds = %57
br i1 %61, label %63, label %68
63: ; preds = %62
store i8 0, i8* %8
br label %65
64: ; preds = %57
br i1 %61, label %65, label %68
65: ; preds = %64, %63
%66 = phi i32 [ 1, %63 ], [ 0, %64 ]
%67 = phi i32 [ 2, %63 ], [ 1, %64 ]
store i8 0, i8* %9
br label %68
68: ; preds = %64, %62, %65
%69 = phi i32 [ 0, %64 ], [ 0, %62 ], [ %66, %65 ]
%70 = phi i32 [ 0, %64 ], [ 0, %62 ], [ %67, %65 ]
%71 = add i8 %43, -65
%72 = icmp ult i8 %71, 26
br i1 %72, label %85, label %73
73: ; preds = %68
%74 = add i8 %43, -97
%75 = icmp ult i8 %74, 26
br i1 %75, label %76, label %78
76: ; preds = %73
%77 = add nsw i8 %43, -71
br label %85
78: ; preds = %73
%79 = add i8 %43, -48
%80 = icmp ult i8 %79, 10
br i1 %80, label %81, label %83
81: ; preds = %78
%82 = add nuw nsw i8 %43, 4
br label %85
83: ; preds = %78
switch i8 %43, label %87 [
i8 43, label %85
i8 47, label %84
]
84: ; preds = %83
br label %85
85: ; preds = %83, %68, %76, %84, %81
%86 = phi i8 [ %82, %81 ], [ 63, %84 ], [ %77, %76 ], [ %71, %68 ], [ 62, %83 ]
store i8 %86, i8* %2
br label %87
87: ; preds = %83, %85
%88 = load i8, i8* %12
%89 = add i8 %88, -65
%90 = icmp ult i8 %89, 26
br i1 %90, label %103, label %91
91: ; preds = %87
%92 = add i8 %88, -97
%93 = icmp ult i8 %92, 26
br i1 %93, label %101, label %94
94: ; preds = %91
%95 = add i8 %88, -48
%96 = icmp ult i8 %95, 10
br i1 %96, label %99, label %97
97: ; preds = %94
switch i8 %88, label %105 [
i8 43, label %103
i8 47, label %98
]
98: ; preds = %97
br label %103
99: ; preds = %94
%100 = add nuw nsw i8 %88, 4
br label %103
101: ; preds = %91
%102 = add nsw i8 %88, -71
br label %103
103: ; preds = %101, %99, %98, %97, %87
%104 = phi i8 [ %100, %99 ], [ 63, %98 ], [ %102, %101 ], [ %89, %87 ], [ 62, %97 ]
store i8 %104, i8* %13
br label %105
105: ; preds = %103, %97
%106 = icmp eq i32 %70, 2
br i1 %106, label %147, label %107
107: ; preds = %105
%108 = load i8, i8* %14
%109 = add i8 %108, -65
%110 = icmp ult i8 %109, 26
br i1 %110, label %123, label %111
111: ; preds = %107
%112 = add i8 %108, -97
%113 = icmp ult i8 %112, 26
br i1 %113, label %121, label %114
114: ; preds = %111
%115 = add i8 %108, -48
%116 = icmp ult i8 %115, 10
br i1 %116, label %119, label %117
117: ; preds = %114
switch i8 %108, label %125 [
i8 43, label %123
i8 47, label %118
]
118: ; preds = %117
br label %123
119: ; preds = %114
%120 = add nuw nsw i8 %108, 4
br label %123
121: ; preds = %111
%122 = add nsw i8 %108, -71
br label %123
123: ; preds = %121, %119, %118, %117, %107
%124 = phi i8 [ %120, %119 ], [ 63, %118 ], [ %122, %121 ], [ %109, %107 ], [ 62, %117 ]
store i8 %124, i8* %15
br label %125
125: ; preds = %123, %117
%126 = icmp eq i32 %70, 1
br i1 %126, label %147, label %127
127: ; preds = %125
%128 = load i8, i8* %16
%129 = add i8 %128, -65
%130 = icmp ult i8 %129, 26
br i1 %130, label %143, label %131
131: ; preds = %127
%132 = add i8 %128, -97
%133 = icmp ult i8 %132, 26
br i1 %133, label %141, label %134
134: ; preds = %131
%135 = add i8 %128, -48
%136 = icmp ult i8 %135, 10
br i1 %136, label %139, label %137
137: ; preds = %134
switch i8 %128, label %145 [
i8 43, label %143
i8 47, label %138
]
138: ; preds = %137
br label %143
139: ; preds = %134
%140 = add nuw nsw i8 %128, 4
br label %143
141: ; preds = %131
%142 = add nsw i8 %128, -71
br label %143
143: ; preds = %141, %139, %138, %137, %127
%144 = phi i8 [ %140, %139 ], [ 63, %138 ], [ %142, %141 ], [ %129, %127 ], [ 62, %137 ]
store i8 %144, i8* %17
br label %145
145: ; preds = %143, %137
%146 = icmp eq i32 %70, 0
br label %147
147: ; preds = %145, %125, %105
%148 = load i8, i8* %2
%149 = load i8, i8* %7
%150 = load i8, i8* %8
%151 = load i8, i8* %9
%152 = shl i8 %148, 2
%153 = lshr i8 %149, 4
%154 = or i8 %153, %152
store i8 %154, i8* %3
%155 = shl i8 %149, 4
%156 = lshr i8 %150, 2
%157 = or i8 %156, %155
store i8 %157, i8* %10
%158 = shl i8 %150, 6
%159 = or i8 %151, %158
store i8 %159, i8* %11
%160 = xor i32 %70, 3
%161 = icmp eq i32 %160, 0
br i1 %161, label %18, label %162
162: ; preds = %147
%163 = zext i32 %160 to i64
%164 = load i32, i32* @stdout
%165 = zext i8 %154 to i32
%166 = tail call i32 (i32, i8*, ...) @fprintf(i32 %164, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %165)
%167 = icmp eq i32 %160, 1
br i1 %167, label %18, label %168
168: ; preds = %162, %168
%169 = phi i64 [ %175, %168 ], [ 1, %162 ]
%170 = getelementptr inbounds i8, i8* %3, i64 %169
%171 = load i8, i8* %170
%172 = load i32, i32* @stdout
%173 = zext i8 %171 to i32
%174 = tail call i32 (i32, i8*, ...) @fprintf(i32 %172, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %173)
%175 = add nuw nsw i64 %169, 1
%176 = icmp eq i64 %175, %163
br i1 %176, label %18, label %168
177: ; preds = %18, %21, %1
%178 = tail call i32 @free(i8* %2)
%179 = tail call i32 @free(i8* %3)
%180 = tail call i32 @fclose(i32* %0)
ret i32 1
}