// File: chhylp123[P]hifiasm/ecovlp.cpp
// Function: worker_hap_dc_ec_chemical_r(void*, long, int)
static void worker_hap_dc_ec_chemical_r(void *data, long i, int tid)
{
    ec_ovec_buf_t0 *b = &(((ec_ovec_buf_t*)data)->a[tid]);
    ma_hit_t_alloc *paf = &(R_INF.paf[i]); uint64_t k, m;

    // if (memcmp("3ed80bc4-1169-4948-a9ff-9c2463b7f7a2", Get_NAME((R_INF), i), Get_NAME_LENGTH((R_INF),i)) == 0) {
    //     fprintf(stderr, "-a-[M::%s-beg] rid->%ld, b->rr->%lu\n", __func__, i, b->rr);
    // } 
    if(b->cnt[1] == 0) {
        // if(i == 6204620) prt_dbg_rid_paf(&(R_INF.paf[i]), &(b->self_read), &(b->v8q));
        // if(is_chemical_r(&(R_INF.paf[i]), &b->v64, Get_READ_LENGTH((R_INF), i), 3, 16)) {
        if(is_chemical_r_adv(&(R_INF.paf[i]), &b->v64, Get_READ_LENGTH((R_INF), i), asm_opt.chemical_cov, asm_opt.chemical_flank, 0.02, 0)) {
            // fprintf(stderr, "-um-[M::%s]\tqn::%u::%.*s\n\n", __func__, (uint32_t)(i), (int)Get_NAME_LENGTH(R_INF, i), Get_NAME((R_INF), i));
            R_INF.paf[i].length = 0; b->cnt[0]++;
        } 
    } else if(b->cnt[1] == 1) {
        for (k = 0; k < paf->length; k++) {
            if(R_INF.paf[paf->buffer[k].tn].length == 0) {
                paf->buffer[k].tn = (uint32_t)-1; b->cnt[0]++;
            }
        }
    } else {
        for (k = m = 0; k < paf->length; k++) {
            if(paf->buffer[k].tn == ((uint32_t)-1)) continue;
            paf->buffer[m++] = paf->buffer[k];
        }
        paf->length = m;
    }

   refresh_ec_ovec_buf_t0(b, REFRESH_N);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movslq -0x14(%rbp), %rcx
imulq $0x5c0, %rcx, %rcx      # imm = 0x5C0
addq %rcx, %rax
movq %rax, -0x20(%rbp)
leaq 0x15a13d(%rip), %rax    # 0x3c52d0
movq 0x78(%rax), %rax
imulq $0x18, -0x10(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rax
cmpq $0x0, 0xc8(%rax)
jne 0x26b24e
leaq 0x15a114(%rip), %rax    # 0x3c52d0
movq 0x78(%rax), %rdi
imulq $0x18, -0x10(%rbp), %rax
addq %rax, %rdi
movq -0x20(%rbp), %rsi
addq $0x4d0, %rsi            # imm = 0x4D0
leaq 0x15a0f6(%rip), %rax    # 0x3c52d0
movq 0x18(%rax), %rax
movq -0x10(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
leaq 0x15960b(%rip), %rax    # 0x3c47f8
movq 0x2b8(%rax), %rcx
leaq 0x1595fd(%rip), %rax    # 0x3c47f8
movq 0x2c0(%rax), %r8
movsd 0x113e3e(%rip), %xmm0   # 0x37f048
xorl %eax, %eax
movl %eax, %r9d
callq 0x25b6e0
cmpl $0x0, %eax
je 0x26b249
leaq 0x15a0b0(%rip), %rax    # 0x3c52d0
movq 0x78(%rax), %rax
imulq $0x18, -0x10(%rbp), %rcx
addq %rcx, %rax
movl $0x0, 0xc(%rax)
movq -0x20(%rbp), %rax
movq 0xc0(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0xc0(%rax)
jmp 0x26b36d
movq -0x20(%rbp), %rax
cmpq $0x1, 0xc8(%rax)
jne 0x26b2e3
movq $0x0, -0x30(%rbp)
movq -0x30(%rbp), %rax
movq -0x28(%rbp), %rcx
movl 0xc(%rcx), %ecx
cmpq %rcx, %rax
jae 0x26b2de
leaq 0x15a051(%rip), %rax    # 0x3c52d0
movq 0x78(%rax), %rax
movq -0x28(%rbp), %rcx
movq (%rcx), %rcx
imulq $0x28, -0x30(%rbp), %rdx
addq %rdx, %rcx
movl 0xc(%rcx), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
cmpl $0x0, 0xc(%rax)
jne 0x26b2ce
movq -0x28(%rbp), %rax
movq (%rax), %rax
imulq $0x28, -0x30(%rbp), %rcx
addq %rcx, %rax
movl $0xffffffff, 0xc(%rax)  # imm = 0xFFFFFFFF
movq -0x20(%rbp), %rax
movq 0xc0(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0xc0(%rax)
jmp 0x26b2d0
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0x26b268
jmp 0x26b36b
movq $0x0, -0x38(%rbp)
movq $0x0, -0x30(%rbp)
movq -0x30(%rbp), %rax
movq -0x28(%rbp), %rcx
movl 0xc(%rcx), %ecx
cmpq %rcx, %rax
jae 0x26b35e
movq -0x28(%rbp), %rax
movq (%rax), %rax
imulq $0x28, -0x30(%rbp), %rcx
addq %rcx, %rax
cmpl $-0x1, 0xc(%rax)
jne 0x26b31a
jmp 0x26b350
movq -0x28(%rbp), %rax
movq (%rax), %rsi
imulq $0x28, -0x30(%rbp), %rax
addq %rax, %rsi
movq -0x28(%rbp), %rax
movq (%rax), %rdi
movq -0x38(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x38(%rbp)
imulq $0x28, %rax, %rax
addq %rax, %rdi
movl $0x28, %edx
callq 0x2180
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0x26b2f3
movq -0x38(%rbp), %rax
movl %eax, %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0xc(%rax)
jmp 0x26b36d
movq -0x20(%rbp), %rdi
movl $0x80, %esi
callq 0x26e2d0
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)