// File: /workspace/github_cpp_makefile_star2_O1/chhylp123[P]hifiasm/Correct.cpp
// Function: push_alnw(overlap_region*, bit_extz_t*)
void push_alnw(overlap_region *aux_o, bit_extz_t *exz)
{
    window_list *p = NULL; int64_t t;
    if(aux_o->w_list.n > 0) {
        p = &(aux_o->w_list.a[aux_o->w_list.n-1]);
        // fprintf(stderr, "+[M::%s::wn->%d] px::[%d, %d], py::[%d, %d], pe::%d, exz->t::[%u, %u], exz->p::[%u, %u], exz->e::%d, clen::%u\n", 
        //     __func__, (int32_t)(aux_o->w_list.n), p->x_start, p->x_end, p->y_start, p->y_end, p->error, 
        //     exz->ts, exz->te, exz->ps, exz->pe, exz->err, p->clen);
        // assert((p->x_end<exz->ts)&&(p->y_end<exz->ps));
        
        if(p->clen > 0) {
            t = ((int64_t)p->error) + ((int64_t)exz->err);
            ///note: t cannot be equal to INT16_MAX; otherwise it is unable to distiguish unaligned regions
            if(((p->x_end+1) == exz->ts) && ((p->y_end+1) == exz->ps) && (t < INT16_MAX)) {
                p->x_end = exz->te; p->y_end = exz->pe; p->error += exz->err;
                append_wcigar(p, &(aux_o->w_list), exz);
            //     fprintf(stderr, "-[M::%s::wn->%d] px::[%d, %d], py::[%d, %d], pe::%d, exz->t::[%u, %u], exz->p::[%u, %u], exz->e::%d, clen::%u\n", 
            // __func__, (int32_t)(aux_o->w_list.n), p->x_start, p->x_end, p->y_start, p->y_end, p->error, 
            // exz->ts, exz->te, exz->ps, exz->pe, exz->err, p->clen);
                return;
            }
        }
    }
    // fprintf(stderr, "[M::%s::wn->%d] exz->t::[%u, %u], exz->p::[%u, %u], exz->e::%d\n", 
    //         __func__, (int32_t)(aux_o->w_list.n), exz->ts, exz->te, exz->ps, exz->pe, exz->err);
    kv_pushp(window_list, aux_o->w_list, &p);
    p->x_start = exz->ts; p->x_end = exz->te;
    p->y_start = exz->ps; p->y_end = exz->pe;
    p->error_threshold = 0; p->error = exz->err;///single round of alignment cannot have INT16_MAX errors
    push_wcigar(p, &(aux_o->w_list), exz);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rsi, %rbx
movq %rdi, %r15
leaq 0x48(%rdi), %r14
movq 0x48(%rdi), %rax
testq %rax, %rax
je 0x65dc9
movq 0x58(%r15), %rdx
movq %rax, %rsi
shlq $0x5, %rsi
cmpl $0x0, -0x4(%rdx,%rsi)
je 0x65dc9
leaq (%rdx,%rsi), %rcx
movl -0x1c(%rcx), %edi
incl %edi
cmpl 0x1c(%rbx), %edi
jne 0x65dc9
movswq -0xc(%rcx), %r8
movslq 0x2c(%rbx), %r9
leaq (%r9,%r8), %rdi
movl -0x14(%rcx), %r10d
incl %r10d
cmpl 0x10(%rbx), %r10d
sete %r10b
cmpq $0x7fff, %rdi           # imm = 0x7FFF
setl %dil
andb %r10b, %dil
cmpb $0x1, %dil
jne 0x65dc9
leaq (%rdx,%rsi), %rdi
addq $-0x20, %rdi
movl 0x20(%rbx), %eax
movl %eax, -0x1c(%rcx)
movl 0x14(%rbx), %eax
movl %eax, -0x14(%rcx)
addl %r9d, %r8d
movw %r8w, -0xc(%rcx)
movq %r14, %rsi
movq %rbx, %rdx
popq %rbx
popq %r14
popq %r15
jmp 0x65ab3
movq 0x50(%r15), %rcx
cmpq %rcx, %rax
jne 0x65df7
leaq (%rcx,%rcx), %rax
testq %rcx, %rcx
movl $0x2, %esi
cmovneq %rax, %rsi
movq %rsi, 0x50(%r15)
movq 0x58(%r15), %rdi
shlq $0x5, %rsi
callq 0x2370
movq %rax, 0x58(%r15)
movq 0x48(%r15), %rax
movq 0x58(%r15), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, 0x48(%r15)
shlq $0x5, %rax
leaq (%rcx,%rax), %rdi
movl 0x1c(%rbx), %edx
movl %edx, (%rcx,%rax)
movl 0x20(%rbx), %edx
movl %edx, 0x4(%rcx,%rax)
movl 0x10(%rbx), %edx
movl %edx, 0x8(%rcx,%rax)
movl 0x14(%rbx), %edx
movl %edx, 0xc(%rcx,%rax)
movw $0x0, 0x16(%rcx,%rax)
movzwl 0x2c(%rbx), %edx
movw %dx, 0x14(%rcx,%rax)
movq %r14, %rsi
movq %rbx, %rdx
popq %rbx
popq %r14
popq %r15
jmp 0x4bdb5