// File: chhylp123[P]hifiasm/Correct.cpp
// Function: extract_sub_cigar_err_debug(overlap_region*, long, long)
int64_t extract_sub_cigar_err_debug(overlap_region *z, int64_t s, int64_t e)
{
    int64_t wk = 0, wn = z->w_list.n, ws, we, os, oe, ovlp; 
    window_list *m; int64_t xl, yl, werr, err; bit_extz_t ez;
    for (wk = err = 0; wk < wn; wk++) {
        m = &(z->w_list.a[wk]); 
        ws = m->x_start; we = m->x_end+1;
        if(ws >= e) break;
        os = MAX(s, ws); oe = MIN(e, we);
        ovlp = ((oe>os)? (oe-os):0);
        if(ovlp) {
            xl = m->x_end+1-m->x_start;
            yl = m->y_end+1-m->y_start;
            if((is_ualn_win((*m))) || (is_est_aln((*m)))) {
                if(is_ualn_win((*m))) { //unmapped
                    werr = gen_err_unaligned(xl, yl);
                } else {
                    werr = m->error;//shared window
                }
                if(ovlp < xl) {
                    werr = (((double)ovlp)/((double)xl))*((double)werr);
                }
                //skip the whole window
                err += werr; 
            } else {
                if(ovlp == xl) {
                    //skip the whole window
                    err += m->error; 
                } else {
                    set_bit_extz_t(ez, (*z), wk); 
                    err += retrieve_cigar_err_debug(&ez, os, oe);
                }                
            }
        }
    }
    return err;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x190, %rsp            # imm = 0x190
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq $0x0, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rax
movq %rax, -0x28(%rbp)
movq $0x0, -0x78(%rbp)
movq $0x0, -0x20(%rbp)
movq -0x20(%rbp), %rax
cmpq -0x28(%rbp), %rax
jge 0x6b456
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x20(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rax
movslq (%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x58(%rbp), %rax
movl 0x4(%rax), %eax
addl $0x1, %eax
cltq
movq %rax, -0x38(%rbp)
movq -0x30(%rbp), %rax
cmpq -0x18(%rbp), %rax
jl 0x6b06a
jmp 0x6b456
movq -0x10(%rbp), %rax
cmpq -0x30(%rbp), %rax
jl 0x6b081
movq -0x10(%rbp), %rax
movq %rax, -0x158(%rbp)
jmp 0x6b08c
movq -0x30(%rbp), %rax
movq %rax, -0x158(%rbp)
movq -0x158(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x18(%rbp), %rax
cmpq -0x38(%rbp), %rax
jg 0x6b0ae
movq -0x18(%rbp), %rax
movq %rax, -0x160(%rbp)
jmp 0x6b0b9
movq -0x38(%rbp), %rax
movq %rax, -0x160(%rbp)
movq -0x160(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
cmpq -0x40(%rbp), %rax
jle 0x6b0df
movq -0x48(%rbp), %rax
subq -0x40(%rbp), %rax
movq %rax, -0x168(%rbp)
jmp 0x6b0ea
xorl %eax, %eax
movq %rax, -0x168(%rbp)
jmp 0x6b0ea
movq -0x168(%rbp), %rax
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x50(%rbp)
je 0x6b443
movq -0x58(%rbp), %rax
movl 0x4(%rax), %eax
addl $0x1, %eax
movq -0x58(%rbp), %rcx
subl (%rcx), %eax
cltq
movq %rax, -0x60(%rbp)
movq -0x58(%rbp), %rax
movl 0xc(%rax), %eax
addl $0x1, %eax
movq -0x58(%rbp), %rcx
subl 0x8(%rcx), %eax
cltq
movq %rax, -0x68(%rbp)
movq -0x58(%rbp), %rax
movswl 0x14(%rax), %eax
cmpl $0x7fff, %eax           # imm = 0x7FFF
jne 0x6b153
movq -0x58(%rbp), %rax
cmpl $0x0, 0x1c(%rax)
jne 0x6b153
movq -0x58(%rbp), %rax
movswl 0x12(%rax), %eax
cmpl $0x0, %eax
jl 0x6b174
movq -0x58(%rbp), %rax
movswl 0x14(%rax), %eax
cmpl $0x7fff, %eax           # imm = 0x7FFF
jge 0x6b309
movq -0x58(%rbp), %rax
cmpl $0x0, 0x1c(%rax)
jne 0x6b309
movq -0x58(%rbp), %rax
movswl 0x14(%rax), %eax
cmpl $0x7fff, %eax           # imm = 0x7FFF
jne 0x6b2be
movq -0x58(%rbp), %rax
cmpl $0x0, 0x1c(%rax)
jne 0x6b2be
movq -0x58(%rbp), %rax
movswl 0x12(%rax), %eax
cmpl $0x0, %eax
jge 0x6b2be
cmpq $0x200, -0x60(%rbp)     # imm = 0x200
jg 0x6b1eb
movq -0x60(%rbp), %rax
cmpq -0x68(%rbp), %rax
jl 0x6b1c7
movq -0x60(%rbp), %rax
movq %rax, -0x170(%rbp)
jmp 0x6b1d2
movq -0x68(%rbp), %rax
movq %rax, -0x170(%rbp)
movq -0x170(%rbp), %rax
cvtsi2sd %rax, %xmm0
movsd %xmm0, -0x178(%rbp)
jmp 0x6b2ab
movq -0x60(%rbp), %rax
cmpq -0x68(%rbp), %rax
jg 0x6b202
movq -0x60(%rbp), %rax
movq %rax, -0x180(%rbp)
jmp 0x6b20d
movq -0x68(%rbp), %rax
movq %rax, -0x180(%rbp)
movq -0x180(%rbp), %rax
cvtsi2sd %rax, %xmm0
cvtsi2sdq -0x60(%rbp), %xmm1
movsd 0x317091(%rip), %xmm2   # 0x3822b8
mulsd %xmm2, %xmm1
movsd 0x316dcd(%rip), %xmm2   # 0x382000
addsd %xmm2, %xmm1
ucomisd %xmm1, %xmm0
jb 0x6b275
movq -0x60(%rbp), %rax
cmpq -0x68(%rbp), %rax
jg 0x6b254
movq -0x60(%rbp), %rax
movq %rax, -0x188(%rbp)
jmp 0x6b25f
movq -0x68(%rbp), %rax
movq %rax, -0x188(%rbp)
movq -0x188(%rbp), %rax
cvtsi2sd %rax, %xmm0
movsd %xmm0, -0x190(%rbp)
jmp 0x6b29b
cvtsi2sdq -0x60(%rbp), %xmm0
movsd 0x317035(%rip), %xmm1   # 0x3822b8
mulsd %xmm1, %xmm0
movsd 0x316d71(%rip), %xmm1   # 0x382000
addsd %xmm1, %xmm0
movsd %xmm0, -0x190(%rbp)
movsd -0x190(%rbp), %xmm0
movsd %xmm0, -0x178(%rbp)
movsd -0x178(%rbp), %xmm0
cvttsd2si %xmm0, %rax
movq %rax, -0x70(%rbp)
jmp 0x6b2cb
movq -0x58(%rbp), %rax
movswq 0x14(%rax), %rax
movq %rax, -0x70(%rbp)
movq -0x50(%rbp), %rax
cmpq -0x60(%rbp), %rax
jge 0x6b2f8
cvtsi2sdq -0x50(%rbp), %xmm0
cvtsi2sdq -0x60(%rbp), %xmm1
divsd %xmm1, %xmm0
cvtsi2sdq -0x70(%rbp), %xmm1
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %rax
movq %rax, -0x70(%rbp)
movq -0x70(%rbp), %rax
addq -0x78(%rbp), %rax
movq %rax, -0x78(%rbp)
jmp 0x6b441
movq -0x50(%rbp), %rax
cmpq -0x60(%rbp), %rax
jne 0x6b329
movq -0x58(%rbp), %rax
movswq 0x14(%rax), %rax
addq -0x78(%rbp), %rax
movq %rax, -0x78(%rbp)
jmp 0x6b43f
jmp 0x6b32b
movq -0x8(%rbp), %rax
movq 0x70(%rax), %rax
movq -0x8(%rbp), %rcx
movq 0x58(%rcx), %rcx
movq -0x20(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rcx
movl 0x18(%rcx), %ecx
shlq %rcx
addq %rcx, %rax
movq %rax, -0x98(%rbp)
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x20(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movl 0x1c(%rax), %eax
movq %rax, -0xa0(%rbp)
movq %rax, -0xa8(%rbp)
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x20(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movl (%rax), %eax
movl %eax, -0x134(%rbp)
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x20(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
movl %eax, -0x130(%rbp)
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x20(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movl %eax, -0x140(%rbp)
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x20(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movl 0xc(%rax), %eax
movl %eax, -0x13c(%rbp)
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x20(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movswl 0x14(%rax), %eax
movl %eax, -0x124(%rbp)
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x20(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movswl 0x14(%rax), %eax
movl %eax, -0x128(%rbp)
movq -0x40(%rbp), %rsi
movq -0x48(%rbp), %rdx
leaq -0x150(%rbp), %rdi
callq 0x6ad30
addq -0x78(%rbp), %rax
movq %rax, -0x78(%rbp)
jmp 0x6b441
jmp 0x6b443
jmp 0x6b445
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
jmp 0x6b01b
movq -0x78(%rbp), %rax
addq $0x190, %rsp            # imm = 0x190
popq %rbp
retq
nopw %cs:(%rax,%rax)