// File: 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
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xc8, %rsp
movq %rdi, -0x30(%rbp)
movq %rsi, -0x38(%rbp)
movq %rdx, -0x40(%rbp)
movq -0x30(%rbp), %rax
cmpl $0x0, 0xc(%rax)
jne 0x25c11f
jmp 0x25c8d3
movq -0x30(%rbp), %rax
movq (%rax), %rax
movq (%rax), %rax
shrq $0x20, %rax
movq %rax, -0x50(%rbp)
movq $0x0, -0x70(%rbp)
movq $0x0, -0x78(%rbp)
movq $0x0, -0x80(%rbp)
leaq 0x169180(%rip), %rax    # 0x3c52d0
movq 0x40(%rax), %rax
movq -0x50(%rbp), %rcx
movq 0x8(%rax,%rcx,8), %rax
leaq 0x16916c(%rip), %rcx    # 0x3c52d0
movq 0x40(%rcx), %rcx
movq -0x50(%rbp), %rdx
subq (%rcx,%rdx,8), %rax
addq $0x40, %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rdi
shlq $0x0, %rdi
callq 0x2270
movq %rax, -0x70(%rbp)
movq -0x70(%rbp), %rdi
leaq 0x16913c(%rip), %rax    # 0x3c52d0
movq 0x40(%rax), %rax
movq -0x50(%rbp), %rcx
movq 0x8(%rax,%rcx,8), %rax
leaq 0x169128(%rip), %rcx    # 0x3c52d0
movq 0x40(%rcx), %rcx
movq -0x50(%rbp), %rdx
subq (%rcx,%rdx,8), %rax
movl %eax, %edx
leaq 0x169113(%rip), %rax    # 0x3c52d0
movq 0x8(%rax), %rcx
leaq 0x169108(%rip), %rax    # 0x3c52d0
movq 0x40(%rax), %rax
movq -0x50(%rbp), %rsi
addq (%rax,%rsi,8), %rcx
leaq 0x133320(%rip), %rsi    # 0x38f4fb
movb $0x0, %al
callq 0x2050
movq -0x70(%rbp), %rdi
leaq 0x13d1e5(%rip), %rsi    # 0x3993d2
callq 0x2200
movq %rax, -0x78(%rbp)
movq $0x0, -0x48(%rbp)
movq -0x48(%rbp), %rax
movq -0x30(%rbp), %rcx
movl 0xc(%rcx), %ecx
cmpq %rcx, %rax
jae 0x25c370
movq -0x30(%rbp), %rax
movq (%rax), %rax
imulq $0x28, -0x48(%rbp), %rcx
addq %rcx, %rax
movl 0xc(%rax), %eax
movq %rax, -0x60(%rbp)
movq -0x38(%rbp), %rdi
movq -0x60(%rbp), %rdx
leaq 0x169099(%rip), %rsi    # 0x3c52d0
callq 0xa380
movq -0x78(%rbp), %rdi
leaq 0x169089(%rip), %rax    # 0x3c52d0
movq 0x40(%rax), %rax
movq -0x60(%rbp), %rcx
movq 0x8(%rax,%rcx,8), %rax
leaq 0x169075(%rip), %rcx    # 0x3c52d0
movq 0x40(%rcx), %rcx
movq -0x60(%rbp), %rdx
subq (%rcx,%rdx,8), %rax
movl %eax, %edx
leaq 0x169060(%rip), %rax    # 0x3c52d0
movq 0x8(%rax), %rcx
leaq 0x169055(%rip), %rax    # 0x3c52d0
movq 0x40(%rax), %rax
movq -0x60(%rbp), %rsi
addq (%rax,%rsi,8), %rcx
leaq 0x125738(%rip), %rsi    # 0x3819c6
movb $0x0, %al
callq 0x22a0
movq -0x78(%rbp), %rdi
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rax
movl %eax, %edx
movq -0x38(%rbp), %rax
movq (%rax), %rcx
leaq 0x13aa99(%rip), %rsi    # 0x396d4a
movb $0x0, %al
callq 0x22a0
movq -0x78(%rbp), %rdi
leaq 0x125278(%rip), %rsi    # 0x38153b
movb $0x0, %al
callq 0x22a0
movq -0x40(%rbp), %rdi
movq -0x60(%rbp), %rdx
xorl %eax, %eax
movl %eax, %esi
movq $-0x1, %r8
xorl %r9d, %r9d
movq %r8, %rcx
movq $0x2, (%rsp)
callq 0xaec0
movq $0x0, -0x68(%rbp)
movq -0x68(%rbp), %rax
movq -0x40(%rbp), %rcx
cmpq (%rcx), %rax
jae 0x25c34d
movq -0x78(%rbp), %rdi
movq -0x40(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x68(%rbp), %rcx
movzbl (%rax,%rcx), %eax
movl %eax, %ecx
leaq 0x13420e(%rip), %rax    # 0x390530
movq (%rax,%rcx,8), %rax
addq $0x21, %rax
subq $0x1, %rax
movsbl %al, %edx
leaq 0x132c91(%rip), %rsi    # 0x38efc9
movb $0x0, %al
callq 0x22a0
movq -0x68(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x68(%rbp)
jmp 0x25c2f8
movq -0x78(%rbp), %rdi
leaq 0x12a6d0(%rip), %rsi    # 0x386a28
movb $0x0, %al
callq 0x22a0
movq -0x48(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x48(%rbp)
jmp 0x25c1fe
movq -0x78(%rbp), %rdi
callq 0x21a0
movq -0x70(%rbp), %rdi
leaq 0x168f4c(%rip), %rax    # 0x3c52d0
movq 0x40(%rax), %rax
movq -0x50(%rbp), %rcx
movq 0x8(%rax,%rcx,8), %rax
leaq 0x168f38(%rip), %rcx    # 0x3c52d0
movq 0x40(%rcx), %rcx
movq -0x50(%rbp), %rdx
subq (%rcx,%rdx,8), %rax
movl %eax, %edx
leaq 0x168f23(%rip), %rax    # 0x3c52d0
movq 0x8(%rax), %rcx
leaq 0x168f18(%rip), %rax    # 0x3c52d0
movq 0x40(%rax), %rax
movq -0x50(%rbp), %rsi
addq (%rax,%rsi,8), %rcx
leaq 0x13313c(%rip), %rsi    # 0x38f507
movb $0x0, %al
callq 0x2050
movq -0x70(%rbp), %rdi
leaq 0x13cff5(%rip), %rsi    # 0x3993d2
callq 0x2200
movq %rax, -0x78(%rbp)
movq -0x50(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x38(%rbp), %rdi
movq -0x60(%rbp), %rdx
leaq 0x168ed3(%rip), %rsi    # 0x3c52d0
callq 0xa380
movq -0x78(%rbp), %rdi
leaq 0x168ec3(%rip), %rax    # 0x3c52d0
movq 0x40(%rax), %rax
movq -0x60(%rbp), %rcx
movq 0x8(%rax,%rcx,8), %rax
leaq 0x168eaf(%rip), %rcx    # 0x3c52d0
movq 0x40(%rcx), %rcx
movq -0x60(%rbp), %rdx
subq (%rcx,%rdx,8), %rax
movl %eax, %edx
leaq 0x168e9a(%rip), %rax    # 0x3c52d0
movq 0x8(%rax), %rcx
leaq 0x168e8f(%rip), %rax    # 0x3c52d0
movq 0x40(%rax), %rax
movq -0x60(%rbp), %rsi
addq (%rax,%rsi,8), %rcx
leaq 0x125572(%rip), %rsi    # 0x3819c6
movb $0x0, %al
callq 0x22a0
movq -0x78(%rbp), %rdi
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rax
movl %eax, %edx
movq -0x38(%rbp), %rax
movq (%rax), %rcx
leaq 0x13a8d3(%rip), %rsi    # 0x396d4a
movb $0x0, %al
callq 0x22a0
movq -0x78(%rbp), %rdi
leaq 0x1250b2(%rip), %rsi    # 0x38153b
movb $0x0, %al
callq 0x22a0
movq -0x40(%rbp), %rdi
movq -0x60(%rbp), %rdx
xorl %eax, %eax
movl %eax, %esi
movq $-0x1, %r8
xorl %r9d, %r9d
movq %r8, %rcx
movq $0x2, (%rsp)
callq 0xaec0
movq $0x0, -0x68(%rbp)
movq -0x68(%rbp), %rax
movq -0x40(%rbp), %rcx
cmpq (%rcx), %rax
jae 0x25c513
movq -0x78(%rbp), %rdi
movq -0x40(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x68(%rbp), %rcx
movzbl (%rax,%rcx), %eax
movl %eax, %ecx
leaq 0x134048(%rip), %rax    # 0x390530
movq (%rax,%rcx,8), %rax
addq $0x21, %rax
subq $0x1, %rax
movsbl %al, %edx
leaq 0x132acb(%rip), %rsi    # 0x38efc9
movb $0x0, %al
callq 0x22a0
movq -0x68(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x68(%rbp)
jmp 0x25c4be
movq -0x78(%rbp), %rdi
leaq 0x12a50a(%rip), %rsi    # 0x386a28
movb $0x0, %al
callq 0x22a0
movq -0x78(%rbp), %rdi
callq 0x21a0
movq -0x70(%rbp), %rdi
leaq 0x168d97(%rip), %rax    # 0x3c52d0
movq 0x40(%rax), %rax
movq -0x50(%rbp), %rcx
movq 0x8(%rax,%rcx,8), %rax
leaq 0x168d83(%rip), %rcx    # 0x3c52d0
movq 0x40(%rcx), %rcx
movq -0x50(%rbp), %rdx
subq (%rcx,%rdx,8), %rax
movl %eax, %edx
leaq 0x168d6e(%rip), %rax    # 0x3c52d0
movq 0x8(%rax), %rcx
leaq 0x168d63(%rip), %rax    # 0x3c52d0
movq 0x40(%rax), %rax
movq -0x50(%rbp), %rsi
addq (%rax,%rsi,8), %rcx
leaq 0x132f93(%rip), %rsi    # 0x38f513
movb $0x0, %al
callq 0x2050
movq -0x70(%rbp), %rdi
leaq 0x13ce40(%rip), %rsi    # 0x3993d2
callq 0x2200
movq %rax, -0x78(%rbp)
movq -0x50(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x38(%rbp), %rdi
movq -0x60(%rbp), %rdx
leaq 0x168d1e(%rip), %rsi    # 0x3c52d0
callq 0xa380
movq -0x78(%rbp), %rdi
leaq 0x168d0e(%rip), %rax    # 0x3c52d0
movq 0x40(%rax), %rax
movq -0x60(%rbp), %rcx
movq 0x8(%rax,%rcx,8), %rax
leaq 0x168cfa(%rip), %rcx    # 0x3c52d0
movq 0x40(%rcx), %rcx
movq -0x60(%rbp), %rdx
subq (%rcx,%rdx,8), %rax
movl %eax, %edx
leaq 0x168ce5(%rip), %rax    # 0x3c52d0
movq 0x8(%rax), %rcx
leaq 0x168cda(%rip), %rax    # 0x3c52d0
movq 0x40(%rax), %rax
movq -0x60(%rbp), %rsi
addq (%rax,%rsi,8), %rcx
leaq 0x12b773(%rip), %rsi    # 0x387d7c
movb $0x0, %al
callq 0x22a0
movq -0x78(%rbp), %rdi
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rax
movl %eax, %edx
movq -0x38(%rbp), %rax
movq (%rax), %rcx
leaq 0x13a71e(%rip), %rsi    # 0x396d4a
movb $0x0, %al
callq 0x22a0
movq -0x78(%rbp), %rdi
callq 0x21a0
movq -0x70(%rbp), %rdi
leaq 0x168c89(%rip), %rax    # 0x3c52d0
movq 0x40(%rax), %rax
movq -0x50(%rbp), %rcx
movq 0x8(%rax,%rcx,8), %rax
leaq 0x168c75(%rip), %rcx    # 0x3c52d0
movq 0x40(%rcx), %rcx
movq -0x50(%rbp), %rdx
subq (%rcx,%rdx,8), %rax
movl %eax, %edx
leaq 0x168c60(%rip), %rax    # 0x3c52d0
movq 0x8(%rax), %rcx
leaq 0x168c55(%rip), %rax    # 0x3c52d0
movq 0x40(%rax), %rax
movq -0x50(%rbp), %rsi
addq (%rax,%rsi,8), %rcx
leaq 0x132e91(%rip), %rsi    # 0x38f51f
movb $0x0, %al
callq 0x2050
movq -0x70(%rbp), %rdi
leaq 0x13cd32(%rip), %rsi    # 0x3993d2
callq 0x2200
movq %rax, -0x78(%rbp)
movq $0x0, -0x48(%rbp)
movq -0x48(%rbp), %rax
movq -0x30(%rbp), %rcx
movl 0xc(%rcx), %ecx
cmpq %rcx, %rax
jae 0x25c8c1
movq -0x30(%rbp), %rax
movq (%rax), %rax
imulq $0x28, -0x48(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x80(%rbp)
movq -0x78(%rbp), %rdi
leaq 0x168bed(%rip), %rax    # 0x3c52d0
movq 0x40(%rax), %rax
movq -0x80(%rbp), %rcx
movq (%rcx), %rcx
shrq $0x20, %rcx
addl $0x1, %ecx
movl %ecx, %ecx
movq (%rax,%rcx,8), %rax
leaq 0x168bce(%rip), %rcx    # 0x3c52d0
movq 0x40(%rcx), %rcx
movq -0x80(%rbp), %rdx
movq (%rdx), %rdx
shrq $0x20, %rdx
movl %edx, %edx
subq (%rcx,%rdx,8), %rax
movl %eax, %edx
leaq 0x168bb0(%rip), %rax    # 0x3c52d0
movq 0x8(%rax), %rcx
leaq 0x168ba5(%rip), %rax    # 0x3c52d0
movq 0x40(%rax), %rax
movq -0x80(%rbp), %rsi
movq (%rsi), %rsi
shrq $0x20, %rsi
movl %esi, %esi
addq (%rax,%rsi,8), %rcx
movq -0x80(%rbp), %rax
movq (%rax), %rax
shrq $0x20, %rax
movl %eax, %r8d
leaq 0x168b7b(%rip), %rax    # 0x3c52d0
movq 0x18(%rax), %rax
movq -0x80(%rbp), %rsi
movq (%rsi), %rsi
shrq $0x20, %rsi
movl %esi, %esi
movq (%rax,%rsi,8), %rax
movl %eax, %r9d
movq -0x80(%rbp), %rax
movq (%rax), %rax
movq -0x80(%rbp), %rsi
movl 0x8(%rsi), %esi
movl %esi, -0x8c(%rbp)
movq -0x80(%rbp), %rsi
movq 0x18(%rsi), %rsi
shrq $0x1f, %rsi
andq $0x1, %rsi
movl %esi, %esi
movl %esi, %r10d
leaq 0x1266fe(%rip), %rsi    # 0x382e9b
movsbl (%rsi,%r10), %esi
movl %esi, -0x88(%rbp)
leaq 0x168b21(%rip), %rsi    # 0x3c52d0
movq 0x40(%rsi), %rsi
movq -0x80(%rbp), %r10
movl 0xc(%r10), %r10d
addl $0x1, %r10d
movl %r10d, %r10d
movq (%rsi,%r10,8), %rsi
leaq 0x168b03(%rip), %r10    # 0x3c52d0
movq 0x40(%r10), %r10
movq -0x80(%rbp), %r11
movl 0xc(%r11), %r11d
subq (%r10,%r11,8), %rsi
movl %esi, %r13d
leaq 0x168ae9(%rip), %rsi    # 0x3c52d0
movq 0x8(%rsi), %r12
leaq 0x168ade(%rip), %rsi    # 0x3c52d0
movq 0x40(%rsi), %rsi
movq -0x80(%rbp), %r10
movl 0xc(%r10), %r10d
addq (%rsi,%r10,8), %r12
movq -0x80(%rbp), %rsi
movl 0xc(%rsi), %r15d
leaq 0x168abf(%rip), %rsi    # 0x3c52d0
movq 0x18(%rsi), %rsi
movq -0x80(%rbp), %r10
movl 0xc(%r10), %r10d
movq (%rsi,%r10,8), %rsi
movl %esi, %r14d
movq -0x80(%rbp), %rsi
movl 0x10(%rsi), %ebx
movq -0x80(%rbp), %rsi
movl 0x14(%rsi), %r11d
movq -0x80(%rbp), %rsi
movq 0x18(%rsi), %rsi
shrq $0x1e, %rsi
andq $0x1, %rsi
movl %esi, %r10d
movq -0x80(%rbp), %rsi
movq 0x18(%rsi), %rsi
shrq $0x20, %rsi
andq $0x7fffffff, %rsi       # imm = 0x7FFFFFFF
movl %esi, -0x84(%rbp)
leaq 0x12d405(%rip), %rsi    # 0x389c6b
movl %eax, (%rsp)
movl -0x8c(%rbp), %eax
movl %eax, 0x8(%rsp)
movl -0x88(%rbp), %eax
movl %eax, 0x10(%rsp)
movl -0x84(%rbp), %eax
movl %r13d, 0x18(%rsp)
movq %r12, 0x20(%rsp)
movl %r15d, 0x28(%rsp)
movl %r14d, 0x30(%rsp)
movl %ebx, 0x38(%rsp)
movl %r11d, 0x40(%rsp)
movl %r10d, 0x48(%rsp)
movl %eax, 0x50(%rsp)
movb $0x0, %al
callq 0x22a0
movq -0x48(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x48(%rbp)
jmp 0x25c6b1
movq -0x78(%rbp), %rdi
callq 0x21a0
movq -0x70(%rbp), %rdi
callq 0x2210
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopw %cs:(%rax,%rax)