// File: chhylp123[P]hifiasm/Correct.cpp
// Function: verify_aln(int, overlap_region*, UC_Read*, UC_Read*, All_reads*, hpc_t*, ul_idx_t const*)
void verify_aln(int32_t sid, overlap_region *z, UC_Read* qu, UC_Read* tu, All_reads *rref, hpc_t *hpc_g, const ul_idx_t *uref)
{
    uint64_t tl, tid = z->y_id, rev = z->y_pos_strand, i; char *tstr, *qstr; window_list *p;
    if(hpc_g) tl = hpc_len(*hpc_g, tid);
    else if(uref) tl = uref->ug->u.a[tid].len;
    else tl = Get_READ_LENGTH((*rref), tid);
    
    qstr = qu->seq; resize_UC_Read(tu, tl);
    if(rref) {
        recover_UC_Read_sub_region(tu->seq, 0, tl, rev, rref, tid); tstr = tu->seq;
    } else {
        tstr = return_str_seq_exz(tu->seq, 0, tl, rev, hpc_g, uref, tid);
    }
    
    for (i = 0; i < z->w_list.n; i++) {
        p = &(z->w_list.a[i]);
        if(p->y_end == -1) continue;
        if(!wcigar_check(p, &(z->w_list), qstr, tstr)) break;
    }
    if(i < z->w_list.n) {
        fprintf(stderr, "sid::%d, tid::%lu, i::%lu, qs::%d, qe::%d, ts::%d, te::%d, err::%d\n", sid, tid, i, 
        p->x_start, p->x_end, p->y_start, p->y_end, p->error); 
        prt_cigar(z->w_list.c.a+p->cidx, p->clen);
        fprintf(stderr, "[tstr::[%u, %u]] %.*s\n", z->y_pos_s, z->y_pos_e, p->y_end+1-p->y_start, tstr+p->y_start);
        fprintf(stderr, "[qstr::[%u, %u]] %.*s\n", z->x_pos_s, z->x_pos_e, p->x_end+1-p->x_start, qstr+p->x_start);
        exit(0);
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
subq $0x88, %rsp
movq 0x10(%rbp), %rax
movl %edi, -0xc(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq %r9, -0x38(%rbp)
movq -0x18(%rbp), %rax
movl 0x10(%rax), %eax
movq %rax, -0x48(%rbp)
movq -0x18(%rbp), %rax
movl 0x1c(%rax), %eax
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x38(%rbp)
je 0x57628
movq -0x38(%rbp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rax
imulq $0x28, -0x48(%rbp), %rcx
addq %rcx, %rax
movl (%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
sarl %eax
cltq
movq %rax, -0x40(%rbp)
jmp 0x57667
cmpq $0x0, 0x10(%rbp)
je 0x57651
movq 0x10(%rbp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rax
imulq $0x28, -0x48(%rbp), %rcx
addq %rcx, %rax
movl (%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl %eax, %eax
movq %rax, -0x40(%rbp)
jmp 0x57665
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x48(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x40(%rbp)
jmp 0x57667
movq -0x20(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x68(%rbp)
movq -0x28(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq 0xa62c0
cmpq $0x0, -0x30(%rbp)
je 0x576b6
movq -0x28(%rbp), %rax
movq (%rax), %rdi
movq -0x40(%rbp), %rdx
movq -0x50(%rbp), %rax
movq -0x30(%rbp), %r8
movq -0x48(%rbp), %r9
xorl %ecx, %ecx
movl %ecx, %esi
movzbl %al, %ecx
callq 0x9a30
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x60(%rbp)
jmp 0x576e5
movq -0x28(%rbp), %rax
movq (%rax), %rdi
movq -0x40(%rbp), %rdx
movq -0x50(%rbp), %rax
movb %al, %cl
movq -0x38(%rbp), %r8
movq 0x10(%rbp), %r9
movq -0x48(%rbp), %rax
xorl %esi, %esi
movzbl %cl, %ecx
movq %rax, (%rsp)
callq 0xa8880
movq %rax, -0x60(%rbp)
movq $0x0, -0x58(%rbp)
movq -0x58(%rbp), %rax
movq -0x18(%rbp), %rcx
cmpq 0x48(%rcx), %rax
jae 0x5774f
movq -0x18(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x58(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq %rax, -0x70(%rbp)
movq -0x70(%rbp), %rax
cmpl $-0x1, 0xc(%rax)
jne 0x5771e
jmp 0x57741
movq -0x70(%rbp), %rdi
movq -0x18(%rbp), %rsi
addq $0x48, %rsi
movq -0x68(%rbp), %rdx
movq -0x60(%rbp), %rcx
callq 0x57510
cmpq $0x0, %rax
jne 0x5773f
jmp 0x5774f
jmp 0x57741
movq -0x58(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x58(%rbp)
jmp 0x576ed
movq -0x58(%rbp), %rax
movq -0x18(%rbp), %rcx
cmpq 0x48(%rcx), %rax
jae 0x57873
movq 0x36c878(%rip), %rax    # 0x3c3fe0
movq (%rax), %rdi
movl -0xc(%rbp), %edx
movq -0x48(%rbp), %rcx
movq -0x58(%rbp), %r8
movq -0x70(%rbp), %rax
movl (%rax), %r9d
movq -0x70(%rbp), %rax
movl 0x4(%rax), %ebx
movq -0x70(%rbp), %rax
movl 0x8(%rax), %r11d
movq -0x70(%rbp), %rax
movl 0xc(%rax), %r10d
movq -0x70(%rbp), %rax
movswl 0x14(%rax), %eax
leaq 0x32bb61(%rip), %rsi    # 0x383304
movl %ebx, (%rsp)
movl %r11d, 0x8(%rsp)
movl %r10d, 0x10(%rsp)
movl %eax, 0x18(%rsp)
movb $0x0, %al
callq 0x22a0
movq -0x18(%rbp), %rax
movq 0x70(%rax), %rdi
movq -0x70(%rbp), %rax
movl 0x18(%rax), %eax
shlq %rax
addq %rax, %rdi
movq -0x70(%rbp), %rax
movl 0x1c(%rax), %esi
callq 0x4efb0
movq 0x36c7fd(%rip), %rax    # 0x3c3fe0
movq (%rax), %rdi
movq -0x18(%rbp), %rax
movl 0x14(%rax), %edx
movq -0x18(%rbp), %rax
movl 0x18(%rax), %ecx
movq -0x70(%rbp), %rax
movl 0xc(%rax), %r8d
addl $0x1, %r8d
movq -0x70(%rbp), %rax
subl 0x8(%rax), %r8d
movq -0x60(%rbp), %r9
movq -0x70(%rbp), %rax
movslq 0x8(%rax), %rax
addq %rax, %r9
leaq 0x32bb2a(%rip), %rsi    # 0x383348
movb $0x0, %al
callq 0x22a0
movq 0x36c7b4(%rip), %rax    # 0x3c3fe0
movq (%rax), %rdi
movq -0x18(%rbp), %rax
movl 0x4(%rax), %edx
movq -0x18(%rbp), %rax
movl 0x8(%rax), %ecx
movq -0x70(%rbp), %rax
movl 0x4(%rax), %r8d
addl $0x1, %r8d
movq -0x70(%rbp), %rax
subl (%rax), %r8d
movq -0x68(%rbp), %r9
movq -0x70(%rbp), %rax
movslq (%rax), %rax
addq %rax, %r9
leaq 0x32bafa(%rip), %rsi    # 0x38335f
movb $0x0, %al
callq 0x22a0
xorl %edi, %edi
callq 0x2240
addq $0x88, %rsp
popq %rbx
popq %rbp
retq
nopl (%rax)