#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*/ isgraph(int);
int printf(char *, int);
int /*<<< orphan*/ putchar(int);
int main() {
  int c, read = 0;
  while ((c = getchar()) != EOF) {
    if (c == '\n' || read == 120) {
      read = 0;
      putchar('\n');
      continue;
    } else
      read++;
    if (!isgraph(c))
      read += printf("0x%x", c) - 1;
    else
      putchar(c);
  }
  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    0x2e81(%rip),%rcx
cmp    (%rcx),%eax
je     11dd <main+0x9d>
cmpl   $0xa,-0x8(%rbp)
je     1183 <main+0x43>
cmpl   $0x78,-0xc(%rbp)
jne    1199 <main+0x59>
movl   $0x0,-0xc(%rbp)
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    1156 <main+0x16>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%edi
call   1060 <isgraph@plt>
cmp    $0x0,%eax
jne    11d0 <main+0x90>
mov    -0x8(%rbp),%esi
lea    0xe43(%rip),%rdi
call   1040 <printf@plt>
sub    $0x1,%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    11d8 <main+0x98>
mov    -0x8(%rbp),%edi
call   1030 <putchar@plt>
jmp    1156 <main+0x16>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1050 <getchar@plt>
mov    0x2e93(%rip),%r15
cmp    (%r15),%eax
jne    1167 <main+0x27>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %eax,%ebp
lea    0xe90(%rip),%r14
xor    %ebx,%ebx
jmp    119a <main+0x5a>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %ebx,%ebx
xor    %eax,%eax
call   1050 <getchar@plt>
mov    %eax,%ebp
cmp    (%r15),%eax
je     115a <main+0x1a>
cmp    $0xa,%ebp
je     1180 <main+0x40>
cmp    $0x78,%ebx
je     1180 <main+0x40>
mov    %ebp,%edi
call   1060 <isgraph@plt>
test   %eax,%eax
je     11bb <main+0x7b>
add    $0x1,%ebx
mov    %ebp,%edi
call   1030 <putchar@plt>
jmp    118c <main+0x4c>
mov    %r14,%rdi
mov    %ebp,%esi
call   1040 <printf@plt>
add    %eax,%ebx
jmp    118c <main+0x4c>

LLVM IR (-O0):
@EOF = global i32 0
@.str = [5 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 = %32, %14, %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 %33
8: ; preds = %4
%9 = load i32, i32* %2
%10 = icmp eq i32 %9, 10
br i1 %10, label %14, label %11
11: ; preds = %8
%12 = load i32, i32* %3
%13 = icmp eq i32 %12, 120
br i1 %13, label %14, label %16
14: ; preds = %11, %8
store i32 0, i32* %3
%15 = call i32 @putchar(i32 10)
br label %4
16: ; preds = %11
%17 = load i32, i32* %3
%18 = add nsw i32 %17, 1
store i32 %18, i32* %3
br label %19
19: ; preds = %16
%20 = load i32, i32* %2
%21 = call i32 @isgraph(i32 %20)
%22 = icmp ne i32 %21, 0
br i1 %22, label %29, label %23
23: ; preds = %19
%24 = load i32, i32* %2
%25 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %24)
%26 = sub nsw i32 %25, 1
%27 = load i32, i32* %3
%28 = add nsw i32 %27, %26
store i32 %28, i32* %3
br label %32
29: ; preds = %19
%30 = load i32, i32* %2
%31 = call i32 @putchar(i32 %30)
br label %32
32: ; preds = %29, %23
br label %4
33: ; preds = %4
ret i32 0
}

LLVM IR (-O2):
@EOF = global i32 0
@.str = [5 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 %26, label %4
4: ; preds = %0, %12
%5 = phi i32 [ %14, %12 ], [ %1, %0 ]
%6 = phi i32 [ %13, %12 ], [ 0, %0 ]
%7 = icmp eq i32 %5, 10
%8 = icmp eq i32 %6, 120
%9 = select i1 %7, i1 true, i1 %8
br i1 %9, label %10, label %17
10: ; preds = %4
%11 = tail call i32 @putchar(i32 10)
br label %12
12: ; preds = %20, %23, %10
%13 = phi i32 [ 0, %10 ], [ %24, %23 ], [ %22, %20 ]
%14 = tail call i32 (...) @getchar()
%15 = load i32, i32* @EOF
%16 = icmp eq i32 %14, %15
br i1 %16, label %26, label %4
17: ; preds = %4
%18 = tail call i32 @isgraph(i32 %5)
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %17
%21 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %5)
%22 = add i32 %21, %6
br label %12
23: ; preds = %17
%24 = add nsw i32 %6, 1
%25 = tail call i32 @putchar(i32 %5)
br label %12
26: ; preds = %12, %0
ret i32 0
}