#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*/ printf(char *);
int /*<<< orphan*/ putchar(int);
int main(int argc, const char *argv[]) {
  int c, newline = 1;
  while ((c = getchar()) != EOF) {
    if (c == '"') {
      putchar('\\');
    }
    if (newline && c != ' ') {
      putchar('"');
      newline = 0;
    }
    if (c == '\n') {
      printf("\"\n");
      newline = 1;
    } else {
      if (c == '\\')
        putchar('\\');
      putchar(c);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x18(%rbp)
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %eax,-0x14(%rbp)
mov    0x2e8a(%rip),%rcx
cmp    (%rcx),%eax
je     11e2 <main+0xb2>
cmpl   $0x22,-0x14(%rbp)
jne    117a <main+0x4a>
mov    $0x5c,%edi
call   1030 <putchar@plt>
cmpl   $0x0,-0x18(%rbp)
je     119f <main+0x6f>
cmpl   $0x20,-0x14(%rbp)
je     119f <main+0x6f>
mov    $0x22,%edi
call   1030 <putchar@plt>
movl   $0x0,-0x18(%rbp)
cmpl   $0xa,-0x14(%rbp)
jne    11c1 <main+0x91>
lea    0xe50(%rip),%rdi
call   1040 <printf@plt>
movl   $0x1,-0x18(%rbp)
jmp    11dd <main+0xad>
cmpl   $0x5c,-0x14(%rbp)
jne    11d5 <main+0xa5>
mov    $0x5c,%edi
call   1030 <putchar@plt>
mov    -0x14(%rbp),%edi
call   1030 <putchar@plt>
jmp    114d <main+0x1d>
xor    %eax,%eax
add    $0x20,%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    0x2ea3(%rip),%r15
cmp    (%r15),%eax
jne    1157 <main+0x27>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %eax,%ebp
mov    $0x1,%ebx
lea    0xe9b(%rip),%r14
jmp    118f <main+0x5f>
nopw   0x0(%rax,%rax,1)
mov    $0x5c,%edi
call   1030 <putchar@plt>
mov    %ebp,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
mov    %eax,%ebp
cmp    (%r15),%eax
je     114a <main+0x1a>
cmp    $0x22,%ebp
jne    119e <main+0x6e>
mov    $0x5c,%edi
call   1030 <putchar@plt>
test   %ebx,%ebx
je     11b3 <main+0x83>
cmp    $0x20,%ebp
je     11b3 <main+0x83>
mov    $0x22,%edi
call   1030 <putchar@plt>
xor    %ebx,%ebx
cmp    $0x5c,%ebp
je     1170 <main+0x40>
cmp    $0xa,%ebp
jne    117a <main+0x4a>
mov    %r14,%rdi
call   1040 <puts@plt>
mov    $0x1,%ebx
jmp    1181 <main+0x51>

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

LLVM IR (-O2):
@EOF = global i32 0
@str = [2 x i8] c"\22\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 (...) @getchar()
%4 = load i32, i32* @EOF
%5 = icmp eq i32 %3, %4
br i1 %5, label %31, label %6
6: ; preds = %2, %26
%7 = phi i32 [ %28, %26 ], [ %3, %2 ]
%8 = phi i32 [ %27, %26 ], [ 1, %2 ]
%9 = icmp eq i32 %7, 34
br i1 %9, label %10, label %12
10: ; preds = %6
%11 = tail call i32 @putchar(i32 92)
br label %12
12: ; preds = %10, %6
%13 = icmp ne i32 %8, 0
%14 = icmp ne i32 %7, 32
%15 = and i1 %13, %14
br i1 %15, label %16, label %18
16: ; preds = %12
%17 = tail call i32 @putchar(i32 34)
br label %18
18: ; preds = %16, %12
%19 = phi i32 [ 0, %16 ], [ %8, %12 ]
switch i32 %7, label %24 [
i32 10, label %20
i32 92, label %22
]
20: ; preds = %18
%21 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
br label %26
22: ; preds = %18
%23 = tail call i32 @putchar(i32 92)
br label %24
24: ; preds = %18, %22
%25 = tail call i32 @putchar(i32 %7)
br label %26
26: ; preds = %24, %20
%27 = phi i32 [ 1, %20 ], [ %19, %24 ]
%28 = tail call i32 (...) @getchar()
%29 = load i32, i32* @EOF
%30 = icmp eq i32 %28, %29
br i1 %30, label %31, label %6
31: ; preds = %26, %2
ret i32 0
}