// File: /workspace/github_cpp_makefile_star2_O3/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, %r14
movslq %edx, %rax
imulq $0x38, %rax, %r13
leaq (%rdi,%r13), %r15
leaq 0x25bbe7(%rip), %rsi    # 0x296230
movq %r15, %rdi
movq %rbx, %rdx
callq 0x333e0
movq 0x25bc3d(%rip), %rax    # 0x296298
leaq (%rbx,%rbx,4), %r12
movl 0x20(%rax,%r12,8), %ecx
movslq 0x20(%r14,%r13), %rdx
cmpq %rdx, %rcx
jle 0x3a68e
movslq %ecx, %rsi
movl %esi, 0x20(%r15)
movq 0x28(%r15), %rdi
callq 0x2370
movq %rax, %rcx
movq %rax, 0x28(%r15)
movq 0x25bc0c(%rip), %rax    # 0x296298
jmp 0x3a692
movq 0x28(%r15), %rcx
leaq (,%rbx,8), %r14
leaq (%r14,%r14,4), %r13
movl 0x8(%rax,%r13), %edx
leaq 0x10(%rsp), %rdi
movq %rdx, 0x18(%rdi)
movl 0x18(%rax,%r13), %edx
movq %rdx, 0x38(%rdi)
movq (%rax,%r13), %rdx
movq %rdx, 0x8(%rdi)
movq 0x10(%rax,%r13), %rax
movq %rax, 0x28(%rdi)
movq (%r15), %rsi
leaq 0xc(%rsp), %r8
callq 0x37e9c
movq 0x25bbc6(%rip), %rax    # 0x2962a0
movl 0x20(%rax,%r13), %ecx
movslq 0x24(%r15), %rdx
cmpq %rdx, %rcx
jle 0x3a708
movslq %ecx, %rsi
movl %esi, 0x24(%r15)
movq 0x30(%r15), %rdi
callq 0x2370
movq %rax, %rcx
movq %rax, 0x30(%r15)
movq 0x25bb9a(%rip), %rax    # 0x2962a0
jmp 0x3a70c
movq 0x30(%r15), %rcx
movl 0x8(%rax,%r12,8), %edx
leaq 0x10(%rsp), %rdi
movq %rdx, 0x18(%rdi)
movl 0x18(%rax,%r12,8), %edx
movq %rdx, 0x38(%rdi)
movq (%rax,%r12,8), %rdx
movq %rdx, 0x8(%rdi)
movq 0x10(%rax,%r12,8), %rax
movq %rax, 0x28(%rdi)
movq 0x28(%r15), %rsi
leaq 0x8(%rsp), %r12
movq %r12, %r8
callq 0x37e9c
movq 0x30(%r15), %r15
movslq (%r12), %r12
leaq 0x25b004(%rip), %rcx    # 0x295758
movl 0xf8(%rcx), %eax
leal -0x1(%rax), %edx
cmpl %edx, 0x108(%rcx)
jne 0x3a769
testb $0x1, %al
jne 0x3a774
movq %r15, %rdi
movq %r12, %rsi
callq 0x33c1d
xorl %r13d, %r13d
testl %r12d, %r12d
jle 0x3a79a
leaq 0x25aead(%rip), %rax    # 0x295630
xorl %ecx, %ecx
movzbl (%r15,%rcx), %edx
cmpb $0x4, (%rax,%rdx)
sbbq $-0x1, %r13
incq %rcx
cmpq %rcx, %r12
jne 0x3a785
movq 0x25baaf(%rip), %rax    # 0x296250
cmpq %r12, (%rax,%rbx,8)
jge 0x3a7d0
movq %r12, (%rax,%rbx,8)
movq 0x25ba8e(%rip), %rax    # 0x296240
movq (%rax,%rbx,8), %rdi
movq %r12, %rsi
shrq $0x2, %rsi
incq %rsi
callq 0x2370
movq 0x25ba74(%rip), %rcx    # 0x296240
movq %rax, (%rcx,%rbx,8)
movq 0x25ba71(%rip), %rax    # 0x296248
movq %r12, (%rax,%rbx,8)
movq 0x25ba5e(%rip), %rax    # 0x296240
movq (%rax,%rbx,8), %rdi
addq 0x25ba43(%rip), %r14    # 0x296230
movq %r15, %rsi
movq %r12, %rdx
movq %r14, %rcx
movq %r13, %r8
addq $0x50, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x335d2