// File: /workspace/github_cpp_makefile_star2_O1/chhylp123[P]hifiasm/ecovlp.cpp
// Function: push_correct0_fhc(window_list*, window_list_alloc*, unsigned int, unsigned int, char*)
uint64_t push_correct0_fhc(window_list *idx, window_list_alloc *res, uint32_t len0, uint32_t rc, char *qstr)
{
    uint64_t nec = 0;
    // fprintf(stderr, "[M::%s] NULL(idx)::%u\n", __func__, idx?0:1);
    if(len0 != ((uint32_t)-1)) {
        push_trace_bp_f(((asg16_v *)(&(res->c))), 0, (uint16_t)-1, (uint16_t)-1, len0, ((idx->clen>0)?1:0)); 
        idx->clen = res->c.n - idx->cidx;
    } else if(rc != ((uint32_t)-1)) {
        // fprintf(stderr, "[M::%s]\t", __func__);
        uint32_t cc = (rc<<4)>>20, cn = rc>>28, ck = 0, cs, cp;
        uint32_t bc = (rc<<20)>>20, bn = (rc<<16)>>28, btk = 0, bqk = 0, bs, bqp, btp;
        ///debug
        // prt_cigar0(cc, cn);
        // prt_bp0(bc, bn);

        for (ck = 0; ck < cn; ck++) {
            cs = (cn-1-ck)<<1; cp = (cc>>cs)&3;

            bqp = btp = (uint32_t)-1;
            if(cp != 3) {///bp == 3: more x
                bs = (bn-1-btk)<<1; btp = (bc>>bs)&3; btk++;
            }
            if(cp != 2) {///bp == 2: more y
                bqp = seq_nt6_table[(uint32_t)qstr[bqk]]; bqk++;
            }
            // fprintf(stderr, "[M::%s] cp::%u, btp::%u, bqp::%u\n", __func__, cp, btp, bqp);

            push_trace_bp_f(((asg16_v *)(&(res->c))), cp, bqp, btp, 1, ((idx->clen>0)?1:0)); 
            idx->clen = res->c.n - idx->cidx;
            // fprintf(stderr, "%c", cm[(in >> mp)&3]);

            // fprintf(stderr, "%c", "MSID"[cp]);
            if(cp != 0) nec++;
        }

        // fprintf(stderr, "\n");
    }

    return nec;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rsi, %r14
movq %rdi, %rbx
cmpl $-0x1, %edx
je 0x17e4ad
movl %edx, %eax
leaq 0x18(%r14), %rdi
xorl %r9d, %r9d
cmpl $0x0, 0x1c(%rbx)
setne %r9b
xorl %r12d, %r12d
xorl %esi, %esi
movl $0xffff, %edx           # imm = 0xFFFF
movl $0xffff, %ecx           # imm = 0xFFFF
movl %eax, %r8d
callq 0x18d9ca
movl 0x18(%r14), %eax
subl 0x18(%rbx), %eax
movl %eax, 0x1c(%rbx)
jmp 0x17e5a6
cmpl $-0x1, %ecx
je 0x17e4ba
cmpl $0x10000000, %ecx       # imm = 0x10000000
jae 0x17e4c2
xorl %r12d, %r12d
jmp 0x17e5a6
movq $0x0, 0x18(%rsp)
movq %r8, 0x20(%rsp)
movl %ecx, %eax
shrl $0x10, %eax
movl $0xfff, %edx            # imm = 0xFFF
andl %edx, %eax
movl %eax, 0x14(%rsp)
movl %ecx, %eax
shrl $0x1c, %eax
andl %ecx, %edx
movl %edx, 0xc(%rsp)
shrl $0xc, %ecx
andl $0xf, %ecx
movl %ecx, 0x10(%rsp)
addq $0x18, %r14
leal -0x2(,%rax,2), %r13d
xorl %r12d, %r12d
xorl %ebp, %ebp
movl 0x14(%rsp), %r15d
movl %r13d, %ecx
shrl %cl, %r15d
andl $0x3, %r15d
movw $0xffff, %ax            # imm = 0xFFFF
cmpl $0x3, %r15d
jne 0x17e525
movw $0xffff, %si            # imm = 0xFFFF
jmp 0x17e53a
movl %ebp, %ecx
notl %ecx
addl 0x10(%rsp), %ecx
addl %ecx, %ecx
movl 0xc(%rsp), %esi
shrl %cl, %esi
incl %ebp
andl $0x3, %esi
cmpl $0x2, %r15d
je 0x17e565
movq 0x18(%rsp), %rdx
movl %edx, %eax
movq 0x20(%rsp), %rcx
movsbq (%rcx,%rax), %rax
movl %eax, %eax
leaq 0x10c0d6(%rip), %rcx    # 0x28a630
movzbl (%rcx,%rax), %eax
incl %edx
movq %rdx, 0x18(%rsp)
xorl %r9d, %r9d
cmpl $0x0, 0x1c(%rbx)
setne %r9b
movzwl %ax, %edx
movzwl %si, %ecx
movq %r14, %rdi
movl %r15d, %esi
movl $0x1, %r8d
callq 0x18d9ca
movl (%r14), %eax
subl 0x18(%rbx), %eax
movl %eax, 0x1c(%rbx)
cmpl $0x1, %r15d
sbbq $-0x1, %r12
addl $-0x2, %r13d
cmpl $-0x2, %r13d
jne 0x17e506
movq %r12, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq