#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 */
char EOF;
char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ fputc(char, int /*<<< orphan*/ *);
void copy(FILE *in_file, FILE *out_file) {
  char cursor;
  for (cursor = fgetc(in_file); cursor != EOF; cursor = fgetc(in_file)) {
    cursor = (cursor == 'c') ? 'o' : cursor;
    fputc(cursor, out_file);
  }
}


x86 assembly (clang, -O0):
<copy>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <fgetc@plt>
mov    %al,-0x11(%rbp)
movsbl -0x11(%rbp),%eax
mov    0x2ea1(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     1199 <copy+0x79>
movsbl -0x11(%rbp),%eax
cmp    $0x63,%eax
jne    116c <copy+0x4c>
mov    $0x6f,%eax
mov    %eax,-0x18(%rbp)
jmp    1173 <copy+0x53>
movsbl -0x11(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
mov    -0x10(%rbp),%rsi
movsbl %al,%edi
call   1040 <fputc@plt>
mov    -0x8(%rbp),%rdi
call   1030 <fgetc@plt>
mov    %al,-0x11(%rbp)
jmp    113c <copy+0x1c>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<copy>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
call   1030 <fgetc@plt>
mov    0x2eaf(%rip),%r15
cmp    (%r15),%al
je     1170 <copy+0x50>
mov    $0x6f,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
cmp    $0x63,%al
movzbl %al,%eax
cmove  %ebp,%eax
movsbl %al,%edi
mov    %r14,%rsi
call   1040 <fputc@plt>
mov    %rbx,%rdi
call   1030 <fgetc@plt>
cmp    (%r15),%al
jne    1150 <copy+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@EOF = global i8 0
define void @copy(i32* %0, i32* %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i8
store i32* %0, i32** %3
store i32* %1, i32** %4
%6 = load i32*, i32** %3
%7 = call signext i8 @fgetc(i32* %6)
store i8 %7, i8* %5
br label %8
8: ; preds = %28, %2
%9 = load i8, i8* %5
%10 = sext i8 %9 to i32
%11 = load i8, i8* @EOF
%12 = sext i8 %11 to i32
%13 = icmp ne i32 %10, %12
br i1 %13, label %14, label %31
14: ; preds = %8
%15 = load i8, i8* %5
%16 = sext i8 %15 to i32
%17 = icmp eq i32 %16, 99
br i1 %17, label %18, label %19
18: ; preds = %14
br label %22
19: ; preds = %14
%20 = load i8, i8* %5
%21 = sext i8 %20 to i32
br label %22
22: ; preds = %19, %18
%23 = phi i32 [ 111, %18 ], [ %21, %19 ]
%24 = trunc i32 %23 to i8
store i8 %24, i8* %5
%25 = load i8, i8* %5
%26 = load i32*, i32** %4
%27 = call i32 @fputc(i8 signext %25, i32* %26)
br label %28
28: ; preds = %22
%29 = load i32*, i32** %3
%30 = call signext i8 @fgetc(i32* %29)
store i8 %30, i8* %5
br label %8
31: ; preds = %8
ret void
}

LLVM IR (-O2):
@EOF = global i8 0
define void @copy(i32* nocapture %0, i32* nocapture %1) {
%3 = tail call signext i8 @fgetc(i32* %0)
%4 = load i8, i8* @EOF
%5 = icmp eq i8 %3, %4
br i1 %5, label %14, label %6
6: ; preds = %2, %6
%7 = phi i8 [ %11, %6 ], [ %3, %2 ]
%8 = icmp eq i8 %7, 99
%9 = select i1 %8, i8 111, i8 %7
%10 = tail call i32 @fputc(i8 signext %9, i32* %1)
%11 = tail call signext i8 @fgetc(i32* %0)
%12 = load i8, i8* @EOF
%13 = icmp eq i8 %11, %12
br i1 %13, label %14, label %6
14: ; preds = %6, %2
ret void
}