// File: 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 %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq $0x0, -0x18(%rbp)
movq -0x8(%rbp), %rax
cmpq $0x0, 0x48(%rax)
jbe 0x60bdb
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x8(%rbp), %rcx
movq 0x48(%rcx), %rcx
subq $0x1, %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
cmpl $0x0, 0x1c(%rax)
jbe 0x60bd9
movq -0x18(%rbp), %rax
movswq 0x14(%rax), %rax
movq -0x10(%rbp), %rcx
movslq 0x2c(%rcx), %rcx
addq %rcx, %rax
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rax
movl 0x4(%rax), %eax
addl $0x1, %eax
movq -0x10(%rbp), %rcx
cmpl 0x1c(%rcx), %eax
jne 0x60bd7
movq -0x18(%rbp), %rax
movl 0xc(%rax), %eax
addl $0x1, %eax
movq -0x10(%rbp), %rcx
cmpl 0x10(%rcx), %eax
jne 0x60bd7
cmpq $0x7fff, -0x20(%rbp)    # imm = 0x7FFF
jge 0x60bd7
movq -0x10(%rbp), %rax
movl 0x20(%rax), %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0x10(%rbp), %rax
movl 0x14(%rax), %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0xc(%rax)
movq -0x10(%rbp), %rax
movl 0x2c(%rax), %edx
movq -0x18(%rbp), %rax
movswl 0x14(%rax), %ecx
addl %edx, %ecx
movw %cx, 0x14(%rax)
movq -0x18(%rbp), %rdi
movq -0x8(%rbp), %rsi
addq $0x48, %rsi
movq -0x10(%rbp), %rdx
callq 0x60830
jmp 0x60cd4
jmp 0x60bd9
jmp 0x60bdb
jmp 0x60bdd
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rax
movq -0x8(%rbp), %rcx
cmpq 0x50(%rcx), %rax
jne 0x60c46
movq -0x8(%rbp), %rax
cmpq $0x0, 0x50(%rax)
je 0x60c0b
movq -0x8(%rbp), %rax
movq 0x50(%rax), %rax
shlq %rax
movq %rax, -0x28(%rbp)
jmp 0x60c16
movl $0x2, %eax
movq %rax, -0x28(%rbp)
jmp 0x60c16
movq -0x28(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x50(%rax)
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rdi
movq -0x8(%rbp), %rax
movq 0x50(%rax), %rsi
shlq $0x5, %rsi
callq 0x2360
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x58(%rax)
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x8(%rbp), %rdx
movq 0x48(%rdx), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, 0x48(%rdx)
shlq $0x5, %rcx
addq %rcx, %rax
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rax
movl 0x1c(%rax), %ecx
movq -0x18(%rbp), %rax
movl %ecx, (%rax)
movq -0x10(%rbp), %rax
movl 0x20(%rax), %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0x10(%rbp), %rax
movl 0x10(%rax), %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x10(%rbp), %rax
movl 0x14(%rax), %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0xc(%rax)
movq -0x18(%rbp), %rax
movw $0x0, 0x16(%rax)
movq -0x10(%rbp), %rax
movl 0x2c(%rax), %eax
movw %ax, %cx
movq -0x18(%rbp), %rax
movw %cx, 0x14(%rax)
movq -0x18(%rbp), %rdi
movq -0x8(%rbp), %rsi
addq $0x48, %rsi
movq -0x10(%rbp), %rdx
callq 0x38180
addq $0x30, %rsp
popq %rbp
retq
nopw (%rax,%rax)