// File: /workspace/github_cpp_makefile_star2_O2/chhylp123[P]hifiasm/Correct.cpp
// Function: ref_cigar_check(char*, UC_Read*, ul_idx_t const*, hpc_t*, All_reads*, long, long, bit_extz_t*)
void ref_cigar_check(char* qstr, UC_Read *tu, const ul_idx_t *uref, hpc_t *hpc_g, All_reads *rref, int64_t id, int64_t rev, bit_extz_t *ez)
{
    int64_t pts = -1, pte = -1, tl = ez->pe-ez->ps+1, ql = ez->te-ez->ts+1, bps, bts, k; 
    char *q, *t; bps = ez->ps; bts = ez->ts;

    q = qstr + ez->ts; 
    t = retrieve_str_seq_exz(tu, ez->ps, tl, pts, pte-pts, rev, uref, hpc_g, rref, id);
    ez->ps = ez->ts = 0; 
    if(!cigar_check(t, q, ez)){
        fprintf(stderr, "[M::%s::] cigar_n::%d\n", __func__, (int32_t)ez->cigar.n);
        for (k = 0; k < (int32_t)ez->cigar.n; k++) {
            fprintf(stderr, "[M::%s::%ld] cigar_len::%u, c::%u\n", __func__, k,
            ez->cigar.a[k]&(0x3fff), (ez->cigar.a[k]>>14));
        }
        
        // fprintf(stderr, "[M::%s::l->%ld] s::%ld, pstr::%.*s\n", __func__, tl, bps, (int32_t)tl, t);
        // fprintf(stderr, "[M::%s::l->%ld] s::%ld, tstr::%.*s\n", __func__, ql, bts, (int32_t)ql, q);
        fprintf(stderr, "[M::%s::l->%ld] s::%ld\n", __func__, tl, bps);
        fprintf(stderr, "[M::%s::l->%ld] s::%ld\n", __func__, ql, bts);
        exit(1);
    }
    ez->ps = bps; ez->ts = bts;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %r9, %rbx
movq %r8, %r11
movq %rcx, %r10
movq %rdx, %rax
movq %rsi, %r8
movq 0x68(%rsp), %r12
movzbl 0x60(%rsp), %r9d
movl 0x10(%r12), %ebp
movl 0x14(%r12), %ecx
subl %ebp, %ecx
incl %ecx
movslq %ecx, %rdx
movl 0x20(%r12), %ecx
movl %ecx, 0xc(%rsp)
movl 0x1c(%r12), %r14d
movslq %ebp, %rsi
movslq %r14d, %r15
leaq (%rdi,%r15), %r13
pushq $-0x1
popq %rcx
movq %r8, %rdi
movq %rsi, 0x18(%rsp)
movq %rdx, 0x20(%rsp)
xorl %r8d, %r8d
pushq %rbx
pushq %r11
pushq %r10
pushq %rax
callq 0x625fc
addq $0x20, %rsp
andl $0x0, 0x1c(%r12)
andl $0x0, 0x10(%r12)
movq %rax, %rdi
movq %r13, %rsi
movq %r12, %rdx
callq 0x626e8
testl %eax, %eax
je 0x33898
movl %ebp, 0x10(%r12)
movl %r14d, 0x1c(%r12)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %r14d, 0x8(%rsp)
movq %r15, 0x10(%rsp)
movq 0x21f737(%rip), %r15    # 0x252fe0
movq (%r15), %rdi
movl 0xa8(%r12), %ecx
leaq 0x1b1223(%rip), %rsi    # 0x1e4ade
leaq 0x1b1233(%rip), %r13    # 0x1e4af5
movq %r13, %rdx
xorl %eax, %eax
callq 0x22b0
leaq 0x1b1232(%rip), %rbp    # 0x1e4b05
xorl %ebx, %ebx
movq 0x18(%rsp), %r14
movslq 0xa8(%r12), %rax
cmpq %rax, %rbx
jge 0x3391a
movq (%r15), %rdi
movq 0xb8(%r12), %rax
movzwl (%rax,%rbx,2), %r9d
movl %r9d, %r8d
andl $0x3fff, %r8d           # imm = 0x3FFF
shrl $0xe, %r9d
movq %rbp, %rsi
movq %r13, %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x22b0
incq %rbx
jmp 0x338da
movl 0xc(%rsp), %eax
subl 0x8(%rsp), %eax
incl %eax
movslq %eax, %rbx
movq (%r15), %rdi
leaq 0x1b11f7(%rip), %r12    # 0x1e4b28
leaq 0x1b11bd(%rip), %r13    # 0x1e4af5
movq %r12, %rsi
movq %r13, %rdx
movq 0x20(%rsp), %rcx
movq %r14, %r8
xorl %eax, %eax
callq 0x22b0
movq (%r15), %rdi
movq %r12, %rsi
movq %r13, %rdx
movq %rbx, %rcx
movq 0x10(%rsp), %r8
xorl %eax, %eax
callq 0x22b0
pushq $0x1
popq %rdi
callq 0x2250