// File: chhylp123[P]hifiasm/inter.cpp
// Function: worker_for_trans_ovlp_adv(void*, long, int)
static void worker_for_trans_ovlp_adv(void *data, long i, int tid) // callback for kt_for()
{
    ug_trans_t *s = (ug_trans_t*)data;
    ha_ovec_buf_t *b = s->hab[tid]; kv_ul_ov_t *bl = &(s->ll[tid].tk);
	uint32_t high_occ = asm_opt.polyploidy + 1; uint64_t cnt;
	char *seq = s->ug->u.a[i].s; int64_t len = s->ug->u.a[i].len;
	if((!s->is_ovlp) && (s->is_cnt)) s->idx_n.a[i] = 0;
	if(IF_HOM(i, (*(s->bub))) || s->ug->g->seq[i].del) return;

	// asprintf(&as, "\n[M::%s] rid::%ld, len::%lu, name::%.*s\n", __func__, s->id+i, s->len[i], (int32_t)UL_INF.nid.a[s->id+i].n, UL_INF.nid.a[s->id+i].a);
    // push_vlog(&(overall_zdbg->a[s->id+i]), as); free(as); as = NULL;

	if(!s->is_ovlp) {
		if(s->is_cnt) {
			s->idx_n.a[i] = ug_map_lchain(b->abl, i, seq, len, s->w, s->k, &(s->udb), NULL, NULL, s->bw_thres, s->bw_thres_double,
            	s->max_n_chain, 1, NULL, &(b->tmp_region), NULL, &(b->sp), &high_occ, NULL, 0, 1, 0.2, 3, s->is_HPC, NULL, 0, NULL, 0, s->mini_cut, s->chain_cut, NULL);
		} else {
			cnt = ug_map_lchain(b->abl, i, seq, len, s->w, s->k, &(s->udb), NULL, NULL, s->bw_thres, s->bw_thres_double,
				s->max_n_chain, 1, NULL, &(b->tmp_region), NULL, &(b->sp), &high_occ, NULL, 0, 1, 0.2, 3, s->is_HPC, s->idx_a.a + s->idx_n.a[i], 0, NULL, 0, s->mini_cut, s->chain_cut, NULL);
			assert(cnt == ((s->idx_n.a[i+1]-s->idx_n.a[i])));
		}
		if(s->free_cnt[tid] >= FREE_BATCH) {
            clear_count_buf(s, tid, 1); s->free_cnt[tid] = 0;
        }
		s->free_cnt[tid]++;
		return;
	} 

	// if(i == 160) {
	// 	fprintf(stderr, "\n-1-[M::%s] utg%.6u%c, rid::%ld, is_ovlp::%d, is_cnt::%d, len::%ld, str::%u\n", 
	// 		__func__, (uint32_t)i+1, "lc"[s->ug->u.a[i].circ], i, s->is_ovlp, s->is_cnt, len, (uint32_t)(!!seq));
	// }

	if(!gen_trans_adaptive_aln(s, i, b, bl, seq, len, s->filter, s->diff_ec_ul, s->diff_ec_ul_double, s->bw_thres, s->bw_thres_double)) {
		gen_trans_adaptive_aln(s, i, b, bl, seq, len, NULL, s->diff_ec_ul_double, s->diff_ec_ul_double, s->bw_thres_double, s->bw_thres_double);
	}

	if(s->free_cnt[tid] >= FREE_BATCH) {
        clear_count_buf(s, tid, 0); s->free_cnt[tid] = 0;
    }
    s->free_cnt[tid]++;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x118, %rsp            # imm = 0x118
movq %rdi, -0x30(%rbp)
movq %rsi, -0x38(%rbp)
movl %edx, -0x3c(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
movq 0x18(%rax), %rax
movslq -0x3c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x50(%rbp)
movq -0x48(%rbp), %rax
movq 0x20(%rax), %rax
movslq -0x3c(%rbp), %rcx
imulq $0x68, %rcx, %rcx
addq %rcx, %rax
addq $0x18, %rax
movq %rax, -0x58(%rbp)
leaq 0xc03fb(%rip), %rax     # 0x3c47f8
movl 0x1bc(%rax), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
movq -0x48(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x10(%rax), %rax
imulq $0x28, -0x38(%rbp), %rcx
addq %rcx, %rax
movq 0x20(%rax), %rax
movq %rax, -0x70(%rbp)
movq -0x48(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x10(%rax), %rax
imulq $0x28, -0x38(%rbp), %rcx
addq %rcx, %rax
movl (%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl %eax, %eax
movq %rax, -0x78(%rbp)
movq -0x48(%rbp), %rax
cmpl $0x0, 0xb8(%rax)
jne 0x304477
movq -0x48(%rbp), %rax
cmpl $0x0, 0xb4(%rax)
je 0x304477
movq -0x48(%rbp), %rax
movq 0x88(%rax), %rax
movq -0x38(%rbp), %rcx
movq $0x0, (%rax,%rcx,8)
movq -0x48(%rbp), %rax
movq 0x28(%rax), %rax
movq (%rax), %rax
movq -0x38(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movq -0x48(%rbp), %rcx
movq 0x28(%rcx), %rcx
movq 0x80(%rcx), %rcx
addq $0x1, %rcx
cmpq %rcx, %rax
ja 0x3044c0
movq -0x48(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x18(%rax), %rax
movq 0x20(%rax), %rax
movq -0x38(%rbp), %rcx
movl (%rax,%rcx,8), %eax
shrl $0x1f, %eax
cmpl $0x0, %eax
je 0x3044c5
jmp 0x30497e
movq -0x48(%rbp), %rax
cmpl $0x0, 0xb8(%rax)
jne 0x304888
movq -0x48(%rbp), %rax
cmpl $0x0, 0xb4(%rax)
je 0x304657
movq -0x50(%rbp), %rax
movq 0xe8(%rax), %rdi
movq -0x38(%rbp), %rax
movl %eax, %esi
movq -0x70(%rbp), %rdx
movq -0x78(%rbp), %rcx
movq -0x48(%rbp), %rax
movslq 0x30(%rax), %r8
movq -0x48(%rbp), %rax
movslq 0x34(%rax), %r9
movq -0x48(%rbp), %r13
addq $0xc8, %r13
movq -0x48(%rbp), %rax
movsd 0x38(%rax), %xmm0
movq -0x48(%rbp), %rax
movsd 0x50(%rax), %xmm1
movq -0x48(%rbp), %rax
movl 0x60(%rax), %r12d
movq -0x50(%rbp), %r15
addq $0x121a0, %r15          # imm = 0x121A0
movq -0x50(%rbp), %r14
addq $0x12250, %r14          # imm = 0x12250
movq -0x48(%rbp), %rax
movl 0xa0(%rax), %r11d
movq -0x48(%rbp), %rax
movslq 0xbc(%rax), %r10
movq -0x48(%rbp), %rax
movslq 0xc0(%rax), %rax
movq %rax, -0x80(%rbp)
xorl %eax, %eax
leaq -0x5c(%rbp), %rbx
xorl %eax, %eax
movq -0x80(%rbp), %rax
movsd 0x7aa8c(%rip), %xmm2    # 0x37f010
movq %r13, (%rsp)
movq $0x0, 0x8(%rsp)
movq $0x0, 0x10(%rsp)
movl %r12d, 0x18(%rsp)
movl $0x1, 0x20(%rsp)
movq $0x0, 0x28(%rsp)
movq %r15, 0x30(%rsp)
movq $0x0, 0x38(%rsp)
movq %r14, 0x40(%rsp)
movq %rbx, 0x48(%rsp)
movq $0x0, 0x50(%rsp)
movl $0x0, 0x58(%rsp)
movl $0x1, 0x60(%rsp)
movl $0x3, 0x68(%rsp)
movl %r11d, 0x70(%rsp)
movq $0x0, 0x78(%rsp)
movq $0x0, 0x80(%rsp)
movq $0x0, 0x88(%rsp)
movq $0x0, 0x90(%rsp)
movq %r10, 0x98(%rsp)
movq %rax, 0xa0(%rsp)
movq $0x0, 0xa8(%rsp)
callq 0x1b3e60
movq %rax, %rdx
movq -0x48(%rbp), %rax
movq 0x88(%rax), %rax
movq -0x38(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
jmp 0x30482f
movq -0x50(%rbp), %rax
movq 0xe8(%rax), %rdi
movq -0x38(%rbp), %rax
movl %eax, %esi
movq -0x70(%rbp), %rdx
movq -0x78(%rbp), %rcx
movq -0x48(%rbp), %rax
movslq 0x30(%rax), %r8
movq -0x48(%rbp), %rax
movslq 0x34(%rax), %r9
movq -0x48(%rbp), %rax
addq $0xc8, %rax
movq %rax, -0x90(%rbp)
movq -0x48(%rbp), %rax
movsd 0x38(%rax), %xmm0
movq -0x48(%rbp), %rax
movsd 0x50(%rax), %xmm1
movq -0x48(%rbp), %rax
movl 0x60(%rax), %r13d
movq -0x50(%rbp), %r12
addq $0x121a0, %r12          # imm = 0x121A0
movq -0x50(%rbp), %r15
addq $0x12250, %r15          # imm = 0x12250
movq -0x48(%rbp), %rax
movl 0xa0(%rax), %ebx
movq -0x48(%rbp), %rax
movq 0x70(%rax), %r11
movq -0x48(%rbp), %rax
movq 0x88(%rax), %rax
movq -0x38(%rbp), %r10
imulq $0x18, (%rax,%r10,8), %rax
addq %rax, %r11
movq -0x48(%rbp), %rax
movslq 0xbc(%rax), %r10
movq -0x48(%rbp), %rax
movslq 0xc0(%rax), %rax
movq %rax, -0x88(%rbp)
xorl %eax, %eax
leaq -0x5c(%rbp), %r14
xorl %eax, %eax
movq -0x90(%rbp), %rax
movsd 0x7a8f2(%rip), %xmm2    # 0x37f010
movq %rax, (%rsp)
movq -0x88(%rbp), %rax
movq $0x0, 0x8(%rsp)
movq $0x0, 0x10(%rsp)
movl %r13d, 0x18(%rsp)
movl $0x1, 0x20(%rsp)
movq $0x0, 0x28(%rsp)
movq %r12, 0x30(%rsp)
movq $0x0, 0x38(%rsp)
movq %r15, 0x40(%rsp)
movq %r14, 0x48(%rsp)
movq $0x0, 0x50(%rsp)
movl $0x0, 0x58(%rsp)
movl $0x1, 0x60(%rsp)
movl $0x3, 0x68(%rsp)
movl %ebx, 0x70(%rsp)
movq %r11, 0x78(%rsp)
movq $0x0, 0x80(%rsp)
movq $0x0, 0x88(%rsp)
movq $0x0, 0x90(%rsp)
movq %r10, 0x98(%rsp)
movq %rax, 0xa0(%rsp)
movq $0x0, 0xa8(%rsp)
callq 0x1b3e60
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rax
movq -0x48(%rbp), %rcx
movq 0x88(%rcx), %rcx
movq -0x38(%rbp), %rdx
movq 0x8(%rcx,%rdx,8), %rcx
movq -0x48(%rbp), %rdx
movq 0x88(%rdx), %rdx
movq -0x38(%rbp), %rsi
subq (%rdx,%rsi,8), %rcx
cmpq %rcx, %rax
jne 0x30480e
jmp 0x30482d
leaq 0x9164d(%rip), %rdi     # 0x395e62
leaq 0x8c013(%rip), %rsi     # 0x39082f
movl $0x28a2, %edx           # imm = 0x28A2
leaq 0x916c4(%rip), %rcx     # 0x395eec
callq 0x2130
jmp 0x30482f
movq -0x48(%rbp), %rax
movq 0x100(%rax), %rax
movslq -0x3c(%rbp), %rcx
cmpl $0x10, (%rax,%rcx,4)
jb 0x30486b
movq -0x48(%rbp), %rdi
movl -0x3c(%rbp), %esi
movl $0x1, %edx
callq 0x2c0ad0
movq -0x48(%rbp), %rax
movq 0x100(%rax), %rax
movslq -0x3c(%rbp), %rcx
movl $0x0, (%rax,%rcx,4)
movq -0x48(%rbp), %rax
movq 0x100(%rax), %rax
movslq -0x3c(%rbp), %rcx
movl (%rax,%rcx,4), %edx
addl $0x1, %edx
movl %edx, (%rax,%rcx,4)
jmp 0x30497e
movq -0x48(%rbp), %rdi
movq -0x38(%rbp), %rsi
movq -0x50(%rbp), %rdx
movq -0x58(%rbp), %rcx
movq -0x70(%rbp), %r8
movq -0x78(%rbp), %r9
movq -0x48(%rbp), %rax
movq 0xf8(%rax), %rax
movq -0x48(%rbp), %r10
movsd 0x40(%r10), %xmm0
movq -0x48(%rbp), %r10
movsd 0x58(%r10), %xmm1
movq -0x48(%rbp), %r10
movsd 0x38(%r10), %xmm2
movq -0x48(%rbp), %r10
movsd 0x50(%r10), %xmm3
movq %rax, (%rsp)
callq 0x2c0400
cmpq $0x0, %rax
jne 0x30492d
movq -0x48(%rbp), %rdi
movq -0x38(%rbp), %rsi
movq -0x50(%rbp), %rdx
movq -0x58(%rbp), %rcx
movq -0x70(%rbp), %r8
movq -0x78(%rbp), %r9
movq -0x48(%rbp), %rax
movsd 0x58(%rax), %xmm0
movq -0x48(%rbp), %rax
movsd 0x58(%rax), %xmm1
movq -0x48(%rbp), %rax
movsd 0x50(%rax), %xmm2
movq -0x48(%rbp), %rax
movsd 0x50(%rax), %xmm3
xorl %eax, %eax
movq $0x0, (%rsp)
callq 0x2c0400
movq -0x48(%rbp), %rax
movq 0x100(%rax), %rax
movslq -0x3c(%rbp), %rcx
cmpl $0x10, (%rax,%rcx,4)
jb 0x304966
movq -0x48(%rbp), %rdi
movl -0x3c(%rbp), %esi
xorl %edx, %edx
callq 0x2c0ad0
movq -0x48(%rbp), %rax
movq 0x100(%rax), %rax
movslq -0x3c(%rbp), %rcx
movl $0x0, (%rax,%rcx,4)
movq -0x48(%rbp), %rax
movq 0x100(%rax), %rax
movslq -0x3c(%rbp), %rcx
movl (%rax,%rcx,4), %edx
addl $0x1, %edx
movl %edx, (%rax,%rcx,4)
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq