#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*/ fail(char *);
int /*<<< orphan*/ feof(int /*<<< orphan*/);
int fread(char *, int, int, int /*<<< orphan*/);
int fwrite(char *, int, int, int /*<<< orphan*/);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
int v(char);
int main(int argc, char **argv) {
  char input[4096];
  char output[1024];
  while (!feof(stdin)) {
    int count = fread(input, 3, 1024, stdin);
    if (0 <= count) {
      int size = 3 * count;
      int o = 0;
      for (int i = 0; i < size; i += 3)
        output[o++] = (v(input[i]) << 4) + v(input[i + 1]);
      if (fwrite(output, 1, o, stdout) != o)
        fail("output error");
    } else
      fail("input error");
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1430,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e78(%rip),%rax
mov    (%rax),%edi
call   1060 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    118c <main+0x3c>
jmp    12af <main+0x15f>
lea    -0x1010(%rbp),%rdi
mov    0x2e4e(%rip),%rax
mov    (%rax),%ecx
mov    $0x3,%esi
mov    $0x400,%edx
call   1030 <fread@plt>
mov    %eax,-0x1414(%rbp)
xor    %eax,%eax
cmp    -0x1414(%rbp),%eax
jg     129e <main+0x14e>
imul   $0x3,-0x1414(%rbp),%eax
mov    %eax,-0x1418(%rbp)
movl   $0x0,-0x141c(%rbp)
movl   $0x0,-0x1420(%rbp)
mov    -0x1420(%rbp),%eax
cmp    -0x1418(%rbp),%eax
jge    1261 <main+0x111>
movslq -0x1420(%rbp),%rax
movsbl -0x1010(%rbp,%rax,1),%edi
call   1050 <v@plt>
shl    $0x4,%eax
mov    %eax,-0x1424(%rbp)
mov    -0x1420(%rbp),%eax
add    $0x1,%eax
cltq
movsbl -0x1010(%rbp,%rax,1),%edi
ff
call   1050 <v@plt>
mov    %eax,%ecx
mov    -0x1424(%rbp),%eax
add    %ecx,%eax
mov    %al,%cl
mov    -0x141c(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x141c(%rbp)
cltq
mov    %cl,-0x1410(%rbp,%rax,1)
mov    -0x1420(%rbp),%eax
add    $0x3,%eax
mov    %eax,-0x1420(%rbp)
jmp    11e0 <main+0x90>
lea    -0x1410(%rbp),%rdi
mov    -0x141c(%rbp),%edx
mov    0x2d63(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%esi
call   1070 <fwrite@plt>
cmp    -0x141c(%rbp),%eax
je     1299 <main+0x149>
lea    0xd6c(%rip),%rdi
call   1040 <fail@plt>
jmp    12aa <main+0x15a>
lea    0xd68(%rip),%rdi
call   1040 <fail@plt>
jmp    1169 <main+0x19>
mov    -0x4(%rbp),%eax
add    $0x1430,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1408,%rsp
mov    0x2e80(%rip),%rbp
mov    0x0(%rbp),%edi
call   1060 <feof@plt>
test   %eax,%eax
je     1188 <main+0x38>
xor    %eax,%eax
add    $0x1408,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0x400(%rsp),%r13
lea    0xe76(%rip),%r12
jmp    11b1 <main+0x61>
nopl   0x0(%rax)
call   1040 <fail@plt>
mov    0x0(%rbp),%edi
call   1060 <feof@plt>
test   %eax,%eax
jne    1174 <main+0x24>
mov    0x0(%rbp),%ecx
mov    %r13,%rdi
mov    $0x3,%esi
mov    $0x400,%edx
call   1030 <fread@plt>
mov    %r12,%rdi
test   %eax,%eax
js     11a0 <main+0x50>
je     1220 <main+0xd0>
lea    (%rax,%rax,2),%r14d
xor    %ebx,%ebx
xor    %r15d,%r15d
nopl   0x0(%rax,%rax,1)
movsbl 0x400(%rsp,%r15,1),%edi
call   1050 <v@plt>
mov    %eax,%ebp
shl    $0x4,%ebp
movsbl 0x401(%rsp,%r15,1),%edi
call   1050 <v@plt>
add    %ebp,%eax
mov    %al,(%rsp,%rbx,1)
add    $0x1,%rbx
add    $0x3,%r15
cmp    %r15d,%r14d
jg     11e0 <main+0x90>
mov    0x2dce(%rip),%rbp
jmp    1222 <main+0xd2>
nopl   0x0(%rax)
xor    %ebx,%ebx
mov    0x2daf(%rip),%rax
mov    (%rax),%ecx
mov    %rsp,%rdi
mov    $0x1,%esi
mov    %ebx,%edx
call   1070 <fwrite@plt>
lea    0xdbf(%rip),%rdi
cmp    %ebx,%eax
jne    11a0 <main+0x50>
jmp    11a5 <main+0x55>

LLVM IR (-O0):
@stdin = global i32 0
@stdout = global i32 0
@.str = [13 x i8] c"output error\00"
@.str.1 = [12 x i8] c"input error\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [4096 x i8]
%7 = alloca [1024 x i8]
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
br label %12
12: ; preds = %64, %2
%13 = load i32, i32* @stdin
%14 = call i32 @feof(i32 %13)
%15 = icmp ne i32 %14, 0
%16 = xor i1 %15, true
br i1 %16, label %17, label %65
17: ; preds = %12
%18 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%19 = load i32, i32* @stdin
%20 = call i32 @fread(i8* %18, i32 3, i32 1024, i32 %19)
store i32 %20, i32* %8
%21 = load i32, i32* %8
%22 = icmp sle i32 0, %21
br i1 %22, label %23, label %62
23: ; preds = %17
%24 = load i32, i32* %8
%25 = mul nsw i32 3, %24
store i32 %25, i32* %9
store i32 0, i32* %10
store i32 0, i32* %11
br label %26
26: ; preds = %49, %23
%27 = load i32, i32* %11
%28 = load i32, i32* %9
%29 = icmp slt i32 %27, %28
br i1 %29, label %30, label %52
30: ; preds = %26
%31 = load i32, i32* %11
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 %32
%34 = load i8, i8* %33
%35 = call i32 @v(i8 signext %34)
%36 = shl i32 %35, 4
%37 = load i32, i32* %11
%38 = add nsw i32 %37, 1
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 %39
%41 = load i8, i8* %40
%42 = call i32 @v(i8 signext %41)
%43 = add nsw i32 %36, %42
%44 = trunc i32 %43 to i8
%45 = load i32, i32* %10
%46 = add nsw i32 %45, 1
store i32 %46, i32* %10
%47 = sext i32 %45 to i64
%48 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 %47
store i8 %44, i8* %48
br label %49
49: ; preds = %30
%50 = load i32, i32* %11
%51 = add nsw i32 %50, 3
store i32 %51, i32* %11
br label %26
52: ; preds = %26
%53 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%54 = load i32, i32* %10
%55 = load i32, i32* @stdout
%56 = call i32 @fwrite(i8* %53, i32 1, i32 %54, i32 %55)
%57 = load i32, i32* %10
%58 = icmp ne i32 %56, %57
br i1 %58, label %59, label %61
59: ; preds = %52
%60 = call i32 @fail(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
br label %61
61: ; preds = %59, %52
br label %64
62: ; preds = %17
%63 = call i32 @fail(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
br label %64
64: ; preds = %62, %61
br label %12
65: ; preds = %12
%66 = load i32, i32* %3
ret i32 %66
}

LLVM IR (-O2):
@stdin = global i32 0
@stdout = global i32 0
@.str = [13 x i8] c"output error\00"
@.str.1 = [12 x i8] c"input error\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [4096 x i8]
%4 = alloca [1024 x i8]
%5 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%7 = load i32, i32* @stdin
%8 = call i32 @feof(i32 %7)
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %49
10: ; preds = %2, %45
%11 = load i32, i32* @stdin
%12 = call i32 @fread(i8* %5, i32 3, i32 1024, i32 %11)
%13 = icmp sgt i32 %12, -1
br i1 %13, label %14, label %42
14: ; preds = %10
%15 = mul nsw i32 %12, 3
%16 = icmp eq i32 %12, 0
br i1 %16, label %19, label %24
17: ; preds = %24
%18 = trunc i64 %37 to i32
br label %19
19: ; preds = %17, %14
%20 = phi i32 [ 0, %14 ], [ %18, %17 ]
%21 = load i32, i32* @stdout
%22 = call i32 @fwrite(i8* %6, i32 1, i32 %20, i32 %21)
%23 = icmp eq i32 %22, %20
br i1 %23, label %45, label %42
24: ; preds = %14, %24
%25 = phi i64 [ %37, %24 ], [ 0, %14 ]
%26 = phi i64 [ %39, %24 ], [ 0, %14 ]
%27 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 %26
%28 = load i8, i8* %27
%29 = call i32 @v(i8 signext %28)
%30 = shl i32 %29, 4
%31 = add nuw nsw i64 %26, 1
%32 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 %31
%33 = load i8, i8* %32
%34 = call i32 @v(i8 signext %33)
%35 = add nsw i32 %34, %30
%36 = trunc i32 %35 to i8
%37 = add nuw i64 %25, 1
%38 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 %25
store i8 %36, i8* %38
%39 = add nuw i64 %26, 3
%40 = trunc i64 %39 to i32
%41 = icmp sgt i32 %15, %40
br i1 %41, label %24, label %17
42: ; preds = %10, %19
%43 = phi i8* [ getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), %19 ], [ getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), %10 ]
%44 = call i32 @fail(i8* %43)
br label %45
45: ; preds = %42, %19
%46 = load i32, i32* @stdin
%47 = call i32 @feof(i32 %46)
%48 = icmp eq i32 %47, 0
br i1 %48, label %10, label %49
49: ; preds = %45, %2
ret i32 0
}