// File: /workspace/github_cpp_makefile_star2_O2/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 0x146510
movq %rdx, %rbp
movq %rdi, 0x28(%rsp)
movq (%rdi), %rax
movq (%rax), %rcx
shrq $0x20, %rcx
leaq 0x10e186(%rip), %rbx    # 0x254230
movq 0x40(%rbx), %rax
movq (%rax,%rcx,8), %r14
movq %rcx, 0x10(%rsp)
movq 0x8(%rax,%rcx,8), %r15
subq %r14, %r15
leaq 0x40(%r15), %rdi
callq 0x2280
movq %rax, %r12
addq 0x8(%rbx), %r14
leaq 0xaa706(%rip), %rsi     # 0x1f07dc
movq %rax, %rdi
movl %r15d, %edx
movq %r14, %rcx
xorl %eax, %eax
callq 0x2050
leaq 0xb45b4(%rip), %rsi     # 0x1fa6a1
movq %r12, 0x18(%rsp)
movq %r12, %rdi
callq 0x2210
movq %rax, %r15
leaq 0xa9d5c(%rip), %r12     # 0x1efe60
xorl %edx, %edx
movq 0x8(%rsp), %rbx
movq 0x28(%rsp), %rcx
movl 0xc(%rcx), %eax
cmpq %rax, %rdx
jae 0x1461f2
movq (%rcx), %rax
movq %rdx, 0x20(%rsp)
imulq $0x28, %rdx, %rcx
movl 0xc(%rax,%rcx), %r14d
movq %rbx, %rdi
leaq 0x10e0f9(%rip), %r13    # 0x254230
movq %r13, %rsi
movq %r14, %rdx
callq 0x715e
movq 0x40(%r13), %rax
movl 0x8(%rax,%r14,8), %edx
movq (%rax,%r14,8), %rcx
subl %ecx, %edx
addq 0x8(%r13), %rcx
movq %r15, %rdi
leaq 0x9cb2d(%rip), %rsi     # 0x1e2c8c
xorl %eax, %eax
callq 0x22b0
movl 0x8(%rbx), %edx
movq (%rbx), %rcx
movq %r15, %rdi
leaq 0xb1ef4(%rip), %rsi     # 0x1f806a
xorl %eax, %eax
callq 0x22b0
leaq 0x9c5e8(%rip), %rdi     # 0x1e276c
pushq $0x2
popq %rsi
pushq $0x1
popq %rdx
movq %r15, %rcx
callq 0x2410
subq $0x8, %rsp
movq %rbp, %rdi
xorl %esi, %esi
movq %r14, %rdx
pushq $-0x1
popq %rcx
movq %rcx, %r8
xorl %r9d, %r9d
pushq $0x2
callq 0x7638
addq $0x10, %rsp
xorl %r14d, %r14d
cmpq (%rbp), %r14
jae 0x1461da
movq 0x10(%rbp), %rax
movzbl (%rax,%r14), %eax
movb (%r12,%rax,8), %al
addb $0x20, %al
movsbl %al, %edi
movq %r15, %rsi
callq 0x2270
incq %r14
jmp 0x1461b5
pushq $0xa
popq %rdi
movq %r15, %rsi
callq 0x2270
movq 0x20(%rsp), %rdx
incq %rdx
jmp 0x14610b
movq %r15, %rdi
callq 0x2190
leaq 0x10e02f(%rip), %r14    # 0x254230
movq 0x40(%r14), %rax
movq 0x10(%rsp), %r13
movl 0x8(%rax,%r13,8), %edx
movq (%rax,%r13,8), %rcx
subl %ecx, %edx
addq 0x8(%r14), %rcx
leaq 0xaa5c8(%rip), %rsi     # 0x1f07e8
xorl %ebx, %ebx
movq 0x18(%rsp), %r15
movq %r15, %rdi
xorl %eax, %eax
callq 0x2050
leaq 0xb4469(%rip), %rsi     # 0x1fa6a1
movq %r15, %rdi
callq 0x2210
movq %rax, %r15
movq 0x8(%rsp), %r14
movq %r14, %rdi
leaq 0x10dfde(%rip), %rsi    # 0x254230
movq %r13, %rdx
callq 0x715e
leaq 0x10dfcf(%rip), %rsi    # 0x254230
movq 0x40(%rsi), %rax
movl 0x8(%rax,%r13,8), %edx
movq (%rax,%r13,8), %rcx
subl %ecx, %edx
addq 0x8(%rsi), %rcx
leaq 0x9ca11(%rip), %rsi     # 0x1e2c8c
movq %r15, %rdi
xorl %eax, %eax
callq 0x22b0
movl 0x8(%r14), %edx
movq (%r14), %rcx
leaq 0xb1dd7(%rip), %rsi     # 0x1f806a
movq %r15, %rdi
xorl %eax, %eax
callq 0x22b0
leaq 0x9c4c8(%rip), %rdi     # 0x1e276c
pushq $0x2
popq %rsi
pushq $0x1
popq %rdx
movq %r15, %rcx
callq 0x2410
subq $0x8, %rsp
pushq $-0x1
popq %rcx
movq %rbp, %rdi
xorl %esi, %esi
movq %r13, %rdx
movq %rcx, %r8
xorl %r9d, %r9d
pushq $0x2
callq 0x7638
addq $0x10, %rsp
cmpq (%rbp), %rbx
jae 0x1462f6
movq 0x10(%rbp), %rax
movzbl (%rax,%rbx), %eax
movb (%r12,%rax,8), %al
addb $0x20, %al
movsbl %al, %edi
movq %r15, %rsi
callq 0x2270
incq %rbx
jmp 0x1462d2
pushq $0xa
popq %rdi
movq %r15, %rsi
callq 0x2270
movq %r15, %rdi
callq 0x2190
leaq 0x10df20(%rip), %rbx    # 0x254230
movq 0x40(%rbx), %rax
movq 0x10(%rsp), %r13
movl 0x8(%rax,%r13,8), %edx
movq (%rax,%r13,8), %rcx
subl %ecx, %edx
addq 0x8(%rbx), %rcx
leaq 0xaa4c5(%rip), %rsi     # 0x1f07f4
movq 0x18(%rsp), %r12
movq %r12, %rdi
xorl %eax, %eax
callq 0x2050
leaq 0xb435c(%rip), %r15     # 0x1fa6a1
movq %r12, %rdi
movq %r15, %rsi
callq 0x2210
movq %rax, %r14
movq 0x8(%rsp), %rbp
movq %rbp, %rdi
movq %rbx, %rsi
movq %r13, %rdx
callq 0x715e
movq 0x40(%rbx), %rax
movl 0x8(%rax,%r13,8), %edx
movq (%rax,%r13,8), %rcx
subl %ecx, %edx
addq 0x8(%rbx), %rcx
leaq 0xa2d11(%rip), %rsi     # 0x1e9091
movq %r14, %rdi
xorl %eax, %eax
callq 0x22b0
movl 0x8(%rbp), %edx
movq (%rbp), %rcx
leaq 0xb1cd2(%rip), %rsi     # 0x1f806a
movq %r14, %rdi
xorl %eax, %eax
callq 0x22b0
movq %r14, %rdi
callq 0x2190
movq 0x40(%rbx), %rax
movl 0x8(%rax,%r13,8), %edx
movq (%rax,%r13,8), %rcx
subl %ecx, %edx
addq 0x8(%rbx), %rcx
leaq 0xaa43c(%rip), %rsi     # 0x1f0800
movq %r12, %rdi
xorl %eax, %eax
callq 0x2050
movq %r12, %rdi
movq %r15, %rsi
callq 0x2210
movq %rax, 0x30(%rsp)
pushq $0x18
popq %r14
xorl %ecx, %ecx
movq 0x28(%rsp), %rdi
movl 0xc(%rdi), %eax
cmpq %rax, %rcx
jae 0x1464ee
movq (%rdi), %rax
movq %rcx, 0x20(%rsp)
leaq 0x10de2c(%rip), %r9     # 0x254230
movq 0x40(%r9), %rsi
movq -0x18(%rax,%r14), %r8
movq %r8, 0x8(%rsp)
shrq $0x20, %r8
leal 0x1(%r8), %ecx
movl (%rsi,%rcx,8), %edx
movq (%rsi,%r8,8), %rcx
subl %ecx, %edx
movq 0x8(%r9), %rbx
movq 0x18(%r9), %rdi
addq %rbx, %rcx
movl (%rdi,%r8,8), %r9d
movl -0x10(%rax,%r14), %r10d
movq %r10, 0x10(%rsp)
movq (%rax,%r14), %r10
movl %r10d, %r15d
shrl $0x1f, %r15d
leaq 0x9ddd5(%rip), %r11     # 0x1e4223
movsbl (%r15,%r11), %r11d
movq %r11, 0x40(%rsp)
movl -0xc(%rax,%r14), %r13d
leal 0x1(%r13), %r12d
movl (%rsi,%r12,8), %r12d
movq (%rsi,%r13,8), %rsi
subl %esi, %r12d
addq %rsi, %rbx
movl (%rdi,%r13,8), %esi
movq %rsi, 0x38(%rsp)
movl -0x8(%rax,%r14), %r15d
movl -0x4(%rax,%r14), %ebp
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 0xa4a98(%rip), %rsi     # 0x1eaf40
xorl %eax, %eax
pushq %r10
pushq %r11
pushq %rbp
pushq %r15
pushq 0x60(%rsp)
pushq %r13
pushq %rbx
pushq %r12
pushq 0x88(%rsp)
pushq 0x60(%rsp)
pushq 0x60(%rsp)
callq 0x22b0
movq 0x88(%rsp), %rdi
movq 0x80(%rsp), %rcx
addq $0x60, %rsp
incq %rcx
addq $0x28, %r14
jmp 0x1463e9
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