// File: 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
movq %rsp, %rbp
subq $0x60, %rsp
movq 0x50(%rbp), %rax
movq 0x48(%rbp), %rax
movq 0x40(%rbp), %rax
movq 0x38(%rbp), %rax
movq 0x30(%rbp), %rax
movq 0x28(%rbp), %rax
movq 0x20(%rbp), %rax
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movq %r8, -0x28(%rbp)
movl %r9d, -0x2c(%rbp)
movq $0x0, -0x38(%rbp)
movq $0x0, -0x40(%rbp)
movl $0x0, -0x4c(%rbp)
movb $-0x1, -0x4d(%rbp)
movq -0x10(%rbp), %rdi
movl -0x2c(%rbp), %edx
movq -0x28(%rbp), %rcx
movq 0x40(%rbp), %r8
movl -0x1c(%rbp), %r9d
movq -0x18(%rbp), %r10
movq 0x20(%rbp), %rax
addq $0x1, %rax
leaq 0x137624(%rip), %rsi    # 0x38f2a8
movq %r10, (%rsp)
movq %rax, 0x8(%rsp)
movb $0x0, %al
callq 0x22a0
cmpq $0x0, 0x30(%rbp)
je 0x257cb1
movq -0x10(%rbp), %rdi
movq 0x30(%rbp), %rdx
leaq 0x137614(%rip), %rsi    # 0x38f2be
movb $0x0, %al
callq 0x22a0
jmp 0x257cb3
movq -0x38(%rbp), %rax
movq 0x50(%rbp), %rcx
cmpq 0xa8(%rcx), %rax
jae 0x257d5a
movq 0x50(%rbp), %rdi
addq $0xa8, %rdi
movq -0x38(%rbp), %rax
movl %eax, %esi
leaq -0x42(%rbp), %rdx
leaq -0x48(%rbp), %rcx
callq 0xa1ee0
movl %eax, %eax
movq %rax, -0x38(%rbp)
movsbl -0x4d(%rbp), %eax
movq -0x8(%rbp), %rcx
movzwl -0x42(%rbp), %edx
movsbl (%rcx,%rdx), %ecx
cmpl %ecx, %eax
jne 0x257d0b
movl -0x48(%rbp), %eax
addl -0x4c(%rbp), %eax
movl %eax, -0x4c(%rbp)
jmp 0x257d41
movsbl -0x4d(%rbp), %eax
cmpl $-0x1, %eax
je 0x257d2d
movq -0x10(%rbp), %rdi
movl -0x4c(%rbp), %edx
movsbl -0x4d(%rbp), %ecx
leaq 0x12b210(%rip), %rsi    # 0x382f36
movb $0x0, %al
callq 0x22a0
movl -0x48(%rbp), %eax
movl %eax, -0x4c(%rbp)
movq -0x8(%rbp), %rax
movzwl -0x42(%rbp), %ecx
movb (%rax,%rcx), %al
movb %al, -0x4d(%rbp)
movzwl -0x42(%rbp), %eax
cmpl $0x0, %eax
je 0x257d55
movl -0x48(%rbp), %eax
addq -0x40(%rbp), %rax
movq %rax, -0x40(%rbp)
jmp 0x257cb3
cmpl $0x0, -0x4c(%rbp)
je 0x257d79
movq -0x10(%rbp), %rdi
movl -0x4c(%rbp), %edx
movsbl -0x4d(%rbp), %ecx
leaq 0x12b1c4(%rip), %rsi    # 0x382f36
movb $0x0, %al
callq 0x22a0
movq 0x18(%rbp), %rax
cmpq 0x38(%rbp), %rax
jbe 0x257d9d
movq -0x10(%rbp), %rdi
movq 0x18(%rbp), %rdx
subq 0x38(%rbp), %rdx
leaq 0x137528(%rip), %rsi    # 0x38f2be
movb $0x0, %al
callq 0x22a0
movq -0x10(%rbp), %rdi
movq 0x18(%rbp), %rax
movl %eax, %edx
movq 0x10(%rbp), %rcx
leaq 0x137511(%rip), %rsi    # 0x38f2c3
movb $0x0, %al
callq 0x22a0
movq $0x0, -0x38(%rbp)
movq -0x38(%rbp), %rax
cmpq 0x18(%rbp), %rax
jae 0x257deb
movq -0x10(%rbp), %rdi
leaq 0x1374fa(%rip), %rsi    # 0x38f2d0
movb $0x0, %al
callq 0x22a0
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x257dc1
movq 0x48(%rbp), %rax
cmpq -0x40(%rbp), %rax
jne 0x257df7
jmp 0x257e16
leaq 0x1374d4(%rip), %rdi    # 0x38f2d2
leaq 0x136e06(%rip), %rsi    # 0x38ec0b
movl $0xb6f, %edx            # imm = 0xB6F
leaq 0x1374ce(%rip), %rcx    # 0x38f2df
callq 0x2130
movq -0x10(%rbp), %rdi
movq 0x48(%rbp), %rdx
leaq 0x13755c(%rip), %rsi    # 0x38f381
movb $0x0, %al
callq 0x22a0
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)