#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 */
char EOF;
char getchar();
scalar_t__ isprint(char);
int nextline(int, int, int);
int /*<<< orphan*/ printf(char *, char *);
int snprintf(char *, int, char *, ...);
int main(void) {
  int pos = 1;
  int len;
  char c;
  char s[13];
  while ((c = getchar()) != EOF) {
    if (isprint(c) || c == '\n' || c == '\t')
      len = snprintf(s, 13, "%c", c);
    else if (c == '\r')
      len = snprintf(s, 13, "");
    else
      len = snprintf(s, 13, " \\x%x ", (unsigned)c);
    pos = nextline(len, pos, 80);
    printf("%s", s);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %al,-0xd(%rbp)
movsbl %al,%eax
mov    0x2e6e(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     124c <main+0xfc>
movsbl -0xd(%rbp),%edi
call   1070 <isprint@plt>
cmp    $0x0,%rax
jne    11b2 <main+0x62>
movsbl -0xd(%rbp),%eax
cmp    $0xa,%eax
je     11b2 <main+0x62>
movsbl -0xd(%rbp),%eax
cmp    $0x9,%eax
jne    11d5 <main+0x85>
lea    -0x1a(%rbp),%rdi
movsbl -0xd(%rbp),%ecx
mov    $0xd,%esi
lea    0xe3a(%rip),%rdx
mov    $0x0,%al
call   1040 <snprintf@plt>
mov    %eax,-0xc(%rbp)
jmp    1224 <main+0xd4>
movsbl -0xd(%rbp),%eax
cmp    $0xd,%eax
jne    1201 <main+0xb1>
lea    -0x1a(%rbp),%rdi
mov    $0xd,%esi
lea    0xe17(%rip),%rdx
mov    $0x0,%al
call   1040 <snprintf@plt>
mov    %eax,-0xc(%rbp)
jmp    121f <main+0xcf>
lea    -0x1a(%rbp),%rdi
movsbl -0xd(%rbp),%ecx
mov    $0xd,%esi
lea    0xdee(%rip),%rdx
mov    $0x0,%al
call   1040 <snprintf@plt>
mov    %eax,-0xc(%rbp)
jmp    1224 <main+0xd4>
mov    -0xc(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    $0x50,%edx
call   1060 <nextline@plt>
mov    %eax,-0x8(%rbp)
lea    -0x1a(%rbp),%rsi
lea    0xdc8(%rip),%rdi
call   1030 <printf@plt>
jmp    1166 <main+0x16>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
xor    %eax,%eax
call   1050 <getchar@plt>
mov    0x2e7c(%rip),%r14
cmp    (%r14),%al
jne    1182 <main+0x32>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %eax,%r12d
mov    $0x1,%ebp
lea    0xb(%rsp),%rbx
lea    0xe74(%rip),%r15
jmp    11e3 <main+0x93>
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    $0xd,%esi
lea    0xe51(%rip),%rdx
mov    %r13d,%ecx
xor    %eax,%eax
call   1040 <snprintf@plt>
mov    %eax,%edi
mov    %ebp,%esi
mov    $0x50,%edx
call   1060 <nextline@plt>
mov    %eax,%ebp
mov    %r15,%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
mov    %eax,%r12d
cmp    (%r14),%al
je     1171 <main+0x21>
movsbl %r12b,%r13d
mov    %r13d,%edi
call   1070 <isprint@plt>
lea    -0x9(%r13),%ecx
cmp    $0x2,%cl
jb     11a0 <main+0x50>
test   %rax,%rax
jne    11a0 <main+0x50>
mov    %rbx,%rdi
mov    $0xd,%esi
cmp    $0xd,%r12b
jne    1220 <main+0xd0>
lea    0xdf7(%rip),%rdx
xor    %eax,%eax
call   1040 <snprintf@plt>
jmp    11b9 <main+0x69>
nopl   0x0(%rax,%rax,1)
lea    0xddc(%rip),%rdx
jmp    11af <main+0x5f>

LLVM IR (-O0):
@EOF = global i8 0
@.str = [3 x i8] c"%c\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [7 x i8] c" \\x%x \00"
@.str.3 = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8
%5 = alloca [13 x i8]
store i32 0, i32* %1
store i32 1, i32* %2
br label %6
6: ; preds = %42, %0
%7 = call signext i8 (...) @getchar()
store i8 %7, i8* %4
%8 = sext i8 %7 to i32
%9 = load i8, i8* @EOF
%10 = sext i8 %9 to i32
%11 = icmp ne i32 %8, %10
br i1 %11, label %12, label %48
12: ; preds = %6
%13 = load i8, i8* %4
%14 = call i64 @isprint(i8 signext %13)
%15 = icmp ne i64 %14, 0
br i1 %15, label %24, label %16
16: ; preds = %12
%17 = load i8, i8* %4
%18 = sext i8 %17 to i32
%19 = icmp eq i32 %18, 10
br i1 %19, label %24, label %20
20: ; preds = %16
%21 = load i8, i8* %4
%22 = sext i8 %21 to i32
%23 = icmp eq i32 %22, 9
br i1 %23, label %24, label %29
24: ; preds = %20, %16, %12
%25 = getelementptr inbounds [13 x i8], [13 x i8]* %5, i64 0, i64 0
%26 = load i8, i8* %4
%27 = sext i8 %26 to i32
%28 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %25, i32 13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %27)
store i32 %28, i32* %3
br label %42
29: ; preds = %20
%30 = load i8, i8* %4
%31 = sext i8 %30 to i32
%32 = icmp eq i32 %31, 13
br i1 %32, label %33, label %36
33: ; preds = %29
%34 = getelementptr inbounds [13 x i8], [13 x i8]* %5, i64 0, i64 0
%35 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %34, i32 13, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
store i32 %35, i32* %3
br label %41
36: ; preds = %29
%37 = getelementptr inbounds [13 x i8], [13 x i8]* %5, i64 0, i64 0
%38 = load i8, i8* %4
%39 = sext i8 %38 to i32
%40 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %37, i32 13, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %39)
store i32 %40, i32* %3
br label %41
41: ; preds = %36, %33
br label %42
42: ; preds = %41, %24
%43 = load i32, i32* %3
%44 = load i32, i32* %2
%45 = call i32 @nextline(i32 %43, i32 %44, i32 80)
store i32 %45, i32* %2
%46 = getelementptr inbounds [13 x i8], [13 x i8]* %5, i64 0, i64 0
%47 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %46)
br label %6
48: ; preds = %6
ret i32 0
}

