#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 */
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
int /*<<< orphan*/ F_OK;
scalar_t__ access(char *, int /*<<< orphan*/);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/);
scalar_t__ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ freopen(char *, char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdin;
int main(int argc, char **argv) {
  char buf[10000];
  char *p;
  int flag;
  if (argc != 2) {
    printf("Usage: %s INPUT_FILE\n\n", argv[0]);
    exit(-1);
  }
  if (access(argv[1], F_OK)) {
    printf("Error: INPUT_FILE %s does not exist\n\n", argv[1]);
    exit(-1);
  }
  freopen(argv[1], "r", stdin);
  flag = 0;
  while (fgets(buf, sizeof(buf), stdin)) {
    p = buf;
    while (*p) {
      if (*p == '"') {
        if (!flag)
          printf("``");
        else
          printf("''");
        flag++;
        flag = flag % 2;
      } else {
        printf("%c", *p);
      }
      p++;
    }
  }
  fclose(stdin);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2730,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     11a2 <main+0x42>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe6f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0xffffffff,%edi
call   1080 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2e1f(%rip),%rax
mov    (%rax),%esi
call   1070 <access@plt>
cmp    $0x0,%rax
je     11e2 <main+0x82>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe46(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0xffffffff,%edi
call   1080 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2df7(%rip),%rax
mov    (%rax),%edx
lea    0xe43(%rip),%rsi
call   1050 <freopen@plt>
movl   $0x0,-0x272c(%rbp)
lea    -0x2720(%rbp),%rdi
mov    0x2dd1(%rip),%rax
mov    (%rax),%edx
mov    $0x2710,%esi
call   1060 <fgets@plt>
cmp    $0x0,%rax
je     12e8 <main+0x188>
lea    -0x2720(%rbp),%rax
mov    %rax,-0x2728(%rbp)
mov    -0x2728(%rbp),%rax
cmpb   $0x0,(%rax)
je     12e3 <main+0x183>
mov    -0x2728(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x22,%eax
jne    12b4 <main+0x154>
cmpl   $0x0,-0x272c(%rbp)
jne    127e <main+0x11e>
lea    0xdcd(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    128c <main+0x12c>
lea    0xdbd(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x272c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x272c(%rbp)
mov    -0x272c(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %edx,-0x272c(%rbp)
jmp    12cc <main+0x16c>
mov    -0x2728(%rbp),%rax
movsbl (%rax),%esi
lea    0xd80(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x2728(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x2728(%rbp)
jmp    123b <main+0xdb>
jmp    1209 <main+0xa9>
mov    0x2cf9(%rip),%rax
mov    (%rax),%edi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x2730,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x2718,%rsp
mov    %rsi,%rbx
cmp    $0x2,%edi
jne    127f <main+0x10f>
mov    0x8(%rbx),%rdi
mov    0x2e38(%rip),%rax
mov    (%rax),%esi
call   1080 <access@plt>
mov    0x8(%rbx),%rcx
test   %rax,%rax
jne    128b <main+0x11b>
mov    0x2e35(%rip),%r14
mov    (%r14),%edx
lea    0xe80(%rip),%rsi
mov    %rcx,%rdi
call   1060 <freopen@plt>
mov    (%r14),%edx
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x2710,%esi
call   1070 <fgets@plt>
test   %rax,%rax
je     1263 <main+0xf3>
lea    0xe57(%rip),%r15
lea    0xe53(%rip),%r12
xor    %r13d,%r13d
mov    %rbx,%rbp
jmp    1230 <main+0xc0>
test   %r13d,%r13d
mov    %r12,%rdi
cmove  %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r13d,%eax
add    $0x1,%eax
shr    $0x1f,%eax
add    %r13d,%eax
add    $0x1,%eax
and    $0xfffffffe,%eax
neg    %eax
add    %eax,%r13d
add    $0x1,%r13d
add    $0x1,%rbp
nopw   0x0(%rax,%rax,1)
movsbl 0x0(%rbp),%edi
test   %edi,%edi
jne    1252 <main+0xe2>
mov    (%r14),%edx
mov    %rbx,%rdi
mov    $0x2710,%esi
call   1070 <fgets@plt>
mov    %rbx,%rbp
test   %rax,%rax
jne    1230 <main+0xc0>
jmp    1263 <main+0xf3>
cmp    $0x22,%dil
je     11f7 <main+0x87>
call   1030 <putchar@plt>
add    $0x1,%rbp
jmp    1230 <main+0xc0>
mov    (%r14),%edi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x2718,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    (%rbx),%rsi
lea    0xd77(%rip),%rdi
jmp    1295 <main+0x125>
lea    0xd85(%rip),%rdi
mov    %rcx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xffffffff,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [23 x i8] c"Usage: %s INPUT_FILE\0A\0A\00"
@F_OK = global i32 0
@.str.1 = [38 x i8] c"Error: INPUT_FILE %s does not exist\0A\0A\00"
@.str.2 = [2 x i8] c"r\00"
@stdin = global i32 0
@.str.3 = [3 x i8] c"``\00"
@.str.4 = [3 x i8] c"''\00"
@.str.5 = [3 x i8] c"%c\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [10000 x i8]
%7 = alloca i8*
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp ne i32 %9, 2
br i1 %10, label %11, label %17
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 0
%14 = load i8*, i8** %13
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %14)
%16 = call i32 @exit(i32 -1)
unreachable
17: ; preds = %2
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = load i32, i32* @F_OK
%22 = call i64 @access(i8* %20, i32 %21)
%23 = icmp ne i64 %22, 0
br i1 %23, label %24, label %30
24: ; preds = %17
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 1
%27 = load i8*, i8** %26
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), i8* %27)
%29 = call i32 @exit(i32 -1)
unreachable
30: ; preds = %17
%31 = load i8**, i8*** %5
%32 = getelementptr inbounds i8*, i8** %31, i64 1
%33 = load i8*, i8** %32
%34 = load i32, i32* @stdin
%35 = call i32 @freopen(i8* %33, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i32 %34)
store i32 0, i32* %8
br label %36
36: ; preds = %72, %30
%37 = getelementptr inbounds [10000 x i8], [10000 x i8]* %6, i64 0, i64 0
%38 = load i32, i32* @stdin
%39 = call i64 @fgets(i8* %37, i32 10000, i32 %38)
%40 = icmp ne i64 %39, 0
br i1 %40, label %41, label %73
41: ; preds = %36
%42 = getelementptr inbounds [10000 x i8], [10000 x i8]* %6, i64 0, i64 0
store i8* %42, i8** %7
br label %43
43: ; preds = %69, %41
%44 = load i8*, i8** %7
%45 = load i8, i8* %44
%46 = icmp ne i8 %45, 0
br i1 %46, label %47, label %72
47: ; preds = %43
%48 = load i8*, i8** %7
%49 = load i8, i8* %48
%50 = sext i8 %49 to i32
%51 = icmp eq i32 %50, 34
br i1 %51, label %52, label %64
52: ; preds = %47
%53 = load i32, i32* %8
%54 = icmp ne i32 %53, 0
br i1 %54, label %57, label %55
55: ; preds = %52
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
br label %59
57: ; preds = %52
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
br label %59
59: ; preds = %57, %55
%60 = load i32, i32* %8
%61 = add nsw i32 %60, 1
store i32 %61, i32* %8
%62 = load i32, i32* %8
%63 = srem i32 %62, 2
store i32 %63, i32* %8
br label %69
64: ; preds = %47
%65 = load i8*, i8** %7
%66 = load i8, i8* %65
%67 = sext i8 %66 to i32
%68 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32 %67)
br label %69
69: ; preds = %64, %59
%70 = load i8*, i8** %7
%71 = getelementptr inbounds i8, i8* %70, i32 1
store i8* %71, i8** %7
br label %43
72: ; preds = %43
br label %36
73: ; preds = %36
%74 = load i32, i32* @stdin
%75 = call i32 @fclose(i32 %74)
ret i32 0
}

LLVM IR (-O2):
@.str = [23 x i8] c"Usage: %s INPUT_FILE\0A\0A\00"
@F_OK = global i32 0
@.str.1 = [38 x i8] c"Error: INPUT_FILE %s does not exist\0A\0A\00"
@.str.2 = [2 x i8] c"r\00"
@stdin = global i32 0
@.str.3 = [3 x i8] c"``\00"
@.str.4 = [3 x i8] c"''\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [10000 x i8]
%4 = getelementptr inbounds [10000 x i8], [10000 x i8]* %3, i64 0, i64 0
%5 = icmp eq i32 %0, 2
br i1 %5, label %10, label %6
6: ; preds = %2
%7 = load i8*, i8** %1
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %7)
%9 = tail call i32 @exit(i32 -1)
unreachable
10: ; preds = %2
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = load i32, i32* @F_OK
%14 = tail call i64 @access(i8* %12, i32 %13)
%15 = icmp eq i64 %14, 0
%16 = load i8*, i8** %11
br i1 %15, label %20, label %17
17: ; preds = %10
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), i8* %16)
%19 = tail call i32 @exit(i32 -1)
unreachable
20: ; preds = %10
%21 = load i32, i32* @stdin
%22 = tail call i32 @freopen(i8* %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i32 %21)
%23 = load i32, i32* @stdin
%24 = call i64 @fgets(i8* %4, i32 10000, i32 %23)
%25 = icmp eq i64 %24, 0
br i1 %25, label %48, label %26
26: ; preds = %20, %45
%27 = phi i8* [ %47, %45 ], [ %4, %20 ]
%28 = phi i32 [ %46, %45 ], [ 0, %20 ]
br label %33
29: ; preds = %33
%30 = load i32, i32* @stdin
%31 = call i64 @fgets(i8* %4, i32 10000, i32 %30)
%32 = icmp eq i64 %31, 0
br i1 %32, label %48, label %33
33: ; preds = %26, %29
%34 = phi i8* [ %4, %29 ], [ %27, %26 ]
%35 = load i8, i8* %34
switch i8 %35, label %42 [
i8 0, label %29
i8 34, label %36
]
36: ; preds = %33
%37 = icmp eq i32 %28, 0
%38 = select i1 %37, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0)
%39 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %38)
%40 = add nsw i32 %28, 1
%41 = srem i32 %40, 2
br label %45
42: ; preds = %33
%43 = sext i8 %35 to i32
%44 = call i32 @putchar(i32 %43)
br label %45
45: ; preds = %42, %36
%46 = phi i32 [ %41, %36 ], [ %28, %42 ]
%47 = getelementptr inbounds i8, i8* %34, i64 1
br label %26
48: ; preds = %29, %20
%49 = load i32, i32* @stdin
%50 = call i32 @fclose(i32 %49)
ret i32 0
}