// File: yuansliu[P]HiRGC/hirgc.cpp
// Function: compressGenome(char*, char*, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>&)
void compressGenome(char *refFold, char *tarFold, vector<string> &chr_name_list) {
    char ref[1020], tar[1020], res[1020];
	char cmd[2048];
	char temp[100];
	sprintf(temp, "%s_ref_%s", tarFold, refFold);
	sprintf(cmd, "rm -r %s", temp);
	system(cmd);
	sprintf(cmd, "mkdir %s", temp);
	system(cmd);

	initial(); //important************* must initial before other operation

	int size = chr_name_list.size();
	for (int i = 0; i < size; i++) {
		sprintf(ref, "%s/%s", refFold, chr_name_list[i].c_str());
		sprintf(tar, "%s/%s", tarFold, chr_name_list[i].c_str());
		printf("compressing %s\n", tar);
		sprintf(res, "%s/%s", temp, chr_name_list[i].c_str());
		compressFile(ref, tar, res);
	}
	
	sprintf(cmd, "./7za a %s.7z %s -m0=PPMd", temp, temp);
	system(cmd);

	sprintf(cmd, "rm -r %s", temp);
	system(cmd);
	
	clear();
}

// Assembly:
subq $0x14c8, %rsp           # imm = 0x14C8
movq %rdi, 0x14c0(%rsp)
movq %rsi, 0x14b8(%rsp)
movq %rdx, 0x14b0(%rsp)
leaq 0x40(%rsp), %rdi
movq 0x14b8(%rsp), %rdx
movq 0x14c0(%rsp), %rcx
leaq 0x3d5e(%rip), %rsi      # 0x8079
movb $0x0, %al
callq 0x2060
leaq 0xb0(%rsp), %rdi
leaq 0x40(%rsp), %rdx
leaq 0x3d6d(%rip), %rsi      # 0x80a3
movb $0x0, %al
callq 0x2060
leaq 0xb0(%rsp), %rdi
callq 0x2140
leaq 0xb0(%rsp), %rdi
leaq 0x40(%rsp), %rdx
leaq 0x3d4e(%rip), %rsi      # 0x80ac
movb $0x0, %al
callq 0x2060
leaq 0xb0(%rsp), %rdi
callq 0x2140
callq 0x52f0
movq 0x14b0(%rsp), %rdi
callq 0x5520
movl %eax, 0x3c(%rsp)
movl $0x0, 0x38(%rsp)
movl 0x38(%rsp), %eax
cmpl 0x3c(%rsp), %eax
jge 0x44cb
leaq 0x10b0(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0x14c0(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0x14b0(%rsp), %rdi
movslq 0x38(%rsp), %rsi
callq 0x5540
movq %rax, %rdi
callq 0x20b0
movq 0x8(%rsp), %rdi
movq 0x10(%rsp), %rdx
movq %rax, %rcx
leaq 0x3ccf(%rip), %rsi      # 0x80b5
movb $0x0, %al
callq 0x2060
leaq 0xcb0(%rsp), %rax
movq %rax, 0x18(%rsp)
movq 0x14b8(%rsp), %rax
movq %rax, 0x20(%rsp)
movq 0x14b0(%rsp), %rdi
movslq 0x38(%rsp), %rsi
callq 0x5540
movq %rax, %rdi
callq 0x20b0
movq 0x18(%rsp), %rdi
movq 0x20(%rsp), %rdx
movq %rax, %rcx
leaq 0x3c80(%rip), %rsi      # 0x80b5
movb $0x0, %al
callq 0x2060
leaq 0xcb0(%rsp), %rsi
leaq 0x3c70(%rip), %rdi      # 0x80bb
movb $0x0, %al
callq 0x2040
leaq 0x8b0(%rsp), %rax
movq %rax, 0x28(%rsp)
leaq 0x40(%rsp), %rax
movq %rax, 0x30(%rsp)
movq 0x14b0(%rsp), %rdi
movslq 0x38(%rsp), %rsi
callq 0x5540
movq %rax, %rdi
callq 0x20b0
movq 0x28(%rsp), %rdi
movq 0x30(%rsp), %rdx
movq %rax, %rcx
leaq 0x3c1e(%rip), %rsi      # 0x80b5
movb $0x0, %al
callq 0x2060
leaq 0x10b0(%rsp), %rdi
leaq 0xcb0(%rsp), %rsi
leaq 0x8b0(%rsp), %rdx
callq 0x53b0
movl 0x38(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x38(%rsp)
jmp 0x4390
leaq 0xb0(%rsp), %rdi
leaq 0x40(%rsp), %rdx
leaq 0x40(%rsp), %rcx
leaq 0x3b9f(%rip), %rsi      # 0x8083
movb $0x0, %al
callq 0x2060
leaq 0xb0(%rsp), %rdi
callq 0x2140
leaq 0xb0(%rsp), %rdi
leaq 0x40(%rsp), %rdx
leaq 0x3b97(%rip), %rsi      # 0x80a3
movb $0x0, %al
callq 0x2060
leaq 0xb0(%rsp), %rdi
callq 0x2140
callq 0x53f0
addq $0x14c8, %rsp           # imm = 0x14C8
retq
nopl (%rax)