#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 */
struct stat {
  int st_size;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ digFile(char const *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ fread(unsigned char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fwrite(unsigned char *, int, int, int /*<<< orphan*/ *);
unsigned char *malloc(int);
int /*<<< orphan*/ stat(char const *, struct stat *);
void destNotExist(const char *file1, const char *file2) {
  FILE *sourceFile = fopen(file1, "r");
  FILE *destFile = fopen(file2, "w");
  struct stat buffer;
  stat(file1, &buffer);
  int size = buffer.st_size;
  digFile(file1);
  unsigned char *fileBuffer = malloc(sizeof(char) * size);
  fread(fileBuffer, 1, size, sourceFile);
  fwrite(fileBuffer, 1, size, destFile);
  fclose(sourceFile);
  fclose(destFile);
  digFile(file2);
}


x86 assembly (clang, -O0):
<destNotExist>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe75(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe63(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x28(%rbp),%rsi
call   1060 <stat@plt>
mov    -0x28(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <digFile@plt>
movslq -0x2c(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x2c(%rbp),%edx
mov    -0x18(%rbp),%rcx
mov    $0x1,%esi
call   1030 <fread@plt>
mov    -0x38(%rbp),%rdi
mov    -0x2c(%rbp),%edx
mov    -0x20(%rbp),%rcx
mov    $0x1,%esi
call   1090 <fwrite@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x10(%rbp),%rdi
call   1050 <digFile@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<destNotExist>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xe77(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%r15
lea    0xe6a(%rip),%rsi
mov    %r14,%rdi
call   1080 <fopen@plt>
mov    %rax,%r12
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <stat@plt>
mov    0x8(%rsp),%ebp
mov    %rbx,%rdi
call   1050 <digFile@plt>
mov    %ebp,%edi
call   1070 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    $0x1,%esi
mov    %ebp,%edx
mov    %r15,%rcx
call   1030 <fread@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    %ebp,%edx
mov    %r12,%rcx
call   1090 <fwrite@plt>
mov    %r15,%rdi
call   1040 <fclose@plt>
mov    %r12,%rdi
call   1040 <fclose@plt>
mov    %r14,%rdi
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <digFile@plt>

LLVM IR (-O0):
%struct.stat = type { i32 }
@.str = [2 x i8] c"r\00"
@.str.1 = [2 x i8] c"w\00"
define void @destNotExist(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca %struct.stat
%8 = alloca i32
%9 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%10 = load i8*, i8** %3
%11 = call i32* @fopen(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %11, i32** %5
%12 = load i8*, i8** %4
%13 = call i32* @fopen(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %13, i32** %6
%14 = load i8*, i8** %3
%15 = call i32 @stat(i8* %14, %struct.stat* %7)
%16 = getelementptr inbounds %struct.stat, %struct.stat* %7, i32 0, i32 0
%17 = load i32, i32* %16
store i32 %17, i32* %8
%18 = load i8*, i8** %3
%19 = call i32 @digFile(i8* %18)
%20 = load i32, i32* %8
%21 = sext i32 %20 to i64
%22 = mul i64 1, %21
%23 = trunc i64 %22 to i32
%24 = call i8* @malloc(i32 %23)
store i8* %24, i8** %9
%25 = load i8*, i8** %9
%26 = load i32, i32* %8
%27 = load i32*, i32** %5
%28 = call i32 @fread(i8* %25, i32 1, i32 %26, i32* %27)
%29 = load i8*, i8** %9
%30 = load i32, i32* %8
%31 = load i32*, i32** %6
%32 = call i32 @fwrite(i8* %29, i32 1, i32 %30, i32* %31)
%33 = load i32*, i32** %5
%34 = call i32 @fclose(i32* %33)
%35 = load i32*, i32** %6
%36 = call i32 @fclose(i32* %35)
%37 = load i8*, i8** %4
%38 = call i32 @digFile(i8* %37)
ret void
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@.str = [2 x i8] c"r\00"
@.str.1 = [2 x i8] c"w\00"
define void @destNotExist(i8* %0, i8* %1) {
%3 = alloca %struct.stat
%4 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%5 = tail call i32* @fopen(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%6 = bitcast %struct.stat* %3 to i8*
%7 = call i32 @stat(i8* %0, %struct.stat* %3)
%8 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0
%9 = load i32, i32* %8
%10 = tail call i32 @digFile(i8* %0)
%11 = tail call i8* @malloc(i32 %9)
%12 = tail call i32 @fread(i8* %11, i32 1, i32 %9, i32* %4)
%13 = tail call i32 @fwrite(i8* %11, i32 1, i32 %9, i32* %5)
%14 = tail call i32 @fclose(i32* %4)
%15 = tail call i32 @fclose(i32* %5)
%16 = tail call i32 @digFile(i8* %1)
ret void
}