// File: /workspace/github_cpp_makefile_star2_O3/chhylp123[P]hifiasm/Assembly.cpp
// Function: Output_PAF()
void Output_PAF()
{
    fprintf(stderr, "Writing PAF to disk ...... \n");
    char* paf_name = (char*)malloc(strlen(asm_opt.output_file_name)+50);
    sprintf(paf_name, "%s.ovlp.paf", asm_opt.output_file_name);
    FILE* output_file = fopen(paf_name, "w");
    uint64_t i, j;
    ma_hit_t_alloc* sources = R_INF.paf;

    for (i = 0; i < R_INF.total_reads; i++)
    {
        for (j = 0; j < sources[i].length; j++)
        {
            fwrite(Get_NAME(R_INF, Get_qn(sources[i].buffer[j])), 1, 
            Get_NAME_LENGTH(R_INF, Get_qn(sources[i].buffer[j])), output_file);
            fwrite("\t", 1, 1, output_file);
            fprintf(output_file, "%lu\t", (unsigned long)Get_READ_LENGTH(R_INF, Get_qn(sources[i].buffer[j])));
            fprintf(output_file, "%d\t", Get_qs(sources[i].buffer[j]));
            fprintf(output_file, "%d\t", Get_qe(sources[i].buffer[j]));
            if(sources[i].buffer[j].rev)
            {
                fprintf(output_file, "-\t");
            }
            else
            {
                fprintf(output_file, "+\t");
            }
            fwrite(Get_NAME(R_INF, Get_tn(sources[i].buffer[j])), 1, 
            Get_NAME_LENGTH(R_INF, Get_tn(sources[i].buffer[j])), output_file);
            fwrite("\t", 1, 1, output_file);
            fprintf(output_file, "%lu\t", (unsigned long)Get_READ_LENGTH(R_INF, Get_tn(sources[i].buffer[j])));
            fprintf(output_file, "%d\t", Get_ts(sources[i].buffer[j]));
            fprintf(output_file, "%d\t", Get_te(sources[i].buffer[j]));
            fprintf(output_file, "%d\t", sources[i].buffer[j].ml);
            fprintf(output_file, "%d\t", sources[i].buffer[j].bl);
            fprintf(output_file, "255\n");

        }
    }

    free(paf_name);
    fclose(output_file);

    fprintf(stderr, "PAF has been written.\n");
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq 0x291361(%rip), %rax    # 0x294fe0
movq (%rax), %rcx
leaq 0x22d1b9(%rip), %rdi    # 0x230e42
pushq $0x1c
popq %rsi
pushq $0x1
popq %rdx
callq 0x2410
leaq 0x291abd(%rip), %rax    # 0x295758
movq 0x10(%rax), %rbx
movq %rbx, %rdi
callq 0x2090
leaq 0x32(%rax), %rdi
callq 0x2280
movq %rax, %r14
leaq 0x22d1c9(%rip), %rsi    # 0x230e83
movq %rax, %rdi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x2050
leaq 0x244a14(%rip), %rsi    # 0x2486e2
movq %r14, (%rsp)
movq %r14, %rdi
callq 0x2210
movq %rax, %r14
movq 0x29259c(%rip), %rax    # 0x296280
testq %rax, %rax
je 0x3ed4
movq 0x2925b4(%rip), %rcx    # 0x2962a8
xorl %r12d, %r12d
movq %rcx, 0x8(%rsp)
pushq $0x1
popq %r15
imulq $0x18, %r12, %rbx
cmpl $0x0, 0xc(%rcx,%rbx)
je 0x3ec8
movq %r12, 0x10(%rsp)
addq %rcx, %rbx
xorl %ebp, %ebp
xorl %r12d, %r12d
movq 0x29254d(%rip), %rax    # 0x296270
movq (%rbx), %rcx
movq (%rcx,%rbp), %rcx
shrq $0x20, %rcx
movq (%rax,%rcx,8), %rsi
movq 0x2924ff(%rip), %rdi    # 0x296238
addq %rsi, %rdi
incl %ecx
movq (%rax,%rcx,8), %rdx
subq %rsi, %rdx
pushq $0x1
popq %rsi
movq %r14, %rcx
callq 0x2410
pushq $0x9
popq %rdi
movq %r14, %rsi
callq 0x2270
movq 0x2924e6(%rip), %rax    # 0x296248
movq (%rbx), %rcx
movl 0x4(%rcx,%rbp), %ecx
movq (%rax,%rcx,8), %rdx
movq %r14, %rdi
leaq 0x23ba34(%rip), %rsi    # 0x23f7ab
xorl %eax, %eax
callq 0x22b0
movq (%rbx), %rax
movl (%rax,%rbp), %edx
movq %r14, %rdi
leaq 0x22d0d1(%rip), %r13    # 0x230e5f
movq %r13, %rsi
xorl %eax, %eax
callq 0x22b0
movq (%rbx), %rax
movl 0x8(%rax,%rbp), %edx
movq %r14, %rdi
movq %r13, %rsi
xorl %eax, %eax
callq 0x22b0
movq (%rbx), %rax
cmpl $0x0, 0x18(%rax,%rbp)
leaq 0x22d0a8(%rip), %rdi    # 0x230e63
leaq 0x22d0a4(%rip), %rax    # 0x230e66
cmovnsq %rax, %rdi
pushq $0x2
popq %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x2410
movq 0x292495(%rip), %rax    # 0x296270
movq (%rbx), %rcx
movl 0xc(%rcx,%rbp), %ecx
movq (%rax,%rcx,8), %rsi
movq 0x29244b(%rip), %rdi    # 0x296238
addq %rsi, %rdi
incl %ecx
movq (%rax,%rcx,8), %rdx
subq %rsi, %rdx
movq %r15, %rsi
movq %r14, %rcx
callq 0x2410
pushq $0x9
popq %rdi
movq %r14, %rsi
callq 0x2270
movq 0x292432(%rip), %rax    # 0x296248
movq (%rbx), %rcx
movl 0xc(%rcx,%rbp), %ecx
movq (%rax,%rcx,8), %rdx
movq %r14, %rdi
leaq 0x23b980(%rip), %rsi    # 0x23f7ab
xorl %eax, %eax
callq 0x22b0
movq (%rbx), %rax
movl 0x10(%rax,%rbp), %edx
movq %r14, %rdi
movq %r13, %rsi
xorl %eax, %eax
callq 0x22b0
movq (%rbx), %rax
movl 0x14(%rax,%rbp), %edx
movq %r14, %rdi
movq %r13, %rsi
xorl %eax, %eax
callq 0x22b0
movq (%rbx), %rax
movl 0x18(%rax,%rbp), %edx
shrl $0x1e, %edx
andl $0x1, %edx
movq %r14, %rdi
movq %r13, %rsi
xorl %eax, %eax
callq 0x22b0
movq (%rbx), %rax
movl 0x1c(%rax,%rbp), %edx
movl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
andl %eax, %edx
movq %r14, %rdi
movq %r13, %rsi
xorl %eax, %eax
callq 0x22b0
leaq 0x2351df(%rip), %rdi    # 0x239075
pushq $0x4
popq %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x2410
incq %r12
movl 0xc(%rbx), %eax
addq $0x28, %rbp
cmpq %rax, %r12
jb 0x3d1c
movq 0x2923c2(%rip), %rax    # 0x296280
movq 0x8(%rsp), %rcx
movq 0x10(%rsp), %r12
incq %r12
cmpq %rax, %r12
jb 0x3d00
movq (%rsp), %rdi
callq 0x2220
movq %r14, %rdi
callq 0x2190
movq 0x2910f4(%rip), %rax    # 0x294fe0
movq (%rax), %rcx
leaq 0x22cf73(%rip), %rdi    # 0x230e69
pushq $0x16
popq %rsi
pushq $0x1
popq %rdx
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2410