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

    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 $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq 0x3aa299(%rip), %rax    # 0x3c3fe0
movq (%rax), %rdi
leaq 0x367e1b(%rip), %rsi    # 0x381b6c
movb $0x0, %al
callq 0x22a0
leaq 0x3aaa99(%rip), %rax    # 0x3c47f8
movq 0x10(%rax), %rdi
callq 0x20a0
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rdi
callq 0x20a0
movq -0x38(%rbp), %rdi
addq %rax, %rdi
addq $0x32, %rdi
callq 0x2270
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdi
leaq 0x3aaa64(%rip), %rax    # 0x3c47f8
movq 0x10(%rax), %rdx
movq -0x10(%rbp), %rcx
leaq 0x367e07(%rip), %rsi    # 0x381baa
movb $0x0, %al
callq 0x2050
movq -0x18(%rbp), %rdi
leaq 0x37f61d(%rip), %rsi    # 0x3993d2
callq 0x2200
movq %rax, -0x20(%rbp)
movq $0x0, -0x28(%rbp)
movq -0x28(%rbp), %rax
cmpq 0x3ab54f(%rip), %rax    # 0x3c5320
jae 0x1a167
movq $0x0, -0x30(%rbp)
movq -0x30(%rbp), %rax
movq -0x8(%rbp), %rcx
imulq $0x18, -0x28(%rbp), %rdx
addq %rdx, %rcx
movl 0xc(%rcx), %ecx
cmpq %rcx, %rax
jae 0x1a154
movq 0x3ab4d6(%rip), %rdi    # 0x3c52d8
movq 0x3ab507(%rip), %rax    # 0x3c5310
movq -0x8(%rbp), %rcx
imulq $0x18, -0x28(%rbp), %rdx
addq %rdx, %rcx
movq (%rcx), %rcx
imulq $0x28, -0x30(%rbp), %rdx
addq %rdx, %rcx
movq (%rcx), %rcx
shrq $0x20, %rcx
movl %ecx, %ecx
addq (%rax,%rcx,8), %rdi
movq 0x3ab4dc(%rip), %rax    # 0x3c5310
movq -0x8(%rbp), %rcx
imulq $0x18, -0x28(%rbp), %rdx
addq %rdx, %rcx
movq (%rcx), %rcx
imulq $0x28, -0x30(%rbp), %rdx
addq %rdx, %rcx
movq (%rcx), %rcx
shrq $0x20, %rcx
addl $0x1, %ecx
movl %ecx, %ecx
movq (%rax,%rcx,8), %rdx
movq 0x3ab4ae(%rip), %rax    # 0x3c5310
movq -0x8(%rbp), %rcx
imulq $0x18, -0x28(%rbp), %rsi
addq %rsi, %rcx
movq (%rcx), %rcx
imulq $0x28, -0x30(%rbp), %rsi
addq %rsi, %rcx
movq (%rcx), %rcx
shrq $0x20, %rcx
movl %ecx, %ecx
subq (%rax,%rcx,8), %rdx
movq -0x20(%rbp), %rcx
movl $0x1, %esi
callq 0x2400
movq -0x20(%rbp), %rcx
leaq 0x37ec8d(%rip), %rdi    # 0x398b2c
movl $0x1, %edx
movq %rdx, %rsi
callq 0x2400
movq -0x20(%rbp), %rdi
movq 0x3ab431(%rip), %rax    # 0x3c52e8
movq -0x8(%rbp), %rcx
imulq $0x18, -0x28(%rbp), %rdx
addq %rdx, %rcx
movq (%rcx), %rcx
imulq $0x28, -0x30(%rbp), %rdx
addq %rdx, %rcx
movq (%rcx), %rcx
shrq $0x20, %rcx
movl %ecx, %ecx
movq (%rax,%rcx,8), %rdx
leaq 0x3764a8(%rip), %rsi    # 0x39038a
movb $0x0, %al
callq 0x22a0
movq -0x20(%rbp), %rdi
movq -0x8(%rbp), %rax
imulq $0x18, -0x28(%rbp), %rcx
addq %rcx, %rax
movq (%rax), %rax
imulq $0x28, -0x30(%rbp), %rcx
addq %rcx, %rax
movq (%rax), %rax
movl %eax, %edx
leaq 0x367c79(%rip), %rsi    # 0x381b89
movb $0x0, %al
callq 0x22a0
movq -0x20(%rbp), %rdi
movq -0x8(%rbp), %rax
imulq $0x18, -0x28(%rbp), %rcx
addq %rcx, %rax
movq (%rax), %rax
imulq $0x28, -0x30(%rbp), %rcx
addq %rcx, %rax
movl 0x8(%rax), %edx
leaq 0x367c4d(%rip), %rsi    # 0x381b89
movb $0x0, %al
callq 0x22a0
movq -0x8(%rbp), %rax
imulq $0x18, -0x28(%rbp), %rcx
addq %rcx, %rax
movq (%rax), %rax
imulq $0x28, -0x30(%rbp), %rcx
addq %rcx, %rax
movq 0x18(%rax), %rax
shrq $0x1f, %rax
andq $0x1, %rax
cmpl $0x0, %eax
je 0x19f7f
movq -0x20(%rbp), %rdi
leaq 0x367c17(%rip), %rsi    # 0x381b8d
movb $0x0, %al
callq 0x22a0
jmp 0x19f91
movq -0x20(%rbp), %rdi
leaq 0x367c06(%rip), %rsi    # 0x381b90
movb $0x0, %al
callq 0x22a0
movq 0x3ab340(%rip), %rdi    # 0x3c52d8
movq 0x3ab371(%rip), %rax    # 0x3c5310
movq -0x8(%rbp), %rcx
imulq $0x18, -0x28(%rbp), %rdx
addq %rdx, %rcx
movq (%rcx), %rcx
imulq $0x28, -0x30(%rbp), %rdx
addq %rdx, %rcx
movl 0xc(%rcx), %ecx
addq (%rax,%rcx,8), %rdi
movq 0x3ab34c(%rip), %rax    # 0x3c5310
movq -0x8(%rbp), %rcx
imulq $0x18, -0x28(%rbp), %rdx
addq %rdx, %rcx
movq (%rcx), %rcx
imulq $0x28, -0x30(%rbp), %rdx
addq %rdx, %rcx
movl 0xc(%rcx), %ecx
addl $0x1, %ecx
movl %ecx, %ecx
movq (%rax,%rcx,8), %rdx
movq 0x3ab322(%rip), %rax    # 0x3c5310
movq -0x8(%rbp), %rcx
imulq $0x18, -0x28(%rbp), %rsi
addq %rsi, %rcx
movq (%rcx), %rcx
imulq $0x28, -0x30(%rbp), %rsi
addq %rsi, %rcx
movl 0xc(%rcx), %ecx
subq (%rax,%rcx,8), %rdx
movq -0x20(%rbp), %rcx
movl $0x1, %esi
callq 0x2400
movq -0x20(%rbp), %rcx
leaq 0x37eb07(%rip), %rdi    # 0x398b2c
movl $0x1, %edx
movq %rdx, %rsi
callq 0x2400
movq -0x20(%rbp), %rdi
movq 0x3ab2ab(%rip), %rax    # 0x3c52e8
movq -0x8(%rbp), %rcx
imulq $0x18, -0x28(%rbp), %rdx
addq %rdx, %rcx
movq (%rcx), %rcx
imulq $0x28, -0x30(%rbp), %rdx
addq %rdx, %rcx
movl 0xc(%rcx), %ecx
movq (%rax,%rcx,8), %rdx
leaq 0x376328(%rip), %rsi    # 0x39038a
movb $0x0, %al
callq 0x22a0
movq -0x20(%rbp), %rdi
movq -0x8(%rbp), %rax
imulq $0x18, -0x28(%rbp), %rcx
addq %rcx, %rax
movq (%rax), %rax
imulq $0x28, -0x30(%rbp), %rcx
addq %rcx, %rax
movl 0x10(%rax), %edx
leaq 0x367afb(%rip), %rsi    # 0x381b89
movb $0x0, %al
callq 0x22a0
movq -0x20(%rbp), %rdi
movq -0x8(%rbp), %rax
imulq $0x18, -0x28(%rbp), %rcx
addq %rcx, %rax
movq (%rax), %rax
imulq $0x28, -0x30(%rbp), %rcx
addq %rcx, %rax
movl 0x14(%rax), %edx
leaq 0x367acf(%rip), %rsi    # 0x381b89
movb $0x0, %al
callq 0x22a0
movq -0x20(%rbp), %rdi
movq -0x8(%rbp), %rax
imulq $0x18, -0x28(%rbp), %rcx
addq %rcx, %rax
movq (%rax), %rax
imulq $0x28, -0x30(%rbp), %rcx
addq %rcx, %rax
movq 0x18(%rax), %rax
shrq $0x1e, %rax
andq $0x1, %rax
movl %eax, %edx
leaq 0x367a98(%rip), %rsi    # 0x381b89
movb $0x0, %al
callq 0x22a0
movq -0x20(%rbp), %rdi
movq -0x8(%rbp), %rax
imulq $0x18, -0x28(%rbp), %rcx
addq %rcx, %rax
movq (%rax), %rax
imulq $0x28, -0x30(%rbp), %rcx
addq %rcx, %rax
movq 0x18(%rax), %rax
shrq $0x20, %rax
andq $0x7fffffff, %rax       # imm = 0x7FFFFFFF
movl %eax, %edx
leaq 0x367a5f(%rip), %rsi    # 0x381b89
movb $0x0, %al
callq 0x22a0
movq -0x20(%rbp), %rdi
leaq 0x36fb64(%rip), %rsi    # 0x389ca0
movb $0x0, %al
callq 0x22a0
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0x19ddf
jmp 0x1a156
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
jmp 0x19dc6
movq -0x18(%rbp), %rdi
callq 0x2210
movq -0x20(%rbp), %rdi
callq 0x21a0
movq 0x3a9e60(%rip), %rax    # 0x3c3fe0
movq (%rax), %rdi
leaq 0x367a09(%rip), %rsi    # 0x381b93
movb $0x0, %al
callq 0x22a0
addq $0x40, %rsp
popq %rbp
retq
nopw (%rax,%rax)