#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))
      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     11cd <main+0x6d>
mov    -0x8(%rbp),%edi
call   1080 <isascii@plt>
cmp    $0x0,%rax
je     11b9 <main+0x59>
mov    -0x8(%rbp),%edi
call   1060 <isprint@plt>
cmp    $0x0,%rax
je     11b9 <main+0x59>
mov    -0x8(%rbp),%edi
call   1030 <putchar@plt>
jmp    11c8 <main+0x68>
mov    -0x8(%rbp),%esi
lea    0xe3d(%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   %r14
push   %rbx
xor    %eax,%eax
call   1050 <getchar@plt>
mov    0x2e76(%rip),%rbx
cmp    (%rbx),%eax
jne    117d <main+0x1d>
xor    %edi,%edi
call   1070 <exit@plt>
mov    %eax,%ebp
lea    0xe7a(%rip),%r14
jmp    11a7 <main+0x47>
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %ebp,%esi
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
mov    %eax,%ebp
cmp    (%rbx),%eax
je     1176 <main+0x16>
mov    %ebp,%edi
call   1080 <isascii@plt>
test   %rax,%rax
je     1190 <main+0x30>
mov    %ebp,%edi
call   1060 <isprint@plt>
test   %rax,%rax
je     1190 <main+0x30>
mov    %ebp,%edi
call   1030 <putchar@plt>
jmp    119a <main+0x3a>

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 = %21, %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 %22
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 %18
11: ; preds = %7
%12 = load i32, i32* %2
%13 = call i64 @isprint(i32 %12)
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %11
%16 = load i32, i32* %2
%17 = call i32 @putchar(i32 %16)
br label %21
18: ; preds = %11, %7
%19 = load i32, i32* %2
%20 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %19)
br label %21
21: ; preds = %18, %15
br label %3
22: ; preds = %3
%23 = 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 %19, label %4
4: ; preds = %0, %15
%5 = phi i32 [ %16, %15 ], [ %1, %0 ]
%6 = tail call i64 @isascii(i32 %5)
%7 = icmp eq i64 %6, 0
br i1 %7, label %13, label %8
8: ; preds = %4
%9 = tail call i64 @isprint(i32 %5)
%10 = icmp eq i64 %9, 0
br i1 %10, label %13, label %11
11: ; preds = %8
%12 = tail call i32 @putchar(i32 %5)
br label %15
13: ; preds = %8, %4
%14 = tail call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %5)
br label %15
15: ; preds = %13, %11
%16 = tail call i32 (...) @getchar()
%17 = load i32, i32* @EOF
%18 = icmp eq i32 %16, %17
br i1 %18, label %19, label %4
19: ; preds = %15, %0
%20 = tail call i32 @exit(i32 0)
unreachable
}