#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 */
int EOF;
int getchar();
int /*<<< orphan*/ putchar(char const);
int main(void) {
  static const char b64[] =
      "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
  unsigned i_bits = 0;
  int i_shift = 0;
  int out_len = 0;
  int in;
  while ((in = getchar()) != EOF) {
    i_bits = (i_bits << 8) + in;
    i_shift += 8;
    while (i_shift > 6)
      do {
        putchar(b64[(i_bits << 6 >> i_shift) & 0x3f]);
        out_len++;
        i_shift -= 6;
      } while (0);
  }
  while (i_shift > 0)
    do {
      putchar(b64[(i_bits << 6 >> i_shift) & 0x3f]);
      out_len++;
      i_shift -= 6;
    } while (0);
  while (out_len++ & 3)
    putchar('=');
  putchar('\n');
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x14(%rbp)
mov    0x2e93(%rip),%rcx
cmp    (%rcx),%eax
je     11bf <main+0x9f>
mov    -0x8(%rbp),%eax
shl    $0x8,%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
add    $0x8,%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x6,-0xc(%rbp)
jle    11ba <main+0x9a>
jmp    1181 <main+0x61>
mov    -0x8(%rbp),%eax
shl    $0x6,%eax
mov    -0xc(%rbp),%ecx
shr    %cl,%eax
and    $0x3f,%eax
mov    %eax,%eax
mov    %eax,%ecx
lea    0xe66(%rip),%rax
movsbl (%rax,%rcx,1),%edi
call   1030 <putchar@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
sub    $0x6,%eax
mov    %eax,-0xc(%rbp)
jmp    1172 <main+0x52>
jmp    1144 <main+0x24>
jmp    11c4 <main+0xa4>
cmpl   $0x0,-0xc(%rbp)
jle    120c <main+0xec>
jmp    11d3 <main+0xb3>
mov    -0x8(%rbp),%eax
shl    $0x6,%eax
mov    -0xc(%rbp),%ecx
shr    %cl,%eax
and    $0x3f,%eax
mov    %eax,%eax
mov    %eax,%ecx
lea    0xe14(%rip),%rax
movsbl (%rax,%rcx,1),%edi
call   1030 <putchar@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
sub    $0x6,%eax
mov    %eax,-0xc(%rbp)
jmp    11c4 <main+0xa4>
jmp    1211 <main+0xf1>
mov    -0x10(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x10(%rbp)
and    $0x3,%eax
cmp    $0x0,%eax
je     1237 <main+0x117>
mov    $0x3d,%edi
call   1030 <putchar@plt>
jmp    1211 <main+0xf1>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %eax,%eax
call   1040 <getchar@plt>
mov    0x2eaf(%rip),%r12
cmp    (%r12),%eax
je     1205 <main+0xe5>
lea    0xeb6(%rip),%r14
xor    %r15d,%r15d
xor    %ebp,%ebp
xor    %ebx,%ebx
jmp    1170 <main+0x50>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x8,%ebx
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    (%r12),%eax
je     11b4 <main+0x94>
shl    $0x8,%r15d
add    %eax,%r15d
cmp    $0xffffffff,%ebx
jl     1160 <main+0x40>
mov    %r15d,%r13d
shl    $0x6,%r13d
add    $0xe,%ebx
cs nopw 0x0(%rax,%rax,1)
add    $0xfffffffa,%ebx
mov    %r13d,%eax
mov    %ebx,%ecx
shr    %cl,%eax
and    $0x3f,%eax
movsbl (%rax,%r14,1),%edi
call   1030 <putchar@plt>
add    $0x1,%ebp
cmp    $0xc,%ebx
ja     1190 <main+0x70>
add    $0xfffffffa,%ebx
jmp    1163 <main+0x43>
test   %ebx,%ebx
jle    11e1 <main+0xc1>
shl    $0x6,%r15d
nopl   0x0(%rax)
mov    %r15d,%eax
mov    %ebx,%ecx
shr    %cl,%eax
and    $0x3f,%eax
movsbl (%rax,%r14,1),%edi
call   1030 <putchar@plt>
add    $0x1,%ebp
lea    -0x6(%rbx),%eax
cmp    $0x6,%ebx
mov    %eax,%ebx
ja     11c0 <main+0xa0>
test   $0x3,%bpl
je     1205 <main+0xe5>
add    $0x1,%ebp
mov    %ebp,%ebx
nopl   0x0(%rax)
mov    $0x3d,%edi
call   1030 <putchar@plt>
add    $0x1,%ebx
test   $0x3,%bpl
mov    %ebx,%ebp
jne    11f0 <main+0xd0>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@main.b64 = internal constant [65 x i8] c"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\00"
@EOF = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
store i32 0, i32* %4
br label %6
6: ; preds = %36, %0
%7 = call i32 (...) @getchar()
store i32 %7, i32* %5
%8 = load i32, i32* @EOF
%9 = icmp ne i32 %7, %8
br i1 %9, label %10, label %37
10: ; preds = %6
%11 = load i32, i32* %2
%12 = shl i32 %11, 8
%13 = load i32, i32* %5
%14 = add i32 %12, %13
store i32 %14, i32* %2
%15 = load i32, i32* %3
%16 = add nsw i32 %15, 8
store i32 %16, i32* %3
br label %17
17: ; preds = %35, %10
%18 = load i32, i32* %3
%19 = icmp sgt i32 %18, 6
br i1 %19, label %20, label %36
20: ; preds = %17
br label %21
21: ; preds = %20
%22 = load i32, i32* %2
%23 = shl i32 %22, 6
%24 = load i32, i32* %3
%25 = lshr i32 %23, %24
%26 = and i32 %25, 63
%27 = zext i32 %26 to i64
%28 = getelementptr inbounds [65 x i8], [65 x i8]* @main.b64, i64 0, i64 %27
%29 = load i8, i8* %28
%30 = call i32 @putchar(i8 signext %29)
%31 = load i32, i32* %4
%32 = add nsw i32 %31, 1
store i32 %32, i32* %4
%33 = load i32, i32* %3
%34 = sub nsw i32 %33, 6
store i32 %34, i32* %3
br label %35
35: ; preds = %21
br label %17
36: ; preds = %17
br label %6
37: ; preds = %6
br label %38
38: ; preds = %56, %37
%39 = load i32, i32* %3
%40 = icmp sgt i32 %39, 0
br i1 %40, label %41, label %57
41: ; preds = %38
br label %42
42: ; preds = %41
%43 = load i32, i32* %2
%44 = shl i32 %43, 6
%45 = load i32, i32* %3
%46 = lshr i32 %44, %45
%47 = and i32 %46, 63
%48 = zext i32 %47 to i64
%49 = getelementptr inbounds [65 x i8], [65 x i8]* @main.b64, i64 0, i64 %48
%50 = load i8, i8* %49
%51 = call i32 @putchar(i8 signext %50)
%52 = load i32, i32* %4
%53 = add nsw i32 %52, 1
store i32 %53, i32* %4
%54 = load i32, i32* %3
%55 = sub nsw i32 %54, 6
store i32 %55, i32* %3
br label %56
56: ; preds = %42
br label %38
57: ; preds = %38
br label %58
58: ; preds = %63, %57
%59 = load i32, i32* %4
%60 = add nsw i32 %59, 1
store i32 %60, i32* %4
%61 = and i32 %59, 3
%62 = icmp ne i32 %61, 0
br i1 %62, label %63, label %65
63: ; preds = %58
%64 = call i32 @putchar(i8 signext 61)
br label %58
65: ; preds = %58
%66 = call i32 @putchar(i8 signext 10)
ret i32 0
}

LLVM IR (-O2):
@main.b64 = internal unnamed_addr constant [65 x i8] c"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\00"
@EOF = global i32 0
define i32 @main() {
%1 = tail call i32 (...) @getchar()
%2 = load i32, i32* @EOF
%3 = icmp eq i32 %1, %2
br i1 %3, label %58, label %13
4: ; preds = %24, %13
%5 = phi i32 [ %20, %13 ], [ %34, %24 ]
%6 = phi i32 [ %16, %13 ], [ %33, %24 ]
%7 = tail call i32 (...) @getchar()
%8 = load i32, i32* @EOF
%9 = icmp eq i32 %7, %8
br i1 %9, label %10, label %13
10: ; preds = %4
%11 = shl i32 %19, 6
%12 = icmp sgt i32 %5, 0
br i1 %12, label %40, label %36
13: ; preds = %0, %4
%14 = phi i32 [ %7, %4 ], [ %1, %0 ]
%15 = phi i32 [ %19, %4 ], [ 0, %0 ]
%16 = phi i32 [ %6, %4 ], [ 0, %0 ]
%17 = phi i32 [ %5, %4 ], [ 0, %0 ]
%18 = shl i32 %15, 8
%19 = add i32 %18, %14
%20 = add nsw i32 %17, 8
%21 = icmp sgt i32 %17, -2
br i1 %21, label %22, label %4
22: ; preds = %13
%23 = shl i32 %19, 6
br label %24
24: ; preds = %22, %24
%25 = phi i32 [ %16, %22 ], [ %33, %24 ]
%26 = phi i32 [ %20, %22 ], [ %34, %24 ]
%27 = lshr i32 %23, %26
%28 = and i32 %27, 63
%29 = zext i32 %28 to i64
%30 = getelementptr inbounds [65 x i8], [65 x i8]* @main.b64, i64 0, i64 %29
%31 = load i8, i8* %30
%32 = tail call i32 @putchar(i8 signext %31)
%33 = add nsw i32 %25, 1
%34 = add nsw i32 %26, -6
%35 = icmp ugt i32 %26, 12
br i1 %35, label %24, label %4
36: ; preds = %40, %10
%37 = phi i32 [ %6, %10 ], [ %49, %40 ]
%38 = and i32 %37, 3
%39 = icmp eq i32 %38, 0
br i1 %39, label %58, label %52
40: ; preds = %10, %40
%41 = phi i32 [ %49, %40 ], [ %6, %10 ]
%42 = phi i32 [ %50, %40 ], [ %5, %10 ]
%43 = lshr i32 %11, %42
%44 = and i32 %43, 63
%45 = zext i32 %44 to i64
%46 = getelementptr inbounds [65 x i8], [65 x i8]* @main.b64, i64 0, i64 %45
%47 = load i8, i8* %46
%48 = tail call i32 @putchar(i8 signext %47)
%49 = add nsw i32 %41, 1
%50 = add nsw i32 %42, -6
%51 = icmp ugt i32 %42, 6
br i1 %51, label %40, label %36
52: ; preds = %36, %52
%53 = phi i32 [ %54, %52 ], [ %37, %36 ]
%54 = add nsw i32 %53, 1
%55 = tail call i32 @putchar(i8 signext 61)
%56 = and i32 %54, 3
%57 = icmp eq i32 %56, 0
br i1 %57, label %58, label %52
58: ; preds = %52, %0, %36
%59 = tail call i32 @putchar(i8 signext 10)
ret i32 0
}