#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 /*<<< orphan*/ EOF;
int /*<<< orphan*/ c;
int /*<<< orphan*/ encode(char *, int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ flushout();
int /*<<< orphan*/ getchar();
main() {
  register char *p;
  register char *e;
  register c;
  char b3[3];
  p = b3;
  e = b3 + 3;
  while ((c = getchar()) != EOF) {
    *p++ = c;
    if (p == e) {
      encode(b3, 3);
      p = b3;
    }
  }
  encode(b3, p - b3);
  flushout();
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x1f(%rbp),%rax
mov    %rax,-0x10(%rbp)
lea    -0x1f(%rbp),%rax
add    $0x3,%rax
mov    %rax,-0x18(%rbp)
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %eax,-0x1c(%rbp)
mov    0x2e74(%rip),%rcx
cmp    (%rcx),%eax
je     11bb <main+0x7b>
mov    -0x1c(%rbp),%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x10(%rbp)
mov    %cl,(%rax)
mov    -0x10(%rbp),%rax
cmp    -0x18(%rbp),%rax
jne    11b6 <main+0x76>
lea    -0x1f(%rbp),%rdi
mov    $0x3,%esi
call   1040 <encode@plt>
lea    -0x1f(%rbp),%rax
mov    %rax,-0x10(%rbp)
jmp    1163 <main+0x23>
lea    -0x1f(%rbp),%rdi
mov    -0x10(%rbp),%rax
lea    -0x1f(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%esi
call   1040 <encode@plt>
mov    $0x0,%al
call   1030 <flushout@plt>
xor    %edi,%edi
call   1060 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
xor    %eax,%eax
call   1050 <getchar@plt>
mov    0x2e92(%rip),%r15
cmp    (%r15),%eax
jne    117c <main+0x3c>
lea    0x5(%rsp),%rbx
lea    0x5(%rsp),%rdi
sub    %edi,%ebx
mov    %ebx,%esi
call   1040 <encode@plt>
xor    %eax,%eax
call   1030 <flushout@plt>
xor    %edi,%edi
call   1060 <exit@plt>
lea    0x8(%rsp),%r12
lea    0x5(%rsp),%r14
mov    %r14,%rbx
jmp    119c <main+0x5c>
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    (%r15),%eax
je     1160 <main+0x20>
mov    %al,(%rbx)
add    $0x1,%rbx
cmp    %r12,%rbx
jne    1190 <main+0x50>
mov    %r14,%rdi
mov    $0x3,%esi
call   1040 <encode@plt>
mov    %r14,%rbx
jmp    1190 <main+0x50>

LLVM IR (-O0):
@EOF = global i32 0
@c = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
%5 = alloca [3 x i8]
store i32 0, i32* %1
%6 = getelementptr inbounds [3 x i8], [3 x i8]* %5, i64 0, i64 0
store i8* %6, i8** %2
%7 = getelementptr inbounds [3 x i8], [3 x i8]* %5, i64 0, i64 0
%8 = getelementptr inbounds i8, i8* %7, i64 3
store i8* %8, i8** %3
br label %9
9: ; preds = %25, %0
%10 = call i32 (...) @getchar()
store i32 %10, i32* %4
%11 = load i32, i32* @EOF
%12 = icmp ne i32 %10, %11
br i1 %12, label %13, label %26
13: ; preds = %9
%14 = load i32, i32* %4
%15 = trunc i32 %14 to i8
%16 = load i8*, i8** %2
%17 = getelementptr inbounds i8, i8* %16, i32 1
store i8* %17, i8** %2
store i8 %15, i8* %16
%18 = load i8*, i8** %2
%19 = load i8*, i8** %3
%20 = icmp eq i8* %18, %19
br i1 %20, label %21, label %25
21: ; preds = %13
%22 = getelementptr inbounds [3 x i8], [3 x i8]* %5, i64 0, i64 0
%23 = call i32 @encode(i8* %22, i32 3)
%24 = getelementptr inbounds [3 x i8], [3 x i8]* %5, i64 0, i64 0
store i8* %24, i8** %2
br label %25
25: ; preds = %21, %13
br label %9
26: ; preds = %9
%27 = getelementptr inbounds [3 x i8], [3 x i8]* %5, i64 0, i64 0
%28 = load i8*, i8** %2
%29 = getelementptr inbounds [3 x i8], [3 x i8]* %5, i64 0, i64 0
%30 = ptrtoint i8* %28 to i64
%31 = ptrtoint i8* %29 to i64
%32 = sub i64 %30, %31
%33 = trunc i64 %32 to i32
%34 = call i32 @encode(i8* %27, i32 %33)
%35 = call i32 (...) @flushout()
%36 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@EOF = global i32 0
@c = global i32 0
define i32 @main() {
%1 = alloca [3 x i8]
%2 = getelementptr inbounds [3 x i8], [3 x i8]* %1, i64 0, i64 0
%3 = getelementptr inbounds [3 x i8], [3 x i8]* %1, i64 0, i64 3
%4 = call i32 (...) @getchar()
%5 = load i32, i32* @EOF
%6 = icmp eq i32 %4, %5
br i1 %6, label %20, label %7
7: ; preds = %0, %15
%8 = phi i32 [ %17, %15 ], [ %4, %0 ]
%9 = phi i8* [ %16, %15 ], [ %2, %0 ]
%10 = trunc i32 %8 to i8
%11 = getelementptr inbounds i8, i8* %9, i64 1
store i8 %10, i8* %9
%12 = icmp eq i8* %11, %3
br i1 %12, label %13, label %15
13: ; preds = %7
%14 = call i32 @encode(i8* %2, i32 3)
br label %15
15: ; preds = %13, %7
%16 = phi i8* [ %2, %13 ], [ %11, %7 ]
%17 = call i32 (...) @getchar()
%18 = load i32, i32* @EOF
%19 = icmp eq i32 %17, %18
br i1 %19, label %20, label %7
20: ; preds = %15, %0
%21 = phi i8* [ %2, %0 ], [ %16, %15 ]
%22 = ptrtoint i8* %21 to i64
%23 = ptrtoint [3 x i8]* %1 to i64
%24 = sub i64 %22, %23
%25 = trunc i64 %24 to i32
%26 = call i32 @encode(i8* %2, i32 %25)
%27 = call i32 (...) @flushout()
%28 = call i32 @exit(i32 0)
unreachable
}