// File: /workspace/github_cpp_makefile_star2_O2/chhylp123[P]hifiasm/Assembly.cpp
// Function: worker_ec_save(void*, long, int)
static void worker_ec_save(void *data, long i, int tid)
{
	ha_ecsave_buf_t *e = (ha_ecsave_buf_t*)data + tid;

	Cigar_record cigar;
	int first_round_read_length;
	int second_round_read_length;
	uint64_t N_occ;

	char *new_read;
	int new_read_length;

	recover_UC_Read(&e->g_read, &R_INF, i);

	// round 1
	if ((long long)R_INF.cigars[i].new_length > e->first_round_read_size) {
		e->first_round_read_size = R_INF.cigars[i].new_length;
		REALLOC(e->first_round_read, e->first_round_read_size);
	}

	cigar.length = R_INF.cigars[i].length;
	cigar.lost_base_length = R_INF.cigars[i].lost_base_length;
	cigar.record = R_INF.cigars[i].record;
	cigar.lost_base = R_INF.cigars[i].lost_base;

	get_corrected_read_from_cigar(&cigar, e->g_read.seq, e->g_read.length, e->first_round_read, &first_round_read_length);

	// round 2
	if ((long long)R_INF.second_round_cigar[i].new_length > e->second_round_read_size) {
		e->second_round_read_size = R_INF.second_round_cigar[i].new_length;
		REALLOC(e->second_round_read, e->second_round_read_size);
	}
	cigar.length = R_INF.second_round_cigar[i].length;
	cigar.lost_base_length = R_INF.second_round_cigar[i].lost_base_length;
	cigar.record = R_INF.second_round_cigar[i].record;
	cigar.lost_base = R_INF.second_round_cigar[i].lost_base;

	get_corrected_read_from_cigar(&cigar, e->first_round_read, first_round_read_length, e->second_round_read, &second_round_read_length);

	new_read = e->second_round_read;
	new_read_length = second_round_read_length;

	if (asm_opt.roundID != asm_opt.number_of_round - 1)
	{
		///need modification
		reverse_complement(new_read, new_read_length);
	}
	else if(asm_opt.number_of_round % 2 == 0)
	{
		///need modification
		reverse_complement(new_read, new_read_length);
	}

	N_occ = get_N_occ(new_read, new_read_length);

	if ((long long)R_INF.read_size[i] < new_read_length) {
		R_INF.read_size[i] = new_read_length;
		REALLOC(R_INF.read_sperate[i], R_INF.read_size[i]/4+1);
	}
	R_INF.read_length[i] = new_read_length;
	ha_compress_base(Get_READ(R_INF, i), new_read, new_read_length, &R_INF.N_site[i], N_occ);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x50, %rsp
movq %rsi, %rbx
movq %rdi, %r15
movslq %edx, %rax
imulq $0x38, %rax, %r13
leaq (%rdi,%r13), %r14
leaq 0x2464c7(%rip), %rsi    # 0x254230
movq %r14, %rdi
movq %rbx, %rdx
callq 0x715e
movq 0x24651d(%rip), %rax    # 0x254298
imulq $0x28, %rbx, %r12
movl 0x20(%rax,%r12), %ecx
movslq 0x20(%r15,%r13), %rdx
cmpq %rdx, %rcx
jle 0xddae
movslq %ecx, %rsi
movl %esi, 0x20(%r14)
movq 0x28(%r14), %rdi
callq 0x2370
movq %rax, %rcx
movq %rax, 0x28(%r14)
movq 0x2464ec(%rip), %rax    # 0x254298
jmp 0xddb2
movq 0x28(%r14), %rcx
movl 0x8(%rax,%r12), %edx
leaq 0x10(%rsp), %rdi
movq %rdx, 0x18(%rdi)
movl 0x18(%rax,%r12), %edx
movq %rdx, 0x38(%rdi)
movq (%rax,%r12), %rdx
movq %rdx, 0x8(%rdi)
movq 0x10(%rax,%r12), %rax
movq %rax, 0x28(%rdi)
movq (%r14), %rsi
leaq 0xc(%rsp), %r8
callq 0xbb70
movq 0x2464b2(%rip), %rax    # 0x2542a0
movl 0x20(%rax,%r12), %ecx
movslq 0x24(%r14), %rdx
cmpq %rdx, %rcx
jle 0xde1c
movslq %ecx, %rsi
movl %esi, 0x24(%r14)
movq 0x30(%r14), %rdi
callq 0x2370
movq %rax, %rcx
movq %rax, 0x30(%r14)
movq 0x246486(%rip), %rax    # 0x2542a0
jmp 0xde20
movq 0x30(%r14), %rcx
movl 0x8(%rax,%r12), %edx
leaq 0x10(%rsp), %rdi
movq %rdx, 0x18(%rdi)
movl 0x18(%rax,%r12), %edx
movq %rdx, 0x38(%rdi)
movq (%rax,%r12), %rdx
movq %rdx, 0x8(%rdi)
movq 0x10(%rax,%r12), %rax
movq %rax, 0x28(%rdi)
movq 0x28(%r14), %rsi
leaq 0x8(%rsp), %r15
movq %r15, %r8
callq 0xbb70
movq 0x30(%r14), %r14
movslq (%r15), %r15
leaq 0x2458f1(%rip), %rcx    # 0x253758
movl 0xf8(%rcx), %eax
leal -0x1(%rax), %edx
cmpl %edx, 0x108(%rcx)
jne 0xde7c
testb $0x1, %al
jne 0xde87
movq %r14, %rdi
movq %r15, %rsi
callq 0x7964
xorl %eax, %eax
testq %r15, %r15
movl $0x0, %ecx
cmovgq %r15, %rcx
leaq 0x245794(%rip), %rdx    # 0x253630
xorl %r12d, %r12d
cmpq %rax, %rcx
je 0xdeb6
movzbl (%r14,%rax), %esi
cmpb $0x4, (%rdx,%rsi)
sbbq $-0x1, %r12
incq %rax
jmp 0xde9f
movq 0x246393(%rip), %rax    # 0x254250
cmpq %r15, (%rax,%rbx,8)
jge 0xdeec
movq %r15, (%rax,%rbx,8)
movq 0x246372(%rip), %rax    # 0x254240
movq (%rax,%rbx,8), %rdi
movq %r15, %rsi
shrq $0x2, %rsi
incq %rsi
callq 0x2370
movq 0x246358(%rip), %rcx    # 0x254240
movq %rax, (%rcx,%rbx,8)
movq 0x246355(%rip), %rax    # 0x254248
leaq (,%rbx,8), %rcx
movq %r15, (%rax,%rbx,8)
movq 0x24633a(%rip), %rax    # 0x254240
movq (%rax,%rbx,8), %rdi
addq 0x24631f(%rip), %rcx    # 0x254230
movq %r14, %rsi
movq %r15, %rdx
movq %r12, %r8
addq $0x50, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x733a