#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*/ FILE;

/* Variables and functions */
int EOF;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ putchar(int);
void process_file(char *filename) {
  FILE *fh;
  if ((fh = fopen(filename, "r"))) {
    int c;
    int prev = 0;
    while ((c = fgetc(fh)) != EOF) {
      if (c == '\'' && prev != '?') {
        putchar(c);
        putchar('\n');
      } else
        putchar(c);
      prev = c;
    }
    fclose(fh);
  }
}


x86 assembly (clang, -O0):
<process_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xea9(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     11d3 <process_file+0x93>
movl   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %eax,-0x14(%rbp)
mov    0x2e64(%rip),%rcx
cmp    (%rcx),%eax
je     11ca <process_file+0x8a>
cmpl   $0x27,-0x14(%rbp)
jne    11b7 <process_file+0x77>
cmpl   $0x3f,-0x18(%rbp)
je     11b7 <process_file+0x77>
mov    -0x14(%rbp),%edi
call   1030 <putchar@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    11bf <process_file+0x7f>
mov    -0x14(%rbp),%edi
call   1030 <putchar@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    1171 <process_file+0x31>
mov    -0x10(%rbp),%rdi
call   1040 <fclose@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<process_file>:
push   %rbp
push   %r14
push   %rbx
lea    0xeb5(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     1178 <process_file+0x38>
mov    %rax,%rbx
mov    %rax,%rdi
call   1050 <fgetc@plt>
mov    0x2e81(%rip),%r14
cmp    (%r14),%eax
jne    117d <process_file+0x3d>
mov    %rbx,%rdi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <fclose@plt>
pop    %rbx
pop    %r14
pop    %rbp
ret
xor    %ebp,%ebp
jmp    11a2 <process_file+0x62>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
call   1030 <putchar@plt>
mov    %rbx,%rdi
call   1050 <fgetc@plt>
cmp    (%r14),%eax
je     116c <process_file+0x2c>
mov    %ebp,%ecx
mov    %eax,%ebp
mov    %eax,%edi
cmp    $0x3f,%ecx
je     1190 <process_file+0x50>
mov    %ebp,%edi
cmp    $0x27,%ebp
jne    1190 <process_file+0x50>
mov    $0x27,%edi
call   1030 <putchar@plt>
mov    $0xa,%edi
jmp    1190 <process_file+0x50>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@EOF = global i32 0
define void @process_file(i8* %0) {
%2 = alloca i8*
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %2
%6 = load i8*, i8** %2
%7 = call i32* @fopen(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %7, i32** %3
%8 = icmp ne i32* %7, null
br i1 %8, label %9, label %33
9: ; preds = %1
store i32 0, i32* %5
br label %10
10: ; preds = %28, %9
%11 = load i32*, i32** %3
%12 = call i32 @fgetc(i32* %11)
store i32 %12, i32* %4
%13 = load i32, i32* @EOF
%14 = icmp ne i32 %12, %13
br i1 %14, label %15, label %30
15: ; preds = %10
%16 = load i32, i32* %4
%17 = icmp eq i32 %16, 39
br i1 %17, label %18, label %25
18: ; preds = %15
%19 = load i32, i32* %5
%20 = icmp ne i32 %19, 63
br i1 %20, label %21, label %25
21: ; preds = %18
%22 = load i32, i32* %4
%23 = call i32 @putchar(i32 %22)
%24 = call i32 @putchar(i32 10)
br label %28
25: ; preds = %18, %15
%26 = load i32, i32* %4
%27 = call i32 @putchar(i32 %26)
br label %28
28: ; preds = %25, %21
%29 = load i32, i32* %4
store i32 %29, i32* %5
br label %10
30: ; preds = %10
%31 = load i32*, i32** %3
%32 = call i32 @fclose(i32* %31)
br label %33
33: ; preds = %30, %1
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@EOF = global i32 0
define void @process_file(i8* nocapture %0) {
%2 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i32* %2, null
br i1 %3, label %24, label %4
4: ; preds = %1
%5 = tail call i32 @fgetc(i32* %2)
%6 = load i32, i32* @EOF
%7 = icmp eq i32 %5, %6
br i1 %7, label %22, label %8
8: ; preds = %4, %16
%9 = phi i32 [ %19, %16 ], [ %5, %4 ]
%10 = phi i32 [ %9, %16 ], [ 0, %4 ]
%11 = icmp eq i32 %9, 39
%12 = icmp ne i32 %10, 63
%13 = and i1 %12, %11
br i1 %13, label %14, label %16
14: ; preds = %8
%15 = tail call i32 @putchar(i32 39)
br label %16
16: ; preds = %8, %14
%17 = phi i32 [ 10, %14 ], [ %9, %8 ]
%18 = tail call i32 @putchar(i32 %17)
%19 = tail call i32 @fgetc(i32* %2)
%20 = load i32, i32* @EOF
%21 = icmp eq i32 %19, %20
br i1 %21, label %22, label %8
22: ; preds = %16, %4
%23 = tail call i32 @fclose(i32* %2)
br label %24
24: ; preds = %22, %1
ret void
}