#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*/ STDIN_FILENO;
int /*<<< orphan*/ STDOUT_FILENO;
int /*<<< orphan*/ fsync(int /*<<< orphan*/);
scalar_t__ isprint(unsigned char);
int read(int /*<<< orphan*/, unsigned char *, int);
int strlen(char *);
int /*<<< orphan*/ write(int /*<<< orphan*/, ...);
int main(void) {
  unsigned char buffer[128 + 1];
  int len = read(STDIN_FILENO, buffer, 128);
  while (len > 0) {
    int i;
    for (i = 0; i < len; i++) {
      if (isprint(buffer[i]) || buffer[i] == '\t' || buffer[i] == '\n') {
        write(STDOUT_FILENO, &buffer[i], 1);
      } else {
        char *prefix = NULL, *list = NULL;
        if (buffer[i] <= 0x7F) {
          prefix = "^";
          list = "@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_?";
        } else if (buffer[i] <= 0x9F || buffer[i] == 0xFF) {
          prefix = "M-^";
          list = "@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_?";
          buffer[i] -= 0x80;
        } else if (buffer[i] < 0xFF) {
          prefix = "M-";
          list = " !\"#$%&'()*+,-./"
                 "0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`"
                 "abcdefghijklmnopqrstuvwxyz{|}~";
          buffer[i] -= 0xA0;
        }
        if (buffer[i] == 0x7F)
          buffer[i] = 0x20;
        char *ch = list + (buffer[i] % strlen(list));
        write(STDOUT_FILENO, prefix, strlen(prefix));
        write(STDOUT_FILENO, ch, 1);
      }
    }
    len = read(STDIN_FILENO, buffer, 128);
  }
  fsync(STDOUT_FILENO);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd0,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e6f(%rip),%rax
mov    (%rax),%edi
lea    -0x90(%rbp),%rsi
mov    $0x80,%edx
call   1050 <read@plt>
mov    %eax,-0x94(%rbp)
cmpl   $0x0,-0x94(%rbp)
jle    144e <main+0x2fe>
movl   $0x0,-0x98(%rbp)
mov    -0x98(%rbp),%eax
cmp    -0x94(%rbp),%eax
jge    1429 <main+0x2d9>
movslq -0x98(%rbp),%rax
movzbl -0x90(%rbp,%rax,1),%edi
ff
call   1060 <isprint@plt>
cmp    $0x0,%rax
jne    11f9 <main+0xa9>
movslq -0x98(%rbp),%rax
movzbl -0x90(%rbp,%rax,1),%eax
ff
cmp    $0x9,%eax
je     11f9 <main+0xa9>
movslq -0x98(%rbp),%rax
movzbl -0x90(%rbp,%rax,1),%eax
ff
cmp    $0xa,%eax
jne    1224 <main+0xd4>
mov    0x2df0(%rip),%rax
mov    (%rax),%edi
movslq -0x98(%rbp),%rax
lea    -0x90(%rbp),%rsi
add    %rax,%rsi
mov    $0x1,%edx
mov    $0x0,%al
call   1030 <write@plt>
jmp    1410 <main+0x2c0>
movq   $0x0,-0xa0(%rbp)
movq   $0x0,-0xa8(%rbp)
movslq -0x98(%rbp),%rax
movzbl -0x90(%rbp,%rax,1),%eax
ff
cmp    $0x7f,%eax
jg     1273 <main+0x123>
lea    0xdcb(%rip),%rax
mov    %rax,-0xa0(%rbp)
lea    0xd99(%rip),%rax
mov    %rax,-0xa8(%rbp)
jmp    1340 <main+0x1f0>
movslq -0x98(%rbp),%rax
movzbl -0x90(%rbp,%rax,1),%eax
ff
cmp    $0x9f,%eax
jle    12a7 <main+0x157>
movslq -0x98(%rbp),%rax
movzbl -0x90(%rbp,%rax,1),%eax
ff
cmp    $0xff,%eax
jne    12e4 <main+0x194>
lea    0xd74(%rip),%rax
mov    %rax,-0xa0(%rbp)
lea    0xd44(%rip),%rax
mov    %rax,-0xa8(%rbp)
movslq -0x98(%rbp),%rax
movzbl -0x90(%rbp,%rax,1),%ecx
ff
sub    $0x80,%ecx
mov    %cl,-0x90(%rbp,%rax,1)
jmp    133b <main+0x1eb>
movslq -0x98(%rbp),%rax
movzbl -0x90(%rbp,%rax,1),%eax
ff
cmp    $0xff,%eax
jge    1336 <main+0x1e6>
lea    0xd21(%rip),%rax
mov    %rax,-0xa0(%rbp)
lea    0xd16(%rip),%rax
mov    %rax,-0xa8(%rbp)
movslq -0x98(%rbp),%rax
movzbl -0x90(%rbp,%rax,1),%ecx
ff
sub    $0xa0,%ecx
mov    %cl,-0x90(%rbp,%rax,1)
jmp    133b <main+0x1eb>
jmp    1340 <main+0x1f0>
movslq -0x98(%rbp),%rax
movzbl -0x90(%rbp,%rax,1),%eax
ff
cmp    $0x7f,%eax
jne    1367 <main+0x217>
movslq -0x98(%rbp),%rax
movb   $0x20,-0x90(%rbp,%rax,1)
20
mov    -0xa8(%rbp),%rax
mov    %rax,-0xc8(%rbp)
movslq -0x98(%rbp),%rax
movzbl -0x90(%rbp,%rax,1),%eax
ff
mov    %eax,-0xcc(%rbp)
mov    -0xa8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0xcc(%rbp),%eax
cltd
idiv   %ecx
mov    -0xc8(%rbp),%rax
movslq %edx,%rcx
add    %rcx,%rax
mov    %rax,-0xb0(%rbp)
mov    0x2c34(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xbc(%rbp)
mov    -0xa0(%rbp),%rax
mov    %rax,-0xb8(%rbp)
mov    -0xa0(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0xbc(%rbp),%edi
mov    -0xb8(%rbp),%rsi
mov    %eax,%edx
mov    $0x0,%al
call   1030 <write@plt>
mov    0x2bf5(%rip),%rax
mov    (%rax),%edi
mov    -0xb0(%rbp),%rsi
mov    $0x1,%edx
mov    $0x0,%al
call   1030 <write@plt>
jmp    1415 <main+0x2c5>
mov    -0x98(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x98(%rbp)
jmp    1199 <main+0x49>
mov    0x2ba8(%rip),%rax
mov    (%rax),%edi
lea    -0x90(%rbp),%rsi
mov    $0x80,%edx
call   1050 <read@plt>
mov    %eax,-0x94(%rbp)
jmp    1182 <main+0x32>
mov    0x2b9b(%rip),%rax
mov    (%rax),%edi
call   1070 <fsync@plt>
xor    %eax,%eax
add    $0xd0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x88,%rsp
mov    0x2e70(%rip),%rax
mov    (%rax),%edi
mov    %rsp,%rbx
mov    %rbx,%rsi
mov    $0x80,%edx
call   1050 <read@plt>
test   %eax,%eax
jle    1276 <main+0x126>
mov    0x2e67(%rip),%r13
jmp    11b1 <main+0x61>
nopl   0x0(%rax,%rax,1)
mov    0x2e41(%rip),%rax
mov    (%rax),%edi
mov    %rsp,%rbx
mov    %rbx,%rsi
mov    $0x80,%edx
call   1050 <read@plt>
test   %eax,%eax
jle    1276 <main+0x126>
mov    %eax,%r14d
jmp    11dd <main+0x8d>
cs nopw 0x0(%rax,%rax,1)
mov    0x0(%r13),%edi
mov    %rbx,%rsi
mov    $0x1,%edx
xor    %eax,%eax
call   1030 <write@plt>
add    $0x1,%rbx
add    $0xffffffffffffffff,%r14
je     1190 <main+0x40>
movzbl (%rbx),%edi
call   1060 <isprint@plt>
test   %rax,%rax
jne    11c0 <main+0x70>
movzbl (%rbx),%eax
lea    -0x9(%rax),%ecx
cmp    $0x1,%cl
jbe    11c0 <main+0x70>
test   %al,%al
js     1202 <main+0xb2>
lea    0xe24(%rip),%r15
jmp    1215 <main+0xc5>
lea    0x1(%rax),%ecx
cmp    $0xa0,%cl
ja     1224 <main+0xd4>
xor    $0x80,%al
mov    %al,(%rbx)
lea    0xe0d(%rip),%r15
mov    $0x20,%cl
lea    0xde2(%rip),%r12
cmp    $0x7f,%al
je     1236 <main+0xe6>
jmp    123a <main+0xea>
add    $0x60,%al
mov    %eax,%ecx
lea    0xdfa(%rip),%r12
lea    0xdf0(%rip),%r15
mov    %cl,(%rbx)
mov    %ecx,%eax
movzbl %al,%ebp
mov    %r12,%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    %ebp,%eax
xor    %edx,%edx
idiv   %ecx
add    %rdx,%r12
mov    0x0(%r13),%ebp
mov    %r15,%rdi
call   1040 <strlen@plt>
mov    %ebp,%edi
mov    %r15,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1030 <write@plt>
mov    0x0(%r13),%edi
mov    %r12,%rsi
jmp    11c7 <main+0x77>
mov    0x2d73(%rip),%rax
mov    (%rax),%edi
call   1070 <fsync@plt>
xor    %eax,%eax
add    $0x88,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@STDIN_FILENO = global i32 0
@STDOUT_FILENO = global i32 0
@.str = [2 x i8] c"^\00"
@.str.1 = [34 x i8] c"@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_?\00"
@.str.2 = [4 x i8] c"M-^\00"
@.str.3 = [3 x i8] c"M-\00"
@.str.4 = [96 x i8] c" !\22#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [129 x i8]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
store i32 0, i32* %1
%8 = load i32, i32* @STDIN_FILENO
%9 = getelementptr inbounds [129 x i8], [129 x i8]* %2, i64 0, i64 0
%10 = call i32 @read(i32 %8, i8* %9, i32 128)
store i32 %10, i32* %3
br label %11
11: ; preds = %128, %0
%12 = load i32, i32* %3
%13 = icmp sgt i32 %12, 0
br i1 %13, label %14, label %132
14: ; preds = %11
store i32 0, i32* %4
br label %15
15: ; preds = %125, %14
%16 = load i32, i32* %4
%17 = load i32, i32* %3
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %128
19: ; preds = %15
%20 = load i32, i32* %4
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [129 x i8], [129 x i8]* %2, i64 0, i64 %21
%23 = load i8, i8* %22
%24 = call i64 @isprint(i8 zeroext %23)
%25 = icmp ne i64 %24, 0
br i1 %25, label %40, label %26
26: ; preds = %19
%27 = load i32, i32* %4
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [129 x i8], [129 x i8]* %2, i64 0, i64 %28
%30 = load i8, i8* %29
%31 = zext i8 %30 to i32
%32 = icmp eq i32 %31, 9
br i1 %32, label %40, label %33
33: ; preds = %26
%34 = load i32, i32* %4
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [129 x i8], [129 x i8]* %2, i64 0, i64 %35
%37 = load i8, i8* %36
%38 = zext i8 %37 to i32
%39 = icmp eq i32 %38, 10
br i1 %39, label %40, label %46
40: ; preds = %33, %26, %19
%41 = load i32, i32* @STDOUT_FILENO
%42 = load i32, i32* %4
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds [129 x i8], [129 x i8]* %2, i64 0, i64 %43
%45 = call i32 (i32, ...) @write(i32 %41, i8* %44, i32 1)
br label %124
46: ; preds = %33
store i8* null, i8** %5
store i8* null, i8** %6
%47 = load i32, i32* %4
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds [129 x i8], [129 x i8]* %2, i64 0, i64 %48
%50 = load i8, i8* %49
%51 = zext i8 %50 to i32
%52 = icmp sle i32 %51, 127
br i1 %52, label %53, label %54
53: ; preds = %46
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8** %5
store i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i8** %6
br label %93
54: ; preds = %46
%55 = load i32, i32* %4
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds [129 x i8], [129 x i8]* %2, i64 0, i64 %56
%58 = load i8, i8* %57
%59 = zext i8 %58 to i32
%60 = icmp sle i32 %59, 159
br i1 %60, label %68, label %61
61: ; preds = %54
%62 = load i32, i32* %4
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds [129 x i8], [129 x i8]* %2, i64 0, i64 %63
%65 = load i8, i8* %64
%66 = zext i8 %65 to i32
%67 = icmp eq i32 %66, 255
br i1 %67, label %68, label %76
68: ; preds = %61, %54
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8** %5
store i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i8** %6
%69 = load i32, i32* %4
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds [129 x i8], [129 x i8]* %2, i64 0, i64 %70
%72 = load i8, i8* %71
%73 = zext i8 %72 to i32
%74 = sub nsw i32 %73, 128
%75 = trunc i32 %74 to i8
store i8 %75, i8* %71
br label %92
76: ; preds = %61
%77 = load i32, i32* %4
%78 = sext i32 %77 to i64
%79 = getelementptr inbounds [129 x i8], [129 x i8]* %2, i64 0, i64 %78
%80 = load i8, i8* %79
%81 = zext i8 %80 to i32
%82 = icmp slt i32 %81, 255
br i1 %82, label %83, label %91
83: ; preds = %76
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8** %5
store i8* getelementptr inbounds ([96 x i8], [96 x i8]* @.str.4, i64 0, i64 0), i8** %6
%84 = load i32, i32* %4
%85 = sext i32 %84 to i64
%86 = getelementptr inbounds [129 x i8], [129 x i8]* %2, i64 0, i64 %85
%87 = load i8, i8* %86
%88 = zext i8 %87 to i32
%89 = sub nsw i32 %88, 160
%90 = trunc i32 %89 to i8
store i8 %90, i8* %86
br label %91
91: ; preds = %83, %76
br label %92
92: ; preds = %91, %68
br label %93
93: ; preds = %92, %53
%94 = load i32, i32* %4
%95 = sext i32 %94 to i64
%96 = getelementptr inbounds [129 x i8], [129 x i8]* %2, i64 0, i64 %95
%97 = load i8, i8* %96
%98 = zext i8 %97 to i32
%99 = icmp eq i32 %98, 127
br i1 %99, label %100, label %104
100: ; preds = %93
%101 = load i32, i32* %4
%102 = sext i32 %101 to i64
%103 = getelementptr inbounds [129 x i8], [129 x i8]* %2, i64 0, i64 %102
store i8 32, i8* %103
br label %104
104: ; preds = %100, %93
%105 = load i8*, i8** %6
%106 = load i32, i32* %4
%107 = sext i32 %106 to i64
%108 = getelementptr inbounds [129 x i8], [129 x i8]* %2, i64 0, i64 %107
%109 = load i8, i8* %108
%110 = zext i8 %109 to i32
%111 = load i8*, i8** %6
%112 = call i32 @strlen(i8* %111)
%113 = srem i32 %110, %112
%114 = sext i32 %113 to i64
%115 = getelementptr inbounds i8, i8* %105, i64 %114
store i8* %115, i8** %7
%116 = load i32, i32* @STDOUT_FILENO
%117 = load i8*, i8** %5
%118 = load i8*, i8** %5
%119 = call i32 @strlen(i8* %118)
%120 = call i32 (i32, ...) @write(i32 %116, i8* %117, i32 %119)
%121 = load i32, i32* @STDOUT_FILENO
%122 = load i8*, i8** %7
%123 = call i32 (i32, ...) @write(i32 %121, i8* %122, i32 1)
br label %124
124: ; preds = %104, %40
br label %125
125: ; preds = %124
%126 = load i32, i32* %4
%127 = add nsw i32 %126, 1
store i32 %127, i32* %4
br label %15
128: ; preds = %15
%129 = load i32, i32* @STDIN_FILENO
%130 = getelementptr inbounds [129 x i8], [129 x i8]* %2, i64 0, i64 0
%131 = call i32 @read(i32 %129, i8* %130, i32 128)
store i32 %131, i32* %3
br label %11
132: ; preds = %11
%133 = load i32, i32* @STDOUT_FILENO
%134 = call i32 @fsync(i32 %133)
ret i32 0
}

LLVM IR (-O2):
@STDIN_FILENO = global i32 0
@STDOUT_FILENO = global i32 0
@.str = [2 x i8] c"^\00"
@.str.1 = [34 x i8] c"@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_?\00"
@.str.2 = [4 x i8] c"M-^\00"
@.str.3 = [3 x i8] c"M-\00"
@.str.4 = [96 x i8] c" !\22#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\00"
define i32 @main() {
%1 = alloca [129 x i8]
%2 = getelementptr inbounds [129 x i8], [129 x i8]* %1, i64 0, i64 0
%3 = load i32, i32* @STDIN_FILENO
%4 = call i32 @read(i32 %3, i8* %2, i32 128)
%5 = icmp sgt i32 %4, 0
br i1 %5, label %6, label %60
6: ; preds = %0, %56
%7 = phi i32 [ %58, %56 ], [ %4, %0 ]
%8 = zext i32 %7 to i64
br label %9
9: ; preds = %6, %53
%10 = phi i64 [ 0, %6 ], [ %54, %53 ]
%11 = getelementptr inbounds [129 x i8], [129 x i8]* %1, i64 0, i64 %10
%12 = load i8, i8* %11
%13 = call i64 @isprint(i8 zeroext %12)
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %19
15: ; preds = %9
%16 = load i8, i8* %11
%17 = add i8 %16, -9
%18 = icmp ult i8 %17, 2
br i1 %18, label %19, label %22
19: ; preds = %15, %9
%20 = load i32, i32* @STDOUT_FILENO
%21 = call i32 (i32, ...) @write(i32 %20, i8* %11, i32 1)
br label %53
22: ; preds = %15
%23 = icmp sgt i8 %16, -1
br i1 %23, label %31, label %24
24: ; preds = %22
%25 = add nsw i8 %16, 1
%26 = icmp ult i8 %25, -95
br i1 %26, label %27, label %29
27: ; preds = %24
%28 = xor i8 %16, -128
store i8 %28, i8* %11
br label %31
29: ; preds = %24
%30 = add nsw i8 %16, 96
br label %35
31: ; preds = %22, %27
%32 = phi i8 [ %16, %22 ], [ %28, %27 ]
%33 = phi i8* [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), %22 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), %27 ]
%34 = icmp eq i8 %32, 127
br i1 %34, label %35, label %39
35: ; preds = %31, %29
%36 = phi i8 [ %30, %29 ], [ 32, %31 ]
%37 = phi i8* [ getelementptr inbounds ([96 x i8], [96 x i8]* @.str.4, i64 0, i64 0), %29 ], [ getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), %31 ]
%38 = phi i8* [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), %29 ], [ %33, %31 ]
store i8 %36, i8* %11
br label %39
39: ; preds = %35, %31
%40 = phi i8 [ %32, %31 ], [ %36, %35 ]
%41 = phi i8* [ getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), %31 ], [ %37, %35 ]
%42 = phi i8* [ %33, %31 ], [ %38, %35 ]
%43 = zext i8 %40 to i32
%44 = call i32 @strlen(i8* %41)
%45 = srem i32 %43, %44
%46 = zext i32 %45 to i64
%47 = getelementptr inbounds i8, i8* %41, i64 %46
%48 = load i32, i32* @STDOUT_FILENO
%49 = call i32 @strlen(i8* %42)
%50 = call i32 (i32, ...) @write(i32 %48, i8* %42, i32 %49)
%51 = load i32, i32* @STDOUT_FILENO
%52 = call i32 (i32, ...) @write(i32 %51, i8* %47, i32 1)
br label %53
53: ; preds = %19, %39
%54 = add nuw nsw i64 %10, 1
%55 = icmp eq i64 %54, %8
br i1 %55, label %56, label %9
56: ; preds = %53
%57 = load i32, i32* @STDIN_FILENO
%58 = call i32 @read(i32 %57, i8* %2, i32 128)
%59 = icmp sgt i32 %58, 0
br i1 %59, label %6, label %60
60: ; preds = %56, %0
%61 = load i32, i32* @STDOUT_FILENO
%62 = call i32 @fsync(i32 %61)
ret i32 0
}