#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 /*<<< orphan*/ base64_encode(unsigned char *, char *, size_t);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *);
size_t fread(unsigned char *, int, int, int /*<<< orphan*/ *);
void encode(FILE *fp_in, FILE *fp_out) {
  unsigned char bindata[2050];
  char base64[4096];
  size_t bytes;
  while (!feof(fp_in)) {
    bytes = fread(bindata, 1, 2049, fp_in);
    base64_encode(bindata, base64, bytes);
    fprintf(fp_out, "%s", base64);
  }
}


x86 assembly (clang, -O0):
<encode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1830,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1171 <encode+0x31>
jmp    11c8 <encode+0x88>
lea    -0x820(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    $0x1,%esi
mov    $0x801,%edx
call   1030 <fread@plt>
mov    %rax,-0x1828(%rbp)
lea    -0x820(%rbp),%rdi
lea    -0x1820(%rbp),%rsi
mov    -0x1828(%rbp),%rdx
call   1060 <base64_encode@plt>
mov    -0x10(%rbp),%rdi
lea    -0x1820(%rbp),%rdx
lea    0xe42(%rip),%rsi
call   1040 <fprintf@plt>
jmp    1153 <encode+0x13>
add    $0x1830,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<encode>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x1818,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
call   1050 <feof@plt>
test   %eax,%eax
jne    11aa <encode+0x6a>
mov    %rsp,%r15
lea    0x810(%rsp),%r12
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    $0x1,%esi
mov    $0x801,%edx
mov    %rbx,%rcx
call   1030 <fread@plt>
mov    %r15,%rdi
mov    %r12,%rsi
mov    %rax,%rdx
call   1060 <base64_encode@plt>
mov    %r12,%rdi
mov    %r14,%rsi
call   1040 <fputs@plt>
mov    %rbx,%rdi
call   1050 <feof@plt>
test   %eax,%eax
je     1170 <encode+0x30>
add    $0x1818,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
define void @encode(i32* %0, i32* %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca [2050 x i8]
%6 = alloca [4096 x i8]
%7 = alloca i64
store i32* %0, i32** %3
store i32* %1, i32** %4
br label %8
8: ; preds = %13, %2
%9 = load i32*, i32** %3
%10 = call i32 @feof(i32* %9)
%11 = icmp ne i32 %10, 0
%12 = xor i1 %11, true
br i1 %12, label %13, label %24
13: ; preds = %8
%14 = getelementptr inbounds [2050 x i8], [2050 x i8]* %5, i64 0, i64 0
%15 = load i32*, i32** %3
%16 = call i64 @fread(i8* %14, i32 1, i32 2049, i32* %15)
store i64 %16, i64* %7
%17 = getelementptr inbounds [2050 x i8], [2050 x i8]* %5, i64 0, i64 0
%18 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%19 = load i64, i64* %7
%20 = call i32 @base64_encode(i8* %17, i8* %18, i64 %19)
%21 = load i32*, i32** %4
%22 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%23 = call i32 @fprintf(i32* %21, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %22)
br label %8
24: ; preds = %8
ret void
}

LLVM IR (-O2):
define void @encode(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 %15
9: ; preds = %2, %9
%10 = call i64 @fread(i8* %5, i32 1, i32 2049, i32* %0)
%11 = call i32 @base64_encode(i8* %5, i8* %6, i64 %10)
%12 = call i32 @fputs(i8* %6, i32* %1)
%13 = call i32 @feof(i32* %0)
%14 = icmp eq i32 %13, 0
br i1 %14, label %9, label %15
15: ; preds = %9, %2
ret void
}