// File: /workspace/github_cpp_makefile_star2_O1/chhylp123[P]hifiasm/Correct.cpp
// Function: prt_sub_cigar(overlap_region*, unsigned long, unsigned long, unsigned long)
void prt_sub_cigar(overlap_region* z, uint64_t str_l, uint64_t site, uint64_t win)
{
    uint64_t k, s, e, ci, xi, yi, ws, we, os, oe, ovlp; uint32_t cl; uint16_t c; bit_extz_t ez; char cm[4]; 
    cm[0] = 'M'; cm[1] = 'S'; cm[2] = 'I'; cm[3] = 'D';  
    s = ((site >= win)?(site-win):(0)); 
    e = (((site+win+1) <= str_l)?(site+win+1):(str_l));

    fprintf(stderr, "[M::%s-site::%lu] [%lu, %lu)\n", __func__, site, s, e);

    for (k = 0; k < z->w_list.n; k++) {
        set_bit_extz_t(ez, (*z), k); ci = 0; xi = ez.ts; yi = ez.ps;
        while (ci < ez.cigar.n) {
            ws = xi;
            ci = pop_trace(&(ez.cigar), ci, &c, &cl);
            if(c!=2) xi += cl;
            if(c!=3) yi += cl; 
            we = xi; 

            os = MAX(s, ws); oe = MIN(e, we);
            ovlp = ((oe>os)? (oe-os):0);

            if(c != 2) {
                if(!ovlp) continue;
            } else {///ws == we
                if(ws < s || ws >= e) continue;
                ovlp = cl;
            }

            fprintf(stderr, "%lu%c[%lu,%lu)", ovlp, cm[c], os, oe);
        }
        fprintf(stderr, "\n");
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdx, %rax
movq %rsi, %rbx
movq %rdi, %r14
movl $0x4449534d, 0x4(%rsp)  # imm = 0x4449534D
subq %rcx, %rdx
movl $0x0, %r15d
cmovaeq %rdx, %r15
addq %rax, %rcx
incq %rcx
cmpq %rsi, %rcx
cmovbq %rcx, %rbx
movq 0x284c63(%rip), %rcx    # 0x289fe0
movq (%rcx), %rdi
leaq 0x220824(%rip), %rsi    # 0x225bab
leaq 0x22084d(%rip), %rdx    # 0x225bdb
movq %rax, %rcx
movq %r15, %r8
movq %rbx, %r9
xorl %eax, %eax
callq 0x22b0
cmpq $0x0, 0x48(%r14)
je 0x54d8
xorl %ecx, %ecx
movq %r14, 0x8(%rsp)
movq 0x58(%r14), %rax
movq %rcx, 0x10(%rsp)
shlq $0x5, %rcx
movl 0x1c(%rax,%rcx), %r14d
testl %r14d, %r14d
je 0x54af
movq 0x8(%rsp), %rdx
movq 0x70(%rdx), %rdx
movl 0x18(%rax,%rcx), %esi
leaq (%rdx,%rsi,2), %r13
movslq (%rax,%rcx), %rbp
xorl %r12d, %r12d
movq %rbp, %rcx
movl %r12d, %eax
movzwl (%r13,%rax,2), %edx
movl %edx, %eax
shrl $0xe, %eax
andl $0x3fff, %edx           # imm = 0x3FFF
incl %r12d
cmpl %r12d, %r14d
jbe 0x5436
movl %r12d, %esi
leaq (,%rsi,2), %rsi
addq %r13, %rsi
movzwl (%rsi), %edi
movl %edi, %r8d
shrl $0xe, %r8d
cmpl %eax, %r8d
jne 0x5436
andl $0x3fff, %edi           # imm = 0x3FFF
addl %edi, %edx
incl %r12d
addq $0x2, %rsi
cmpl %r12d, %r14d
jne 0x5410
movl %r14d, %r12d
cmpw $0x2, %ax
movl %edx, %edx
movl $0x0, %ebp
cmovneq %rdx, %rbp
addq %rcx, %rbp
cmpq %rcx, %r15
movq %rcx, %r8
cmovaq %r15, %r8
cmpq %rbp, %rbx
movq %rbp, %r9
cmovbq %rbx, %r9
cmpw $0x2, %ax
jne 0x547f
cmpq %r15, %rcx
setb %sil
cmpq %rbx, %rcx
setae %cl
orb %sil, %cl
je 0x5490
cmpl %r12d, %r14d
ja 0x53e3
jmp 0x54af
movq %r9, %rcx
movl $0x0, %edx
subq %r8, %rcx
cmovaeq %rcx, %rdx
jbe 0x5474
movq 0x284b49(%rip), %rcx    # 0x289fe0
movq (%rcx), %rdi
movsbl 0x4(%rsp,%rax), %ecx
leaq 0x220743(%rip), %rsi    # 0x225be9
xorl %eax, %eax
callq 0x22b0
jmp 0x5474
movq 0x284b2a(%rip), %rax    # 0x289fe0
movq (%rax), %rsi
pushq $0xa
popq %rdi
callq 0x2270
movq 0x10(%rsp), %rcx
incq %rcx
movq 0x8(%rsp), %r14
cmpq 0x48(%r14), %rcx
jb 0x53b0
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq