#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() {
  char ch;
  char flag;
  flag = 0;
  while ((ch = getchar()) != EOF) {
    if (ch == '\"' && flag == 0) {
      printf("``");
      flag ^= 1;
    } else if (ch == '\"' && flag == 1) {
      printf("''");
      flag ^= 1;
    } else {
      putchar(ch);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movb   $0x0,-0x6(%rbp)
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %al,-0x5(%rbp)
movsbl %al,%eax
mov    0x2e91(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     11df <main+0xaf>
movsbl -0x5(%rbp),%eax
cmp    $0x22,%eax
jne    1197 <main+0x67>
movsbl -0x6(%rbp),%eax
cmp    $0x0,%eax
jne    1197 <main+0x67>
lea    0xe7d(%rip),%rdi
call   1040 <printf@plt>
movsbl -0x6(%rbp),%eax
xor    $0x1,%eax
mov    %al,-0x6(%rbp)
jmp    11da <main+0xaa>
movsbl -0x5(%rbp),%eax
cmp    $0x22,%eax
jne    11cc <main+0x9c>
movsbl -0x6(%rbp),%eax
cmp    $0x1,%eax
jne    11cc <main+0x9c>
lea    0xe4b(%rip),%rdi
call   1040 <printf@plt>
movsbl -0x6(%rbp),%eax
xor    $0x1,%eax
mov    %al,-0x6(%rbp)
jmp    11d5 <main+0xa5>
movsbl -0x5(%rbp),%edi
call   1030 <putchar@plt>
jmp    11da <main+0xaa>
jmp    1143 <main+0x13>
xor    %eax,%eax
add    $0x10,%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),%rbx
cmp    (%rbx),%al
jne    1156 <main+0x26>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xea3(%rip),%r15
lea    0xe9f(%rip),%r14
xor    %ebp,%ebp
jmp    1183 <main+0x53>
nopl   0x0(%rax,%rax,1)
movsbl %al,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    (%rbx),%al
je     1149 <main+0x19>
cmp    $0x22,%al
jne    11a0 <main+0x70>
test   %bpl,%bpl
jne    11a0 <main+0x70>
mov    %r15,%rdi
call   1040 <printf@plt>
mov    $0x1,%bpl
jmp    1178 <main+0x48>
nopl   0x0(%rax)
cmp    $0x22,%al
jne    1170 <main+0x40>
cmp    $0x1,%bpl
jne    1170 <main+0x40>
mov    %r14,%rdi
call   1040 <printf@plt>
xor    %ebp,%ebp
jmp    1178 <main+0x48>

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

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