#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*/ copy(char *, char *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, char *);
int main() {
  char path[4096];
  char destPath[4096];
  printf("Please enter path to file: ");
  scanf("%s", path);
  printf("Please enter path to modified file:");
  scanf("%s", destPath);
  FILE *file = fopen(path, "r");
  FILE *destFile = fopen(destPath, "w");
  char buffer[4096 + 1];
  if (file) {
    copy(path, destPath);
    printf("Done!\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x3030,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xea7(%rip),%rdi
call   1030 <printf@plt>
lea    -0x1010(%rbp),%rsi
lea    0xeb0(%rip),%rdi
call   1050 <scanf@plt>
lea    0xea7(%rip),%rdi
call   1030 <printf@plt>
lea    -0x2010(%rbp),%rsi
lea    0xe91(%rip),%rdi
call   1050 <scanf@plt>
lea    -0x1010(%rbp),%rdi
lea    0xea5(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x2018(%rbp)
lea    -0x2010(%rbp),%rdi
lea    0xe8d(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x2020(%rbp)
cmpq   $0x0,-0x2018(%rbp)
je     11f1 <main+0xb1>
lea    -0x1010(%rbp),%rdi
lea    -0x2010(%rbp),%rsi
call   1040 <copy@plt>
lea    0xe5b(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x3030,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x2000,%rsp
lea    0xe9d(%rip),%rdi
call   1040 <printf@plt>
lea    0xead(%rip),%rbx
lea    0x1000(%rsp),%r14
mov    %rbx,%rdi
mov    %r14,%rsi
call   1060 <scanf@plt>
lea    0xe96(%rip),%rdi
call   1040 <printf@plt>
mov    %rsp,%r15
mov    %rbx,%rdi
mov    %r15,%rsi
call   1060 <scanf@plt>
lea    0xea0(%rip),%rsi
mov    %r14,%rdi
call   1070 <fopen@plt>
mov    %rax,%rbx
lea    0xe90(%rip),%rsi
mov    %r15,%rdi
call   1070 <fopen@plt>
test   %rbx,%rbx
je     11de <main+0x8e>
lea    0x1000(%rsp),%rdi
mov    %rsp,%rsi
call   1050 <copy@plt>
lea    0xe6e(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x2000,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [28 x i8] c"Please enter path to file: \00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [36 x i8] c"Please enter path to modified file:\00"
@.str.3 = [2 x i8] c"r\00"
@.str.4 = [2 x i8] c"w\00"
@.str.5 = [7 x i8] c"Done!\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [4096 x i8]
%3 = alloca [4096 x i8]
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca [4097 x i8]
store i32 0, i32* %1
%7 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%8 = getelementptr inbounds [4096 x i8], [4096 x i8]* %2, i64 0, i64 0
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %8)
%10 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0))
%11 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 0
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %11)
%13 = getelementptr inbounds [4096 x i8], [4096 x i8]* %2, i64 0, i64 0
%14 = call i32* @fopen(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %14, i32** %4
%15 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 0
%16 = call i32* @fopen(i8* %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32* %16, i32** %5
%17 = load i32*, i32** %4
%18 = icmp ne i32* %17, null
br i1 %18, label %19, label %24
19: ; preds = %0
%20 = getelementptr inbounds [4096 x i8], [4096 x i8]* %2, i64 0, i64 0
%21 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 0
%22 = call i32 @copy(i8* %20, i8* %21)
%23 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
br label %24
24: ; preds = %19, %0
ret i32 0
}

LLVM IR (-O2):
@.str = [28 x i8] c"Please enter path to file: \00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [36 x i8] c"Please enter path to modified file:\00"
@.str.3 = [2 x i8] c"r\00"
@.str.4 = [2 x i8] c"w\00"
@str = [6 x i8] c"Done!\00"
define i32 @main() {
%1 = alloca [4096 x i8]
%2 = alloca [4096 x i8]
%3 = getelementptr inbounds [4096 x i8], [4096 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [4096 x i8], [4096 x i8]* %2, i64 0, i64 0
%5 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%7 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%9 = call i32* @fopen(i8* %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%10 = call i32* @fopen(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%11 = icmp eq i32* %9, null
br i1 %11, label %15, label %12
12: ; preds = %0
%13 = call i32 @copy(i8* %3, i8* %4)
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str, i64 0, i64 0))
br label %15
15: ; preds = %12, %0
ret i32 0
}