// File: /workspace/github_cpp_makefile_star2_O3/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 $0x18, %rsp
movq %rsi, %r14
movq %rdi, %rbx
cmpl $-0x1, %edx
je 0x1858fe
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 0x1967e1
movl 0x18(%r14), %eax
subl 0x18(%rbx), %eax
movl %eax, 0x1c(%rbx)
jmp 0x1859ef
cmpl $-0x1, %ecx
je 0x18590d
xorl %ebp, %ebp
cmpl $0x10000000, %ecx       # imm = 0x10000000
jae 0x185915
xorl %r12d, %r12d
jmp 0x1859ef
movq %r8, 0x10(%rsp)
movl %ecx, %eax
shrl $0x10, %eax
movl $0xfff, %edx            # imm = 0xFFF
andl %edx, %eax
movl %eax, 0xc(%rsp)
movl %ecx, %eax
shrl $0x1c, %eax
andl %ecx, %edx
movl %edx, 0x4(%rsp)
shrl $0xc, %ecx
andl $0xf, %ecx
movl %ecx, 0x8(%rsp)
addq $0x18, %r14
leal -0x2(,%rax,2), %r13d
xorl %r12d, %r12d
movl $0x0, (%rsp)
movl 0xc(%rsp), %r15d
movl %r13d, %ecx
shrl %cl, %r15d
andl $0x3, %r15d
movw $0xffff, %ax            # imm = 0xFFFF
cmpl $0x3, %r15d
je 0x185993
movl (%rsp), %edx
movl %edx, %ecx
notl %ecx
addl 0x8(%rsp), %ecx
addl %ecx, %ecx
movl 0x4(%rsp), %eax
shrl %cl, %eax
incl %edx
movl %edx, (%rsp)
andl $0x3, %eax
movw $0xffff, %cx            # imm = 0xFFFF
cmpl $0x2, %r15d
je 0x1859ae
movl %ebp, %ecx
movq 0x10(%rsp), %rdx
movsbq (%rdx,%rcx), %rcx
movl %ecx, %ecx
leaq 0x10fc88(%rip), %rdx    # 0x295630
movzbl (%rdx,%rcx), %ecx
incl %ebp
xorl %r9d, %r9d
cmpl $0x0, 0x1c(%rbx)
setne %r9b
movzwl %cx, %edx
movzwl %ax, %ecx
movq %r14, %rdi
movl %r15d, %esi
movl $0x1, %r8d
callq 0x1967e1
movl (%r14), %eax
subl 0x18(%rbx), %eax
movl %eax, 0x1c(%rbx)
cmpl $0x1, %r15d
sbbq $-0x1, %r12
addl $-0x2, %r13d
cmpl $-0x2, %r13d
jne 0x185955
movq %r12, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq