#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;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char);
char getc(int /*<<< orphan*/ *);
int copy_file(FILE *to_file, FILE *from_file) {
  if (to_file == NULL || from_file == NULL)
    return ((-1));
  char character;
  character = getc(from_file);
  while (character != EOF) {
    fprintf(to_file, "%c", character);
    character = getc(from_file);
  }
  return ((0));
}


x86 assembly (clang, -O0):
<copy_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1146 <copy_file+0x26>
cmpq   $0x0,-0x18(%rbp)
jne    1152 <copy_file+0x32>
movl   $0xffffffff,-0x4(%rbp)
jmp    11a0 <copy_file+0x80>
mov    -0x18(%rbp),%rdi
call   1040 <getc@plt>
mov    %al,-0x19(%rbp)
movsbl -0x19(%rbp),%eax
mov    0x2e7f(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     1199 <copy_file+0x79>
mov    -0x10(%rbp),%rdi
lea    0xe81(%rip),%rsi
movsbl -0x19(%rbp),%edx
call   1030 <fprintf@plt>
mov    -0x18(%rbp),%rdi
call   1040 <getc@plt>
mov    %al,-0x19(%rbp)
jmp    115e <copy_file+0x3e>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<copy_file>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    $0xffffffff,%r14d
test   %rdi,%rdi
je     1178 <copy_file+0x58>
mov    %rsi,%rbx
test   %rsi,%rsi
je     1178 <copy_file+0x58>
mov    %rdi,%rbp
mov    %rbx,%rdi
call   1040 <getc@plt>
mov    0x2e9c(%rip),%r15
xor    %r14d,%r14d
cmp    (%r15),%al
je     1178 <copy_file+0x58>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsbl %al,%edi
mov    %rbp,%rsi
call   1030 <fputc@plt>
mov    %rbx,%rdi
call   1040 <getc@plt>
cmp    (%r15),%al
jne    1160 <copy_file+0x40>
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@EOF = global i8 0
define i32 @copy_file(i32* %0, i32* %1) {
%3 = icmp eq i32* %0, null
%4 = icmp eq i32* %1, null
%5 = or i1 %3, %4
br i1 %5, label %17, label %6
6: ; preds = %2
%7 = tail call signext i8 @getc(i32* %1)
%8 = load i8, i8* @EOF
%9 = icmp eq i8 %7, %8
br i1 %9, label %17, label %10
10: ; preds = %6, %10
%11 = phi i8 [ %14, %10 ], [ %7, %6 ]
%12 = sext i8 %11 to i32
%13 = tail call i32 @fputc(i32 %12, i32* %0)
%14 = tail call signext i8 @getc(i32* %1)
%15 = load i8, i8* @EOF
%16 = icmp eq i8 %14, %15
br i1 %16, label %17, label %10
17: ; preds = %10, %6, %2
%18 = phi i32 [ -1, %2 ], [ 0, %6 ], [ 0, %10 ]
ret i32 %18
}