// File: 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 %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq -0x8(%rbp), %rax
movslq -0x14(%rbp), %rcx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rdi
movq -0x10(%rbp), %rdx
leaq 0x3addf8(%rip), %rsi    # 0x3c52d0
callq 0xa380
movq 0x3ade54(%rip), %rax    # 0x3c5338
imulq $0x28, -0x10(%rbp), %rcx
addq %rcx, %rax
movl 0x20(%rax), %eax
movq -0x20(%rbp), %rcx
movslq 0x20(%rcx), %rcx
cmpq %rcx, %rax
jle 0x17539
movq 0x3ade35(%rip), %rax    # 0x3c5338
imulq $0x28, -0x10(%rbp), %rcx
addq %rcx, %rax
movl 0x20(%rax), %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x20(%rax)
movq -0x20(%rbp), %rax
movq 0x28(%rax), %rdi
movq -0x20(%rbp), %rax
movslq 0x20(%rax), %rsi
shlq $0x0, %rsi
callq 0x2360
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x28(%rax)
movq 0x3addf8(%rip), %rax    # 0x3c5338
imulq $0x28, -0x10(%rbp), %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movq %rax, -0x48(%rbp)
movq 0x3adde2(%rip), %rax    # 0x3c5338
imulq $0x28, -0x10(%rbp), %rcx
addq %rcx, %rax
movl 0x18(%rax), %eax
movq %rax, -0x28(%rbp)
movq 0x3addcc(%rip), %rax    # 0x3c5338
imulq $0x28, -0x10(%rbp), %rcx
addq %rcx, %rax
movq (%rax), %rax
movq %rax, -0x58(%rbp)
movq 0x3addb6(%rip), %rax    # 0x3c5338
imulq $0x28, -0x10(%rbp), %rcx
addq %rcx, %rax
movq 0x10(%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x20(%rbp), %rax
movq (%rax), %rsi
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
movl %eax, %edx
movq -0x20(%rbp), %rax
movq 0x28(%rax), %rcx
leaq -0x60(%rbp), %rdi
leaq -0x64(%rbp), %r8
callq 0x13cf0
movq 0x3add81(%rip), %rax    # 0x3c5340
imulq $0x28, -0x10(%rbp), %rcx
addq %rcx, %rax
movl 0x20(%rax), %eax
movq -0x20(%rbp), %rcx
movslq 0x24(%rcx), %rcx
cmpq %rcx, %rax
jle 0x17614
movq 0x3add62(%rip), %rax    # 0x3c5340
imulq $0x28, -0x10(%rbp), %rcx
addq %rcx, %rax
movl 0x20(%rax), %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x24(%rax)
movq -0x20(%rbp), %rax
movq 0x30(%rax), %rdi
movq -0x20(%rbp), %rax
movslq 0x24(%rax), %rsi
shlq $0x0, %rsi
callq 0x2360
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x30(%rax)
movq 0x3add25(%rip), %rax    # 0x3c5340
imulq $0x28, -0x10(%rbp), %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movq %rax, -0x48(%rbp)
movq 0x3add0f(%rip), %rax    # 0x3c5340
imulq $0x28, -0x10(%rbp), %rcx
addq %rcx, %rax
movl 0x18(%rax), %eax
movq %rax, -0x28(%rbp)
movq 0x3adcf9(%rip), %rax    # 0x3c5340
imulq $0x28, -0x10(%rbp), %rcx
addq %rcx, %rax
movq (%rax), %rax
movq %rax, -0x58(%rbp)
movq 0x3adce3(%rip), %rax    # 0x3c5340
imulq $0x28, -0x10(%rbp), %rcx
addq %rcx, %rax
movq 0x10(%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x20(%rbp), %rax
movq 0x28(%rax), %rsi
movl -0x64(%rbp), %edx
movq -0x20(%rbp), %rax
movq 0x30(%rax), %rcx
leaq -0x60(%rbp), %rdi
leaq -0x68(%rbp), %r8
callq 0x13cf0
movq -0x20(%rbp), %rax
movq 0x30(%rax), %rax
movq %rax, -0x78(%rbp)
movl -0x68(%rbp), %eax
movl %eax, -0x7c(%rbp)
leaq 0x3ad152(%rip), %rax    # 0x3c47f8
movl 0x108(%rax), %eax
leaq 0x3ad145(%rip), %rcx    # 0x3c47f8
movl 0xf8(%rcx), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
je 0x176cf
movq -0x78(%rbp), %rdi
movslq -0x7c(%rbp), %rsi
callq 0xb4c0
jmp 0x176f8
leaq 0x3ad122(%rip), %rax    # 0x3c47f8
movl 0xf8(%rax), %eax
movl $0x2, %ecx
cltd
idivl %ecx
cmpl $0x0, %edx
jne 0x176f6
movq -0x78(%rbp), %rdi
movslq -0x7c(%rbp), %rsi
callq 0xb4c0
jmp 0x176f8
movq -0x78(%rbp), %rdi
movslq -0x7c(%rbp), %rsi
callq 0x1bee0
movq %rax, -0x70(%rbp)
movq 0x3adbe0(%rip), %rax    # 0x3c52f0
movq -0x10(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x7c(%rbp), %rcx
cmpq %rcx, %rax
jge 0x17775
movslq -0x7c(%rbp), %rdx
movq 0x3adbc4(%rip), %rax    # 0x3c52f0
movq -0x10(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movq 0x3adba5(%rip), %rax    # 0x3c52e0
movq -0x10(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
movq 0x3adba6(%rip), %rax    # 0x3c52f0
movq -0x10(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
shrq $0x2, %rsi
addq $0x1, %rsi
shlq $0x0, %rsi
callq 0x2360
movq %rax, %rdx
movq 0x3adb73(%rip), %rax    # 0x3c52e0
movq -0x10(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movslq -0x7c(%rbp), %rdx
movq 0x3adb68(%rip), %rax    # 0x3c52e8
movq -0x10(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movq 0x3adb51(%rip), %rax    # 0x3c52e0
movq -0x10(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
movq -0x78(%rbp), %rsi
movslq -0x7c(%rbp), %rdx
movq 0x3adb2a(%rip), %rcx    # 0x3c52d0
movq -0x10(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rcx
movq -0x70(%rbp), %r8
callq 0xa710
addq $0x80, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)