// File: /workspace/github_cpp_makefile_star2_O1/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 0x10aa85(%rip), %rsi    # 0x28b230
movq %rax, 0x28(%rsp)
movq %rax, %rdi
callq 0x33cf8
movq %rbx, 0x38(%rsp)
testq %rbx, %rbx
jle 0x180a13
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 0x180809
movq 0x10(%rsp), %rdi
leaq 0x10aa2e(%rip), %rsi    # 0x28b230
callq 0x33dc3
jmp 0x18081a
movq 0x10(%rsp), %rdi
leaq 0x10aa1b(%rip), %rsi    # 0x28b230
callq 0x33cf8
cmpq $0x0, 0x20(%rsp)
jle 0x180a00
addq %rbx, 0x8(%rsp)
xorl %ecx, %ecx
movq 0x8(%rsp), %rax
movq 0x58(%rax), %rax
movq %rcx, 0x58(%rsp)
shlq $0x5, %rcx
movl 0x1c(%rax,%rcx), %r13d
testl %r13d, %r13d
je 0x1809ed
movq 0x8(%rsp), %rdx
movq 0x70(%rdx), %rdx
movl 0x18(%rax,%rcx), %esi
leaq (%rdx,%rsi,2), %r11
movslq 0x8(%rax,%rcx), %rdx
movslq (%rax,%rcx), %r12
xorl %ebx, %ebx
movq %r11, 0x30(%rsp)
movq %rdx, %rbp
movq %r12, %r9
movl %ebx, %eax
movzwl (%r11,%rax,2), %eax
movl %eax, %ecx
shrl $0xe, %ecx
movl %eax, %edx
andl $0x3fff, %edx           # imm = 0x3FFF
incl %ebx
cmpl %ebx, %r13d
jbe 0x1808ba
movl %ebx, %esi
leaq (%r11,%rsi,2), %rsi
movzwl (%rsi), %edi
movl %edi, %r8d
shrl $0xe, %r8d
cmpl %ecx, %r8d
jne 0x1808ba
andl $0x3fff, %edi           # imm = 0x3FFF
addl %edi, %edx
incl %ebx
addq $0x2, %rsi
cmpl %ebx, %r13d
jne 0x180895
movl %r13d, %ebx
cmpw $0x2, %cx
movl %edx, %r14d
movq %r14, %r15
movl $0x0, %edx
cmoveq %rdx, %r15
cmpw $0x3, %cx
cmoveq %rdx, %r14
leaq (%r15,%r9), %r12
leaq (%r14,%rbp), %rdx
movzwl %ax, %eax
cmpl $0x3fff, %eax           # imm = 0x3FFF
ja 0x18092b
movq 0x28(%rsp), %rax
movq (%rax), %rdi
addq %r9, %rdi
movq 0x10(%rsp), %rax
movq (%rax), %rsi
addq %rbp, %rsi
movq %rdx, 0x18(%rsp)
movq %r15, %rdx
movq %r12, 0x60(%rsp)
movq %r9, %r12
callq 0x21a0
movq 0x18(%rsp), %rdx
movq %rbp, %r9
movq %r12, %rbp
movq 0x60(%rsp), %r12
movq 0x30(%rsp), %r11
testl %eax, %eax
jne 0x180939
cmpl %ebx, %r13d
ja 0x18086e
jmp 0x1809ed
movq 0x1096a0(%rip), %rax    # 0x289fe0
movq (%rax), %rdi
movq 0x8(%rsp), %rax
movl 0x1c(%rax), %eax
leaq 0xa5871(%rip), %rcx     # 0x2261c3
movsbl (%rax,%rcx), %r10d
leaq 0xb1aba(%rip), %rsi     # 0x232418
leaq 0xb1ae1(%rip), %rdx     # 0x232446
movq %rbp, %rcx
movq %r12, %r8
xorl %eax, %eax
pushq %r10
pushq 0x20(%rsp)
movq %r9, 0x60(%rsp)
callq 0x22b0
addq $0x10, %rsp
movq 0x109658(%rip), %rax    # 0x289fe0
movq (%rax), %rdi
movq 0x8(%rsp), %rax
movl (%rax), %edx
movq 0x28(%rsp), %rax
addq (%rax), %rbp
leaq 0xb1aba(%rip), %rsi     # 0x23245b
movl %r15d, %ecx
movq %rbp, %r8
xorl %eax, %eax
callq 0x22b0
movq 0x10962b(%rip), %rax    # 0x289fe0
movq (%rax), %rdi
movq 0x8(%rsp), %rax
movl 0x10(%rax), %edx
movq 0x10(%rsp), %rax
movq 0x50(%rsp), %r8
addq (%rax), %r8
leaq 0xb1a97(%rip), %rsi     # 0x23246b
movl %r14d, %ecx
xorl %eax, %eax
callq 0x22b0
movq 0x18(%rsp), %rdx
movq 0x30(%rsp), %r11
jmp 0x18092b
movq 0x58(%rsp), %rcx
incq %rcx
cmpq 0x20(%rsp), %rcx
jne 0x18082d
movq 0x48(%rsp), %rcx
incq %rcx
cmpq 0x38(%rsp), %rcx
jne 0x1807c8
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq