// File: /workspace/github_cpp_makefile_star2_O3/chhylp123[P]hifiasm/ecovlp.cpp
// Function: debug_mm_exact_cigar(overlap_region_alloc*, unsigned int, UC_Read*, UC_Read*)
void debug_mm_exact_cigar(overlap_region_alloc* ol, uint32_t qid, UC_Read *qu, UC_Read *tu)
{
    int64_t on = ol->length, k, i, zwn, xk, yk; uint32_t cl, ck; ///bit_extz_t ez; 
    overlap_region *z; asg16_v ct; uint64_t wx[2], wy[2]; uint16_t c;
    recover_UC_Read(qu, &R_INF, qid);

    for (i = 0; i < on; i++) {
        z = &(ol->list[i]); zwn = z->w_list.n; 
        if(z->y_pos_strand) {
            recover_UC_Read_RC(tu, &R_INF, z->y_id);
        } else {
            recover_UC_Read(tu, &R_INF, z->y_id); ///b->z.length
        }

        // fprintf(stderr, "[M::%s] x_id::%u\ty_id::%u\tx::[%u, %u)\ty::[%u, %u)\tzwn::%ld\n", 
        //         __func__, z->x_id, z->y_id, z->x_pos_s, z->x_pos_e + 1, z->y_pos_s, z->y_pos_e + 1, zwn);
        // fprintf(stderr, "qstr(%lld)::%.*s\n", qu->length, (int32_t)(qu->length), qu->seq);
        // fprintf(stderr, "tstr(%lld)::%.*s\n", tu->length, (int32_t)(tu->length), tu->seq);

        for (k = 0; k < zwn; k++) {
            // set_bit_extz_t(ez, (*z), k);
            // if(!cigar_check(tu->seq, qu->seq, &ez)) {
            //     fprintf(stderr, "\n[M::%s] x_id::%u, y_id::%u, x::[%u, %u), y::[%u, %u)\n", __func__, z->x_id, z->y_id, z->x_pos_s, z->x_pos_e + 1, z->y_pos_s, z->y_pos_e + 1);
            //     exit(1);
            // }
            // continue;
            ct.a = z->w_list.c.a + z->w_list.a[k].cidx;
            ct.n = ct.m = z->w_list.a[k].clen; ck = 0; 
            xk = z->w_list.a[k].x_start; yk = z->w_list.a[k].y_start;
            while (ck < ct.n) {
                wx[0] = xk; wy[0] = yk;
                ck = pop_trace(&ct, ck, &c, &cl);
                if(c != 2) xk += cl;
                if(c != 3) yk += cl;
                wx[1] = xk; wy[1] = yk;
                if(c == 0) {
                    if(memcmp(qu->seq + wx[0], tu->seq + wy[0], wx[1] - wx[0])) {
                        fprintf(stderr, "\n-0-[M::%s]\teq::[%lu,\t%lu)\tet::[%lu,\t%lu)\t%c\n", __func__, wx[0], wx[1], wy[0], wy[1], "+-"[z->y_pos_strand]);
                        fprintf(stderr, "qstr(%u)::%.*s\n", z->x_id, (int32_t)(wx[1] - wx[0]), qu->seq + wx[0]);
                        fprintf(stderr, "tstr(%u)::%.*s\n", z->y_id, (int32_t)(wy[1] - wy[0]), tu->seq + wy[0]);
                        // exit(1);
                    } 
                    // else {
                    //     fprintf(stderr, "\n-1-[M::%s]\teq::[%lu,\t%lu)\tet::[%lu,\t%lu)\t%c\n", __func__, wx[0], wx[1], wy[0], wy[1], "+-"[z->y_pos_strand]);
                    //     fprintf(stderr, "qstr(%u)::%.*s\n", z->x_id, (int32_t)(wx[1] - wx[0]), qu->seq + wx[0]);
                    //     fprintf(stderr, "tstr(%u)::%.*s\n", z->y_id, (int32_t)(wy[1] - wy[0]), tu->seq + wy[0]);
                    // }
                }
            }
        }
        
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rcx, 0x10(%rsp)
movq %rdx, %rax
movq %rdi, 0x40(%rsp)
movq 0x10(%rdi), %rbx
movl %esi, %edx
leaq 0x10e549(%rip), %rsi    # 0x296230
movq %rax, 0x28(%rsp)
movq %rax, %rdi
callq 0x333e0
movq %rbx, 0x38(%rsp)
testq %rbx, %rbx
jle 0x187f51
xorl %ecx, %ecx
movq 0x40(%rsp), %rax
movq (%rax), %rax
imulq $0xa8, %rcx, %rbx
movq 0x48(%rax,%rbx), %rdx
movq %rdx, 0x20(%rsp)
cmpl $0x0, 0x1c(%rax,%rbx)
movq %rax, 0x8(%rsp)
movl 0x10(%rax,%rbx), %edx
movq %rcx, 0x48(%rsp)
je 0x187d45
movq 0x10(%rsp), %rdi
leaq 0x10e4f2(%rip), %rsi    # 0x296230
callq 0x334a6
jmp 0x187d56
movq 0x10(%rsp), %rdi
leaq 0x10e4df(%rip), %rsi    # 0x296230
callq 0x333e0
cmpq $0x0, 0x20(%rsp)
jle 0x187f3e
addq %rbx, 0x8(%rsp)
xorl %ecx, %ecx
movq 0x8(%rsp), %rax
movq 0x58(%rax), %rax
movq %rcx, 0x50(%rsp)
shlq $0x5, %rcx
movl 0x1c(%rax,%rcx), %r14d
testl %r14d, %r14d
je 0x187f2b
movq 0x8(%rsp), %rdx
movq 0x70(%rdx), %rdx
movl 0x18(%rax,%rcx), %esi
leaq (%rdx,%rsi,2), %r11
movslq 0x8(%rax,%rcx), %rbp
movslq (%rax,%rcx), %r15
xorl %ebx, %ebx
movq %r11, 0x30(%rsp)
movq %rbp, %r13
movq %r15, %r9
movl %ebx, %esi
movzwl (%r11,%rsi,2), %eax
movl %eax, %ecx
shrl $0xe, %ecx
movl %eax, %edx
andl $0x3fff, %edx           # imm = 0x3FFF
incl %ebx
cmpl %ebx, %r14d
jbe 0x187df8
leaq (%r11,%rsi,2), %rsi
addq $0x2, %rsi
movzwl (%rsi), %edi
movl %edi, %r8d
shrl $0xe, %r8d
cmpl %ecx, %r8d
jne 0x187df8
andl $0x3fff, %edi           # imm = 0x3FFF
addl %edi, %edx
incl %ebx
addq $0x2, %rsi
cmpl %ebx, %r14d
jne 0x187dd3
movl %r14d, %ebx
movl %edx, %edx
leaq (%r9,%rdx), %r8
cmpw $0x2, %cx
movq %r8, %r15
cmoveq %r9, %r15
leaq (%rdx,%r13), %rbp
cmpw $0x3, %cx
movq %rbp, 0x18(%rsp)
cmoveq %r13, %rbp
movzwl %ax, %eax
cmpl $0x3fff, %eax           # imm = 0x3FFF
ja 0x187e71
movq 0x28(%rsp), %rax
movq (%rax), %rdi
addq %r9, %rdi
movq 0x10(%rsp), %rax
movq (%rax), %rsi
addq %r13, %rsi
movq %rdx, 0x60(%rsp)
movq %r15, 0x58(%rsp)
movq %r9, %r15
movq %rbp, %r12
movq %r8, %rbp
callq 0x21a0
movq %rbp, %r8
movq %r12, %rbp
movq %r13, %r9
movq %r15, %r13
movq 0x58(%rsp), %r15
movq 0x60(%rsp), %r12
movq 0x30(%rsp), %r11
testl %eax, %eax
jne 0x187e7f
cmpl %ebx, %r14d
ja 0x187daa
jmp 0x187f2b
movq 0x10d15a(%rip), %rax    # 0x294fe0
movq (%rax), %rdi
movq 0x8(%rsp), %rax
movl 0x1c(%rax), %eax
leaq 0xaa43b(%rip), %rcx     # 0x2322d3
movsbl (%rax,%rcx), %r10d
leaq 0xb67c4(%rip), %rsi     # 0x23e668
leaq 0xb67eb(%rip), %rdx     # 0x23e696
movq %r13, %rcx
xorl %eax, %eax
pushq %r10
pushq 0x20(%rsp)
movq %r9, 0x28(%rsp)
callq 0x22b0
addq $0x10, %rsp
movq 0x10d115(%rip), %rax    # 0x294fe0
movq (%rax), %rdi
movq 0x8(%rsp), %rax
movl (%rax), %edx
movq 0x28(%rsp), %rax
addq (%rax), %r13
leaq 0xb67c7(%rip), %rsi     # 0x23e6ab
movl %r12d, %ecx
movq %r13, %r8
xorl %eax, %eax
callq 0x22b0
movq 0x10d0e8(%rip), %rax    # 0x294fe0
movq (%rax), %rdi
movq 0x8(%rsp), %rax
movl 0x10(%rax), %edx
movq 0x10(%rsp), %rax
movq 0x18(%rsp), %r8
addq (%rax), %r8
leaq 0xb67a4(%rip), %rsi     # 0x23e6bb
movl %r12d, %ecx
xorl %eax, %eax
callq 0x22b0
movq 0x30(%rsp), %r11
jmp 0x187e71
movq 0x50(%rsp), %rcx
incq %rcx
cmpq 0x20(%rsp), %rcx
jne 0x187d69
movq 0x48(%rsp), %rcx
incq %rcx
cmpq 0x38(%rsp), %rcx
jne 0x187d04
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq