// File: /workspace/github_cpp_makefile_star2_O1/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 $0x48, %rsp
movq %rdi, %r12
movq 0xff4f6(%rip), %rcx     # 0x28b548
movq %rsi, 0x8(%rsp)
leaq (%rsi,%rsi,2), %rsi
movq (%rcx,%rsi,8), %rax
testq %rax, %rax
movq %rsi, 0x20(%rsp)
je 0x18c1a1
movl %edx, 0x18(%rsp)
leaq (%rcx,%rsi,8), %rcx
movq 0x10(%rcx), %rcx
xorl %edx, %edx
xorl %edi, %edi
xorl %r14d, %r14d
xorl %r8d, %r8d
movzwl (%rcx,%rdx,2), %r9d
movl %r9d, %r10d
shrl $0xe, %r10d
leal -0x2(%r10), %edx
cmpl $0x2, %edx
jae 0x18c0ae
movl %r9d, %r11d
shrl $0xc, %r11d
andl $0x3, %r11d
movl %r9d, %edx
andl $0xfff, %edx            # imm = 0xFFF
jmp 0x18c0c1
testl %r10d, %r10d
jne 0x18c0c8
movl %r9d, %edx
andl $0x3fff, %edx           # imm = 0x3FFF
movw $0xffff, %r11w          # imm = 0xFFFF
movl $0xffff, %ebp           # imm = 0xFFFF
jmp 0x18c0e5
movl %r9d, %r11d
shrl $0xc, %r11d
andl $0x3, %r11d
movl %r9d, %ebp
shrl $0xa, %ebp
andl $0x3, %ebp
movl %r9d, %edx
andl $0x3ff, %edx            # imm = 0x3FF
movq %r14, 0x28(%rsp)
movzwl %dx, %ebx
incl %r8d
cmpq %r8, %rax
jbe 0x18c167
movzwl %r10w, %r14d
leal -0x2(%r14), %r13d
movzwl (%rcx,%r8,2), %esi
movl %esi, %edx
shrl $0xe, %edx
cmpl %r10d, %edx
jne 0x18c167
cmpl $0x2, %r13d
jae 0x18c122
movl %esi, %edx
shrl $0xc, %edx
andl $0x3, %edx
andl $0xfff, %esi            # imm = 0xFFF
jmp 0x18c131
testl %r14d, %r14d
jne 0x18c139
andl $0x3fff, %esi           # imm = 0x3FFF
movw $0xffff, %dx            # imm = 0xFFFF
movl $0xffff, %r15d          # imm = 0xFFFF
jmp 0x18c152
movl %esi, %edx
shrl $0xc, %edx
andl $0x3, %edx
movl %esi, %r15d
shrl $0xa, %r15d
andl $0x3, %r15d
andl $0x3ff, %esi            # imm = 0x3FF
cmpl %ebp, %r15d
jne 0x18c167
cmpw %dx, %r11w
jne 0x18c167
addl %esi, %ebx
incl %r8d
cmpq %r8, %rax
ja 0x18c0fd
cmpw $0x3, %r10w
movl %ebx, %edx
movl $0x0, %esi
cmovel %esi, %edx
movq 0x28(%rsp), %r14
addl %edx, %r14d
cmpl $0x4000, %r9d           # imm = 0x4000
cmovbl %esi, %ebx
addl %ebx, %edi
movl %r8d, %edx
cmpq %rdx, %rax
ja 0x18c083
testl %edi, %edi
sete %al
movl 0x18(%rsp), %edx
jmp 0x18c1a6
movb $0x1, %al
xorl %r14d, %r14d
testb %al, %al
jne 0x18c742
movslq %edx, %rax
leaq (%rax,%rax,4), %rax
shlq $0x4, %rax
addq %rax, %r12
leal 0x1(%r14), %eax
cmpq %rax, 0x8(%r12)
jae 0x18c212
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)
movq 0x10(%r12), %rax
movl %r14d, %ecx
movq %rcx, 0x10(%rsp)
movb $0x0, (%rax,%rcx)
leaq 0x18(%r12), %rdi
leaq 0xff001(%rip), %rsi     # 0x28b230
movq 0x8(%rsp), %rdx
callq 0x33cf8
movq 0xff308(%rip), %rax     # 0x28b548
movq 0x20(%rsp), %r10
movq (%rax,%r10,8), %r11
xorl %r15d, %r15d
testq %r11, %r11
movq %r14, 0x28(%rsp)
je 0x18c417
xorl %ecx, %ecx
xorl %edx, %edx
xorl %r8d, %r8d
xorl %r14d, %r14d
xorl %esi, %esi
movl %r14d, %r9d
movl %r8d, %edi
movq 0x10(%rax,%r10,8), %r14
movzwl (%r14,%rcx,2), %eax
movl %eax, %r10d
shrl $0xe, %r10d
leal -0x2(%r10), %ecx
cmpl $0x2, %ecx
jae 0x18c298
movl %eax, %ebp
shrl $0xc, %ebp
andl $0x3, %ebp
movl %eax, %ecx
andl $0xfff, %ecx            # imm = 0xFFF
jmp 0x18c2a9
testl %r10d, %r10d
jne 0x18c2b0
movl %eax, %ecx
andl $0x3fff, %ecx           # imm = 0x3FFF
movw $0xffff, %bp            # imm = 0xFFFF
movl $0xffff, %ebx           # imm = 0xFFFF
jmp 0x18c2c8
movl %eax, %ebp
shrl $0xc, %ebp
andl $0x3, %ebp
movl %eax, %ebx
shrl $0xa, %ebx
andl $0x3, %ebx
movl %eax, %ecx
andl $0x3ff, %ecx            # imm = 0x3FF
movzwl %cx, %r8d
incl %esi
cmpq %rsi, %r11
jbe 0x18c344
movzwl (%r14,%rsi,2), %r13d
movl %r13d, %ecx
shrl $0xe, %ecx
cmpl %r10d, %ecx
jne 0x18c344
movzwl %r10w, %ecx
leal -0x2(%rcx), %r15d
cmpl $0x2, %r15d
jae 0x18c303
movl %r13d, %ecx
shrl $0xc, %ecx
andl $0x3, %ecx
andl $0xfff, %r13d           # imm = 0xFFF
jmp 0x18c312
testl %ecx, %ecx
jne 0x18c31a
andl $0x3fff, %r13d          # imm = 0x3FFF
movw $0xffff, %cx            # imm = 0xFFFF
movl $0xffff, %r15d          # imm = 0xFFFF
jmp 0x18c335
movl %r13d, %ecx
shrl $0xc, %ecx
andl $0x3, %ecx
movl %r13d, %r15d
shrl $0xa, %r15d
andl $0x3, %r15d
andl $0x3ff, %r13d           # imm = 0x3FF
cmpl %ebx, %r15d
jne 0x18c344
cmpw %cx, %bp
jne 0x18c344
addl %r13d, %r8d
jmp 0x18c2cc
cmpw $0x2, %r10w
movl %r8d, %r14d
movl $0x0, %ecx
cmovel %ecx, %r14d
addl %r9d, %r14d
cmpw $0x3, %r10w
movl $0xffff, %r11d          # imm = 0xFFFF
cmovel %r11d, %ebp
cmovel %ecx, %r8d
addl %edi, %r8d
cmpl $0x3fff, %eax           # imm = 0x3FFF
ja 0x18c3b5
cmpl %r14d, %r9d
jae 0x18c3f9
movl %r9d, %eax
movl %r14d, %ecx
movq 0x10(%r12), %r9
movq 0x18(%r12), %r10
movb (%r10,%rax), %r10b
movl %edi, %r11d
movb %r10b, (%r9,%r11)
movq 0x10(%r12), %r9
xorl %r10d, %r10d
cmpb $0x4e, (%r9,%r11)
sete %r10b
addl %r10d, %edx
incq %rax
incl %edi
cmpq %rax, %rcx
jne 0x18c380
jmp 0x18c3f9
cmpw $0x3, %r10w
leaq 0xfe36f(%rip), %r11     # 0x28a730
je 0x18c3f9
cmpl %r8d, %edi
jae 0x18c3f9
movzwl %bp, %eax
movl %edi, %ecx
movl %r8d, %edi
movb (%r11,%rax), %r9b
movq 0x10(%r12), %r10
movb %r9b, (%r10,%rcx)
movq 0x10(%r12), %r9
xorl %r10d, %r10d
cmpb $0x4e, (%r9,%rcx)
sete %r10b
addl %r10d, %edx
incq %rcx
cmpq %rcx, %rdi
jne 0x18c3d0
movl %esi, %ecx
movq 0xff146(%rip), %rax     # 0x28b548
movq 0x20(%rsp), %r10
movq (%rax,%r10,8), %r11
cmpq %rcx, %r11
ja 0x18c266
movl %edx, %r15d
leaq 0xfe33a(%rip), %rbx     # 0x28a758
cmpq $0x0, 0x2b0(%rbx)
movq 0x8(%rsp), %rdx
je 0x18c459
leaq 0x38(%r12), %rdi
subq $0x8, %rsp
xorl %esi, %esi
movq $-0x1, %rcx
movq $-0x1, %r8
xorl %r9d, %r9d
pushq $0x2
callq 0x342bc
movq 0x18(%rsp), %rdx
addq $0x10, %rsp
leaq 0xfedd0(%rip), %rdi     # 0x28b230
movq 0x20(%rdi), %rax
movq 0x10(%rsp), %rsi
cmpq %rsi, (%rax,%rdx,8)
jae 0x18c500
movq %rsi, (%rax,%rdx,8)
movq 0x10(%rdi), %rax
movq (%rax,%rdx,8), %rdi
movq 0x10(%rsp), %rsi
shrl $0x2, %esi
incq %rsi
callq 0x2370
leaq 0xfed9a(%rip), %rdi     # 0x28b230
movq 0x10(%rsp), %rsi
movq 0x10(%rdi), %rcx
movq 0x8(%rsp), %rdx
movq %rax, (%rcx,%rdx,8)
movq 0x8(%rsp), %rdx
cmpq $0x0, 0x2b0(%rbx)
je 0x18c500
movq 0x20(%rdi), %rax
movq 0x30(%rdi), %rcx
movq 0x8(%rsp), %rdx
movq (%rcx,%rdx,8), %rdi
movq 0x8(%rsp), %rcx
movq (%rax,%rcx,8), %rsi
movq %rsi, %rax
shrq %rax
andl $0x1, %esi
addq %rax, %rsi
callq 0x2370
leaq 0xfed47(%rip), %rdi     # 0x28b230
movq 0x10(%rsp), %rsi
movq 0x30(%rdi), %rcx
movq 0x8(%rsp), %rdx
movq %rax, (%rcx,%rdx,8)
movq 0x8(%rsp), %rdx
movq 0x18(%rdi), %rax
leaq (,%rdx,8), %rcx
movq %rsi, (%rax,%rdx,8)
movq 0x10(%rdi), %rax
movq %rdi, %r8
movq (%rax,%rdx,8), %rdi
movq %rsi, %rdx
movq 0x10(%r12), %rsi
addq (%r8), %rcx
movq %r15, %r8
callq 0x33ef7
cmpq $0x0, 0x2b0(%rbx)
movq 0x20(%rsp), %rdi
je 0x18c742
movq 0x10(%r12), %rsi
movq 0xfeffb(%rip), %rcx     # 0x28b548
movq (%rcx,%rdi,8), %rax
testq %rax, %rax
je 0x18c715
movq 0x48(%r12), %rdx
movq %rdx, 0x30(%rsp)
xorl %edx, %edx
xorl %r14d, %r14d
xorl %ebx, %ebx
xorl %r12d, %r12d
movq %rsi, 0x18(%rsp)
movl %r14d, %ebp
movq 0x10(%rcx,%rdi,8), %rsi
movzwl (%rsi,%rdx,2), %edx
movl %edx, %ecx
shrl $0xe, %ecx
leal -0x2(%rcx), %edi
cmpl $0x2, %edi
jae 0x18c5a0
movl %edx, %edi
shrl $0xc, %edi
andl $0x3, %edi
movl %edx, %r9d
andl $0xfff, %r9d            # imm = 0xFFF
jmp 0x18c5b2
testl %ecx, %ecx
jne 0x18c5ba
movl %edx, %r9d
andl $0x3fff, %r9d           # imm = 0x3FFF
movw $0xffff, %di            # imm = 0xFFFF
movl $0xffff, %r8d           # imm = 0xFFFF
jmp 0x18c5d7
movl %edx, %edi
shrl $0xc, %edi
andl $0x3, %edi
movl %edx, %r8d
shrl $0xa, %r8d
andl $0x3, %r8d
movl %edx, %r9d
andl $0x3ff, %r9d            # imm = 0x3FF
movzwl %r9w, %r14d
incl %r12d
cmpq %r12, %rax
jbe 0x18c662
movzwl %cx, %r9d
movzwl (%rsi,%r12,2), %r10d
movl %r10d, %r11d
shrl $0xe, %r11d
cmpl %ecx, %r11d
jne 0x18c662
leal -0x2(%r9), %r11d
cmpl $0x2, %r11d
jae 0x18c616
movl %r10d, %r11d
shrl $0xc, %r11d
andl $0x3, %r11d
andl $0xfff, %r10d           # imm = 0xFFF
jmp 0x18c627
testl %r9d, %r9d
jne 0x18c62f
andl $0x3fff, %r10d          # imm = 0x3FFF
movw $0xffff, %r11w          # imm = 0xFFFF
movl $0xffff, %r15d          # imm = 0xFFFF
jmp 0x18c64c
movl %r10d, %r11d
shrl $0xc, %r11d
andl $0x3, %r11d
movl %r10d, %r15d
shrl $0xa, %r15d
andl $0x3, %r15d
andl $0x3ff, %r10d           # imm = 0x3FF
cmpl %r8d, %r15d
jne 0x18c662
cmpw %r11w, %di
jne 0x18c662
addl %r10d, %r14d
incl %r12d
cmpq %r12, %rax
ja 0x18c5e7
cmpw $0x2, %cx
movl %r14d, %r13d
movl $0x0, %eax
cmovel %eax, %r13d
cmpw $0x3, %cx
cmovel %eax, %r14d
addl %ebp, %r14d
testw %dx, %dx
js 0x18c6a0
movl %ebp, %edi
movq 0x18(%rsp), %r15
addq %r15, %rdi
movl %ebx, %esi
addq 0x30(%rsp), %rsi
movl %r13d, %edx
callq 0x2160
movq %r15, %rsi
jmp 0x18c6f4
cmpw $0x2, %cx
movq 0x18(%rsp), %rsi
jne 0x18c6f4
movl %ebx, %esi
movl $0x5, %r9d
movq 0x8(%rsp), %rdi
xorl %edx, %edx
xorl %ecx, %ecx
movq 0x30(%rsp), %r8
leaq 0x38(%rsp), %rax
pushq %rax
leaq 0x48(%rsp), %rax
pushq %rax
callq 0x54e80
movq 0x28(%rsp), %rsi
addq $0x10, %rsp
cmpl %r14d, %ebp
jae 0x18c6f4
movl %ebp, %eax
movl %r14d, %ecx
movb 0x38(%rsp), %dl
movb %dl, (%rsi,%rax)
incq %rax
cmpq %rax, %rcx
jne 0x18c6e5
addl %r13d, %ebx
movl %r12d, %edx
movq 0xfee47(%rip), %rcx     # 0x28b548
movq 0x20(%rsp), %rdi
movq (%rcx,%rdi,8), %rax
cmpq %rdx, %rax
ja 0x18c573
jmp 0x18c718
xorl %r14d, %r14d
cmpl 0x28(%rsp), %r14d
jne 0x18c751
leaq 0xfeb0a(%rip), %rax     # 0x28b230
movq 0x30(%rax), %rax
movq 0x8(%rsp), %rcx
movq (%rax,%rcx,8), %rdi
movl $0x2, %ecx
movq 0x10(%rsp), %rdx
callq 0x340f3
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xa6f74(%rip), %rdi     # 0x2336cc
leaq 0xa568c(%rip), %rsi     # 0x231deb
leaq 0xa6f6f(%rip), %rcx     # 0x2336d5
movl $0x17aa, %edx           # imm = 0x17AA
callq 0x2110