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

    stats_clear(&stats);

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

    /* read file */
    while (i<size) {
        if (T[i] != '@') {
            fprintf(stderr, "parasail_stat_fastq_buffer: "
                    "poorly formatted FASTQ file, line %lu\n", line);
            return NULL;
        }

        /* encountered a new sequence */
        ++seq;
        if (first) {
            first = 0;
        }
        else {
            stats_sample_value(&stats, c);
        }
        c = 0;

        i = skip_line(T, i);

        /* go to next line */
        ++i;
        ++line;

        /* rest of next line is the sequence */
        while (T[i] != '\n' && T[i] != '\r') {
            ++c;
            ++i;
        }

        /* for the case of "\r\n" or "\n\r" */
        if (i+1<size && (T[i+1] == '\n' || T[i+1] == '\r')) {
            ++i;
        }

        stats_sample_value(&stats, c);

        /* go to next line */
        ++i;
        ++line;

        if (T[i] != '+') {
            fprintf(stderr, "parasail_stat_fastq_buffer: "
                    "poorly formatted FASTQ file, line %lu\n", line);
            return NULL;
        }

        i = skip_line(T, i);

        /* go to next line */
        ++i;
        ++line;

        /* rest of next line are the quality control values */
        i = skip_line(T, i);

        /* go to next line */
        ++i;
        ++line;
    }

    pfs = (parasail_file_stat_t*)malloc(sizeof(parasail_file_stat_t));
    if (NULL == pfs) {
        perror("malloc");
        fprintf(stderr, "parasail_stat_fastq_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 %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x38, %rsp
testq %rdi, %rdi
je 0x251c86
testq %rsi, %rsi
jle 0x251bf5
xorpd %xmm2, %xmm2
xorl %edx, %edx
movq 0x3c66e5(%rip), %xmm0   # 0x618020
movapd 0x3c66ed(%rip), %xmm1   # 0x618030
xorl %r8d, %r8d
xorl %r14d, %r14d
xorl %ecx, %ecx
xorl %r10d, %r10d
xorpd %xmm5, %xmm5
xorpd %xmm10, %xmm10
xorpd %xmm4, %xmm4
xorl %r9d, %r9d
cmpb $0x40, (%rdi,%rcx)
jne 0x251c94
testb $0x1, %r10b
je 0x2519ec
movq %r8, %xmm6
punpckldq %xmm0, %xmm6    # xmm6 = xmm6[0],xmm0[0],xmm6[1],xmm0[1]
subpd %xmm1, %xmm6
movapd %xmm6, %xmm3
unpckhpd %xmm6, %xmm3            # xmm3 = xmm3[1],xmm6[1]
addsd %xmm6, %xmm3
movapd %xmm3, %xmm7
movapd %xmm3, %xmm8
testq %r9, %r9
je 0x2519a6
minsd %xmm3, %xmm5
maxsd %xmm3, %xmm2
movapd %xmm5, %xmm7
movapd %xmm2, %xmm8
incq %r9
movapd %xmm3, %xmm2
subsd %xmm4, %xmm2
movq %r9, %xmm5
punpckldq %xmm0, %xmm5    # xmm5 = xmm5[0],xmm0[0],xmm5[1],xmm0[1]
subpd %xmm1, %xmm5
movapd %xmm5, %xmm9
unpckhpd %xmm5, %xmm9            # xmm9 = xmm9[1],xmm5[1]
addsd %xmm5, %xmm9
movapd %xmm2, %xmm6
divsd %xmm9, %xmm6
addsd %xmm4, %xmm6
subsd %xmm6, %xmm3
mulsd %xmm2, %xmm3
addsd %xmm10, %xmm3
movq %r9, %rax
jmp 0x251a01
movq %r9, %rax
movapd %xmm4, %xmm6
movapd %xmm10, %xmm3
movapd %xmm5, %xmm7
movapd %xmm2, %xmm8
incq %r14
movb $0x40, %r8b
cmpb $0xa, %r8b
je 0x251a21
movzbl %r8b, %r8d
cmpl $0xd, %r8d
je 0x251a21
movb 0x1(%rdi,%rcx), %r8b
incq %rcx
jmp 0x251a07
leaq 0x1(%rcx), %r10
movzbl 0x1(%rdi,%rcx), %r8d
cmpl $0xa, %r8d
je 0x251a3a
cmpl $0xd, %r8d
je 0x251a3a
movq %rcx, %r10
addq $0x2, %r10
xorl %r8d, %r8d
movzbl -0x1(%rdi,%r10), %ecx
cmpl $0xa, %ecx
je 0x251a59
cmpl $0xd, %ecx
je 0x251a59
incq %r8
incq %r10
jmp 0x251a41
leaq -0x1(%r10), %rcx
cmpq %rsi, %r10
jge 0x251a73
movzbl (%rdi,%r10), %r9d
cmpl $0xa, %r9d
je 0x251a76
cmpl $0xd, %r9d
je 0x251a76
movq %rcx, %r10
movq %r8, %xmm2
punpckldq %xmm0, %xmm2    # xmm2 = xmm2[0],xmm0[0],xmm2[1],xmm0[1]
subpd %xmm1, %xmm2
movapd %xmm2, %xmm10
unpckhpd %xmm2, %xmm10           # xmm10 = xmm10[1],xmm2[1]
addsd %xmm2, %xmm10
movapd %xmm10, %xmm5
movapd %xmm10, %xmm2
testq %rax, %rax
je 0x251ab4
minsd %xmm10, %xmm7
maxsd %xmm10, %xmm8
movapd %xmm7, %xmm5
movapd %xmm8, %xmm2
leaq 0x1(%rax), %r9
movq %r9, %xmm4
punpckldq %xmm0, %xmm4    # xmm4 = xmm4[0],xmm0[0],xmm4[1],xmm0[1]
subpd %xmm1, %xmm4
cmpb $0x2b, 0x1(%r10,%rdi)
jne 0x251cb0
movapd %xmm10, %xmm7
subsd %xmm6, %xmm7
movapd %xmm4, %xmm8
unpckhpd %xmm4, %xmm8            # xmm8 = xmm8[1],xmm4[1]
addsd %xmm4, %xmm8
movapd %xmm7, %xmm4
divsd %xmm8, %xmm4
addsd %xmm6, %xmm4
subsd %xmm4, %xmm10
mulsd %xmm7, %xmm10
addsd %xmm3, %xmm10
addq $0x2, %r10
movb $0x2b, %r11b
movq %r10, %rcx
cmpb $0xa, %r11b
je 0x251b28
movzbl %r11b, %r10d
cmpl $0xd, %r10d
je 0x251b28
movb (%rdi,%rcx), %r11b
incq %rcx
jmp 0x251b0f
movzbl (%rdi,%rcx), %r10d
cmpl $0xa, %r10d
je 0x251b3c
cmpl $0xd, %r10d
je 0x251b3c
decq %rcx
incq %rcx
movzbl (%rdi,%rcx), %r10d
incq %rcx
cmpl $0xd, %r10d
je 0x251b53
cmpl $0xa, %r10d
jne 0x251b3f
movzbl (%rdi,%rcx), %r10d
cmpl $0xa, %r10d
je 0x251b67
cmpl $0xd, %r10d
je 0x251b67
decq %rcx
incq %rcx
addq $0x4, %rdx
movb $0x1, %r10b
cmpq %rsi, %rcx
jl 0x25195e
movapd %xmm10, 0x20(%rsp)
cvttsd2si %xmm5, %rcx
movsd 0x3faf02(%rip), %xmm0   # 0x64ca90
subsd %xmm0, %xmm5
cvttsd2si %xmm5, %rdx
movq %rcx, %r15
sarq $0x3f, %r15
andq %rdx, %r15
orq %rcx, %r15
cvttsd2si %xmm2, %rcx
subsd %xmm0, %xmm2
cvttsd2si %xmm2, %rdx
movq %rcx, %r12
sarq $0x3f, %r12
andq %rdx, %r12
xorps %xmm0, %xmm0
cvtsd2ss %xmm4, %xmm0
movss %xmm0, 0xc(%rsp)
movq %rax, %xmm0
punpckldq 0x3c644a(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x3c6452(%rip), %xmm0   # 0x618030
orq %rcx, %r12
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
movapd %xmm1, 0x10(%rsp)
jmp 0x251c1d
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
xorps %xmm0, %xmm0
movss %xmm0, 0xc(%rsp)
movsd 0x3c63fa(%rip), %xmm0   # 0x618008
movapd %xmm0, 0x10(%rsp)
xorl %r15d, %r15d
xorl %r12d, %r12d
xorl %r14d, %r14d
movl $0x28, %edi
callq 0x1f01f0
testq %rax, %rax
je 0x251c8d
movq %rax, %rbx
movq %r14, (%rax)
movq $0x0, 0x8(%rax)
movq %r15, 0x10(%rax)
movq %r12, 0x18(%rax)
movss 0xc(%rsp), %xmm0
movss %xmm0, 0x20(%rax)
movapd 0x20(%rsp), %xmm0
divsd 0x10(%rsp), %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x251c69
sqrtsd %xmm0, %xmm0
jmp 0x251c6e
callq 0x1f0120
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x24(%rbx)
movq %rbx, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
callq 0x1f08e7
jmp 0x251cb8
callq 0x1f08bd
jmp 0x251cb8
movq 0x59033d(%rip), %rax    # 0x7e1fd8
movq (%rax), %rdi
leaq 0x3fb254(%rip), %rsi    # 0x64cef9
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x1f0220
jmp 0x251c77
movq %rdx, %rdi
callq 0x1f089e
xorl %ebx, %ebx
jmp 0x251c77