// File: /workspace/github_cpp_makefile_star2_O2/yuansliu[P]HiRGC/hirgc.cpp
// Function: compressSet(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>>>>&, 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>>>>&)
int compressSet(char *ref_fold, vector<string> &fold_list, vector<string> &chr_name_list) {//hirgc refFold tarFold
	char ref[1024], tar[1024], res[1024];
	char cmd[1024]; 
	char temp[1024];
	
	int fold_size = fold_list.size();

	for (int ti = 0; ti < fold_size; ti++) {
		sprintf(temp, "%s_ref_%s", fold_list[ti].c_str(), ref_fold);
		sprintf(cmd, "rm -r %s", temp);
		system(cmd);
		sprintf(cmd, "mkdir %s", temp);
		system(cmd);
	}

	initial(); //important*************

	int size = chr_name_list.size();
	for (int i = 0; i < size; i++) {

		sprintf(ref, "%s/%s", ref_fold, chr_name_list[i].c_str());

		readRefFile(ref);
		preProcessRef();

		for (int ti = 0; ti < fold_size; ti++) {
			sprintf(temp, "%s_ref_%s", fold_list[ti].c_str(), ref_fold);

			sprintf(tar, "%s/%s", fold_list[ti].c_str(), chr_name_list[i].c_str());
			readTarFile(tar);

			printf("compressing %s ...\n", tar);

			sprintf(res, "%s/%s", temp, chr_name_list[i].c_str());
			// compressFile(ref, tar, res);
			searchMatch(res);
		}
	}

	for (int ti = 0; ti < fold_size; ti++) {
		sprintf(temp, "%s_ref_%s", fold_list[ti].c_str(), ref_fold);

		sprintf(cmd, "./7za a %s.7z %s -m0=PPMd", temp, temp);
		system(cmd);

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

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1438, %rsp           # imm = 0x1438
movq %rdx, 0x8(%rsp)
movq 0x8(%rsi), %rcx
movq %rsi, 0x10(%rsp)
subq (%rsi), %rcx
shrq $0x5, %rcx
xorl %eax, %eax
testl %ecx, %ecx
cmovlel %eax, %ecx
movq %rdi, (%rsp)
shlq $0x5, %rcx
movq %rcx, 0x18(%rsp)
leaq 0x1b67(%rip), %r15      # 0x5087
leaq 0x30(%rsp), %r12
leaq 0x1b85(%rip), %r13      # 0x50b1
leaq 0x430(%rsp), %rbp
leaq 0x1b7f(%rip), %r14      # 0x50ba
xorl %ebx, %ebx
cmpq %rbx, 0x18(%rsp)
je 0x3597
movq 0x10(%rsp), %rax
movq (%rax), %rax
movq (%rax,%rbx), %rdx
movq %r12, %rdi
movq %r15, %rsi
movq (%rsp), %rcx
xorl %eax, %eax
callq 0x2060
movq %rbp, %rdi
movq %r13, %rsi
movq %r12, %rdx
xorl %eax, %eax
callq 0x2060
movq %rbp, %rdi
callq 0x2120
movq %rbp, %rdi
movq %r14, %rsi
movq %r12, %rdx
xorl %eax, %eax
callq 0x2060
movq %rbp, %rdi
callq 0x2120
addq $0x20, %rbx
jmp 0x353d
callq 0x3d4d
movq 0x8(%rsp), %rax
movq 0x8(%rax), %rcx
subq (%rax), %rcx
shrq $0x5, %rcx
xorl %eax, %eax
testl %ecx, %ecx
cmovlel %eax, %ecx
movq %rcx, 0x20(%rsp)
leaq 0xc30(%rsp), %rbp
xorl %ebx, %ebx
cmpq 0x20(%rsp), %rbx
je 0x36bf
movq 0x8(%rsp), %rax
movq (%rax), %rax
movq %rbx, 0x28(%rsp)
shlq $0x5, %rbx
movq (%rax,%rbx), %rcx
leaq 0x1030(%rsp), %r12
movq %r12, %rdi
leaq 0x1acf(%rip), %rsi      # 0x50c3
movq (%rsp), %rdx
xorl %eax, %eax
callq 0x2060
movq %r12, %rdi
callq 0x2773
callq 0x2fba
xorl %r12d, %r12d
cmpq %r12, 0x18(%rsp)
je 0x36b2
movq 0x10(%rsp), %r13
movq (%r13), %rax
movq (%rax,%r12), %rdx
leaq 0x30(%rsp), %r14
movq %r14, %rdi
leaq 0x1a51(%rip), %rsi      # 0x5087
movq (%rsp), %rcx
xorl %eax, %eax
callq 0x2060
movq (%r13), %rax
movq (%rax,%r12), %rdx
movq 0x8(%rsp), %r15
movq (%r15), %rax
movq (%rax,%rbx), %rcx
movq %rbp, %rdi
leaq 0x1a64(%rip), %r13      # 0x50c3
movq %r13, %rsi
xorl %eax, %eax
callq 0x2060
movq %rbp, %rdi
callq 0x2888
leaq 0x1a61(%rip), %rdi      # 0x50d9
movq %rbp, %rsi
xorl %eax, %eax
callq 0x2040
movq (%r15), %rax
movq (%rax,%rbx), %rcx
leaq 0x830(%rsp), %r15
movq %r15, %rdi
movq %r13, %rsi
movq %r14, %rdx
xorl %eax, %eax
callq 0x2060
movq %r15, %rdi
callq 0x3053
addq $0x20, %r12
jmp 0x360f
movq 0x28(%rsp), %rbx
incq %rbx
jmp 0x35c2
leaq 0x19c1(%rip), %r14      # 0x5087
leaq 0x30(%rsp), %r15
leaq 0x19bf(%rip), %r12      # 0x5091
leaq 0x430(%rsp), %r13
leaq 0x19d0(%rip), %rbp      # 0x50b1
xorl %ebx, %ebx
cmpq %rbx, 0x18(%rsp)
je 0x3740
movq 0x10(%rsp), %rax
movq (%rax), %rax
movq (%rax,%rbx), %rdx
movq %r15, %rdi
movq %r14, %rsi
movq (%rsp), %rcx
xorl %eax, %eax
callq 0x2060
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %r15, %rcx
xorl %eax, %eax
callq 0x2060
movq %r13, %rdi
callq 0x2120
movq %r13, %rdi
movq %rbp, %rsi
movq %r15, %rdx
xorl %eax, %eax
callq 0x2060
movq %r13, %rdi
callq 0x2120
addq $0x20, %rbx
jmp 0x36e3
callq 0x3e2a
xorl %eax, %eax
addq $0x1438, %rsp           # imm = 0x1438
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq