#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 */
scalar_t__ gets(char *);
int /*<<< orphan*/ printf(char *, ...);
long strlen(char *);
int main() {
  long int i, count = 0, l;
  char s[100000];
  while (gets(s)) {
    l = strlen(s);
    for (i = 0; i < l; i++) {
      if (s[i] == '"') {
        count = count + 1;
        if (count % 2 == 1)
          printf("``");
        else
          printf("''");
      } else
        printf("%c", s[i]);
    }
    printf("\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x186c0,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x18(%rbp)
lea    -0x186c0(%rbp),%rdi
call   1050 <gets@plt>
cmp    $0x0,%rax
je     1228 <main+0xf8>
lea    -0x186c0(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x20(%rbp)
movq   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmp    -0x20(%rbp),%rax
jge    1215 <main+0xe5>
mov    -0x10(%rbp),%rax
movsbl -0x186c0(%rbp,%rax,1),%eax
ff
cmp    $0x22,%eax
jne    11e5 <main+0xb5>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    $0x2,%ecx
cqto
idiv   %rcx
cmp    $0x1,%rdx
jne    11d2 <main+0xa2>
lea    0xe3a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11e0 <main+0xb0>
lea    0xe2a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11ff <main+0xcf>
mov    -0x10(%rbp),%rax
movsbl -0x186c0(%rbp,%rax,1),%esi
ff
lea    0xe0e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1204 <main+0xd4>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1178 <main+0x48>
lea    0xded(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    114a <main+0x1a>
xor    %eax,%eax
add    $0x186c0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x186a8,%rsp
mov    %rsp,%rdi
call   1060 <gets@plt>
test   %rax,%rax
je     121c <main+0xdc>
mov    %rsp,%rbx
lea    0xe94(%rip),%r15
lea    0xe90(%rip),%r12
xor    %ebp,%ebp
jmp    11a0 <main+0x60>
nopw   0x0(%rax,%rax,1)
mov    %rbp,%r14
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1060 <gets@plt>
mov    %r14,%rbp
test   %rax,%rax
je     121c <main+0xdc>
mov    %rbx,%rdi
call   1040 <strlen@plt>
test   %rax,%rax
jle    1180 <main+0x40>
mov    %rax,%r13
xor    %ebx,%ebx
jmp    11d4 <main+0x94>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
call   1030 <putchar@plt>
mov    %rbp,%r14
add    $0x1,%rbx
mov    %r14,%rbp
cmp    %rbx,%r13
je     1183 <main+0x43>
movsbl (%rsp,%rbx,1),%edi
cmp    $0x22,%edi
jne    11c0 <main+0x80>
lea    0x1(%rbp),%r14
mov    %r14,%rax
shr    $0x3f,%rax
add    %rbp,%rax
add    $0x1,%rax
and    $0xfffffffffffffffe,%rax
mov    %r14,%rcx
sub    %rax,%rcx
cmp    $0x1,%rcx
jne    1210 <main+0xd0>
mov    %r15,%rdi
jmp    1213 <main+0xd3>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r12,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    11c8 <main+0x88>
xor    %eax,%eax
add    $0x186a8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"``\00"
@.str.1 = [3 x i8] c"''\00"
define i32 @main() {
%1 = alloca [100000 x i8]
%2 = getelementptr inbounds [100000 x i8], [100000 x i8]* %1, i64 0, i64 0
%3 = call i64 @gets(i8* %2)
%4 = icmp eq i64 %3, 0
br i1 %4, label %35, label %5
5: ; preds = %0, %30
%6 = phi i64 [ %31, %30 ], [ 0, %0 ]
%7 = call i64 @strlen(i8* %2)
%8 = icmp sgt i64 %7, 0
br i1 %8, label %9, label %30
9: ; preds = %5, %26
%10 = phi i64 [ %28, %26 ], [ 0, %5 ]
%11 = phi i64 [ %27, %26 ], [ %6, %5 ]
%12 = getelementptr inbounds [100000 x i8], [100000 x i8]* %1, i64 0, i64 %10
%13 = load i8, i8* %12
%14 = icmp eq i8 %13, 34
br i1 %14, label %15, label %23
15: ; preds = %9
%16 = add nsw i64 %11, 1
%17 = srem i64 %16, 2
%18 = icmp eq i64 %17, 1
br i1 %18, label %19, label %21
19: ; preds = %15
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %26
21: ; preds = %15
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %26
23: ; preds = %9
%24 = sext i8 %13 to i32
%25 = call i32 @putchar(i32 %24)
br label %26
26: ; preds = %23, %21, %19
%27 = phi i64 [ %16, %19 ], [ %16, %21 ], [ %11, %23 ]
%28 = add nuw nsw i64 %10, 1
%29 = icmp eq i64 %28, %7
br i1 %29, label %30, label %9
30: ; preds = %26, %5
%31 = phi i64 [ %6, %5 ], [ %27, %26 ]
%32 = call i32 @putchar(i32 10)
%33 = call i64 @gets(i8* %2)
%34 = icmp eq i64 %33, 0
br i1 %34, label %35, label %5
35: ; preds = %30, %0
ret i32 0
}