// File: chhylp123[P]hifiasm/ecovlp.cpp
// Function: worker_ov_dbg_pipeline(void*, int, void*)
static void *worker_ov_dbg_pipeline(void *data, int step, void *in) // callback for kt_pipeline()
{
    cal_ec_r_dbg_t *p = (cal_ec_r_dbg_t*)data; char cm[4]; cm[0] = 'M'; cm[1] = 'M'; cm[2] = 'I'; cm[3] = 'D'; 
    // cal_ec_r_dbg_step_t
    if (step == 0) { // step 1: read a block of sequences
        cal_ec_r_dbg_step_t *s; CALLOC(s, 1);
        s->si = p->cn; p->cn += p->chunk_size; 
        if(p->cn > p->n_a) p->cn = p->n_a; s->ei = p->cn;
        if(s->si >= s->ei) free(s);
        else return s;
    } else if (step == 1) { // step 2: alignment
        cal_ec_r_dbg_step_t *s = (cal_ec_r_dbg_step_t*)in;
        s->buf = gen_ec_ovec_buf_t(p->n_thread); CALLOC(s->res, p->n_thread);  
        kt_for(p->n_thread, worker_hap_ec_dbg_paf, s, (s->ei - s->si));
        destroy_ec_ovec_buf_t(s->buf);
        return s;
    } else if (step == 2) { // step 3: dump
        cal_ec_r_dbg_step_t *s = (cal_ec_r_dbg_step_t*)in; uint64_t k, z; bit_extz_t ez; memset(&ez, 0, sizeof(ez));
        // UC_Read qu; UC_Read tu; init_UC_Read(&qu); init_UC_Read(&tu); 
        for (k = 0; k < p->n_thread; k++) {
            for (z = 0; z < s->res[k].n; z++) {
                ez.cigar.a = s->res[k].ec.a + s->res[k].a[z].bl; ez.cigar.n = ez.cigar.m = s->res[k].a[z].cc;

                // UC_Read_resize(qu, (s->res[k].a[z].qe - ((uint32_t)s->res[k].a[z].qns))); 
                // recover_UC_Read_sub_region(qu.seq, ((uint32_t)s->res[k].a[z].qns), (s->res[k].a[z].qe - ((uint32_t)s->res[k].a[z].qns)), 0, &R_INF, (s->res[k].a[z].qns>>32));

                // UC_Read_resize(tu, (s->res[k].a[z].te - s->res[k].a[z].ts));
                // recover_UC_Read_sub_region(tu.seq, s->res[k].a[z].ts, s->res[k].a[z].te - s->res[k].a[z].ts, 0, &R_INF, s->res[k].a[z].tn); 

                print_ov_dbg_paf(p->fp, NULL/**qu.seq**/, Get_NAME(R_INF, (s->res[k].a[z].qns>>32)), Get_NAME_LENGTH(R_INF, (s->res[k].a[z].qns>>32)), 
                            NULL/**tu.seq**/, Get_NAME(R_INF, (s->res[k].a[z].tn)), Get_NAME_LENGTH(R_INF, (s->res[k].a[z].tn)), (uint32_t)s->res[k].a[z].qns, s->res[k].a[z].qe, Get_READ_LENGTH(R_INF, (s->res[k].a[z].qns>>32)), s->res[k].a[z].ts, s->res[k].a[z].te, Get_READ_LENGTH(R_INF, (s->res[k].a[z].tn)), s->res[k].a[z].rev, &ez, cm);
            }
            free(s->res[k].a); free(s->res[k].ec.a);
        }
        free(s->res); free(s); ///destory_UC_Read(&qu); destory_UC_Read(&tu);
    }
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x198, %rsp            # imm = 0x198
movq %rdi, -0x38(%rbp)
movl %esi, -0x3c(%rbp)
movq %rdx, -0x48(%rbp)
movq -0x38(%rbp), %rax
movq %rax, -0x50(%rbp)
movb $0x4d, -0x54(%rbp)
movb $0x4d, -0x53(%rbp)
movb $0x49, -0x52(%rbp)
movb $0x44, -0x51(%rbp)
cmpl $0x0, -0x3c(%rbp)
jne 0x26a2ac
movl $0x1, %edi
movl $0x18, %esi
callq 0x2140
movq %rax, -0x60(%rbp)
movq -0x50(%rbp), %rax
movl 0xc(%rax), %ecx
movq -0x60(%rbp), %rax
movl %ecx, 0x10(%rax)
movq -0x50(%rbp), %rax
movl 0x8(%rax), %ecx
movq -0x50(%rbp), %rax
addl 0xc(%rax), %ecx
movl %ecx, 0xc(%rax)
movq -0x50(%rbp), %rax
movl 0xc(%rax), %eax
movq -0x50(%rbp), %rcx
cmpl 0x4(%rcx), %eax
jbe 0x26a271
movq -0x50(%rbp), %rax
movl 0x4(%rax), %ecx
movq -0x50(%rbp), %rax
movl %ecx, 0xc(%rax)
movq -0x50(%rbp), %rax
movl 0xc(%rax), %ecx
movq -0x60(%rbp), %rax
movl %ecx, 0x14(%rax)
movq -0x60(%rbp), %rax
movl 0x10(%rax), %eax
movq -0x60(%rbp), %rcx
cmpl 0x14(%rcx), %eax
jb 0x26a29a
movq -0x60(%rbp), %rdi
callq 0x2210
jmp 0x26a2a7
movq -0x60(%rbp), %rax
movq %rax, -0x30(%rbp)
jmp 0x26a73e
jmp 0x26a736
cmpl $0x1, -0x3c(%rbp)
jne 0x26a32d
movq -0x48(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x50(%rbp), %rax
movl (%rax), %edi
callq 0x24ac00
movq %rax, %rcx
movq -0x68(%rbp), %rax
movq %rcx, (%rax)
movq -0x50(%rbp), %rax
movl (%rax), %eax
movl %eax, %edi
movl $0x30, %esi
callq 0x2140
movq %rax, %rcx
movq -0x68(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x50(%rbp), %rax
movl (%rax), %edi
movq -0x68(%rbp), %rdx
movq -0x68(%rbp), %rax
movl 0x14(%rax), %eax
movq -0x68(%rbp), %rcx
subl 0x10(%rcx), %eax
movl %eax, %eax
movl %eax, %ecx
leaq 0x1e71(%rip), %rsi      # 0x26c180
callq 0x16d710
movq -0x68(%rbp), %rax
movq (%rax), %rdi
callq 0x24afe0
movq -0x68(%rbp), %rax
movq %rax, -0x30(%rbp)
jmp 0x26a73e
cmpl $0x2, -0x3c(%rbp)
jne 0x26a732
movq -0x48(%rbp), %rax
movq %rax, -0x70(%rbp)
leaq -0x158(%rbp), %rdi
xorl %esi, %esi
movl $0xd8, %edx
callq 0x2100
movq $0x0, -0x78(%rbp)
movq -0x78(%rbp), %rax
movq -0x50(%rbp), %rcx
movl (%rcx), %ecx
cmpq %rcx, %rax
jae 0x26a71c
movq $0x0, -0x80(%rbp)
movq -0x80(%rbp), %rax
movq -0x70(%rbp), %rcx
movq 0x8(%rcx), %rcx
imulq $0x30, -0x78(%rbp), %rdx
addq %rdx, %rcx
cmpq 0x8(%rcx), %rax
jae 0x26a6da
movq -0x70(%rbp), %rax
movq 0x8(%rax), %rax
imulq $0x30, -0x78(%rbp), %rcx
addq %rcx, %rax
movq 0x28(%rax), %rax
movq -0x70(%rbp), %rcx
movq 0x8(%rcx), %rcx
imulq $0x30, -0x78(%rbp), %rdx
addq %rdx, %rcx
movq (%rcx), %rcx
imulq $0x28, -0x80(%rbp), %rdx
addq %rdx, %rcx
movq 0x18(%rcx), %rcx
shrq $0x20, %rcx
andq $0x7fffffff, %rcx       # imm = 0x7FFFFFFF
movslq %ecx, %rcx
shlq %rcx
addq %rcx, %rax
movq %rax, -0xa0(%rbp)
movq -0x70(%rbp), %rax
movq 0x8(%rax), %rax
imulq $0x30, -0x78(%rbp), %rcx
addq %rcx, %rax
movq (%rax), %rax
imulq $0x28, -0x80(%rbp), %rcx
addq %rcx, %rax
movq 0x18(%rax), %rax
andq $0x3fffffff, %rax       # imm = 0x3FFFFFFF
movl %eax, %eax
movq %rax, -0xa8(%rbp)
movq %rax, -0xb0(%rbp)
movq -0x50(%rbp), %rax
movq 0x10(%rax), %rdi
leaq 0x15aeab(%rip), %rax    # 0x3c52d0
movq 0x8(%rax), %rdx
leaq 0x15aea0(%rip), %rax    # 0x3c52d0
movq 0x40(%rax), %rax
movq -0x70(%rbp), %rcx
movq 0x8(%rcx), %rcx
imulq $0x30, -0x78(%rbp), %rsi
addq %rsi, %rcx
movq (%rcx), %rcx
imulq $0x28, -0x80(%rbp), %rsi
addq %rsi, %rcx
movq (%rcx), %rcx
shrq $0x20, %rcx
addq (%rax,%rcx,8), %rdx
leaq 0x15ae6f(%rip), %rax    # 0x3c52d0
movq 0x40(%rax), %rax
movq -0x70(%rbp), %rcx
movq 0x8(%rcx), %rcx
imulq $0x30, -0x78(%rbp), %rsi
addq %rsi, %rcx
movq (%rcx), %rcx
imulq $0x28, -0x80(%rbp), %rsi
addq %rsi, %rcx
movq (%rcx), %rcx
shrq $0x20, %rcx
movq 0x8(%rax,%rcx,8), %rax
leaq 0x15ae3d(%rip), %rcx    # 0x3c52d0
movq 0x40(%rcx), %rcx
movq -0x70(%rbp), %rsi
movq 0x8(%rsi), %rsi
imulq $0x30, -0x78(%rbp), %r8
addq %r8, %rsi
movq (%rsi), %rsi
imulq $0x28, -0x80(%rbp), %r8
addq %r8, %rsi
movq (%rsi), %rsi
shrq $0x20, %rsi
subq (%rcx,%rsi,8), %rax
movl %eax, %ecx
leaq 0x15ae0a(%rip), %rax    # 0x3c52d0
movq 0x8(%rax), %r9
leaq 0x15adff(%rip), %rax    # 0x3c52d0
movq 0x40(%rax), %rax
movq -0x70(%rbp), %rsi
movq 0x8(%rsi), %rsi
imulq $0x30, -0x78(%rbp), %r8
addq %r8, %rsi
movq (%rsi), %rsi
imulq $0x28, -0x80(%rbp), %r8
addq %r8, %rsi
movl 0xc(%rsi), %esi
addq (%rax,%rsi,8), %r9
leaq 0x15add2(%rip), %rax    # 0x3c52d0
movq 0x40(%rax), %rax
movq -0x70(%rbp), %rsi
movq 0x8(%rsi), %rsi
imulq $0x30, -0x78(%rbp), %r8
addq %r8, %rsi
movq (%rsi), %rsi
imulq $0x28, -0x80(%rbp), %r8
addq %r8, %rsi
movl 0xc(%rsi), %esi
addl $0x1, %esi
movl %esi, %esi
movq (%rax,%rsi,8), %rax
leaq 0x15ada0(%rip), %rsi    # 0x3c52d0
movq 0x40(%rsi), %rsi
movq -0x70(%rbp), %r8
movq 0x8(%r8), %r8
imulq $0x30, -0x78(%rbp), %r10
addq %r10, %r8
movq (%r8), %r8
imulq $0x28, -0x80(%rbp), %r10
addq %r10, %r8
movl 0xc(%r8), %r8d
subq (%rsi,%r8,8), %rax
movq -0x70(%rbp), %rsi
movq 0x8(%rsi), %rsi
imulq $0x30, -0x78(%rbp), %r8
addq %r8, %rsi
movq (%rsi), %rsi
imulq $0x28, -0x80(%rbp), %r8
addq %r8, %rsi
movq (%rsi), %rsi
movl %esi, %esi
movq %rsi, -0x168(%rbp)
movq -0x70(%rbp), %rsi
movq 0x8(%rsi), %rsi
imulq $0x30, -0x78(%rbp), %r8
addq %r8, %rsi
movq (%rsi), %rsi
imulq $0x28, -0x80(%rbp), %r8
addq %r8, %rsi
movl 0x8(%rsi), %esi
movl %esi, %r13d
leaq 0x15ad2a(%rip), %rsi    # 0x3c52d0
movq 0x18(%rsi), %rsi
movq -0x70(%rbp), %r8
movq 0x8(%r8), %r8
imulq $0x30, -0x78(%rbp), %r10
addq %r10, %r8
movq (%r8), %r8
imulq $0x28, -0x80(%rbp), %r10
addq %r10, %r8
movq (%r8), %r8
shrq $0x20, %r8
movq (%rsi,%r8,8), %r12
movq -0x70(%rbp), %rsi
movq 0x8(%rsi), %rsi
imulq $0x30, -0x78(%rbp), %r8
addq %r8, %rsi
movq (%rsi), %rsi
imulq $0x28, -0x80(%rbp), %r8
addq %r8, %rsi
movl 0x10(%rsi), %esi
movl %esi, %r15d
movq -0x70(%rbp), %rsi
movq 0x8(%rsi), %rsi
imulq $0x30, -0x78(%rbp), %r8
addq %r8, %rsi
movq (%rsi), %rsi
imulq $0x28, -0x80(%rbp), %r8
addq %r8, %rsi
movl 0x14(%rsi), %esi
movl %esi, %r14d
leaq 0x15acb7(%rip), %rsi    # 0x3c52d0
movq 0x18(%rsi), %rsi
movq -0x70(%rbp), %r8
movq 0x8(%r8), %r8
imulq $0x30, -0x78(%rbp), %r10
addq %r10, %r8
movq (%r8), %r8
imulq $0x28, -0x80(%rbp), %r10
addq %r10, %r8
movl 0xc(%r8), %r8d
movq (%rsi,%r8,8), %rbx
movq -0x70(%rbp), %rsi
movq 0x8(%rsi), %rsi
imulq $0x30, -0x78(%rbp), %r8
addq %r8, %rsi
movq (%rsi), %rsi
imulq $0x28, -0x80(%rbp), %r8
addq %r8, %rsi
movq 0x18(%rsi), %rsi
shrq $0x1f, %rsi
andq $0x1, %rsi
movl %esi, %esi
movl %esi, %r11d
leaq -0x54(%rbp), %rsi
movq %rsi, -0x160(%rbp)
xorl %esi, %esi
movl %esi, %r8d
leaq -0x158(%rbp), %r10
movq %r8, %rsi
movl %eax, (%rsp)
movq -0x168(%rbp), %rax
movq %rax, 0x8(%rsp)
movq -0x160(%rbp), %rax
movq %r13, 0x10(%rsp)
movq %r12, 0x18(%rsp)
movq %r15, 0x20(%rsp)
movq %r14, 0x28(%rsp)
movq %rbx, 0x30(%rsp)
movq %r11, 0x38(%rsp)
movq %r10, 0x40(%rsp)
movq %rax, 0x48(%rsp)
callq 0x269fc0
movq -0x80(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x80(%rbp)
jmp 0x26a375
movq -0x70(%rbp), %rax
movq 0x8(%rax), %rax
imulq $0x30, -0x78(%rbp), %rcx
addq %rcx, %rax
movq (%rax), %rdi
callq 0x2210
movq -0x70(%rbp), %rax
movq 0x8(%rax), %rax
imulq $0x30, -0x78(%rbp), %rcx
addq %rcx, %rax
movq 0x28(%rax), %rdi
callq 0x2210
movq -0x78(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x78(%rbp)
jmp 0x26a35a
movq -0x70(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x2210
movq -0x70(%rbp), %rdi
callq 0x2210
jmp 0x26a734
jmp 0x26a736
movq $0x0, -0x30(%rbp)
movq -0x30(%rbp), %rax
addq $0x198, %rsp            # imm = 0x198
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopw %cs:(%rax,%rax)