// File: /workspace/github_cpp_makefile_star2_O1/Dts0[P]addCopyright/addCopyright.cpp
// Function: addCopyright(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::ostream&)
int addCopyright(string fileName,string copyrightFile,ostream& os){
	ifstream rfile(fileName.c_str());
	if(!rfile.is_open()){
		os<<"错误: 文件 "<<fileName<<" 无法被读取。"<<endl;
		return -1;
	}

	ifstream header(copyrightFile.c_str());
	stringstream buf;
	if(!header.is_open()){
		os<<"错误: 没有选择版权信息文件或版权信息文件无法被读取。所以未添加。"<<endl;
		//buf<<"/*这是默认的版权信息\n"
		//   <<"* copyright (c) 2018 DTS\n"
		//   <<"*/\n";
		 return -3;
	} else{
		buf<<header.rdbuf();
	}

	string charbuf1,charbuf2;
	header.seekg(header.beg);
	header>>charbuf1;
	header.close();

	rfile>>charbuf2;
	rfile.seekg(rfile.beg);

	if(charbuf1==charbuf2){
		os<<"警告: 这个版权信息文件已被添加到文件 "<<fileName<<" 过，因此没有继续执行。"<<endl;
		return 1;
	}

	buf<<rfile.rdbuf();
	rfile.close();

	ofstream wfile(fileName.c_str(), ios::out|ios::trunc);
	if(!wfile.is_open()){
		os<<"错误: 文件 "<<fileName<<" 无法被写入。"<<endl;
		return -2;
	}
	wfile<<buf.rdbuf();
	wfile.close();

	os<<"信息: 版权信息被成功添加到文件 "<<fileName<<" 。"<<endl;
	return 1;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x7e0, %rsp            # imm = 0x7E0
movq %rdx, %rbx
movq %rsi, %r15
movq %rdi, %r14
movq (%rdi), %rsi
leaq 0x5d8(%rsp), %rdi
movl $0x8, %edx
callq 0x2240
leaq 0x650(%rsp), %rdi
callq 0x2060
testb %al, %al
je 0x25ae
movq (%r15), %rsi
leaq 0x3d0(%rsp), %rdi
movl $0x8, %edx
callq 0x2240
leaq 0x48(%rsp), %rdi
callq 0x20e0
leaq 0x448(%rsp), %rdi
callq 0x2060
testb %al, %al
je 0x2619
leaq 0x58(%rsp), %r15
leaq 0x3e0(%rsp), %rsi
movq %r15, %rdi
callq 0x2050
leaq 0x38(%rsp), %r12
movq %r12, -0x10(%r12)
xorl %eax, %eax
movq %rax, -0x8(%r12)
movb %al, (%r12)
leaq 0x18(%rsp), %r13
movq %r13, -0x10(%r13)
movq %rax, -0x8(%r13)
movb %al, (%r13)
leaq 0x3d0(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x21b0
leaq 0x3d0(%rsp), %rdi
leaq 0x28(%rsp), %rsi
callq 0x21c0
leaq 0x3d0(%rsp), %rdi
callq 0x2040
leaq 0x5d8(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x21c0
leaq 0x5d8(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x21b0
movq 0x30(%rsp), %rdx
cmpq 0x10(%rsp), %rdx
jne 0x24dd
testq %rdx, %rdx
je 0x26fe
movq 0x8(%rsp), %rsi
movq 0x28(%rsp), %rdi
callq 0x2180
testl %eax, %eax
je 0x26fe
leaq 0x5e8(%rsp), %rsi
movq %r15, %rdi
callq 0x2050
leaq 0x5d8(%rsp), %rdi
callq 0x2040
movq (%r14), %rsi
leaq 0x1d0(%rsp), %rdi
movl $0x30, %edx
callq 0x2190
leaq 0x240(%rsp), %rdi
callq 0x2060
testb %al, %al
je 0x265e
leaq 0x60(%rsp), %rsi
leaq 0x1d0(%rsp), %rdi
callq 0x2050
leaq 0x1d0(%rsp), %rdi
callq 0x21d0
leaq 0x1bac(%rip), %rsi      # 0x40f6
movl $0x2d, %edx
movq %rbx, %rdi
callq 0x21a0
movq (%r14), %rsi
movq 0x8(%r14), %rdx
movq %rbx, %rdi
callq 0x21a0
movq %rax, %rbx
leaq 0x1bb4(%rip), %rsi      # 0x4124
movl $0x4, %edx
movq %rax, %rdi
callq 0x21a0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2150
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movl $0x1, %ebx
movq %rax, %rdi
callq 0x20d0
jmp 0x26c4
leaq 0x1a4f(%rip), %rsi      # 0x4004
movl $0xf, %edx
movq %rbx, %rdi
callq 0x21a0
movq (%r14), %rsi
movq 0x8(%r14), %rdx
movq %rbx, %rdi
callq 0x21a0
movq %rax, %rbx
leaq 0x1a39(%rip), %rsi      # 0x4014
movl $0x13, %edx
movq %rax, %rdi
callq 0x21a0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2150
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movq %rax, %rdi
callq 0x20d0
jmp 0x27bd
leaq 0x1a08(%rip), %rsi      # 0x4028
movl $0x5f, %edx
movq %rbx, %rdi
callq 0x21a0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2150
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movl $0xfffffffd, %ebx       # imm = 0xFFFFFFFD
movq %rax, %rdi
callq 0x20d0
jmp 0x2792
leaq 0x199f(%rip), %rsi      # 0x4004
movl $0xf, %edx
movq %rbx, %rdi
callq 0x21a0
movq (%r14), %rsi
movq 0x8(%r14), %rdx
movq %rbx, %rdi
callq 0x21a0
movq %rax, %rbx
leaq 0x1a57(%rip), %rsi      # 0x40e2
movl $0x13, %edx
movq %rax, %rdi
callq 0x21a0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2150
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movl $0xfffffffe, %ebx       # imm = 0xFFFFFFFE
movq %rax, %rdi
callq 0x20d0
movq 0x3905(%rip), %rax      # 0x5fd0
movq (%rax), %rcx
movq 0x18(%rax), %rax
leaq 0x1d8(%rsp), %rdi
movq %rcx, -0x8(%rdi)
movq -0x18(%rcx), %rcx
movq %rax, 0x1d0(%rsp,%rcx)
callq 0x2130
leaq 0x2c8(%rsp), %rdi
callq 0x2090
jmp 0x2764
leaq 0x1983(%rip), %rsi      # 0x4088
movl $0x36, %edx
movq %rbx, %rdi
callq 0x21a0
movq (%r14), %rsi
movq 0x8(%r14), %rdx
movq %rbx, %rdi
callq 0x21a0
movq %rax, %rbx
leaq 0x1994(%rip), %rsi      # 0x40bf
movl $0x22, %edx
movq %rax, %rdi
callq 0x21a0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2150
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movl $0x1, %ebx
movq %rax, %rdi
callq 0x20d0
movq 0x8(%rsp), %rdi
cmpq %r13, %rdi
je 0x277b
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x2170
movq 0x28(%rsp), %rdi
cmpq %r12, %rdi
je 0x2792
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x2170
movq 0x381f(%rip), %rsi      # 0x5fb8
leaq 0x48(%rsp), %rdi
callq 0x2100
leaq 0xc8(%rsp), %rdi
callq 0x2090
leaq 0x3d0(%rsp), %rdi
callq 0x2070
leaq 0x5d8(%rsp), %rdi
callq 0x2070
movl %ebx, %eax
addq $0x7e0, %rsp            # imm = 0x7E0
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
jmp 0x27fd
movq %rax, %rbx
jmp 0x284c
jmp 0x285b
movq %rax, %rbx
leaq 0x1d0(%rsp), %rdi
callq 0x21e0
jmp 0x2800
movq %rax, %rbx
jmp 0x282e
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r13, %rdi
je 0x2817
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x2170
movq 0x28(%rsp), %rdi
cmpq %r12, %rdi
je 0x282e
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x2170
movq 0x3783(%rip), %rsi      # 0x5fb8
leaq 0x48(%rsp), %rdi
callq 0x2100
leaq 0xc8(%rsp), %rdi
callq 0x2090
leaq 0x3d0(%rsp), %rdi
callq 0x2070
jmp 0x285e
movq %rax, %rbx
leaq 0x5d8(%rsp), %rdi
callq 0x2070
movq %rbx, %rdi
callq 0x2220
nop