// File: /workspace/github_cpp_makefile_star2_O2/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 %rbx
subq $0x7e0, %rsp            # imm = 0x7E0
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
movq (%rdi), %rsi
leaq 0x250(%rsp), %rdi
pushq $0x8
popq %rdx
callq 0x2250
leaq 0x2c8(%rsp), %rdi
callq 0x2050
testb %al, %al
je 0x24fc
movq (%r15), %rsi
leaq 0x48(%rsp), %rdi
pushq $0x8
popq %rdx
callq 0x2250
leaq 0x458(%rsp), %rdi
callq 0x2100
leaq 0xc0(%rsp), %rdi
callq 0x2050
testb %al, %al
je 0x2535
leaq 0x468(%rsp), %r15
leaq 0x58(%rsp), %rsi
movq %r15, %rdi
callq 0x2040
leaq 0x38(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
xorl %ecx, %ecx
movb %cl, (%rax)
leaq 0x18(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb %cl, (%rax)
leaq 0x48(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x21b0
leaq 0x48(%rsp), %rdi
leaq 0x28(%rsp), %rsi
callq 0x21c0
leaq 0x48(%rsp), %rdi
callq 0x2030
leaq 0x250(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x21c0
leaq 0x250(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x21b0
leaq 0x28(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x26dc
testb %al, %al
je 0x2554
leaq 0xbbe(%rip), %rsi       # 0x3088
movq %r14, %rdi
callq 0x2170
movq %rax, %rdi
movq %rbx, %rsi
callq 0x2160
leaq 0xbdb(%rip), %rsi       # 0x30bf
movq %rax, %rdi
callq 0x2170
movq %rax, %rdi
callq 0x20e0
pushq $0x1
popq %rbx
jmp 0x262d
leaq 0xb01(%rip), %rsi       # 0x3004
movq %r14, %rdi
callq 0x2170
movq %rax, %rdi
movq %rbx, %rsi
callq 0x2160
leaq 0xaf7(%rip), %rsi       # 0x3014
movq %rax, %rdi
callq 0x2170
movq %rax, %rdi
callq 0x20e0
pushq $-0x1
popq %rbx
jmp 0x2658
leaq 0xaec(%rip), %rsi       # 0x3028
movq %r14, %rdi
callq 0x2170
movq %rax, %rdi
callq 0x20e0
pushq $-0x3
popq %rbx
jmp 0x2641
leaq 0x260(%rsp), %rsi
movq %r15, %rdi
callq 0x2040
leaq 0x250(%rsp), %rdi
callq 0x2030
movq (%rbx), %rsi
leaq 0x5e0(%rsp), %rdi
pushq $0x30
popq %rdx
callq 0x21a0
leaq 0x650(%rsp), %rdi
callq 0x2050
testb %al, %al
je 0x25ec
leaq 0x470(%rsp), %rsi
leaq 0x5e0(%rsp), %rdi
callq 0x2040
leaq 0x5e0(%rsp), %rdi
callq 0x21f0
leaq 0xb38(%rip), %rsi       # 0x30f6
movq %r14, %rdi
callq 0x2170
movq %rax, %rdi
movq %rbx, %rsi
callq 0x2160
leaq 0xb4c(%rip), %rsi       # 0x3124
movq %rax, %rdi
callq 0x2170
movq %rax, %rdi
callq 0x20e0
pushq $0x1
jmp 0x261f
leaq 0xa11(%rip), %rsi       # 0x3004
movq %r14, %rdi
callq 0x2170
movq %rax, %rdi
movq %rbx, %rsi
callq 0x2160
leaq 0xad5(%rip), %rsi       # 0x30e2
movq %rax, %rdi
callq 0x2170
movq %rax, %rdi
callq 0x20e0
pushq $-0x2
popq %rbx
leaq 0x5e0(%rsp), %rdi
callq 0x2200
leaq 0x8(%rsp), %rdi
callq 0x20d0
leaq 0x28(%rsp), %rdi
callq 0x20d0
leaq 0x458(%rsp), %rdi
callq 0x2120
leaq 0x48(%rsp), %rdi
callq 0x2060
leaq 0x250(%rsp), %rdi
callq 0x2060
movl %ebx, %eax
addq $0x7e0, %rsp            # imm = 0x7E0
popq %rbx
popq %r14
popq %r15
retq
jmp 0x2694
movq %rax, %rbx
jmp 0x26b8
jmp 0x26c4
movq %rax, %rbx
leaq 0x5e0(%rsp), %rdi
callq 0x2200
jmp 0x2697
movq %rax, %rbx
jmp 0x26ab
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x20d0
leaq 0x28(%rsp), %rdi
callq 0x20d0
leaq 0x458(%rsp), %rdi
callq 0x2120
leaq 0x48(%rsp), %rdi
callq 0x2060
jmp 0x26c7
movq %rax, %rbx
leaq 0x250(%rsp), %rdi
callq 0x2060
movq %rbx, %rdi
callq 0x2230