LLVM IR (-O2):
@EOF = global i8 0
@.str = [3 x i8] c"%c\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [7 x i8] c" \\x%x \00"
@.str.3 = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca [13 x i8]
%2 = getelementptr inbounds [13 x i8], [13 x i8]* %1, i64 0, i64 0
%3 = call signext i8 (...) @getchar()
%4 = load i8, i8* @EOF
%5 = icmp eq i8 %3, %4
br i1 %5, label %30, label %6
6: ; preds = %0, %23
%7 = phi i8 [ %27, %23 ], [ %3, %0 ]
%8 = phi i32 [ %25, %23 ], [ 1, %0 ]
%9 = sext i8 %7 to i32
%10 = call i64 @isprint(i8 signext %7)
%11 = icmp ne i64 %10, 0
%12 = add i8 %7, -9
%13 = icmp ult i8 %12, 2
%14 = or i1 %13, %11
br i1 %14, label %15, label %17
15: ; preds = %6
%16 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %2, i32 13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %9)
br label %23
17: ; preds = %6
%18 = icmp eq i8 %7, 13
br i1 %18, label %19, label %21
19: ; preds = %17
%20 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %2, i32 13, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
br label %23
21: ; preds = %17
%22 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %2, i32 13, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %9)
br label %23
23: ; preds = %19, %21, %15
%24 = phi i32 [ %16, %15 ], [ %20, %19 ], [ %22, %21 ]
%25 = call i32 @nextline(i32 %24, i32 %8, i32 80)
%26 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %2)
%27 = call signext i8 (...) @getchar()
%28 = load i8, i8* @EOF
%29 = icmp eq i8 %27, %28
br i1 %29, label %30, label %6
30: ; preds = %23, %0
ret i32 0
}