#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();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ putchar(char);
int main(int argc, char *argv[]) {
  int eol = 1;
  char ch;
  while ((ch = getchar()) != EOF) {
    if (eol) {
      printf("\"");
      eol = 0;
    }
    if (ch == '"')
      printf("\\\"");
    else if (ch == '\\')
      printf("\\\\");
    else if (ch == '\n') {
      printf("\\r\\n\"\n");
      eol = 1;
    } else
      putchar(ch);
  }
  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,-0x14(%rbp)
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %al,-0x15(%rbp)
movsbl %al,%eax
mov    0x2e87(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     1202 <main+0xd2>
cmpl   $0x0,-0x14(%rbp)
je     1189 <main+0x59>
lea    0xe84(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x14(%rbp)
movsbl -0x15(%rbp),%eax
cmp    $0x22,%eax
jne    11a7 <main+0x77>
lea    0xe63(%rip),%rdi
call   1040 <printf@plt>
jmp    11fd <main+0xcd>
movsbl -0x15(%rbp),%eax
cmp    $0x5c,%eax
jne    11c5 <main+0x95>
lea    0xe48(%rip),%rdi
call   1040 <printf@plt>
jmp    11f8 <main+0xc8>
movsbl -0x15(%rbp),%eax
cmp    $0xa,%eax
jne    11ea <main+0xba>
lea    0xe2d(%rip),%rdi
call   1040 <printf@plt>
movl   $0x1,-0x14(%rbp)
jmp    11f3 <main+0xc3>
movsbl -0x15(%rbp),%edi
call   1030 <putchar@plt>
jmp    11f8 <main+0xc8>
jmp    11fd <main+0xcd>
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   %r13
push   %r12
push   %rbx
push   %rax
xor    %eax,%eax
call   1060 <getchar@plt>
mov    0x2e8f(%rip),%r13
cmp    0x0(%r13),%al
jne    1170 <main+0x30>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %eax,%ebx
mov    $0x1,%ebp
lea    0xe88(%rip),%r14
lea    0xe7e(%rip),%r12
lea    0xe74(%rip),%r15
jmp    11a9 <main+0x69>
xchg   %ax,%ax
mov    %r12,%rdi
call   1050 <printf@plt>
xor    %ebp,%ebp
xor    %eax,%eax
call   1060 <getchar@plt>
mov    %eax,%ebx
cmp    0x0(%r13),%al
je     115f <main+0x1f>
test   %ebp,%ebp
je     11b7 <main+0x77>
mov    $0x22,%edi
call   1030 <putchar@plt>
cmp    $0xa,%bl
je     11d0 <main+0x90>
cmp    $0x5c,%bl
je     1190 <main+0x50>
cmp    $0x22,%bl
jne    11e0 <main+0xa0>
mov    %r15,%rdi
jmp    1193 <main+0x53>
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1040 <puts@plt>
mov    $0x1,%ebp
jmp    119a <main+0x5a>
nop
movsbl %bl,%edi
call   1030 <putchar@plt>
jmp    1198 <main+0x58>

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

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