// File: /workspace/github_cpp_makefile_star2_O3/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 $0x1448, %rsp           # imm = 0x1448
movq %rdx, 0x20(%rsp)
movq %rsi, %r13
movq %rdi, 0x8(%rsp)
movq 0x8(%rsi), %rax
subq (%rsi), %rax
shrq $0x5, %rax
movq %rax, 0x18(%rsp)
testl %eax, %eax
jle 0x38fd
movq 0x18(%rsp), %rbx
andl $0x7fffffff, %ebx       # imm = 0x7FFFFFFF
leaq 0x40(%rsp), %r12
leaq 0x440(%rsp), %rbp
leaq 0x181b(%rip), %r14      # 0x50ba
xorl %r15d, %r15d
movq (%r13), %rax
movq (%rax,%r15), %rdx
movq %r12, %rdi
leaq 0x17d3(%rip), %rsi      # 0x5087
movq 0x8(%rsp), %rcx
xorl %eax, %eax
callq 0x2060
movq %rbp, %rdi
leaq 0x17e7(%rip), %rsi      # 0x50b1
movq %r12, %rdx
xorl %eax, %eax
callq 0x2060
movq %rbp, %rdi
callq 0x2130
movq %rbp, %rdi
movq %r14, %rsi
movq %r12, %rdx
xorl %eax, %eax
callq 0x2060
movq %rbp, %rdi
callq 0x2130
addq $0x20, %r15
decq %rbx
jne 0x38a2
movq %r13, 0x10(%rsp)
movl $0x400, %edi            # imm = 0x400
callq 0x2030
movq %rax, 0x4865(%rip)      # 0x8178
movl $0x800000, %edi         # imm = 0x800000
callq 0x2030
movq %rax, 0x485c(%rip)      # 0x8180
movl $0x2000000, %edi        # imm = 0x2000000
callq 0x2030
movq %rax, 0x4863(%rip)      # 0x8198
movl $0x800000, %edi         # imm = 0x800000
callq 0x2030
movq %rax, 0x4842(%rip)      # 0x8188
movl $0x800000, %edi         # imm = 0x800000
callq 0x2030
movq %rax, 0x4839(%rip)      # 0x8190
movl $0x40000000, %edi       # imm = 0x40000000
callq 0x2030
movq %rax, 0x4838(%rip)      # 0x81a0
movl $0x40000000, %edi       # imm = 0x40000000
callq 0x2030
movq %rax, 0x482f(%rip)      # 0x81a8
movl $0x40000000, %edi       # imm = 0x40000000
callq 0x2030
movq %rax, 0x4846(%rip)      # 0x81d0
movabsq $0x100000000, %rdi      # imm = 0x100000000
callq 0x2030
movq %rax, 0x4838(%rip)      # 0x81d8
movl $0x100000, %edi         # imm = 0x100000
callq 0x2030
movq %rax, 0x482f(%rip)      # 0x81e0
movq 0x20(%rsp), %rcx
movq 0x8(%rcx), %rax
subq (%rcx), %rax
shrq $0x5, %rax
movq %rax, 0x28(%rsp)
testl %eax, %eax
movq 0x8(%rsp), %r8
movq 0x18(%rsp), %r12
jle 0x3b14
movl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
andq %rax, 0x28(%rsp)
andq %r12, %rax
movq %rax, 0x30(%rsp)
leaq 0x16d2(%rip), %rbp      # 0x50c3
xorl %ebx, %ebx
movq (%rcx), %rax
movq %rbx, 0x38(%rsp)
shlq $0x5, %rbx
movq (%rax,%rbx), %rcx
leaq 0x1040(%rsp), %r15
movq %r15, %rdi
movq %rbp, %rsi
movq %r8, %rdx
xorl %eax, %eax
callq 0x2060
movq %r15, %rdi
callq 0x27c0
callq 0x3194
testl %r12d, %r12d
movq 0x10(%rsp), %rcx
leaq 0x40(%rsp), %r13
jle 0x3af2
movq 0x30(%rsp), %r15
xorl %r12d, %r12d
movq (%rcx), %rax
movq (%rax,%r12), %rdx
movq %r13, %rdi
leaq 0x1633(%rip), %rsi      # 0x5087
movq 0x8(%rsp), %rcx
xorl %eax, %eax
callq 0x2060
movq 0x10(%rsp), %rax
movq (%rax), %rax
movq (%rax,%r12), %rdx
movq %rbx, %r13
movq %rbp, %rbx
movq 0x20(%rsp), %rbp
movq (%rbp), %rax
movq (%rax,%r13), %rcx
leaq 0xc40(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
xorl %eax, %eax
callq 0x2060
movq %r14, %rdi
callq 0x291d
leaq 0x1636(%rip), %rdi      # 0x50d9
movq %r14, %rsi
leaq 0x840(%rsp), %r14
xorl %eax, %eax
callq 0x2040
movq (%rbp), %rax
movq %rbx, %rbp
movq %r13, %rbx
leaq 0x40(%rsp), %r13
movq (%rax,%rbx), %rcx
movq %r14, %rdi
movq %rbp, %rsi
movq %r13, %rdx
xorl %eax, %eax
callq 0x2060
movq %r14, %rdi
callq 0x3228
movq 0x10(%rsp), %rcx
addq $0x20, %r12
decq %r15
jne 0x3a43
movq 0x38(%rsp), %rbx
incq %rbx
cmpq 0x28(%rsp), %rbx
movq 0x8(%rsp), %r8
movq 0x18(%rsp), %r12
movq 0x20(%rsp), %rcx
jne 0x39f3
testl %r12d, %r12d
movq 0x10(%rsp), %r14
jle 0x3ba3
andl $0x7fffffff, %r12d      # imm = 0x7FFFFFFF
leaq 0x40(%rsp), %r15
leaq 0x440(%rsp), %r13
xorl %ebx, %ebx
movq (%r14), %rax
movq (%rax,%rbx), %rdx
movq %r15, %rdi
leaq 0x153e(%rip), %rsi      # 0x5087
movq %r8, %rcx
xorl %eax, %eax
movq %r12, %rbp
movq %r8, %r12
callq 0x2060
movq %r13, %rdi
leaq 0x152e(%rip), %rsi      # 0x5091
movq %r15, %rdx
movq %r15, %rcx
xorl %eax, %eax
callq 0x2060
movq %r13, %rdi
callq 0x2130
movq %r13, %rdi
leaq 0x152f(%rip), %rsi      # 0x50b1
movq %r15, %rdx
xorl %eax, %eax
callq 0x2060
movq %r13, %rdi
callq 0x2130
movq %r12, %r8
movq %rbp, %r12
addq $0x20, %rbx
decq %r12
jne 0x3b38
callq 0x41e6
xorl %eax, %eax
addq $0x1448, %rsp           # imm = 0x1448
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq