// File: 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
movq %rsp, %rbp
subq $0x30, %rsp
movq 0x3aa701(%rip), %rax    # 0x3c3fe0
movq (%rax), %rdi
leaq 0x368283(%rip), %rsi    # 0x381b6c
movb $0x0, %al
callq 0x22a0
leaq 0x3aaf01(%rip), %rax    # 0x3c47f8
movq 0x10(%rax), %rdi
callq 0x20a0
movq %rax, %rdi
addq $0x32, %rdi
callq 0x2270
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rdi
leaq 0x3aaedd(%rip), %rax    # 0x3c47f8
movq 0x10(%rax), %rdx
leaq 0x368287(%rip), %rsi    # 0x381bad
movb $0x0, %al
callq 0x2050
movq -0x8(%rbp), %rdi
leaq 0x37fa9a(%rip), %rsi    # 0x3993d2
callq 0x2200
movq %rax, -0x10(%rbp)
movq 0x3aba00(%rip), %rax    # 0x3c5348
movq %rax, -0x28(%rbp)
movq $0x0, -0x18(%rbp)
movq -0x18(%rbp), %rax
cmpq 0x3ab9c1(%rip), %rax    # 0x3c5320
jae 0x19cf5
movq $0x0, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq -0x28(%rbp), %rcx
imulq $0x18, -0x18(%rbp), %rdx
addq %rdx, %rcx
movl 0xc(%rcx), %ecx
cmpq %rcx, %rax
jae 0x19ce2
movq 0x3ab948(%rip), %rdi    # 0x3c52d8
movq 0x3ab979(%rip), %rax    # 0x3c5310
movq -0x28(%rbp), %rcx
imulq $0x18, -0x18(%rbp), %rdx
addq %rdx, %rcx
movq (%rcx), %rcx
imulq $0x28, -0x20(%rbp), %rdx
addq %rdx, %rcx
movq (%rcx), %rcx
shrq $0x20, %rcx
movl %ecx, %ecx
addq (%rax,%rcx,8), %rdi
movq 0x3ab94e(%rip), %rax    # 0x3c5310
movq -0x28(%rbp), %rcx
imulq $0x18, -0x18(%rbp), %rdx
addq %rdx, %rcx
movq (%rcx), %rcx
imulq $0x28, -0x20(%rbp), %rdx
addq %rdx, %rcx
movq (%rcx), %rcx
shrq $0x20, %rcx
addl $0x1, %ecx
movl %ecx, %ecx
movq (%rax,%rcx,8), %rdx
movq 0x3ab920(%rip), %rax    # 0x3c5310
movq -0x28(%rbp), %rcx
imulq $0x18, -0x18(%rbp), %rsi
addq %rsi, %rcx
movq (%rcx), %rcx
imulq $0x28, -0x20(%rbp), %rsi
addq %rsi, %rcx
movq (%rcx), %rcx
shrq $0x20, %rcx
movl %ecx, %ecx
subq (%rax,%rcx,8), %rdx
movq -0x10(%rbp), %rcx
movl $0x1, %esi
callq 0x2400
movq -0x10(%rbp), %rcx
leaq 0x37f0ff(%rip), %rdi    # 0x398b2c
movl $0x1, %edx
movq %rdx, %rsi
callq 0x2400
movq -0x10(%rbp), %rdi
movq 0x3ab8a3(%rip), %rax    # 0x3c52e8
movq -0x28(%rbp), %rcx
imulq $0x18, -0x18(%rbp), %rdx
addq %rdx, %rcx
movq (%rcx), %rcx
imulq $0x28, -0x20(%rbp), %rdx
addq %rdx, %rcx
movq (%rcx), %rcx
shrq $0x20, %rcx
movl %ecx, %ecx
movq (%rax,%rcx,8), %rdx
leaq 0x37691a(%rip), %rsi    # 0x39038a
movb $0x0, %al
callq 0x22a0
movq -0x10(%rbp), %rdi
movq -0x28(%rbp), %rax
imulq $0x18, -0x18(%rbp), %rcx
addq %rcx, %rax
movq (%rax), %rax
imulq $0x28, -0x20(%rbp), %rcx
addq %rcx, %rax
movq (%rax), %rax
movl %eax, %edx
leaq 0x3680eb(%rip), %rsi    # 0x381b89
movb $0x0, %al
callq 0x22a0
movq -0x10(%rbp), %rdi
movq -0x28(%rbp), %rax
imulq $0x18, -0x18(%rbp), %rcx
addq %rcx, %rax
movq (%rax), %rax
imulq $0x28, -0x20(%rbp), %rcx
addq %rcx, %rax
movl 0x8(%rax), %edx
leaq 0x3680bf(%rip), %rsi    # 0x381b89
movb $0x0, %al
callq 0x22a0
movq -0x28(%rbp), %rax
imulq $0x18, -0x18(%rbp), %rcx
addq %rcx, %rax
movq (%rax), %rax
imulq $0x28, -0x20(%rbp), %rcx
addq %rcx, %rax
movq 0x18(%rax), %rax
shrq $0x1f, %rax
andq $0x1, %rax
cmpl $0x0, %eax
je 0x19b0d
movq -0x10(%rbp), %rdi
leaq 0x368089(%rip), %rsi    # 0x381b8d
movb $0x0, %al
callq 0x22a0
jmp 0x19b1f
movq -0x10(%rbp), %rdi
leaq 0x368078(%rip), %rsi    # 0x381b90
movb $0x0, %al
callq 0x22a0
movq 0x3ab7b2(%rip), %rdi    # 0x3c52d8
movq 0x3ab7e3(%rip), %rax    # 0x3c5310
movq -0x28(%rbp), %rcx
imulq $0x18, -0x18(%rbp), %rdx
addq %rdx, %rcx
movq (%rcx), %rcx
imulq $0x28, -0x20(%rbp), %rdx
addq %rdx, %rcx
movl 0xc(%rcx), %ecx
addq (%rax,%rcx,8), %rdi
movq 0x3ab7be(%rip), %rax    # 0x3c5310
movq -0x28(%rbp), %rcx
imulq $0x18, -0x18(%rbp), %rdx
addq %rdx, %rcx
movq (%rcx), %rcx
imulq $0x28, -0x20(%rbp), %rdx
addq %rdx, %rcx
movl 0xc(%rcx), %ecx
addl $0x1, %ecx
movl %ecx, %ecx
movq (%rax,%rcx,8), %rdx
movq 0x3ab794(%rip), %rax    # 0x3c5310
movq -0x28(%rbp), %rcx
imulq $0x18, -0x18(%rbp), %rsi
addq %rsi, %rcx
movq (%rcx), %rcx
imulq $0x28, -0x20(%rbp), %rsi
addq %rsi, %rcx
movl 0xc(%rcx), %ecx
subq (%rax,%rcx,8), %rdx
movq -0x10(%rbp), %rcx
movl $0x1, %esi
callq 0x2400
movq -0x10(%rbp), %rcx
leaq 0x37ef79(%rip), %rdi    # 0x398b2c
movl $0x1, %edx
movq %rdx, %rsi
callq 0x2400
movq -0x10(%rbp), %rdi
movq 0x3ab71d(%rip), %rax    # 0x3c52e8
movq -0x28(%rbp), %rcx
imulq $0x18, -0x18(%rbp), %rdx
addq %rdx, %rcx
movq (%rcx), %rcx
imulq $0x28, -0x20(%rbp), %rdx
addq %rdx, %rcx
movl 0xc(%rcx), %ecx
movq (%rax,%rcx,8), %rdx
leaq 0x37679a(%rip), %rsi    # 0x39038a
movb $0x0, %al
callq 0x22a0
movq -0x10(%rbp), %rdi
movq -0x28(%rbp), %rax
imulq $0x18, -0x18(%rbp), %rcx
addq %rcx, %rax
movq (%rax), %rax
imulq $0x28, -0x20(%rbp), %rcx
addq %rcx, %rax
movl 0x10(%rax), %edx
leaq 0x367f6d(%rip), %rsi    # 0x381b89
movb $0x0, %al
callq 0x22a0
movq -0x10(%rbp), %rdi
movq -0x28(%rbp), %rax
imulq $0x18, -0x18(%rbp), %rcx
addq %rcx, %rax
movq (%rax), %rax
imulq $0x28, -0x20(%rbp), %rcx
addq %rcx, %rax
movl 0x14(%rax), %edx
leaq 0x367f41(%rip), %rsi    # 0x381b89
movb $0x0, %al
callq 0x22a0
movq -0x10(%rbp), %rdi
movq -0x28(%rbp), %rax
imulq $0x18, -0x18(%rbp), %rcx
addq %rcx, %rax
movq (%rax), %rax
imulq $0x28, -0x20(%rbp), %rcx
addq %rcx, %rax
movq 0x18(%rax), %rax
shrq $0x1e, %rax
andq $0x1, %rax
movl %eax, %edx
leaq 0x367f0a(%rip), %rsi    # 0x381b89
movb $0x0, %al
callq 0x22a0
movq -0x10(%rbp), %rdi
movq -0x28(%rbp), %rax
imulq $0x18, -0x18(%rbp), %rcx
addq %rcx, %rax
movq (%rax), %rax
imulq $0x28, -0x20(%rbp), %rcx
addq %rcx, %rax
movq 0x18(%rax), %rax
shrq $0x20, %rax
andq $0x7fffffff, %rax       # imm = 0x7FFFFFFF
movl %eax, %edx
leaq 0x367ed1(%rip), %rsi    # 0x381b89
movb $0x0, %al
callq 0x22a0
movq -0x10(%rbp), %rdi
leaq 0x36ffd6(%rip), %rsi    # 0x389ca0
movb $0x0, %al
callq 0x22a0
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
jmp 0x1996d
jmp 0x19ce4
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
jmp 0x19954
movq -0x8(%rbp), %rdi
callq 0x2210
movq -0x10(%rbp), %rdi
callq 0x21a0
movq 0x3aa2d2(%rip), %rax    # 0x3c3fe0
movq (%rax), %rdi
leaq 0x367e7b(%rip), %rsi    # 0x381b93
movb $0x0, %al
callq 0x22a0
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)