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

/* Variables and functions */
int /*<<< orphan*/ STDIN_FILENO;
int /*<<< orphan*/ STDOUT_FILENO;
int /*<<< orphan*/ b64_encode(char *, char *, int);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
scalar_t__ read(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ write(int /*<<< orphan*/, char *, int);
int main(int argc, char *argv[]) {
  char ascii[(3)] = {0}, b64[(4)] = {0};
  while (read(STDIN_FILENO, ascii, (3))) {
    b64_encode(b64, ascii, (3));
    write(STDOUT_FILENO, b64, (4));
    memset(b64, 0, sizeof(b64));
    memset(ascii, 0, sizeof(ascii));
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x13(%rbp),%rdi
xor    %esi,%esi
mov    $0x3,%edx
call   1050 <memset@plt>
lea    -0x17(%rbp),%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1050 <memset@plt>
mov    0x2e5b(%rip),%rax
mov    (%rax),%edi
lea    -0x13(%rbp),%rsi
mov    $0x3,%edx
call   1060 <read@plt>
cmp    $0x0,%rax
je     11e5 <main+0xa5>
lea    -0x17(%rbp),%rdi
lea    -0x13(%rbp),%rsi
mov    $0x3,%edx
call   1040 <b64_encode@plt>
mov    0x2e40(%rip),%rax
mov    (%rax),%edi
lea    -0x17(%rbp),%rsi
mov    $0x4,%edx
call   1030 <write@plt>
lea    -0x17(%rbp),%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1050 <memset@plt>
lea    -0x13(%rbp),%rdi
xor    %esi,%esi
mov    $0x3,%edx
call   1050 <memset@plt>
jmp    1176 <main+0x36>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
movb   $0x0,0x2(%rsp)
movw   $0x0,(%rsp)
movl   $0x0,0x4(%rsp)
mov    0x2e76(%rip),%r15
mov    (%r15),%edi
mov    %rsp,%rsi
mov    $0x3,%edx
call   1060 <read@plt>
test   %rax,%rax
je     11e4 <main+0xa4>
lea    0x4(%rsp),%r14
mov    %rsp,%rbx
mov    0x2e6a(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x3,%edx
call   1040 <b64_encode@plt>
mov    (%r12),%edi
mov    %r14,%rsi
mov    $0x4,%edx
call   1030 <write@plt>
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1050 <memset@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x3,%edx
call   1050 <memset@plt>
mov    (%r15),%edi
mov    %rbx,%rsi
mov    $0x3,%edx
call   1060 <read@plt>
test   %rax,%rax
jne    1190 <main+0x50>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@STDIN_FILENO = global i32 0
@STDOUT_FILENO = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [3 x i8]
%7 = alloca [4 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = bitcast [3 x i8]* %6 to i8*
%9 = bitcast [4 x i8]* %7 to i8*
br label %10
10: ; preds = %15, %2
%11 = load i32, i32* @STDIN_FILENO
%12 = getelementptr inbounds [3 x i8], [3 x i8]* %6, i64 0, i64 0
%13 = call i64 @read(i32 %11, i8* %12, i32 3)
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %26
15: ; preds = %10
%16 = getelementptr inbounds [4 x i8], [4 x i8]* %7, i64 0, i64 0
%17 = getelementptr inbounds [3 x i8], [3 x i8]* %6, i64 0, i64 0
%18 = call i32 @b64_encode(i8* %16, i8* %17, i32 3)
%19 = load i32, i32* @STDOUT_FILENO
%20 = getelementptr inbounds [4 x i8], [4 x i8]* %7, i64 0, i64 0
%21 = call i32 @write(i32 %19, i8* %20, i32 4)
%22 = getelementptr inbounds [4 x i8], [4 x i8]* %7, i64 0, i64 0
%23 = call i32 @memset(i8* %22, i32 0, i32 4)
%24 = getelementptr inbounds [3 x i8], [3 x i8]* %6, i64 0, i64 0
%25 = call i32 @memset(i8* %24, i32 0, i32 3)
br label %10
26: ; preds = %10
ret i32 0
}

LLVM IR (-O2):
@STDIN_FILENO = global i32 0
@STDOUT_FILENO = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [3 x i8]
%4 = alloca i32
%5 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 0
%6 = bitcast i32* %4 to i8*
store i32 0, i32* %4
%7 = load i32, i32* @STDIN_FILENO
%8 = call i64 @read(i32 %7, i8* %5, i32 3)
%9 = icmp eq i64 %8, 0
br i1 %9, label %19, label %10
10: ; preds = %2, %10
%11 = call i32 @b64_encode(i8* %6, i8* %5, i32 3)
%12 = load i32, i32* @STDOUT_FILENO
%13 = call i32 @write(i32 %12, i8* %6, i32 4)
%14 = call i32 @memset(i8* %6, i32 0, i32 4)
%15 = call i32 @memset(i8* %5, i32 0, i32 3)
%16 = load i32, i32* @STDIN_FILENO
%17 = call i64 @read(i32 %16, i8* %5, i32 3)
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %10
19: ; preds = %10, %2
ret i32 0
}