// File: 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
movq %rsp, %rbp
subq $0xc0, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x18(%rbp), %rdi
movl -0xc(%rbp), %eax
movl %eax, %edx
leaq 0x16e5fa(%rip), %rsi    # 0x3c52d0
callq 0xa380
movq $0x0, -0x38(%rbp)
movq -0x38(%rbp), %rax
cmpq -0x28(%rbp), %rax
jge 0x256faf
movq -0x8(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x38(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rax
movq 0x48(%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x60(%rbp), %rax
cmpl $0x0, 0x1c(%rax)
je 0x256d38
movq -0x20(%rbp), %rdi
movq -0x60(%rbp), %rax
movl 0x10(%rax), %eax
movl %eax, %edx
leaq 0x16e59f(%rip), %rsi    # 0x3c52d0
callq 0xa500
jmp 0x256d51
movq -0x20(%rbp), %rdi
movq -0x60(%rbp), %rax
movl 0x10(%rax), %eax
movl %eax, %edx
leaq 0x16e584(%rip), %rsi    # 0x3c52d0
callq 0xa380
movq $0x0, -0x30(%rbp)
movq -0x30(%rbp), %rax
cmpq -0x40(%rbp), %rax
jge 0x256f9c
movq -0x60(%rbp), %rax
movq 0x70(%rax), %rax
movq -0x60(%rbp), %rcx
movq 0x58(%rcx), %rcx
movq -0x30(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rcx
movl 0x18(%rcx), %ecx
shlq %rcx
addq %rcx, %rax
movq %rax, -0x68(%rbp)
movq -0x60(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x30(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movl 0x1c(%rax), %eax
movq %rax, -0x70(%rbp)
movq %rax, -0x78(%rbp)
movl $0x0, -0x58(%rbp)
movq -0x60(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x30(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movslq (%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x60(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x30(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movslq 0x8(%rax), %rax
movq %rax, -0x50(%rbp)
movl -0x58(%rbp), %eax
cmpq -0x78(%rbp), %rax
jae 0x256f89
movq -0x48(%rbp), %rax
movq %rax, -0x90(%rbp)
movq -0x50(%rbp), %rax
movq %rax, -0xa0(%rbp)
movl -0x58(%rbp), %esi
leaq -0x78(%rbp), %rdi
leaq -0xa2(%rbp), %rdx
leaq -0x54(%rbp), %rcx
callq 0xa1ee0
movl %eax, -0x58(%rbp)
movzwl -0xa2(%rbp), %eax
cmpl $0x2, %eax
je 0x256e3d
movl -0x54(%rbp), %eax
addq -0x48(%rbp), %rax
movq %rax, -0x48(%rbp)
movzwl -0xa2(%rbp), %eax
cmpl $0x3, %eax
je 0x256e54
movl -0x54(%rbp), %eax
addq -0x50(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x48(%rbp), %rax
movq %rax, -0x88(%rbp)
movq -0x50(%rbp), %rax
movq %rax, -0x98(%rbp)
movzwl -0xa2(%rbp), %eax
cmpl $0x0, %eax
jne 0x256f84
movq -0x18(%rbp), %rax
movq (%rax), %rdi
addq -0x90(%rbp), %rdi
movq -0x20(%rbp), %rax
movq (%rax), %rsi
addq -0xa0(%rbp), %rsi
movq -0x88(%rbp), %rdx
subq -0x90(%rbp), %rdx
callq 0x20b0
cmpl $0x0, %eax
je 0x256f82
movq 0x16d127(%rip), %rax    # 0x3c3fe0
movq (%rax), %rdi
movq -0x90(%rbp), %rcx
movq -0x88(%rbp), %r8
movq -0xa0(%rbp), %r9
movq -0x98(%rbp), %r10
movq -0x60(%rbp), %rax
movl 0x1c(%rax), %eax
movl %eax, %edx
leaq 0x12bfb3(%rip), %rax    # 0x382e9b
movsbl (%rax,%rdx), %eax
leaq 0x138352(%rip), %rsi    # 0x38f245
leaq 0x138379(%rip), %rdx    # 0x38f273
movq %r10, (%rsp)
movl %eax, 0x8(%rsp)
movb $0x0, %al
callq 0x22a0
movq 0x16d0d0(%rip), %rax    # 0x3c3fe0
movq (%rax), %rdi
movq -0x60(%rbp), %rax
movl (%rax), %edx
movq -0x88(%rbp), %rax
subq -0x90(%rbp), %rax
movl %eax, %ecx
movq -0x18(%rbp), %rax
movq (%rax), %r8
addq -0x90(%rbp), %r8
leaq 0x13834a(%rip), %rsi    # 0x38f288
movb $0x0, %al
callq 0x22a0
movq 0x16d094(%rip), %rax    # 0x3c3fe0
movq (%rax), %rdi
movq -0x60(%rbp), %rax
movl 0x10(%rax), %edx
movq -0x98(%rbp), %rax
subq -0xa0(%rbp), %rax
movl %eax, %ecx
movq -0x20(%rbp), %rax
movq (%rax), %r8
addq -0xa0(%rbp), %r8
leaq 0x13831d(%rip), %rsi    # 0x38f298
movb $0x0, %al
callq 0x22a0
jmp 0x256f84
jmp 0x256de9
jmp 0x256f8b
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0x256d59
jmp 0x256f9e
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x256ce3
addq $0xc0, %rsp
popq %rbp
retq
nopl (%rax,%rax)