// File: /workspace/github_cpp_makefile_star2_O3/BleuLlama[P]msf-tools/DiskUtils.cpp
// Function: DiskUtils::CopyFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, bool)
bool DiskUtils::CopyFile( std::string fromPath, std::string toPath, bool skipIfExists )
{
	char buf[ kCopyFileBufSize ];

	// if the file is already there, and it's okay to skip, we're done
	if( skipIfExists ) {
		if( DiskUtils::IsSimilarFile( fromPath, toPath )) return true;
	}
	
	// copy the file from fromPath to toPath. ;)

	// open the files
	FILE * inf = fopen( fromPath.c_str(), "rb" );
	if( !inf ) {
		std::cerr << "Couldn't open input file " << fromPath << std::endl;
		return true;
	}

	FILE * outf = fopen( toPath.c_str(), "wb" );
	if( !outf ) {
		std::cerr << "Couldn't open output file " << toPath << std::endl;
		fclose( inf );
		return true;
	}


	// copy it over one buffer at a time
	size_t n = 0;
	do {
		n = fread( buf, 1, kCopyFileBufSize, inf );
		fwrite( buf, n, 1, outf );
	} while( n!= 0 );

	// close the files
	fclose( inf );
	fclose( outf );

	return false;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x40040, %rsp          # imm = 0x40040
movq %rsi, %rbx
movq %rdi, %r14
testl %edx, %edx
je 0x2ab5
leaq 0x30(%rsp), %r15
movq %r15, -0x10(%r15)
movq (%r14), %rsi
movq 0x8(%r14), %rdx
addq %rsi, %rdx
leaq 0x20(%rsp), %rdi
callq 0x2c8e
leaq 0x10(%rsp), %r12
movq %r12, -0x10(%r12)
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
addq %rsi, %rdx
movq %rsp, %rdi
callq 0x2c8e
leaq 0x20(%rsp), %rdi
movq %rsp, %rsi
callq 0x2520
movl %eax, %ebp
movq (%rsp), %rdi
cmpq %r12, %rdi
je 0x2a93
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x2110
movq 0x20(%rsp), %rdi
cmpq %r15, %rdi
je 0x2aaa
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x2110
movb $0x1, %al
testb %bpl, %bpl
jne 0x2be7
movq (%r14), %rdi
leaq 0x2560(%rip), %rsi      # 0x501f
callq 0x2140
testq %rax, %rax
je 0x2b33
movq %rax, %r15
movq (%rbx), %rdi
leaq 0x2566(%rip), %rsi      # 0x503c
callq 0x2140
testq %rax, %rax
je 0x2b89
movq %rax, %r14
leaq 0x40(%rsp), %rbx
movl $0x1, %esi
movl $0x40000, %edx          # imm = 0x40000
movq %rbx, %rdi
movq %r15, %rcx
callq 0x2180
movq %rax, %r12
movl $0x1, %edx
movq %rbx, %rdi
movq %rax, %rsi
movq %r14, %rcx
callq 0x2260
testq %r12, %r12
jne 0x2aec
movq %r15, %rdi
callq 0x2100
movq %r14, %rdi
callq 0x2100
xorl %eax, %eax
jmp 0x2be7
movq 0x54b6(%rip), %rbx      # 0x7ff0
leaq 0x24e1(%rip), %rsi      # 0x5022
movl $0x19, %edx
movq %rbx, %rdi
callq 0x2130
movq (%r14), %rsi
movq 0x8(%r14), %rdx
movq %rbx, %rdi
callq 0x2130
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x20f0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x20a0
jmp 0x2be5
movq 0x5460(%rip), %r14      # 0x7ff0
leaq 0x24a8(%rip), %rsi      # 0x503f
movl $0x1a, %edx
movq %r14, %rdi
callq 0x2130
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
movq %r14, %rdi
callq 0x2130
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x20f0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x20a0
movq %r15, %rdi
callq 0x2100
movb $0x1, %al
addq $0x40040, %rsp          # imm = 0x40040
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq (%rsp), %rdi
cmpq %r12, %rdi
je 0x2c15
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x2110
jmp 0x2c15
movq %rax, %rbx
movq 0x20(%rsp), %rdi
cmpq %r15, %rdi
je 0x2c2c
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x2110
movq %rbx, %rdi
callq 0x2230