#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*/ feof(int /*<<< orphan*/ *);
int fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ fputc(int, int /*<<< orphan*/ *);
void copyFile(const char *sourcePath, const char *targetPath) {
  if (sourcePath == NULL || targetPath == NULL) {
    return;
  }
  FILE *rfile = fopen(sourcePath, "r");
  FILE *wfile = fopen(targetPath, "w");
  if (rfile == NULL || wfile == NULL) {
    return;
  }
  while (!feof(rfile)) {
    int ch = fgetc(rfile);
    if (ch != EOF) {
      fputc(ch, wfile);
    }
  }
}


x86 assembly (clang, -O0):
<copyFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     1166 <copyFile+0x26>
cmpq   $0x0,-0x10(%rbp)
jne    116b <copyFile+0x2b>
jmp    1200 <copyFile+0xc0>
mov    -0x8(%rbp),%rdi
lea    0xe8a(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe78(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11a9 <copyFile+0x69>
cmpq   $0x0,-0x20(%rbp)
jne    11ae <copyFile+0x6e>
jmp    1200 <copyFile+0xc0>
jmp    11b3 <copyFile+0x73>
mov    -0x18(%rbp),%rdi
call   1050 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11d1 <copyFile+0x91>
jmp    1200 <copyFile+0xc0>
mov    -0x18(%rbp),%rdi
call   1030 <fgetc@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    0x2e01(%rip),%rcx
cmp    (%rcx),%eax
je     11fb <copyFile+0xbb>
mov    -0x24(%rbp),%edi
mov    -0x20(%rbp),%rsi
call   1040 <fputc@plt>
jmp    11b3 <copyFile+0x73>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<copyFile>:
push   %r15
push   %r14
push   %rbx
test   %rdi,%rdi
je     1189 <copyFile+0x49>
mov    %rsi,%r14
test   %rsi,%rsi
je     1189 <copyFile+0x49>
lea    0xea7(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%rbx
lea    0xe9a(%rip),%rsi
mov    %r14,%rdi
call   1060 <fopen@plt>
test   %rbx,%rbx
je     1189 <copyFile+0x49>
mov    %rax,%r14
test   %rax,%rax
je     1189 <copyFile+0x49>
mov    %rbx,%rdi
call   1050 <feof@plt>
test   %eax,%eax
je     118f <copyFile+0x4f>
pop    %rbx
pop    %r14
pop    %r15
ret
mov    0x2e52(%rip),%r15
jmp    11ac <copyFile+0x6c>
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1050 <feof@plt>
test   %eax,%eax
jne    1189 <copyFile+0x49>
mov    %rbx,%rdi
call   1030 <fgetc@plt>
cmp    (%r15),%eax
je     11a0 <copyFile+0x60>
mov    %eax,%edi
mov    %r14,%rsi
call   1040 <fputc@plt>
jmp    11a0 <copyFile+0x60>

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

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