#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 /*<<< orphan*/ exit(int /*<<< orphan*/);
int getchar();
scalar_t__ isascii(int);
scalar_t__ isprint(int);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ putchar(int);
main() {
  int c;
  while ((c = getchar()) != EOF)
    if (isascii(c) && (isprint(c) || c == '\n' || c == '\t' || c == ' '))
      putchar(c);
    else
      printf("\\%03o", c);
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %eax,-0x8(%rbp)
mov    0x2e68(%rip),%rcx
cmp    (%rcx),%eax
je     11eb <main+0x8b>
mov    -0x8(%rbp),%edi
call   1080 <isascii@plt>
cmp    $0x0,%rax
je     11d7 <main+0x77>
mov    -0x8(%rbp),%edi
call   1060 <isprint@plt>
cmp    $0x0,%rax
jne    11ca <main+0x6a>
cmpl   $0xa,-0x8(%rbp)
je     11ca <main+0x6a>
cmpl   $0x9,-0x8(%rbp)
je     11ca <main+0x6a>
cmpl   $0x20,-0x8(%rbp)
jne    11d7 <main+0x77>
mov    -0x8(%rbp),%edi
call   1030 <putchar@plt>
jmp    11e6 <main+0x86>
mov    -0x8(%rbp),%esi
lea    0xe1f(%rip),%rdi
call   1040 <printf@plt>
jmp    116f <main+0xf>
xor    %edi,%edi
call   1070 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1050 <getchar@plt>
mov    0x2e73(%rip),%rbx
cmp    (%rbx),%eax
jne    1180 <main+0x20>
xor    %edi,%edi
call   1070 <exit@plt>
mov    %eax,%ebp
lea    0xe77(%rip),%r14
movabs $0x100000600,%r15
jmp    11b7 <main+0x57>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r14,%rdi
mov    %ebp,%esi
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
mov    %eax,%ebp
cmp    (%rbx),%eax
je     1179 <main+0x19>
mov    %ebp,%edi
call   1080 <isascii@plt>
test   %rax,%rax
je     11a0 <main+0x40>
mov    %ebp,%edi
call   1060 <isprint@plt>
test   %rax,%rax
jne    11dc <main+0x7c>
cmp    $0x20,%ebp
ja     11a0 <main+0x40>
mov    %ebp,%eax
bt     %rax,%r15
jae    11a0 <main+0x40>
mov    %ebp,%edi
call   1030 <putchar@plt>
jmp    11aa <main+0x4a>

LLVM IR (-O0):
@EOF = global i32 0
@.str = [6 x i8] c"\\%03o\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
br label %3
3: ; preds = %30, %0
%4 = call i32 (...) @getchar()
store i32 %4, i32* %2
%5 = load i32, i32* @EOF
%6 = icmp ne i32 %4, %5
br i1 %6, label %7, label %31
7: ; preds = %3
%8 = load i32, i32* %2
%9 = call i64 @isascii(i32 %8)
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %27
11: ; preds = %7
%12 = load i32, i32* %2
%13 = call i64 @isprint(i32 %12)
%14 = icmp ne i64 %13, 0
br i1 %14, label %24, label %15
15: ; preds = %11
%16 = load i32, i32* %2
%17 = icmp eq i32 %16, 10
br i1 %17, label %24, label %18
18: ; preds = %15
%19 = load i32, i32* %2
%20 = icmp eq i32 %19, 9
br i1 %20, label %24, label %21
21: ; preds = %18
%22 = load i32, i32* %2
%23 = icmp eq i32 %22, 32
br i1 %23, label %24, label %27
24: ; preds = %21, %18, %15, %11
%25 = load i32, i32* %2
%26 = call i32 @putchar(i32 %25)
br label %30
27: ; preds = %21, %7
%28 = load i32, i32* %2
%29 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %28)
br label %30
30: ; preds = %27, %24
br label %3
31: ; preds = %3
%32 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@EOF = global i32 0
@.str = [6 x i8] c"\\%03o\00"
define i32 @main() {
%1 = tail call i32 (...) @getchar()
%2 = load i32, i32* @EOF
%3 = icmp eq i32 %1, %2
br i1 %3, label %21, label %4
4: ; preds = %0, %17
%5 = phi i32 [ %18, %17 ], [ %1, %0 ]
%6 = tail call i64 @isascii(i32 %5)
%7 = icmp eq i64 %6, 0
br i1 %7, label %15, label %8
8: ; preds = %4
%9 = tail call i64 @isprint(i32 %5)
%10 = freeze i64 %9
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %8
switch i32 %5, label %15 [
i32 32, label %13
i32 10, label %13
i32 9, label %13
]
13: ; preds = %12, %12, %12, %8
%14 = tail call i32 @putchar(i32 %5)
br label %17
15: ; preds = %12, %4
%16 = tail call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %5)
br label %17
17: ; preds = %15, %13
%18 = tail call i32 (...) @getchar()
%19 = load i32, i32* @EOF
%20 = icmp eq i32 %18, %19
br i1 %20, label %21, label %4
21: ; preds = %17, %0
%22 = tail call i32 @exit(i32 0)
unreachable
}