#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;
  int quote_count = 0;
  while ((ch = getchar()) != EOF) {
    switch (ch) {
    case '"':
      quote_count++;
      if (quote_count % 2 != 0) {
        printf("``");
      } else {
        printf("''");
      }
      break;
    default:
      putchar(ch);
      break;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %al,-0x5(%rbp)
movsbl %al,%eax
mov    0x2e8e(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     11c2 <main+0x92>
mov    -0x5(%rbp),%al
sub    $0x22,%al
jne    11b4 <main+0x84>
jmp    1175 <main+0x45>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     11a3 <main+0x73>
lea    0xe67(%rip),%rdi
call   1040 <printf@plt>
jmp    11af <main+0x7f>
lea    0xe59(%rip),%rdi
call   1040 <printf@plt>
jmp    11bd <main+0x8d>
movsbl -0x5(%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   %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    0xea6(%rip),%r14
lea    0xe9c(%rip),%r15
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    1170 <main+0x40>
add    $0x1,%ebp
test   $0x1,%bpl
jne    11a0 <main+0x70>
mov    %r14,%rdi
call   1040 <printf@plt>
jmp    1178 <main+0x48>
nopw   0x0(%rax,%rax,1)
mov    %r15,%rdi
call   1040 <printf@plt>
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 i32
store i32 0, i32* %1
store i32 0, i32* %3
br label %4
4: ; preds = %27, %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 %28
10: ; preds = %4
%11 = load i8, i8* %2
%12 = sext i8 %11 to i32
switch i32 %12, label %24 [
i32 34, label %13
]
13: ; preds = %10
%14 = load i32, i32* %3
%15 = add nsw i32 %14, 1
store i32 %15, i32* %3
%16 = load i32, i32* %3
%17 = srem i32 %16, 2
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %13
%20 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %23
21: ; preds = %13
%22 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %23
23: ; preds = %21, %19
br label %27
24: ; preds = %10
%25 = load i8, i8* %2
%26 = call i32 @putchar(i8 signext %25)
br label %27
27: ; preds = %24, %23
br label %4
28: ; 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 %23, label %4
4: ; preds = %0, %18
%5 = phi i8 [ %20, %18 ], [ %1, %0 ]
%6 = phi i32 [ %19, %18 ], [ 0, %0 ]
%7 = icmp eq i8 %5, 34
br i1 %7, label %8, label %16
8: ; preds = %4
%9 = add nsw i32 %6, 1
%10 = and i32 %9, 1
%11 = icmp eq i32 %10, 0
br i1 %11, label %14, label %12
12: ; preds = %8
%13 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %18
14: ; preds = %8
%15 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %18
16: ; preds = %4
%17 = tail call i32 @putchar(i8 signext %5)
br label %18
18: ; preds = %12, %14, %16
%19 = phi i32 [ %9, %12 ], [ %9, %14 ], [ %6, %16 ]
%20 = tail call signext i8 (...) @getchar()
%21 = load i8, i8* @EOF
%22 = icmp eq i8 %20, %21
br i1 %22, label %23, label %4
23: ; preds = %18, %0
ret i32 0
}