// File: chhylp123[P]hifiasm/ecovlp.cpp
// Function: push_correct0(window_list*, window_list_alloc*, unsigned int, unsigned int)
uint64_t push_correct0(window_list *idx, window_list_alloc *res, uint32_t len0, uint32_t rc)
{
    uint64_t nec = 0;
    // fprintf(stderr, "[M::%s] NULL(idx)::%u\n", __func__, idx?0:1);
    if(len0 != ((uint32_t)-1)) {
        push_trace_bp(((asg16_v *)(&(res->c))), 0, (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, bk = 0, bs, bp;
        ///debug
        // prt_cigar0(cc, cn);
        // prt_bp0(bc, bn);

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

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

            push_trace_bp(((asg16_v *)(&(res->c))), cp, bp, 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
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl %ecx, -0x18(%rbp)
movq $0x0, -0x20(%rbp)
cmpl $-0x1, -0x14(%rbp)
je 0x252cc1
movq -0x10(%rbp), %rdi
addq $0x18, %rdi
movl -0x14(%rbp), %ecx
movq -0x8(%rbp), %rax
movl 0x1c(%rax), %edx
xorl %r8d, %r8d
movl $0x1, %eax
cmpl $0x0, %edx
cmoval %eax, %r8d
xorl %esi, %esi
movl $0xffff, %edx           # imm = 0xFFFF
callq 0x26d4e0
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x8(%rbp), %rcx
movl 0x18(%rcx), %ecx
subq %rcx, %rax
movl %eax, %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x1c(%rax)
jmp 0x252ddf
cmpl $-0x1, -0x18(%rbp)
je 0x252ddd
movl -0x18(%rbp), %eax
shll $0x4, %eax
shrl $0x14, %eax
movl %eax, -0x24(%rbp)
movl -0x18(%rbp), %eax
shrl $0x1c, %eax
movl %eax, -0x28(%rbp)
movl $0x0, -0x2c(%rbp)
movl -0x18(%rbp), %eax
shll $0x14, %eax
shrl $0x14, %eax
movl %eax, -0x38(%rbp)
movl -0x18(%rbp), %eax
shll $0x10, %eax
shrl $0x1c, %eax
movl %eax, -0x3c(%rbp)
movl $0x0, -0x40(%rbp)
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
cmpl -0x28(%rbp), %eax
jae 0x252ddb
movl -0x28(%rbp), %eax
subl $0x1, %eax
subl -0x2c(%rbp), %eax
shll %eax
movl %eax, -0x30(%rbp)
movl -0x24(%rbp), %eax
movl -0x30(%rbp), %ecx
shrl %cl, %eax
andl $0x3, %eax
movl %eax, -0x34(%rbp)
movl $0xffffffff, -0x48(%rbp) # imm = 0xFFFFFFFF
cmpl $0x3, -0x34(%rbp)
je 0x252d67
movl -0x3c(%rbp), %eax
subl $0x1, %eax
subl -0x40(%rbp), %eax
shll %eax
movl %eax, -0x44(%rbp)
movl -0x38(%rbp), %eax
movl -0x44(%rbp), %ecx
shrl %cl, %eax
andl $0x3, %eax
movl %eax, -0x48(%rbp)
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
movq -0x10(%rbp), %rdi
addq $0x18, %rdi
movl -0x34(%rbp), %eax
movw %ax, %dx
movl -0x48(%rbp), %eax
movq -0x8(%rbp), %rcx
movl 0x1c(%rcx), %esi
xorl %r8d, %r8d
movl $0x1, %ecx
cmpl $0x0, %esi
cmoval %ecx, %r8d
movl $0x1, %ecx
movzwl %dx, %esi
movzwl %ax, %edx
callq 0x26d4e0
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x8(%rbp), %rcx
movl 0x18(%rcx), %ecx
subq %rcx, %rax
movl %eax, %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x1c(%rax)
cmpl $0x0, -0x34(%rbp)
je 0x252dcb
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
jmp 0x252dcd
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x252d0d
jmp 0x252ddd
jmp 0x252ddf
movq -0x20(%rbp), %rax
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax)