#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*/ printf(char *, int);
int /*<<< orphan*/ putchar(char);
int main(void) {
  int c;
  int pos = 0;
  while ((c = getchar()) != EOF) {
    if (c == '\n') {
      pos = 0;
      putchar(c);
    } else if ((c > 31) && (c < 127)) {
      pos++;
      putchar(c);
      if (pos == 85) {
        pos = 0;
        putchar('\n');
      }
    } else {
      pos += 6;
      if (pos == 85) {
        pos = 0;
        printf("_0x%X\n", c);
      } else if (pos > 85) {
        pos = 2;
        printf("\n_0x%X_", c);
      } else {
        printf("_0x%X_", c);
      }
    }
  }
  putchar('\n');
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %eax,-0x8(%rbp)
mov    0x2e91(%rip),%rcx
cmp    (%rcx),%eax
je     123e <main+0x10e>
cmpl   $0xa,-0x8(%rbp)
jne    1180 <main+0x50>
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%eax
movsbl %al,%edi
call   1030 <putchar@plt>
jmp    1239 <main+0x109>
cmpl   $0x1f,-0x8(%rbp)
jle    11c8 <main+0x98>
cmpl   $0x7f,-0x8(%rbp)
jge    11c8 <main+0x98>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
movsbl %al,%edi
call   1030 <putchar@plt>
cmpl   $0x55,-0xc(%rbp)
jne    11c3 <main+0x93>
movl   $0x0,-0xc(%rbp)
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    1234 <main+0x104>
mov    -0xc(%rbp),%eax
add    $0x6,%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x55,-0xc(%rbp)
jne    11f6 <main+0xc6>
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%esi
lea    0xe14(%rip),%rdi
call   1040 <printf@plt>
jmp    122f <main+0xff>
cmpl   $0x55,-0xc(%rbp)
jle    121b <main+0xeb>
movl   $0x2,-0xc(%rbp)
mov    -0x8(%rbp),%esi
lea    0xdf6(%rip),%rdi
call   1040 <printf@plt>
jmp    122a <main+0xfa>
mov    -0x8(%rbp),%esi
lea    0xde3(%rip),%rdi
call   1040 <printf@plt>
jmp    122f <main+0xff>
jmp    1234 <main+0x104>
jmp    1239 <main+0x109>
jmp    1146 <main+0x16>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x10,%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   1050 <getchar@plt>
mov    0x2e9f(%rip),%r13
cmp    0x0(%r13),%eax
jne    116a <main+0x3a>
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
lea    0xe8f(%rip),%r15
lea    0xe8f(%rip),%r14
lea    0xe89(%rip),%r12
xor    %ebx,%ebx
jmp    11bf <main+0x8f>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%ebx
movsbl %al,%edi
call   1030 <putchar@plt>
mov    %ebx,%ebp
cmp    $0x55,%ebx
je     11c4 <main+0x94>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %eax,%eax
call   1050 <getchar@plt>
mov    %ebp,%ebx
cmp    0x0(%r13),%eax
je     114f <main+0x1f>
cmp    $0xa,%eax
jne    11e0 <main+0xb0>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %ebp,%ebp
jmp    11b0 <main+0x80>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
lea    -0x20(%rax),%ecx
cmp    $0x5e,%ecx
jbe    1190 <main+0x60>
lea    0x6(%rbx),%ebp
cmp    $0x55,%ebp
je     1201 <main+0xd1>
cmp    $0x50,%ebx
jge    120d <main+0xdd>
mov    %r12,%rdi
mov    %eax,%esi
call   1040 <printf@plt>
jmp    11b0 <main+0x80>
mov    %r15,%rdi
mov    %eax,%esi
call   1040 <printf@plt>
jmp    11ce <main+0x9e>
mov    %r14,%rdi
mov    %eax,%esi
call   1040 <printf@plt>
mov    $0x2,%ebp
jmp    11b0 <main+0x80>

LLVM IR (-O0):
@EOF = global i32 0
@.str = [7 x i8] c"_0x%X\0A\00"
@.str.1 = [8 x i8] c"\0A_0x%X_\00"
@.str.2 = [7 x i8] c"_0x%X_\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
br label %4
4: ; preds = %52, %0
%5 = call i32 (...) @getchar()
store i32 %5, i32* %2
%6 = load i32, i32* @EOF
%7 = icmp ne i32 %5, %6
br i1 %7, label %8, label %53
8: ; preds = %4
%9 = load i32, i32* %2
%10 = icmp eq i32 %9, 10
br i1 %10, label %11, label %15
11: ; preds = %8
store i32 0, i32* %3
%12 = load i32, i32* %2
%13 = trunc i32 %12 to i8
%14 = call i32 @putchar(i8 signext %13)
br label %52
15: ; preds = %8
%16 = load i32, i32* %2
%17 = icmp sgt i32 %16, 31
br i1 %17, label %18, label %32
18: ; preds = %15
%19 = load i32, i32* %2
%20 = icmp slt i32 %19, 127
br i1 %20, label %21, label %32
21: ; preds = %18
%22 = load i32, i32* %3
%23 = add nsw i32 %22, 1
store i32 %23, i32* %3
%24 = load i32, i32* %2
%25 = trunc i32 %24 to i8
%26 = call i32 @putchar(i8 signext %25)
%27 = load i32, i32* %3
%28 = icmp eq i32 %27, 85
br i1 %28, label %29, label %31
29: ; preds = %21
store i32 0, i32* %3
%30 = call i32 @putchar(i8 signext 10)
br label %31
31: ; preds = %29, %21
br label %51
32: ; preds = %18, %15
%33 = load i32, i32* %3
%34 = add nsw i32 %33, 6
store i32 %34, i32* %3
%35 = load i32, i32* %3
%36 = icmp eq i32 %35, 85
br i1 %36, label %37, label %40
37: ; preds = %32
store i32 0, i32* %3
%38 = load i32, i32* %2
%39 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %38)
br label %50
40: ; preds = %32
%41 = load i32, i32* %3
%42 = icmp sgt i32 %41, 85
br i1 %42, label %43, label %46
43: ; preds = %40
store i32 2, i32* %3
%44 = load i32, i32* %2
%45 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %44)
br label %49
46: ; preds = %40
%47 = load i32, i32* %2
%48 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %47)
br label %49
49: ; preds = %46, %43
br label %50
50: ; preds = %49, %37
br label %51
51: ; preds = %50, %31
br label %52
52: ; preds = %51, %11
br label %4
53: ; preds = %4
%54 = call i32 @putchar(i8 signext 10)
ret i32 0
}

LLVM IR (-O2):
@EOF = global i32 0
@.str = [7 x i8] c"_0x%X\0A\00"
@.str.1 = [8 x i8] c"\0A_0x%X_\00"
@.str.2 = [7 x i8] c"_0x%X_\00"
define i32 @main() {
%1 = tail call i32 (...) @getchar()
%2 = load i32, i32* @EOF
%3 = icmp eq i32 %1, %2
br i1 %3, label %36, label %4
4: ; preds = %0, %31
%5 = phi i32 [ %33, %31 ], [ %1, %0 ]
%6 = phi i32 [ %32, %31 ], [ 0, %0 ]
%7 = icmp eq i32 %5, 10
br i1 %7, label %8, label %10
8: ; preds = %4
%9 = tail call i32 @putchar(i8 signext 10)
br label %31
10: ; preds = %4
%11 = add i32 %5, -32
%12 = icmp ult i32 %11, 95
br i1 %12, label %13, label %20
13: ; preds = %10
%14 = add nsw i32 %6, 1
%15 = trunc i32 %5 to i8
%16 = tail call i32 @putchar(i8 signext %15)
%17 = icmp eq i32 %14, 85
br i1 %17, label %18, label %31
18: ; preds = %13
%19 = tail call i32 @putchar(i8 signext 10)
br label %31
20: ; preds = %10
%21 = add nsw i32 %6, 6
%22 = icmp eq i32 %21, 85
br i1 %22, label %23, label %25
23: ; preds = %20
%24 = tail call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %5)
br label %31
25: ; preds = %20
%26 = icmp sgt i32 %6, 79
br i1 %26, label %27, label %29
27: ; preds = %25
%28 = tail call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %5)
br label %31
29: ; preds = %25
%30 = tail call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %5)
br label %31
31: ; preds = %18, %13, %27, %29, %23, %8
%32 = phi i32 [ 0, %8 ], [ 0, %18 ], [ %14, %13 ], [ 0, %23 ], [ 2, %27 ], [ %21, %29 ]
%33 = tail call i32 (...) @getchar()
%34 = load i32, i32* @EOF
%35 = icmp eq i32 %33, %34
br i1 %35, label %36, label %4
36: ; preds = %31, %0
%37 = tail call i32 @putchar(i8 signext 10)
ret i32 0
}