// File: /workspace/github_c_makefile_star2_O2/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 0x1f3b53
movq %rdx, %r13
testq %rdx, %rdx
je 0x1f3b68
movq %rsi, %r15
movq %rdi, %r12
callq 0x1f3183
testq %rax, %rax
je 0x1f3b7b
movq %rax, %r14
movq (%rax), %rax
movq 0x8(%r14), %rcx
leaq (%rcx,%rax), %rdi
incq %rdi
callq 0x1f01f0
testq %rax, %rax
je 0x1f3b9c
movq %rax, %rbx
movq %r14, %rdi
callq 0x1f01c0
cmpb $0x3e, (%r12)
jne 0x1f3bc9
movq %r13, 0x10(%rsp)
movq %rbx, 0x8(%rsp)
xorl %ebx, %ebx
movq %r12, %rdi
xorl %esi, %esi
callq 0x1f36c6
movq %rax, %rbp
leaq 0x1(%rbp), %r13
cmpq %r15, %r13
jge 0x1f3b38
movsbq (%r12,%r13), %r14
cmpq $0x3e, %r14
je 0x1f3b0b
callq 0x1f0190
movq (%rax), %rax
movzwl (%rax,%r14,2), %eax
btl $0xa, %eax
jb 0x1f3b24
movzbl %r14b, %ecx
cmpl $0xd, %ecx
je 0x1f3ae5
cmpl $0xa, %ecx
jne 0x1f3bea
movq %rbp, %rax
addq $0x2, %rax
movq %r13, %rbp
cmpq %r15, %rax
jge 0x1f3aa8
movzbl (%r12,%rax), %ecx
movq %rax, %rbp
cmpl $0xd, %ecx
je 0x1f3aa8
movq %r13, %rbp
cmpl $0xa, %ecx
je 0x1f3aa5
jmp 0x1f3aa8
movq 0x8(%rsp), %rax
movb $0x24, (%rax,%rbx)
movq %r12, %rdi
movq %r13, %rsi
callq 0x1f36c6
movq %rax, %r13
jmp 0x1f3b2d
movq 0x8(%rsp), %rax
movb %r14b, (%rax,%rbx)
incq %rbx
movq %r13, %rbp
jmp 0x1f3aa8
movq 0x8(%rsp), %rax
movw $0x24, (%rax,%rbx)
incq %rbx
movq 0x10(%rsp), %rcx
movq %rbx, (%rcx)
jmp 0x1f3c20
movq 0x55047e(%rip), %rax    # 0x743fd8
movq (%rax), %rcx
leaq 0x3f75be(%rip), %rdi    # 0x5eb122
pushq $0x29
jmp 0x1f3b8e
movq 0x550469(%rip), %rax    # 0x743fd8
movq (%rax), %rcx
leaq 0x3f75d3(%rip), %rdi    # 0x5eb14c
jmp 0x1f3b8c
movq 0x550456(%rip), %rax    # 0x743fd8
movq (%rax), %rcx
leaq 0x3f75ef(%rip), %rdi    # 0x5eb17b
pushq $0x2e
popq %rsi
pushq $0x1
popq %rdx
callq 0x1f02b0
jmp 0x1f3c1e
leaq 0x3f6f9c(%rip), %rdi    # 0x5eab3f
callq 0x1f0140
movq 0x550429(%rip), %rax    # 0x743fd8
movq (%rax), %rcx
leaq 0x3f75f1(%rip), %rdi    # 0x5eb1aa
pushq $0x2a
popq %rsi
pushq $0x1
popq %rdx
callq 0x1f02b0
movq %r14, %rdi
jmp 0x1f3c19
movq 0x550408(%rip), %rax    # 0x743fd8
movq (%rax), %rcx
leaq 0x3f75fb(%rip), %rdi    # 0x5eb1d5
pushq $0x38
popq %rsi
pushq $0x1
popq %rdx
callq 0x1f02b0
movq %rbx, %rdi
jmp 0x1f3c19
btl $0xe, %eax
movq 0x5503e3(%rip), %rax    # 0x743fd8
movq (%rax), %rdi
jb 0x1f3c03
leaq 0x3f7645(%rip), %rsi    # 0x5eb246
jmp 0x1f3c0a
leaq 0x3f7604(%rip), %rsi    # 0x5eb20e
movl %r14d, %edx
xorl %eax, %eax
callq 0x1f0220
movq 0x8(%rsp), %rdi
callq 0x1f01c0
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq