// File: /workspace/github_c_makefile_star2_O2/nh13[P]ksw/src/parasail/src/io.c
// Function: parasail_stat_fasta_buffer
parasail_file_stat_t* parasail_stat_fasta_buffer(const char *T, off_t size)
{
    off_t i = 0;
    unsigned long seq = 0;
    unsigned long c = 0;
    unsigned long c_tot = 0;
    stats_t stats;
    parasail_file_stat_t *pfs = NULL;

    stats_clear(&stats);

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

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

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

    /* count that first sequence */
    ++seq;

    /* read rest of file */
    while (i<size) {
        if (T[i] == '>') {
            /* encountered a new sequence */
            ++seq;
            stats_sample_value(&stats, c);
            c = 0;
            i = skip_line(T, i);
        }
        else if (isalpha(T[i])) {
            ++c;
            ++c_tot;
        }
        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_stat_fasta_buffer: "
                    "non-alpha character ('%c')\n", T[i]);
            return NULL;
        }
        else {
            fprintf(stderr, "parasail_stat_fasta_buffer: "
                    "non-printing character ('%d')\n", T[i]);
            return NULL;
        }
        ++i;
    }

    /* still should have one sequence in the pipe */
    if (0 == c) {
        fprintf(stderr, "parasail_stat_fasta_buffer: "
                "empty sequence at end of input\n");
        return NULL;
    }
    stats_sample_value(&stats, c);

    pfs = (parasail_file_stat_t*)malloc(sizeof(parasail_file_stat_t));
    if (NULL == pfs) {
        perror("malloc");
        fprintf(stderr, "parasail_stat_fasta_buffer: "
                "cannont allocate parasail_file_stat_t");
        return NULL;
    }

    pfs->sequences = seq;
    pfs->characters = c_tot;
    pfs->shortest = (unsigned long)stats._min;
    pfs->longest = (unsigned long)stats._max;
    pfs->mean = (float)stats._mean;
    pfs->stddev = (float)stats_stddev(&stats);

    return pfs;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
