#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 main(int argc, char **argv) {
  char input[1024];
  char output[4096];
  while (!feof(stdin)) {
    int size = fread(input, 1, 1024, stdin);
    if (0 <= size) {
      int o = 0;
      for (int i = 0; i < size; i++) {
        char *hex = "0123456789ABCDEF";
        char b = input[i];
        output[o++] = hex[(b >> 4) & 15];
        output[o++] = hex[(b >> 0) & 15];
        output[o++] = '_';
      }
      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    0x2e88(%rip),%rax
mov    (%rax),%edi
call   1050 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    117c <main+0x3c>
jmp    12dc <main+0x19c>
lea    -0x410(%rbp),%rdi
mov    0x2e5e(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%esi
mov    $0x400,%edx
call   1030 <fread@plt>
mov    %eax,-0x1414(%rbp)
xor    %eax,%eax
cmp    -0x1414(%rbp),%eax
jg     12cb <main+0x18b>
movl   $0x0,-0x1418(%rbp)
movl   $0x0,-0x141c(%rbp)
mov    -0x141c(%rbp),%eax
cmp    -0x1414(%rbp),%eax
jge    128e <main+0x14e>
lea    0xe24(%rip),%rax
mov    %rax,-0x1428(%rbp)
movslq -0x141c(%rbp),%rax
mov    -0x410(%rbp,%rax,1),%al
mov    %al,-0x1429(%rbp)
mov    -0x1428(%rbp),%rax
movsbl -0x1429(%rbp),%ecx
sar    $0x4,%ecx
and    $0xf,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,1),%cl
mov    -0x1418(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x1418(%rbp)
cltq
mov    %cl,-0x1410(%rbp,%rax,1)
mov    -0x1428(%rbp),%rax
movsbl -0x1429(%rbp),%ecx
sar    $0x0,%ecx
and    $0xf,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,1),%cl
mov    -0x1418(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x1418(%rbp)
cltq
mov    %cl,-0x1410(%rbp,%rax,1)
mov    -0x1418(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x1418(%rbp)
cltq
movb   $0x5f,-0x1410(%rbp,%rax,1)
5f
mov    -0x141c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x141c(%rbp)
jmp    11c3 <main+0x83>
lea    -0x1410(%rbp),%rdi
mov    -0x1418(%rbp),%edx
mov    0x2d36(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%esi
call   1060 <fwrite@plt>
cmp    -0x1418(%rbp),%eax
je     12c6 <main+0x186>
lea    0xd50(%rip),%rdi
call   1040 <fail@plt>
jmp    12d7 <main+0x197>
lea    0xd4c(%rip),%rdi
call   1040 <fail@plt>
jmp    1159 <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    0x2e90(%rip),%r12
mov    (%r12),%edi
call   1050 <feof@plt>
test   %eax,%eax
je     1179 <main+0x39>
xor    %eax,%eax
add    $0x1408,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0x1000(%rsp),%r15
lea    0xe96(%rip),%r13
lea    0xe82(%rip),%rbp
lea    0xe6a(%rip),%r14
jmp    11b2 <main+0x72>
nopl   0x0(%rax,%rax,1)
call   1040 <fail@plt>
mov    (%r12),%edi
call   1050 <feof@plt>
test   %eax,%eax
jne    1165 <main+0x25>
mov    (%r12),%ecx
mov    %r15,%rdi
mov    $0x1,%esi
mov    $0x400,%edx
call   1030 <fread@plt>
mov    %r13,%rdi
test   %eax,%eax
js     11a0 <main+0x60>
je     1220 <main+0xe0>
mov    %eax,%eax
lea    (%rax,%rax,2),%rdi
mov    %r15,%rcx
xor    %ebx,%ebx
nopl   0x0(%rax)
movzbl (%rcx),%edx
mov    %rdx,%rsi
shr    $0x4,%rsi
movzbl (%rsi,%r14,1),%eax
mov    %al,(%rsp,%rbx,1)
and    $0xf,%edx
movzbl (%rdx,%r14,1),%eax
mov    %al,0x1(%rsp,%rbx,1)
movb   $0x5f,0x2(%rsp,%rbx,1)
add    $0x3,%rbx
add    $0x1,%rcx
cmp    %rbx,%rdi
jne    11e0 <main+0xa0>
jmp    1222 <main+0xe2>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %ebx,%ebx
mov    0x2daf(%rip),%rax
mov    (%rax),%ecx
mov    %rsp,%rdi
mov    $0x1,%esi
mov    %ebx,%edx
call   1060 <fwrite@plt>
mov    %rbp,%rdi
cmp    %ebx,%eax
jne    11a0 <main+0x60>
jmp    11a5 <main+0x65>

LLVM IR (-O0):
@stdin = global i32 0
@.str = [17 x i8] c"0123456789ABCDEF\00"
@stdout = global i32 0
@.str.1 = [13 x i8] c"output error\00"
@.str.2 = [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 [1024 x i8]
%7 = alloca [4096 x i8]
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i8
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
br label %13
13: ; preds = %77, %2
%14 = load i32, i32* @stdin
%15 = call i32 @feof(i32 %14)
%16 = icmp ne i32 %15, 0
%17 = xor i1 %16, true
br i1 %17, label %18, label %78
18: ; preds = %13
%19 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%20 = load i32, i32* @stdin
%21 = call i32 @fread(i8* %19, i32 1, i32 1024, i32 %20)
store i32 %21, i32* %8
%22 = load i32, i32* %8
%23 = icmp sle i32 0, %22
br i1 %23, label %24, label %75
24: ; preds = %18
store i32 0, i32* %9
store i32 0, i32* %10
br label %25
25: ; preds = %62, %24
%26 = load i32, i32* %10
%27 = load i32, i32* %8
%28 = icmp slt i32 %26, %27
br i1 %28, label %29, label %65
29: ; preds = %25
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8** %11
%30 = load i32, i32* %10
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 %31
%33 = load i8, i8* %32
store i8 %33, i8* %12
%34 = load i8*, i8** %11
%35 = load i8, i8* %12
%36 = sext i8 %35 to i32
%37 = ashr i32 %36, 4
%38 = and i32 %37, 15
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i8, i8* %34, i64 %39
%41 = load i8, i8* %40
%42 = load i32, i32* %9
%43 = add nsw i32 %42, 1
store i32 %43, i32* %9
%44 = sext i32 %42 to i64
%45 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 %44
store i8 %41, i8* %45
%46 = load i8*, i8** %11
%47 = load i8, i8* %12
%48 = sext i8 %47 to i32
%49 = ashr i32 %48, 0
%50 = and i32 %49, 15
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds i8, i8* %46, i64 %51
%53 = load i8, i8* %52
%54 = load i32, i32* %9
%55 = add nsw i32 %54, 1
store i32 %55, i32* %9
%56 = sext i32 %54 to i64
%57 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 %56
store i8 %53, i8* %57
%58 = load i32, i32* %9
%59 = add nsw i32 %58, 1
store i32 %59, i32* %9
%60 = sext i32 %58 to i64
%61 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 %60
store i8 95, i8* %61
br label %62
62: ; preds = %29
%63 = load i32, i32* %10
%64 = add nsw i32 %63, 1
store i32 %64, i32* %10
br label %25
65: ; preds = %25
%66 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 0
%67 = load i32, i32* %9
%68 = load i32, i32* @stdout
%69 = call i32 @fwrite(i8* %66, i32 1, i32 %67, i32 %68)
%70 = load i32, i32* %9
%71 = icmp ne i32 %69, %70
br i1 %71, label %72, label %74
72: ; preds = %65
%73 = call i32 @fail(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
br label %74
74: ; preds = %72, %65
br label %77
75: ; preds = %18
%76 = call i32 @fail(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
br label %77
77: ; preds = %75, %74
br label %13
78: ; preds = %13
%79 = load i32, i32* %3
ret i32 %79
}

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