// File: /workspace/github_cpp_makefile_star2_O1/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 0x250198(%rip), %rsi    # 0x28b230
movq %r15, %rdi
movq %rbx, %rdx
callq 0x33cf8
movq 0x2501ee(%rip), %rax    # 0x28b298
leaq (%rbx,%rbx,4), %r12
movl 0x20(%rax,%r12,8), %eax
movslq 0x20(%r14,%r13), %rcx
cmpq %rcx, %rax
jle 0x3b0d1
movslq %eax, %rsi
movl %esi, 0x20(%r15)
movq 0x28(%r15), %rdi
callq 0x2370
movq %rax, 0x28(%r15)
movq 0x2501c0(%rip), %rax    # 0x28b298
leaq (,%rbx,8), %r14
leaq (%r14,%r14,4), %r13
movl 0x8(%rax,%r13), %ecx
leaq 0x10(%rsp), %rdi
movq %rcx, 0x18(%rdi)
movl 0x18(%rax,%r13), %ecx
movq %rcx, 0x38(%rdi)
movq (%rax,%r13), %rcx
movq %rcx, 0x8(%rdi)
movq 0x10(%rax,%r13), %rax
movq %rax, 0x28(%rdi)
movq (%r15), %rsi
movq 0x28(%r15), %rcx
leaq 0xc(%rsp), %r8
callq 0x388dc
movq 0x25017c(%rip), %rax    # 0x28b2a0
movl 0x20(%rax,%r13), %eax
movslq 0x24(%r15), %rcx
cmpq %rcx, %rax
jle 0x3b146
movslq %eax, %rsi
movl %esi, 0x24(%r15)
movq 0x30(%r15), %rdi
callq 0x2370
movq %rax, 0x30(%r15)
movq 0x250153(%rip), %rax    # 0x28b2a0
movl 0x8(%rax,%r12,8), %ecx
leaq 0x10(%rsp), %rdi
movq %rcx, 0x18(%rdi)
movl 0x18(%rax,%r12,8), %ecx
movq %rcx, 0x38(%rdi)
movq (%rax,%r12,8), %rcx
movq %rcx, 0x8(%rdi)
movq 0x10(%rax,%r12,8), %rax
movq %rax, 0x28(%rdi)
movq 0x28(%r15), %rsi
movq 0x30(%r15), %rcx
leaq 0x8(%rsp), %r12
movq %r12, %r8
callq 0x388dc
movq 0x30(%r15), %r15
movslq (%r12), %r12
leaq 0x24f5bf(%rip), %rax    # 0x28a758
movl 0xf8(%rax), %ecx
leal -0x1(%rcx), %edx
cmpl %edx, 0x108(%rax)
sete %al
testb %cl, %al
jne 0x3b1ba
movq %r15, %rdi
movq %r12, %rsi
callq 0x345cf
xorl %r13d, %r13d
testl %r12d, %r12d
jle 0x3b1e0
leaq 0x24f467(%rip), %rax    # 0x28a630
xorl %ecx, %ecx
movzbl (%r15,%rcx), %edx
cmpb $0x4, (%rax,%rdx)
sbbq $-0x1, %r13
incq %rcx
cmpq %rcx, %r12
jne 0x3b1cb
movq 0x250069(%rip), %rax    # 0x28b250
cmpq %r12, (%rax,%rbx,8)
jge 0x3b216
movq %r12, (%rax,%rbx,8)
movq 0x250048(%rip), %rax    # 0x28b240
movq (%rax,%rbx,8), %rdi
movq %r12, %rsi
shrq $0x2, %rsi
incq %rsi
callq 0x2370
movq 0x25002e(%rip), %rcx    # 0x28b240
movq %rax, (%rcx,%rbx,8)
movq 0x25002b(%rip), %rax    # 0x28b248
movq %r12, (%rax,%rbx,8)
movq 0x250018(%rip), %rax    # 0x28b240
movq (%rax,%rbx,8), %rdi
addq 0x24fffd(%rip), %r14    # 0x28b230
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 0x33ef7