xorpd %xmm0, %xmm0
movapd %xmm0, 0x40(%rsp)
movapd %xmm0, 0x30(%rsp)
movapd %xmm0, 0x20(%rsp)
testq %rdi, %rdi
je 0x1f33a6
movq %rdi, %r14
cmpb $0x3e, (%rdi)
jne 0x1f33bb
movq %rsi, %rbx
movq $0x0, 0x8(%rsp)
movq %r14, %rdi
xorl %esi, %esi
callq 0x1f36c6
movq %rax, %r15
pushq $0x1
popq %rax
movq %rax, 0x10(%rsp)
xorl %ebp, %ebp
movq %r15, %r12
leaq 0x1(%r12), %r15
movq %rbp, %xmm1
cmpq %rbx, %r15
jge 0x1f3297
movsbq (%r14,%r15), %r13
cmpq $0x3e, %r13
je 0x1f3259
callq 0x1f0190
movq (%rax), %rax
movzwl (%rax,%r13,2), %eax
btl $0xa, %eax
jb 0x1f324f
cmpb $0xd, %r13b
je 0x1f3226
movzbl %r13b, %ecx
cmpl $0xa, %ecx
jne 0x1f3421
movq %r12, %rax
addq $0x2, %rax
movq %r15, %r12
cmpq %rbx, %rax
jge 0x1f31e2
movzbl (%r14,%rax), %ecx
movq %rax, %r12
cmpl $0xd, %ecx
je 0x1f31e2
movq %r15, %r12
cmpl $0xa, %ecx
jne 0x1f31e2
movq %rax, %r12
jmp 0x1f31e2
incq %rbp
incq 0x8(%rsp)
jmp 0x1f31df
incq 0x10(%rsp)
punpckldq 0x3c2daa(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x3c2db2(%rip), %xmm1   # 0x5b6020
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
leaq 0x20(%rsp), %rdi
callq 0x1f36f0
movq %r14, %rdi
movq %r15, %rsi
callq 0x1f36c6
movq %rax, %r15
jmp 0x1f31dd
testq %rbp, %rbp
je 0x1f33d0
punpckldq 0x3c2d68(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x3c2d70(%rip), %xmm1   # 0x5b6020
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
leaq 0x20(%rsp), %rdi
callq 0x1f36f0
pushq $0x28
popq %rdi
callq 0x1f01f0
testq %rax, %rax
je 0x1f33e5
movq %rax, %rbx
movq 0x10(%rsp), %rax
movq %rax, (%rbx)
movq 0x8(%rsp), %rax
movq %rax, 0x8(%rbx)
movsd 0x40(%rsp), %xmm0
movsd 0x3f778f(%rip), %xmm1   # 0x5eaa88
cvttsd2si %xmm0, %rax
subsd %xmm1, %xmm0
cvttsd2si %xmm0, %rcx
movq %rax, %rdx
sarq $0x3f, %rdx
andq %rcx, %rdx
orq %rax, %rdx
movq %rdx, 0x10(%rbx)
movsd 0x48(%rsp), %xmm0
cvttsd2si %xmm0, %rax
subsd %xmm1, %xmm0
cvttsd2si %xmm0, %rcx
movq %rax, %rdx
sarq $0x3f, %rdx
andq %rcx, %rdx
orq %rax, %rdx
movq %rdx, 0x18(%rbx)
movupd 0x28(%rsp), %xmm3
movq 0x20(%rsp), %rax
decq %rax
movq %rax, %xmm1
punpckldq 0x3c2cb8(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x3c2cc0(%rip), %xmm1   # 0x5b6020
movsd 0x30(%rsp), %xmm0
movapd %xmm1, %xmm2
unpckhpd %xmm1, %xmm2            # xmm2 = xmm2[1],xmm1[1]
addsd %xmm1, %xmm2
divsd %xmm2, %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x1f3386
sqrtsd %xmm0, %xmm0
jmp 0x1f3397
movapd %xmm3, 0x10(%rsp)
callq 0x1f0120
movapd 0x10(%rsp), %xmm3
unpcklpd %xmm0, %xmm3            # xmm3 = xmm3[0],xmm0[0]
cvtpd2ps %xmm3, %xmm0
movlpd %xmm0, 0x20(%rbx)
jmp 0x1f340f
movq 0x550c2b(%rip), %rax    # 0x743fd8
movq (%rax), %rcx
leaq 0x3f7999(%rip), %rdi    # 0x5ead50
pushq $0x29
jmp 0x1f3404
movq 0x550c16(%rip), %rax    # 0x743fd8
movq (%rax), %rcx
leaq 0x3f79ae(%rip), %rdi    # 0x5ead7a
pushq $0x38
jmp 0x1f3404
movq 0x550c01(%rip), %rax    # 0x743fd8
movq (%rax), %rcx
leaq 0x3f7a45(%rip), %rdi    # 0x5eae26
pushq $0x3b
jmp 0x1f3404
leaq 0x3f7753(%rip), %rdi    # 0x5eab3f
callq 0x1f0140
movq 0x550be0(%rip), %rax    # 0x743fd8
movq (%rax), %rcx
leaq 0x3f7a60(%rip), %rdi    # 0x5eae62
pushq $0x41
popq %rsi
pushq $0x1
popq %rdx
callq 0x1f02b0
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
btl $0xe, %eax
movq 0x550bac(%rip), %rax    # 0x743fd8
movq (%rax), %rdi
jb 0x1f343a
leaq 0x3f79b3(%rip), %rsi    # 0x5eadeb
jmp 0x1f3441
leaq 0x3f7972(%rip), %rsi    # 0x5eadb3
xorl %ebx, %ebx
movl %r13d, %edx
xorl %eax, %eax
callq 0x1f0220
jmp 0x1f340f