#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 *, char *);
int /*<<< orphan*/ putchar(int);
int main() {
  int text;
  int flag_even = 1;
  while ((text = getchar()) != EOF) {
    if (text == '\"') {
      printf("%s", flag_even ? "``" : "''");
      flag_even = !flag_even;
    } else {
      putchar(text);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0xc(%rbp)
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %eax,-0x8(%rbp)
mov    0x2e91(%rip),%rcx
cmp    (%rcx),%eax
je     11b0 <main+0x80>
cmpl   $0x22,-0x8(%rbp)
jne    11a3 <main+0x73>
mov    -0xc(%rbp),%ecx
lea    0xe93(%rip),%rsi
lea    0xe89(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rsi
lea    0xe78(%rip),%rdi
call   1040 <printf@plt>
cmpl   $0x0,-0xc(%rbp)
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0xc(%rbp)
jmp    11ab <main+0x7b>
mov    -0x8(%rbp),%edi
call   1030 <putchar@plt>
jmp    1146 <main+0x16>
xor    %eax,%eax
add    $0x10,%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   1050 <getchar@plt>
mov    0x2e9f(%rip),%r13
cmp    0x0(%r13),%eax
jne    1160 <main+0x30>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0x1,%ebx
lea    0xe9a(%rip),%r15
lea    0xe90(%rip),%r12
lea    0xe86(%rip),%r14
jmp    1194 <main+0x64>
nopl   0x0(%rax)
mov    %eax,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    0x0(%r13),%eax
je     114f <main+0x1f>
cmp    $0x22,%eax
jne    1180 <main+0x50>
xor    %ebp,%ebp
test   %ebx,%ebx
sete   %bpl
mov    %r12,%rsi
cmove  %r15,%rsi
mov    %r14,%rdi
call   1040 <printf@plt>
mov    %ebp,%ebx
jmp    1187 <main+0x57>

LLVM IR (-O0):
@EOF = global i32 0
@.str = [3 x i8] c"%s\00"
@.str.1 = [3 x i8] c"``\00"
@.str.2 = [3 x i8] c"''\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
store i32 1, i32* %3
br label %4
4: ; preds = %24, %0
%5 = call i32 (...) @getchar()
store i32 %5, i32* %2
%6 = load i32, i32* @EOF
%7 = icmp ne i32 %5, %6
br i1 %7, label %8, label %25
8: ; preds = %4
%9 = load i32, i32* %2
%10 = icmp eq i32 %9, 34
br i1 %10, label %11, label %21
11: ; preds = %8
%12 = load i32, i32* %3
%13 = icmp ne i32 %12, 0
%14 = zext i1 %13 to i64
%15 = select i1 %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0)
%16 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %15)
%17 = load i32, i32* %3
%18 = icmp ne i32 %17, 0
%19 = xor i1 %18, true
%20 = zext i1 %19 to i32
store i32 %20, i32* %3
br label %24
21: ; preds = %8
%22 = load i32, i32* %2
%23 = call i32 @putchar(i32 %22)
br label %24
24: ; preds = %21, %11
br label %4
25: ; preds = %4
ret i32 0
}

LLVM IR (-O2):
@EOF = global i32 0
@.str = [3 x i8] c"%s\00"
@.str.1 = [3 x i8] c"``\00"
@.str.2 = [3 x i8] c"''\00"
define i32 @main() {
%1 = tail call i32 (...) @getchar()
%2 = load i32, i32* @EOF
%3 = icmp eq i32 %1, %2
br i1 %3, label %20, label %4
4: ; preds = %0, %15
%5 = phi i32 [ %17, %15 ], [ %1, %0 ]
%6 = phi i32 [ %16, %15 ], [ 1, %0 ]
%7 = icmp eq i32 %5, 34
br i1 %7, label %8, label %13
8: ; preds = %4
%9 = icmp eq i32 %6, 0
%10 = select i1 %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0)
%11 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %10)
%12 = zext i1 %9 to i32
br label %15
13: ; preds = %4
%14 = tail call i32 @putchar(i32 %5)
br label %15
15: ; preds = %13, %8
%16 = phi i32 [ %12, %8 ], [ %6, %13 ]
%17 = tail call i32 (...) @getchar()
%18 = load i32, i32* @EOF
%19 = icmp eq i32 %17, %18
br i1 %19, label %20, label %4
20: ; preds = %15, %0
ret i32 0
}