#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 */
char EOF;
size_t base64_decode(char *, unsigned char *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ fwrite(unsigned char *, size_t, int, int /*<<< orphan*/ *);
void decode(FILE *fp_in, FILE *fp_out) {
  int i;
  unsigned char bindata[2050];
  char base64[4096];
  size_t bytes;
  while (!feof(fp_in)) {
    for (i = 0; i < 2048; i++) {
      base64[i] = fgetc(fp_in);
      if (base64[i] == EOF)
        break;
      else if (base64[i] == '\n' || base64[i] == '\r')
        i--;
    }
    bytes = base64_decode(base64, bindata);
    fwrite(bindata, bytes, 1, fp_out);
  }
}


x86 assembly (clang, -O0):
<decode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1830,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1171 <decode+0x31>
jmp    1244 <decode+0x104>
movl   $0x0,-0x14(%rbp)
cmpl   $0x800,-0x14(%rbp)
jge    1209 <decode+0xc9>
mov    -0x8(%rbp),%rdi
call   1030 <fgetc@plt>
mov    %al,%cl
movslq -0x14(%rbp),%rax
mov    %cl,-0x1820(%rbp,%rax,1)
movslq -0x14(%rbp),%rax
movsbl -0x1820(%rbp,%rax,1),%eax
ff
mov    0x2e3a(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
jne    11be <decode+0x7e>
jmp    1209 <decode+0xc9>
movslq -0x14(%rbp),%rax
movsbl -0x1820(%rbp,%rax,1),%eax
ff
cmp    $0xa,%eax
je     11e8 <decode+0xa8>
movslq -0x14(%rbp),%rax
movsbl -0x1820(%rbp,%rax,1),%eax
ff
cmp    $0xd,%eax
jne    11f1 <decode+0xb1>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    11f6 <decode+0xb6>
jmp    11fb <decode+0xbb>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1178 <decode+0x38>
lea    -0x1820(%rbp),%rdi
lea    -0x820(%rbp),%rsi
call   1060 <base64_decode@plt>
mov    %rax,-0x1828(%rbp)
lea    -0x820(%rbp),%rdi
mov    -0x1828(%rbp),%rsi
mov    -0x10(%rbp),%rcx
mov    $0x1,%edx
call   1050 <fwrite@plt>
jmp    1153 <decode+0x13>
add    $0x1830,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<decode>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1808,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
call   1040 <feof@plt>
test   %eax,%eax
je     1172 <decode+0x32>
add    $0x1808,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %ebp,%ebp
mov    0x2e6d(%rip),%r13
mov    %rsp,%r15
lea    0x1000(%rsp),%r12
jmp    11bf <decode+0x7f>
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %r12,%rsi
call   1060 <base64_decode@plt>
mov    %r12,%rdi
mov    %rax,%rsi
mov    $0x1,%edx
mov    %r14,%rcx
call   1050 <fwrite@plt>
mov    %rbx,%rdi
call   1040 <feof@plt>
mov    $0x0,%ebp
test   %eax,%eax
jne    1160 <decode+0x20>
mov    %rbx,%rdi
call   1030 <fgetc@plt>
movslq %ebp,%rcx
mov    %al,(%rsp,%rcx,1)
cmp    0x0(%r13),%al
je     1190 <decode+0x50>
cmp    $0xd,%al
je     11db <decode+0x9b>
cmp    $0xa,%al
jne    11de <decode+0x9e>
add    $0xffffffff,%ebp
lea    0x1(%rbp),%eax
cmp    $0x7ff,%ebp
mov    %eax,%ebp
jl     11bf <decode+0x7f>
jmp    1190 <decode+0x50>

LLVM IR (-O0):
@EOF = global i8 0
define void @decode(i32* %0, i32* %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i32
%6 = alloca [2050 x i8]
%7 = alloca [4096 x i8]
%8 = alloca i64
store i32* %0, i32** %3
store i32* %1, i32** %4
br label %9
9: ; preds = %55, %2
%10 = load i32*, i32** %3
%11 = call i32 @feof(i32* %10)
%12 = icmp ne i32 %11, 0
%13 = xor i1 %12, true
br i1 %13, label %14, label %63
14: ; preds = %9
store i32 0, i32* %5
br label %15
15: ; preds = %52, %14
%16 = load i32, i32* %5
%17 = icmp slt i32 %16, 2048
br i1 %17, label %18, label %55
18: ; preds = %15
%19 = load i32*, i32** %3
%20 = call signext i8 @fgetc(i32* %19)
%21 = load i32, i32* %5
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 %22
store i8 %20, i8* %23
%24 = load i32, i32* %5
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 %25
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = load i8, i8* @EOF
%30 = sext i8 %29 to i32
%31 = icmp eq i32 %28, %30
br i1 %31, label %32, label %33
32: ; preds = %18
br label %55
33: ; preds = %18
%34 = load i32, i32* %5
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 %35
%37 = load i8, i8* %36
%38 = sext i8 %37 to i32
%39 = icmp eq i32 %38, 10
br i1 %39, label %47, label %40
40: ; preds = %33
%41 = load i32, i32* %5
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 %42
%44 = load i8, i8* %43
%45 = sext i8 %44 to i32
%46 = icmp eq i32 %45, 13
br i1 %46, label %47, label %50
47: ; preds = %40, %33
%48 = load i32, i32* %5
%49 = add nsw i32 %48, -1
store i32 %49, i32* %5
br label %50
50: ; preds = %47, %40
br label %51
51: ; preds = %50
br label %52
52: ; preds = %51
%53 = load i32, i32* %5
%54 = add nsw i32 %53, 1
store i32 %54, i32* %5
br label %15
55: ; preds = %32, %15
%56 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 0
%57 = getelementptr inbounds [2050 x i8], [2050 x i8]* %6, i64 0, i64 0
%58 = call i64 @base64_decode(i8* %56, i8* %57)
store i64 %58, i64* %8
%59 = getelementptr inbounds [2050 x i8], [2050 x i8]* %6, i64 0, i64 0
%60 = load i64, i64* %8
%61 = load i32*, i32** %4
%62 = call i32 @fwrite(i8* %59, i64 %60, i32 1, i32* %61)
br label %9
63: ; preds = %9
ret void
}

LLVM IR (-O2):
@EOF = global i8 0
define void @decode(i32* nocapture %0, i32* nocapture %1) {
%3 = alloca [2050 x i8]
%4 = alloca [4096 x i8]
%5 = getelementptr inbounds [2050 x i8], [2050 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [4096 x i8], [4096 x i8]* %4, i64 0, i64 0
%7 = call i32 @feof(i32* %0)
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %30
9: ; preds = %2, %23
%10 = phi i32 [ %24, %23 ], [ 0, %2 ]
%11 = call signext i8 @fgetc(i32* %0)
%12 = sext i32 %10 to i64
%13 = getelementptr inbounds [4096 x i8], [4096 x i8]* %4, i64 0, i64 %12
store i8 %11, i8* %13
%14 = load i8, i8* @EOF
%15 = icmp eq i8 %11, %14
br i1 %15, label %25, label %16
16: ; preds = %9
switch i8 %11, label %19 [
i8 10, label %17
i8 13, label %17
]
17: ; preds = %16, %16
%18 = add nsw i32 %10, -1
br label %19
19: ; preds = %16, %17
%20 = phi i32 [ %18, %17 ], [ %10, %16 ]
%21 = add nsw i32 %20, 1
%22 = icmp slt i32 %20, 2047
br i1 %22, label %23, label %25
23: ; preds = %19, %25
%24 = phi i32 [ %21, %19 ], [ 0, %25 ]
br label %9
25: ; preds = %9, %19
%26 = call i64 @base64_decode(i8* %6, i8* %5)
%27 = call i32 @fwrite(i8* %5, i64 %26, i32 1, i32* %1)
%28 = call i32 @feof(i32* %0)
%29 = icmp eq i32 %28, 0
br i1 %29, label %23, label %30
30: ; preds = %25, %2
ret void
}