// File: /workspace/github_cpp_makefile_star2_O3/chhylp123[P]hifiasm/ecovlp.cpp
// Function: prt_dbg_rid_paf(ma_hit_t_alloc*, UC_Read*, asg8_v*)
void prt_dbg_rid_paf(ma_hit_t_alloc *ov, UC_Read *ra, asg8_v *qa)
{
    if(!(ov->length)) return;
    uint64_t k, qn = (ov->buffer[0].qns>>32), qn_n, i, m; char *nn = NULL; FILE *fp = NULL; ma_hit_t *h = NULL;
    qn_n = Get_NAME_LENGTH((R_INF), qn) + 64; MALLOC(nn, qn_n);

    sprintf(nn, "%.*s.qry.fq", (int)Get_NAME_LENGTH(R_INF, qn), Get_NAME((R_INF), qn)); fp = fopen(nn, "w");
    for (k = 0; k < ov->length; k++) {
        i = ov->buffer[k].tn;
        recover_UC_Read(ra, &R_INF, i);
        fprintf(fp, "@%.*s\n", (int32_t)Get_NAME_LENGTH(R_INF, i), Get_NAME(R_INF, i));
        fprintf(fp, "%.*s\n", (int32_t)ra->length, ra->seq);        
        fprintf(fp, "+\n");
        retrive_bqual(qa, NULL, i, -1, -1, 0, sc_bn);
        for (m = 0; m < qa->n; m++) fprintf(fp, "%c", (char)(sc_tb[qa->a[m]] + 33 - 1));
        fprintf(fp, "\n");
    }
    fclose(fp);

    sprintf(nn, "%.*s.ref.fq", (int)Get_NAME_LENGTH(R_INF, qn), Get_NAME((R_INF), qn)); fp = fopen(nn, "w");
    i = qn;
    recover_UC_Read(ra, &R_INF, i);
    fprintf(fp, "@%.*s\n", (int32_t)Get_NAME_LENGTH(R_INF, i), Get_NAME(R_INF, i));
    fprintf(fp, "%.*s\n", (int32_t)ra->length, ra->seq);        
    fprintf(fp, "+\n");
    retrive_bqual(qa, NULL, i, -1, -1, 0, sc_bn);
    for (m = 0; m < qa->n; m++) fprintf(fp, "%c", (char)(sc_tb[qa->a[m]] + 33 - 1));
    fprintf(fp, "\n");
    fclose(fp);

    sprintf(nn, "%.*s.ref.fa", (int)Get_NAME_LENGTH(R_INF, qn), Get_NAME((R_INF), qn)); fp = fopen(nn, "w");
    i = qn;
    recover_UC_Read(ra, &R_INF, i);
    fprintf(fp, ">%.*s\n", (int32_t)Get_NAME_LENGTH(R_INF, i), Get_NAME(R_INF, i));
    fprintf(fp, "%.*s\n", (int32_t)ra->length, ra->seq);        
    // fprintf(fp, "+\n");
    // retrive_bqual(qa, NULL, i, -1, -1, 0, sc_bn);
    // for (m = 0; m < qa->n; m++) fprintf(fp, "%c", (char)(sc_tb[qa->a[m]] + 33 - 1));
    // fprintf(fp, "\n");
    fclose(fp);

    sprintf(nn, "%.*s.ov.paf", (int)Get_NAME_LENGTH(R_INF, qn), Get_NAME((R_INF), qn)); fp = fopen(nn, "w");
    for (k = 0; k < ov->length; k++) {
        h = &(ov->buffer[k]);
        fprintf(fp, "%.*s(qn::%u)\t%u\t%u\t%u\t%c\t%.*s(tn::%u)\t%u\t%u\t%u\t%u\t%u\t255\n", (int)Get_NAME_LENGTH(R_INF, Get_qn(*h)), Get_NAME((R_INF), Get_qn(*h)), Get_qn(*h), (uint32_t)Get_READ_LENGTH(R_INF, Get_qn(*h)), Get_qs(*h), Get_qe(*h), "+-"[h->rev], 
        (int)Get_NAME_LENGTH(R_INF, Get_tn(*h)), Get_NAME((R_INF), Get_tn(*h)), Get_tn(*h), (uint32_t)Get_READ_LENGTH(R_INF, Get_tn(*h)), Get_ts(*h), Get_te(*h), h->ml, h->bl);
    }
    fclose(fp);

    free(nn);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rsi, 0x8(%rsp)
cmpl $0x0, 0xc(%rdi)
je 0x18b1e9
movq %rdx, %rbp
movq (%rdi), %rax
movq (%rax), %rcx
shrq $0x20, %rcx
leaq 0x10b4d9(%rip), %rbx    # 0x296230
movq 0x40(%rbx), %rax
movq (%rax,%rcx,8), %r15
movq %rcx, 0x20(%rsp)
movq 0x8(%rax,%rcx,8), %r12
subq %r15, %r12
movq %rdi, 0x10(%rsp)
leaq 0x40(%r12), %rdi
callq 0x2280
movq %rax, %r14
addq 0x8(%rbx), %r15
leaq 0xb3b93(%rip), %rsi     # 0x23e91c
movq %rax, %rdi
movl %r12d, %edx
movq %r15, %rcx
xorl %eax, %eax
callq 0x2050
leaq 0xbd942(%rip), %rsi     # 0x2486e2
movq %r14, 0x18(%rsp)
movq %r14, %rdi
callq 0x2210
movq 0x10(%rsp), %rcx
movq %rax, %r15
cmpl $0x0, 0xc(%rcx)
je 0x18aec2
leaq 0xb31da(%rip), %r14     # 0x23dfa0
xorl %edx, %edx
movq 0x8(%rsp), %rbx
movq (%rcx), %rax
movq %rdx, 0x28(%rsp)
leaq (%rdx,%rdx,4), %rcx
movl 0xc(%rax,%rcx,8), %r12d
movq %rbx, %rdi
leaq 0x10b448(%rip), %r13    # 0x296230
movq %r13, %rsi
movq %r12, %rdx
callq 0x333e0
movq 0x40(%r13), %rax
movl 0x8(%rax,%r12,8), %edx
movq (%rax,%r12,8), %rcx
subl %ecx, %edx
addq 0x8(%r13), %rcx
movq %r15, %rdi
leaq 0xa5e8c(%rip), %rsi     # 0x230c9c
xorl %eax, %eax
callq 0x22b0
movl 0x8(%rbx), %edx
movq (%rbx), %rcx
movq %r15, %rdi
leaq 0xbb373(%rip), %rsi     # 0x24619a
xorl %eax, %eax
callq 0x22b0
movl $0x2, %esi
movl $0x1, %edx
leaq 0xa592d(%rip), %rdi     # 0x23076c
movq %r15, %rcx
callq 0x2410
subq $0x8, %rsp
movq %rbp, %rdi
xorl %esi, %esi
movq %r12, %rdx
movq $-0x1, %rcx
movq $-0x1, %r8
xorl %r9d, %r9d
pushq $0x2
callq 0x33933
addq $0x10, %rsp
cmpq $0x0, (%rbp)
je 0x18ae9c
xorl %r12d, %r12d
movq 0x10(%rbp), %rax
movzbl (%rax,%r12), %eax
movb (%r14,%rax,8), %al
addb $0x20, %al
movsbl %al, %edi
movq %r15, %rsi
callq 0x2270
incq %r12
cmpq (%rbp), %r12
jb 0x18ae79
movl $0xa, %edi
movq %r15, %rsi
callq 0x2270
movq 0x28(%rsp), %rdx
incq %rdx
movq 0x10(%rsp), %rcx
movl 0xc(%rcx), %eax
cmpq %rax, %rdx
jb 0x18adcd
movq %r15, %rdi
callq 0x2190
leaq 0x10b35f(%rip), %rbx    # 0x296230
movq 0x40(%rbx), %rax
movq 0x20(%rsp), %r13
movl 0x8(%rax,%r13,8), %edx
movq (%rax,%r13,8), %rcx
subl %ecx, %edx
addq 0x8(%rbx), %rcx
leaq 0xb3a38(%rip), %rsi     # 0x23e928
movq 0x18(%rsp), %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x2050
leaq 0xbd7dc(%rip), %rsi     # 0x2486e2
movq %r14, %rdi
callq 0x2210
movq %rax, %r15
movq 0x8(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
movq %r13, %rdx
callq 0x333e0
movq 0x40(%rbx), %rax
movl 0x8(%rax,%r13,8), %edx
movq (%rax,%r13,8), %rcx
subl %ecx, %edx
addq 0x8(%rbx), %rcx
leaq 0xa5d5e(%rip), %rsi     # 0x230c9c
movq %r15, %rdi
xorl %eax, %eax
callq 0x22b0
movl 0x8(%r14), %edx
movq (%r14), %rcx
leaq 0xbb244(%rip), %rsi     # 0x24619a
movq %r15, %rdi
xorl %eax, %eax
callq 0x22b0
leaq 0xa5805(%rip), %rdi     # 0x23076c
movl $0x2, %esi
movl $0x1, %edx
movq %r15, %rcx
callq 0x2410
subq $0x8, %rsp
movq %rbp, %rdi
xorl %esi, %esi
movq %r13, %rdx
movq $-0x1, %rcx
movq $-0x1, %r8
xorl %r9d, %r9d
pushq $0x2
callq 0x33933
addq $0x10, %rsp
cmpq $0x0, (%rbp)
je 0x18afd3
xorl %ebx, %ebx
leaq 0xb2fef(%rip), %r14     # 0x23dfa0
movq 0x10(%rbp), %rax
movzbl (%rax,%rbx), %eax
movb (%r14,%rax,8), %al
addb $0x20, %al
movsbl %al, %edi
movq %r15, %rsi
callq 0x2270
incq %rbx
cmpq (%rbp), %rbx
jb 0x18afb1
movl $0xa, %edi
movq %r15, %rsi
callq 0x2270
movq %r15, %rdi
callq 0x2190
leaq 0x10b241(%rip), %r14    # 0x296230
movq 0x40(%r14), %rax
movl 0x8(%rax,%r13,8), %edx
movq (%rax,%r13,8), %rcx
subl %ecx, %edx
addq 0x8(%r14), %rcx
leaq 0xb392b(%rip), %rsi     # 0x23e934
movq 0x18(%rsp), %rbx
movq %rbx, %rdi
xorl %eax, %eax
callq 0x2050
leaq 0xbd6c3(%rip), %r15     # 0x2486e2
movq %rbx, %rdi
movq %r15, %rsi
callq 0x2210
movq %rax, %r12
movq 0x8(%rsp), %rbp
movq %rbp, %rdi
movq %r14, %rsi
movq %r13, %rdx
callq 0x333e0
movq 0x40(%r14), %rax
movl 0x8(%rax,%r13,8), %edx
movq (%rax,%r13,8), %rcx
subl %ecx, %edx
addq 0x8(%r14), %rcx
leaq 0xac137(%rip), %rsi     # 0x237191
movq %r12, %rdi
xorl %eax, %eax
callq 0x22b0
movl 0x8(%rbp), %edx
movq (%rbp), %rcx
leaq 0xbb128(%rip), %rsi     # 0x24619a
movq %r12, %rdi
xorl %eax, %eax
callq 0x22b0
movq %r12, %rdi
callq 0x2190
movq 0x40(%r14), %rax
movl 0x8(%rax,%r13,8), %edx
movq (%rax,%r13,8), %rcx
subl %ecx, %edx
addq 0x8(%r14), %rcx
leaq 0xb38a2(%rip), %rsi     # 0x23e940
movq %rbx, %rdi
xorl %eax, %eax
callq 0x2050
movq %rbx, %rdi
movq %r15, %rsi
callq 0x2210
movq %rax, 0x30(%rsp)
movq 0x10(%rsp), %rcx
cmpl $0x0, 0xc(%rcx)
je 0x18b1c7
movl $0x18, %r13d
xorl %ebp, %ebp
movq (%rcx), %rax
movq 0x40(%r14), %rsi
movq -0x18(%rax,%r13), %r8
movq %r8, 0x28(%rsp)
shrq $0x20, %r8
leal 0x1(%r8), %ecx
movl (%rsi,%rcx,8), %edx
movq (%rsi,%r8,8), %rcx
subl %ecx, %edx
movq 0x8(%r14), %rbx
movq 0x18(%r14), %rdi
addq %rbx, %rcx
movl (%rdi,%r8,8), %r9d
movl -0x10(%rax,%r13), %r10d
movq %r10, 0x8(%rsp)
movq (%rax,%r13), %r10
movl %r10d, %r14d
shrl $0x1f, %r14d
leaq 0xa71b7(%rip), %r11     # 0x2322d3
movsbl (%r14,%r11), %r11d
movq %r11, 0x20(%rsp)
movl -0xc(%rax,%r13), %r15d
leal 0x1(%r15), %r14d
movl (%rsi,%r14,8), %r12d
movq (%rsi,%r15,8), %rsi
subl %esi, %r12d
addq %rsi, %rbx
movl (%rdi,%r15,8), %esi
movq %rsi, 0x40(%rsp)
movl -0x8(%rax,%r13), %esi
movq %rsi, 0x38(%rsp)
movl -0x4(%rax,%r13), %r14d
movl %r10d, %r11d
shrl $0x1e, %r11d
andl $0x1, %r11d
shrq $0x20, %r10
andl $0x7fffffff, %r10d      # imm = 0x7FFFFFFF
subq $0x8, %rsp
movq 0x38(%rsp), %rdi
leaq 0xadec5(%rip), %rsi     # 0x239040
xorl %eax, %eax
pushq %r10
pushq %r11
pushq %r14
leaq 0x10b0a6(%rip), %r14    # 0x296230
pushq 0x58(%rsp)
pushq 0x68(%rsp)
pushq %r15
pushq %rbx
pushq %r12
pushq 0x68(%rsp)
pushq 0x58(%rsp)
pushq 0x80(%rsp)
callq 0x22b0
movq 0x70(%rsp), %rcx
addq $0x60, %rsp
incq %rbp
movl 0xc(%rcx), %eax
addq $0x28, %r13
cmpq %rax, %rbp
jb 0x18b0cf
movq 0x30(%rsp), %rdi
callq 0x2190
movq 0x18(%rsp), %rdi
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2220
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq