#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 /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fputc(char, int /*<<< orphan*/ *);
void CopyFile(char sInputFile[], char sOutputFile[]) {
  FILE *fpInputFile, *fpOutputFile;
  char ch;
  if ((fpInputFile = fopen(sInputFile, "rb")) != NULL) {
    fpOutputFile = fopen(sOutputFile, "wb");
    while (!feof(fpInputFile)) {
      ch = fgetc(fpInputFile);
      if (!feof(fpInputFile))
        fputc(ch, fpOutputFile);
    }
    fclose(fpInputFile);
    fclose(fpOutputFile);
  }
}


x86 assembly (clang, -O0):
<CopyFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe95(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     11f4 <CopyFile+0xa4>
mov    -0x10(%rbp),%rdi
lea    0xe7a(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11b0 <CopyFile+0x60>
jmp    11e2 <CopyFile+0x92>
mov    -0x18(%rbp),%rdi
call   1040 <fgetc@plt>
mov    %al,-0x21(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <feof@plt>
cmp    $0x0,%eax
jne    11dd <CopyFile+0x8d>
mov    -0x21(%rbp),%al
mov    -0x20(%rbp),%rsi
movsbl %al,%edi
call   1050 <fputc@plt>
jmp    1192 <CopyFile+0x42>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CopyFile>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
lea    0xea2(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     11c4 <CopyFile+0x74>
mov    %rax,%rbx
lea    0xe91(%rip),%rsi
mov    %r14,%rdi
call   1070 <fopen@plt>
mov    %rax,%r14
nopl   (%rax)
mov    %rbx,%rdi
call   1060 <feof@plt>
test   %eax,%eax
jne    11b0 <CopyFile+0x60>
mov    %rbx,%rdi
call   1040 <fgetc@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1060 <feof@plt>
test   %eax,%eax
jne    1180 <CopyFile+0x30>
movsbl %bpl,%edi
mov    %r14,%rsi
call   1050 <fputc@plt>
jmp    1180 <CopyFile+0x30>
mov    %rbx,%rdi
call   1030 <fclose@plt>
mov    %r14,%rdi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <fclose@plt>
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"rb\00"
@.str.1 = [3 x i8] c"wb\00"
define void @CopyFile(i8* nocapture %0, i8* nocapture %1) {
%3 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i32* %3, null
br i1 %4, label %21, label %5
5: ; preds = %2
%6 = tail call i32* @fopen(i8* %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%7 = tail call i32 @feof(i32* %3)
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %18
9: ; preds = %5, %15
%10 = tail call signext i8 @fgetc(i32* %3)
%11 = tail call i32 @feof(i32* %3)
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %9
%14 = tail call i32 @fputc(i8 signext %10, i32* %6)
br label %15
15: ; preds = %13, %9
%16 = tail call i32 @feof(i32* %3)
%17 = icmp eq i32 %16, 0
br i1 %17, label %9, label %18
18: ; preds = %15, %5
%19 = tail call i32 @fclose(i32* %3)
%20 = tail call i32 @fclose(i32* %6)
br label %21
21: ; preds = %18, %2
ret void
}