// File: /workspace/github_c_makefile_star2_O3/nh13[P]ksw/src/parasail/src/io.c
// Function: parasail_pack_fasta_buffer
char * parasail_pack_fasta_buffer(const char *T, off_t size, long * packed_size)
{
    parasail_file_stat_t *pfs = NULL;
    off_t i = 0;
    off_t w = 0;
    char *P = NULL;

    if (NULL == T) {
        fprintf(stderr, "parasail_pack_fasta_buffer: NULL pointer\n");
        return NULL;
    }

    if (NULL == packed_size) {
        fprintf(stderr, "parasail_pack_fasta_buffer: NULL size pointer\n");
        return NULL;
    }

    pfs = parasail_stat_fasta_buffer(T, size);
    if (NULL == pfs) {
        fprintf(stderr, "parasail_stat_fasta_buffer: fasta stat failed\n");
        return NULL;
    }

    P = (char*)malloc(sizeof(char) * (pfs->characters+pfs->sequences+1));
    if (NULL == P) {
        perror("malloc");
        fprintf(stderr, "parasail_pack_fasta_buffer: malloc failed\n");
        free(pfs);
        return NULL;
    }
    free(pfs);

    /* first line is always first sequence ID */
    if (T[i] != '>') {
        fprintf(stderr, "parasail_pack_fasta_buffer: "
                "poorly formatted FASTA file\n");
        free(P);
        return NULL;
    }

    i = skip_line(T, i);
    ++i;

    /* read rest of file */
    while (i<size) {
        if (T[i] == '>') {
            /* encountered a new sequence */
            P[w++] = '$';
            i = skip_line(T, i);
        }
        else if (isalpha(T[i])) {
            P[w++] = T[i];
        }
        else if (T[i] == '\n' || T[i] == '\r') {
            /* ignore newline */
            /* for the case of "\r\n" or "\n\r" */
            if (i+1<size && (T[i+1] == '\n' || T[i+1] == '\r')) {
                ++i;
            }
        }
        else if (isprint(T[i])) {
            fprintf(stderr, "parasail_pack_fasta_buffer: "
                    "non-alpha character ('%c')\n", T[i]);
            free(P);
            return NULL;
        }
        else {
            fprintf(stderr, "parasail_pack_fasta_buffer: "
                    "non-printing character ('%d')\n", T[i]);
            free(P);
            return NULL;
        }
        ++i;
    }

    P[w++] = '$';
    P[w] = '\0';
    *packed_size = w;
    return P;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
testq %rdi, %rdi
je 0x251fb1
movq %rdx, %rbx
testq %rdx, %rdx
je 0x251fb8
movq %rsi, %r15
movq %rdi, %r12
callq 0x251496
testq %rax, %rax
je 0x251fbf
movq %rax, %r13
movq (%rax), %rax
movq 0x8(%r13), %rcx
leaq (%rcx,%rax), %rdi
incq %rdi
callq 0x1f01f0
testq %rax, %rax
je 0x251fc6
movq %rax, 0x8(%rsp)
movq %r13, %rdi
callq 0x1f01c0
cmpb $0x3e, (%r12)
jne 0x251fd0
movq %rbx, 0x10(%rsp)
movb $0x3e, %cl
movl $0x1, %ebx
movq 0x8(%rsp), %rax
cmpb $0xa, %cl
je 0x251ed6
movzbl %cl, %ecx
cmpl $0xd, %ecx
je 0x251ed6
movb (%r12,%rbx), %cl
incq %rbx
jmp 0x251ec0
movzbl (%r12,%rbx), %ecx
cmpl $0xa, %ecx
je 0x251ee5
cmpl $0xd, %ecx
jne 0x251eeb
leaq 0x1(%rbx), %r14
jmp 0x251ef1
movq %rbx, %r14
decq %rbx
xorl %ebp, %ebp
cmpq %r15, %r14
jge 0x251f9e
movsbq (%r12,%r14), %r13
cmpq $0x3e, %r13
jne 0x251f27
movb $0x24, (%rax,%rbp)
incq %rbp
movb $0x3e, %cl
cmpb $0xa, %cl
je 0x251f6e
movzbl %cl, %ecx
cmpl $0xd, %ecx
je 0x251f6e
movb 0x1(%r12,%r14), %cl
incq %r14
jmp 0x251f10
callq 0x1f0190
movq (%rax), %rax
movzwl (%rax,%r13,2), %edx
btl $0xa, %edx
jb 0x251f87
movzbl %r13b, %ecx
cmpl $0xd, %ecx
movq 0x8(%rsp), %rax
je 0x251f51
cmpl $0xa, %ecx
jne 0x251feb
addq $0x2, %rbx
cmpq %r15, %rbx
jge 0x251f93
movzbl (%r12,%rbx), %ecx
cmpl $0xd, %ecx
je 0x251f69
cmpl $0xa, %ecx
jne 0x251f93
movq %rbx, %r14
jmp 0x251f93
leaq 0x1(%r14), %rdx
movzbl 0x1(%r12,%r14), %ecx
cmpl $0xa, %ecx
je 0x251f82
cmpl $0xd, %ecx
jne 0x251f93
movq %rdx, %r14
jmp 0x251f93
movq 0x8(%rsp), %rax
movb %r13b, (%rax,%rbp)
incq %rbp
movq %r14, %rbx
incq %r14
jmp 0x251ef3
movw $0x24, (%rax,%rbp)
incq %rbp
movq 0x10(%rsp), %rcx
movq %rbp, (%rcx)
jmp 0x251fdc
callq 0x1f0b4b
jmp 0x251fda
callq 0x1f0b2f
jmp 0x251fda
callq 0x1f0b13
jmp 0x251fda
movq %r13, %rdi
callq 0x1f0ade
jmp 0x251fda
movq 0x8(%rsp), %rdi
callq 0x1f0ab5
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
btl $0xe, %edx
movq 0x58ffe2(%rip), %rax    # 0x7e1fd8
movq (%rax), %rdi
jb 0x252004
leaq 0x3fb24c(%rip), %rsi    # 0x64d24e
jmp 0x25200b
leaq 0x3fb20b(%rip), %rsi    # 0x64d216
movl %r13d, %edx
xorl %eax, %eax
callq 0x1f0220
movq 0x8(%rsp), %rdi
callq 0x1f01c0
jmp 0x251fda