// File: /workspace/github_c_makefile_star2_O1/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 0x251dfd
movq %rdx, %r14
testq %rdx, %rdx
je 0x251e04
movq %rsi, %r15
movq %rdi, %r12
callq 0x2512fb
testq %rax, %rax
je 0x251e0b
movq %rax, %r13
movq (%rax), %rax
movq 0x8(%r13), %rcx
leaq (%rcx,%rax), %rdi
incq %rdi
callq 0x1f01f0
testq %rax, %rax
je 0x251e12
movq %rax, 0x8(%rsp)
movq %r13, %rdi
callq 0x1f01c0
cmpb $0x3e, (%r12)
jne 0x251e1c
movl $0x1, %ebx
movq 0x8(%rsp), %rax
movzbl -0x1(%r12,%rbx), %ecx
cmpl $0xa, %ecx
je 0x251d27
cmpl $0xd, %ecx
je 0x251d27
incq %rbx
jmp 0x251d12
movzbl (%r12,%rbx), %ecx
cmpl $0xa, %ecx
movq %r14, 0x10(%rsp)
je 0x251d3e
cmpl $0xd, %ecx
je 0x251d3e
decq %rbx
leaq 0x1(%rbx), %r14
xorl %ebp, %ebp
cmpq %r15, %r14
jge 0x251dea
movsbq (%r12,%r14), %r13
cmpq $0x3e, %r13
jne 0x251d73
movb $0x24, (%rax,%rbp)
incq %rbp
movzbl (%r12,%r14), %ecx
cmpl $0xa, %ecx
je 0x251dba
cmpl $0xd, %ecx
je 0x251dba
incq %r14
jmp 0x251d5f
callq 0x1f0190
movq (%rax), %rax
movzwl (%rax,%r13,2), %edx
btl $0xa, %edx
jb 0x251dd3
movzbl %r13b, %ecx
cmpl $0xd, %ecx
movq 0x8(%rsp), %rax
je 0x251d9d
cmpl $0xa, %ecx
jne 0x251e37
addq $0x2, %rbx
cmpq %r15, %rbx
jge 0x251ddf
movzbl (%r12,%rbx), %ecx
cmpl $0xd, %ecx
je 0x251db5
cmpl $0xa, %ecx
jne 0x251ddf
movq %rbx, %r14
jmp 0x251ddf
leaq 0x1(%r14), %rdx
movzbl 0x1(%r12,%r14), %ecx
cmpl $0xa, %ecx
je 0x251dce
cmpl $0xd, %ecx
jne 0x251ddf
movq %rdx, %r14
jmp 0x251ddf
movq 0x8(%rsp), %rax
movb %r13b, (%rax,%rbp)
incq %rbp
movq %r14, %rbx
incq %r14
jmp 0x251d44
movw $0x24, (%rax,%rbp)
incq %rbp
movq 0x10(%rsp), %rcx
movq %rbp, (%rcx)
jmp 0x251e28
callq 0x1f0b4b
jmp 0x251e26
callq 0x1f0b2f
jmp 0x251e26
callq 0x1f0b13
jmp 0x251e26
movq %r13, %rdi
callq 0x1f0ade
jmp 0x251e26
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 0x55b196(%rip), %rax    # 0x7acfd8
movq (%rax), %rdi
jb 0x251e50
leaq 0x3c8400(%rip), %rsi    # 0x61a24e
jmp 0x251e57
leaq 0x3c83bf(%rip), %rsi    # 0x61a216
movl %r13d, %edx
xorl %eax, %eax
callq 0x1f0220
movq 0x8(%rsp), %rdi
callq 0x1f01c0
jmp 0x251e26