// File: /workspace/github_cpp_makefile_star2_O2/chhylp123[P]hifiasm/ecovlp.cpp
// Function: worker_sl_ec(void*, long, int)
static void worker_sl_ec(void *data, long i, int tid)
{
    // if(i != 0) return;

	sl_v *p = &(((sl_v*)data)[tid]); uint8_t *oa = NULL; char *na = NULL; uint64_t tqual, wqual;
    uint32_t ci = 0, len, xk, yk, wx[2], wy[2], k, Nn, yn = 0, tot_e; uint16_t c, bq, bt; 


    ci = 0; xk = yk = 0; tot_e = 0;
    while (ci < scc.a[i].n) {
        // ci = pop_trace_bp(&scc.a[i], ci, &c, &b, &len);
        ci = pop_trace_bp_f(&scc.a[i], ci, &c, &bq, &bt, &len);
        if(c != 3) yk += len;
        if(c != 0) tot_e += len;
        // fprintf(stderr, "|%u%c(%c)", len, cm[c], ((c==1)||(c==2))?(cc[b]):('*')); // s_H
    }
    if(tot_e == 0) return;///no change

    yn = yk; yk++; kv_resize(char, (*p), yk); p->a[yn] = '\0';
    recover_UC_Read(&p->z, &R_INF, i); ///b->z.length


    // char cm[4], cc[4]; 
    // cm[0] = 'M'; cm[1] = 'S'; cm[2] = 'I'; cm[3] = 'D';
    // cc[0] = 'A'; cc[1] = 'C'; cc[2] = 'G'; cc[3] = 'T';

    ci = 0; xk = yk = 0; Nn = 0;
    while (ci < scc.a[i].n) {
        wx[0] = xk; wy[0] = yk;
        // ci = pop_trace_bp(&scc.a[i], ci, &c, &b, &len);
        ci = pop_trace_bp_f(&scc.a[i], ci, &c, &bq, &bt, &len);
        if(c != 2) xk += len;
        if(c != 3) yk += len;
        wx[1] = xk; wy[1] = yk;
        // if(xk > (uint32_t)p->z.length) fprintf(stderr, "[M::%s] xk::%u, len::%u, c::%u, rid::%ld\n", __func__, xk, (uint32_t)p->z.length, c, i);
        if(c == 0) {
            // memcpy(p->a + wy[0], p->z.seq + wx[0], (wx[1]-wx[0])*sizeof((*(p->a))));
            for (; wx[0] < wx[1]; wx[0]++, wy[0]++) {
                p->a[wy[0]] = p->z.seq[wx[0]];
                if(p->a[wy[0]] == 'N') Nn++;
            }
        } else if(c == 1 || c == 2) {
            for (k = wy[0]; k < wy[1]; k++) {
                p->a[k] = s_H[bt]; 
                if(p->a[k] == 'N') Nn++;
            }
        }

        // if(i == 700) fprintf(stderr, "|%u%c(%c)(x::%u)(y::%u)", len, cm[c], ((c==1)||(c==2))?(cc[b]):('*'), wx[1], wy[1]); // s_H
    }

    // if(i == 700) fprintf(stderr, "|\n");
    if(asm_opt.is_sc) retrive_bqual(&(p->q), NULL, i, -1, -1, 0, sc_bn);


    if (R_INF.read_size[i] < yn) {
		R_INF.read_size[i] = yn;
		REALLOC(R_INF.read_sperate[i], R_INF.read_size[i]/4+1);
        if(asm_opt.is_sc) REALLOC(R_INF.rsc[i], ((R_INF.read_size[i]/sc_bn) + ((R_INF.read_size[i]%sc_bn)?1:0)));
	}
	R_INF.read_length[i] = yn;
    // if(Nn > 0) fprintf(stderr, "[M::%s] Nn->%u\n", __func__, Nn);

    // for (k = 0; k < yn; k++) {
    //     c = seq_nt6_table[(uint8_t)p->a[k]]; 
    //     if (c >= 4) { 
    //         fprintf(stderr, "[M::%s] Nn->%u, yn::%u, xn::%lld, k::%u, str::%c, c::%u, rid::%ld\n", __func__, Nn, yn, p->z.length, k, p->a[k], c, i);
    //     }
    // }


    ///debug
    // resize_UC_Read(&p->z, p->z.length * 2); 
    // dbg_rsc(p->z.seq + p->z.length, p->z.length, p->a, yn, &(scc.a[i]), p->z.seq, i);


	ha_compress_base(Get_READ(R_INF, i), p->a, yn, &R_INF.N_site[i], Nn);
    if(asm_opt.is_sc) {
        oa = p->q.a; na = p->a; 
        ci = 0; xk = yk = 0; Nn = 0;
        while (ci < scc.a[i].n) {
            wx[0] = xk; wy[0] = yk;
            ci = pop_trace_bp_f(&scc.a[i], ci, &c, &bq, &bt, &len);
            if(c != 2) xk += len;
            if(c != 3) yk += len;
            wx[1] = xk; wy[1] = yk;
            if(c == 0 || c == 1) {
                memcpy(na + wy[0], oa + wx[0], (wx[1]-wx[0])*sizeof((*oa)));
            } else if(c == 2) {
                get_wqual(i, wx[0], 0, NULL, oa, sc_wn, &tqual, &wqual);
                for (k = wy[0]; k < wy[1]; k++) na[k] = wqual;
            }
        }
        assert(yk == yn);
        ha_compress_qual_bit(Get_QUAL(R_INF, i), na, yn, sc_bn);
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rdi, %r12
movslq %edx, %rax
movq %rax, 0x30(%rsp)
xorl %ebp, %ebp
movq %rsi, 0x18(%rsp)
imulq $0x18, %rsi, %r8
leaq 0x16(%rsp), %r14
leaq 0xe(%rsp), %r15
leaq 0x10(%rsp), %r13
xorl %eax, %eax
movq $0x0, 0x28(%rsp)
xorl %ebx, %ebx
movq %r8, 0x20(%rsp)
movl %eax, %ecx
movq 0x1065e7(%rip), %rdi    # 0x254548
cmpq %rcx, (%rdi,%r8)
jbe 0x14dfac
addq %r8, %rdi
movl %eax, %esi
leaq 0xc(%rsp), %rdx
movq %r14, %rcx
movq %r15, %r8
movq %r13, %r9
callq 0xeeaa9
movq 0x20(%rsp), %r8
movzwl 0xc(%rsp), %ecx
cmpw $0x3, %cx
movl 0x10(%rsp), %edx
movl %edx, %esi
cmovel %ebp, %esi
movq 0x28(%rsp), %rdi
addl %esi, %edi
movq %rdi, 0x28(%rsp)
testw %cx, %cx
cmovel %ebp, %edx
addl %edx, %ebx
jmp 0x14df58
testl %ebx, %ebx
je 0x14e336
imulq $0x50, 0x30(%rsp), %rax
addq %rax, %r12
movq 0x28(%rsp), %rax
incl %eax
cmpq %rax, 0x8(%r12)
jae 0x14e018
decq %rax
movq %rax, %rcx
shrq %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x2, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x4, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x8, %rax
orq %rcx, %rax
movq %rax, %rsi
shrq $0x10, %rsi
orq %rax, %rsi
incq %rsi
movq %rsi, 0x8(%r12)
movq 0x10(%r12), %rdi
callq 0x2370
movq %rax, 0x10(%r12)
jmp 0x14e01d
movq 0x10(%r12), %rax
movq 0x18(%rsp), %rdx
movl 0x28(%rsp), %ecx
movq %rcx, 0x40(%rsp)
movb $0x0, (%rax,%rcx)
leaq 0x18(%r12), %rdi
leaq 0x1061f5(%rip), %rsi    # 0x254230
callq 0x715e
xorl %ebx, %ebx
leaq 0x10(%rsp), %r14
xorl %eax, %eax
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r13d, %r13d
movq 0x20(%rsp), %r10
movl %edx, %ebp
movl %ecx, %r15d
movl %eax, %ecx
movq 0x1064e5(%rip), %rdi    # 0x254548
cmpq %rcx, (%rdi,%r10)
jbe 0x14e134
addq %r10, %rdi
movl %eax, %esi
leaq 0xc(%rsp), %rdx
leaq 0x16(%rsp), %rcx
leaq 0xe(%rsp), %r8
movq %r14, %r9
callq 0xeeaa9
movzwl 0xc(%rsp), %esi
cmpw $0x2, %si
movl 0x10(%rsp), %ecx
movl %ecx, %edx
cmovel %ebx, %edx
addl %ebp, %edx
cmpw $0x3, %si
cmovel %ebx, %ecx
addl %r15d, %ecx
testw %si, %si
je 0x14e0f6
movl %edx, %ebp
cmpw $0x2, %si
movq 0x20(%rsp), %r10
ja 0x14e057
movl %r15d, %esi
movl %ecx, %edi
leaq 0x10566b(%rip), %r11    # 0x253730
cmpq %rdi, %rsi
jae 0x14e055
movzwl 0xe(%rsp), %r8d
movb (%r11,%r8), %r8b
movq 0x10(%r12), %r9
movb %r8b, (%r9,%rsi)
movq 0x10(%r12), %r8
xorl %r9d, %r9d
cmpb $0x4e, (%r8,%rsi)
sete %r9b
addl %r9d, %r13d
incq %rsi
jmp 0x14e0c5
movl %ebp, %esi
movl %edx, %edi
cmpq %rdi, %rsi
jae 0x14e050
movq 0x10(%r12), %r8
movq 0x18(%r12), %r9
movb (%r9,%rsi), %r9b
movl %r15d, %r10d
movb %r9b, (%r8,%r10)
movq 0x10(%r12), %r8
xorl %r9d, %r9d
cmpb $0x4e, (%r8,%r10)
sete %r9b
addl %r9d, %r13d
incq %rsi
incl %r15d
jmp 0x14e0fa
leaq 0x10561d(%rip), %rbx    # 0x253758
cmpq $0x0, 0x2b0(%rbx)
movq 0x18(%rsp), %r14
je 0x14e16a
leaq 0x38(%r12), %rdi
subq $0x8, %rsp
pushq $-0x1
popq %rcx
xorl %esi, %esi
movq %r14, %rdx
movq %rcx, %r8
xorl %r9d, %r9d
pushq $0x2
callq 0x7638
popq %rcx
popq %rdx
leaq 0x1060bf(%rip), %rbp    # 0x254230
movq 0x20(%rbp), %rax
movq 0x40(%rsp), %r15
cmpq %r15, (%rax,%r14,8)
jae 0x14e1d5
movq %r15, (%rax,%r14,8)
movq 0x10(%rbp), %rax
movq (%rax,%r14,8), %rdi
movl %r15d, %esi
shrl $0x2, %esi
incq %rsi
callq 0x2370
movq 0x10(%rbp), %rcx
movq %rax, (%rcx,%r14,8)
cmpq $0x0, 0x2b0(%rbx)
je 0x14e1d5
movq 0x20(%rbp), %rax
movq 0x30(%rbp), %rcx
movq (%rcx,%r14,8), %rdi
movq (%rax,%r14,8), %rsi
movq %rsi, %rax
shrq %rax
andl $0x1, %esi
addq %rax, %rsi
callq 0x2370
movq 0x30(%rbp), %rcx
movq %rax, (%rcx,%r14,8)
movq 0x18(%rbp), %rax
leaq (,%r14,8), %rcx
movq %r15, (%rax,%r14,8)
movq 0x10(%rbp), %rax
movq (%rax,%r14,8), %rdi
movq 0x10(%r12), %rsi
addq (%rbp), %rcx
movl %r13d, %r8d
movq %r15, %rdx
callq 0x733a
cmpq $0x0, 0x2b0(%rbx)
je 0x14e336
movq 0x10(%r12), %r14
movq 0x48(%r12), %rax
movq %rax, 0x30(%rsp)
xorl %eax, %eax
xorl %ebp, %ebp
xorl %r12d, %r12d
movl %eax, %edx
movq 0x10631a(%rip), %rdi    # 0x254548
movq 0x20(%rsp), %rcx
cmpq %rdx, (%rdi,%rcx)
jbe 0x14e30b
addq %rcx, %rdi
movl %eax, %esi
leaq 0xc(%rsp), %rdx
leaq 0x16(%rsp), %rcx
leaq 0xe(%rsp), %r8
leaq 0x10(%rsp), %r9
callq 0xeeaa9
movzwl 0xc(%rsp), %edi
cmpw $0x2, %di
movl 0x10(%rsp), %edx
movl %edx, %r15d
movl $0x0, %ecx
cmovel %ecx, %r15d
addl %ebp, %r15d
cmpw $0x3, %di
movl %edx, %ebx
cmovel %ecx, %ebx
addl %r12d, %ebx
movl %r12d, %r13d
movl %ebp, %esi
cmpw $0x1, %di
ja 0x14e2ad
addq %r14, %r13
addq 0x30(%rsp), %rsi
movq %r13, %rdi
movl %eax, %ebp
callq 0x2160
movl %ebp, %eax
movl %r15d, %ebp
movl %ebx, %r12d
jmp 0x14e225
movl %r15d, %ebp
movl %ebx, %r12d
cmpw $0x2, %di
jne 0x14e225
movl %eax, 0x3c(%rsp)
movq 0x18(%rsp), %rdi
xorl %edx, %edx
xorl %ecx, %ecx
movq 0x30(%rsp), %r8
pushq $0x5
popq %r9
leaq 0x48(%rsp), %rax
pushq %rax
leaq 0x58(%rsp), %rax
pushq %rax
callq 0x25d2c
addq $0x10, %rsp
movl %ebx, %eax
cmpq %rax, %r13
jae 0x14e2fc
movb 0x48(%rsp), %cl
movb %cl, (%r14,%r13)
incq %r13
jmp 0x14e2ea
movl %r15d, %ebp
movl %ebx, %r12d
movl 0x3c(%rsp), %eax
jmp 0x14e225
cmpl 0x28(%rsp), %r12d
jne 0x14e345
leaq 0x105f17(%rip), %rax    # 0x254230
movq 0x30(%rax), %rax
movq 0x18(%rsp), %rcx
movq (%rax,%rcx,8), %rdi
pushq $0x2
popq %rcx
movq %r14, %rsi
movq 0x40(%rsp), %rdx
callq 0x74d3
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xa3490(%rip), %rdi     # 0x1f17dc
leaq 0xa1ba8(%rip), %rsi     # 0x1efefb
leaq 0xa348b(%rip), %rcx     # 0x1f17e5
movl $0x17aa, %edx           # imm = 0x17AA
callq 0x2110