// File: /workspace/github_cpp_makefile_star2_O3/chhylp123[P]hifiasm/ecovlp.cpp
// Function: prt_ovlp_sam_0(char*, _IO_FILE*, char*, int, char*, int, char*, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, bit_extz_t*)
void prt_ovlp_sam_0(char *cm, FILE *fp, char *ref_id, int32_t ref_id_n, char *qry_id, int32_t qry_id_n, char *qry_seq, uint64_t qry_seq_n, uint64_t rs, uint64_t re, uint64_t qs, uint64_t qe, uint64_t flag, uint64_t err0, bit_extz_t *ez)
{
    uint64_t ci = 0, err1 = 0; uint16_t c; uint32_t cl, cl0 = 0; char c0 = (char)-1;
    fprintf(fp, "%.*s\t%lu\t%.*s\t%lu\t60\t", qry_id_n, qry_id, flag, ref_id_n, ref_id, rs + 1);

    if(qs) fprintf(fp, "%luS", qs);
    while (ci < ez->cigar.n) {
        ci = pop_trace(&(ez->cigar), ci, &c, &cl);
        if(c0 == cm[c]) {
            cl0 += cl;
        } else {
            if(c0 != ((char)-1)) {
                fprintf(fp, "%u%c", cl0, c0);
            }
            cl0 = cl; c0 = cm[c];
        }
        // fprintf(fp, "%u%c", cl, cm[c]);
        if(c != 0) err1 += cl;
    }
    if(cl0) fprintf(fp, "%u%c", cl0, c0);
    if(qry_seq_n > qe) fprintf(fp, "%luS", qry_seq_n - qe);
    fprintf(fp, "\t*\t0\t0\t%.*s\t", (int32_t)qry_seq_n, qry_seq);
    for (ci = 0; ci < qry_seq_n; ci++) fprintf(fp, "~");
    assert(err0 == err1);
    fprintf(fp, "\tNM:i:%lu\n", err0);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %r8, %r11
movl %ecx, %eax
movq %rdx, %r10
movq %rsi, %r14
movq %rdi, 0x20(%rsp)
movq 0xb0(%rsp), %rcx
movq %rcx, 0x28(%rsp)
movq 0xa8(%rsp), %r13
movq 0x98(%rsp), %rcx
movq %rcx, 0x30(%rsp)
movq 0x90(%rsp), %rbp
movq 0x78(%rsp), %r15
movq 0x70(%rsp), %rcx
movq %rcx, 0x18(%rsp)
movq 0xa0(%rsp), %r8
movq 0x80(%rsp), %rbx
incq %rbx
leaq 0xb6020(%rip), %rsi     # 0x23e6cb
movq %r14, %rdi
movl %r9d, %edx
movq %r11, %rcx
movl %eax, %r9d
xorl %eax, %eax
pushq %rbx
pushq %r10
callq 0x22b0
addq $0x10, %rsp
testq %rbp, %rbp
je 0x1886de
leaq 0xb6010(%rip), %rsi     # 0x23e6e1
movq %r14, %rdi
movq %rbp, %rdx
xorl %eax, %eax
callq 0x22b0
movq 0x28(%rsp), %r10
movq 0xa8(%r10), %rcx
testq %rcx, %rcx
je 0x1887db
movq %r13, 0x10(%rsp)
movq %r14, 0x8(%rsp)
movb $-0x1, %dil
xorl %eax, %eax
xorl %r12d, %r12d
xorl %ebp, %ebp
movq 0x20(%rsp), %r9
movl %eax, %edx
movl %edi, %esi
movq 0xb8(%r10), %rax
movzwl (%rax,%rbp,2), %r13d
movl %r13d, %r14d
shrl $0xe, %r14d
movl %r13d, %ebx
andl $0x3fff, %ebx           # imm = 0x3FFF
incl %ebp
cmpq %rbp, %rcx
jbe 0x188751
movzwl (%rax,%rbp,2), %edi
movl %edi, %r8d
shrl $0xe, %r8d
cmpl %r14d, %r8d
jne 0x18874f
andl $0x3fff, %edi           # imm = 0x3FFF
addl %edi, %ebx
incl %ebp
jmp 0x18872e
movl %ebp, %ebp
movb (%r9,%r14), %dil
cmpb %dil, %sil
jne 0x188762
addl %ebx, %edx
movl %edx, %eax
movl %esi, %edi
jmp 0x188798
movl %ebx, %eax
cmpb $-0x1, %sil
je 0x188798
movsbl %sil, %ecx
movq 0x8(%rsp), %rdi
leaq 0xa9bf4(%rip), %rsi     # 0x23236e
xorl %eax, %eax
callq 0x22b0
movq 0x28(%rsp), %r10
movq 0x20(%rsp), %r9
movb (%r9,%r14), %dil
movq 0xa8(%r10), %rcx
movl %ebx, %eax
movzwl %r13w, %edx
cmpl $0x4000, %edx           # imm = 0x4000
movl %ebx, %edx
movl $0x0, %esi
cmovaeq %rdx, %rsi
addq %rsi, %r12
cmpq %rbp, %rcx
ja 0x18870c
testl %eax, %eax
je 0x1887e0
movsbl %dil, %ecx
leaq 0xa9ba6(%rip), %rsi     # 0x23236e
movq 0x8(%rsp), %r14
movq %r14, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0x22b0
jmp 0x1887e5
xorl %r12d, %r12d
jmp 0x1887ea
movq 0x8(%rsp), %r14
movq 0x10(%rsp), %r13
movq %r15, %rdx
subq 0x30(%rsp), %rdx
jbe 0x188820
leaq 0xb5ee6(%rip), %rsi     # 0x23e6e1
movq %r14, %rdi
xorl %eax, %eax
callq 0x22b0
leaq 0xb5eda(%rip), %rsi     # 0x23e6e6
movq %r14, %rdi
movl %r15d, %edx
movq 0x18(%rsp), %rcx
xorl %eax, %eax
callq 0x22b0
jmp 0x18883e
leaq 0xb5ebf(%rip), %rsi     # 0x23e6e6
movq %r14, %rdi
movl %r15d, %edx
movq 0x18(%rsp), %rcx
xorl %eax, %eax
callq 0x22b0
testq %r15, %r15
je 0x188850
movl $0x7e, %edi
movq %r14, %rsi
callq 0x2270
decq %r15
jne 0x18883e
cmpq %r13, %r12
jne 0x188877
leaq 0xb5f46(%rip), %rsi     # 0x23e7a2
movq %r14, %rdi
movq %r13, %rdx
xorl %eax, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x22b0
leaq 0xb5e75(%rip), %rdi     # 0x23e6f3
leaq 0xb57b6(%rip), %rsi     # 0x23e03b
leaq 0xb5e74(%rip), %rcx     # 0x23e700
movl $0xb6f, %edx            # imm = 0xB6F
callq 0x2110