// File: /workspace/github_c_makefile_star2_O2/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 %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
xorpd %xmm0, %xmm0
movapd %xmm0, 0x20(%rsp)
movapd %xmm0, 0x10(%rsp)
movapd %xmm0, (%rsp)
testq %rdi, %rdi
je 0x1f3660
movq %rsi, %r14
movq %rdi, %r15
xorl %eax, %eax
xorl %r13d, %r13d
xorl %ebp, %ebp
xorl %r12d, %r12d
xorl %ebx, %ebx
cmpq %r14, %r13
jge 0x1f3579
cmpb $0x40, (%r15,%r13)
jne 0x1f3679
testb $0x1, %al
je 0x1f34ce
movq %r12, %xmm1
punpckldq 0x3c2b5e(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x3c2b66(%rip), %xmm1   # 0x5b6020
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
movq %rsp, %rdi
callq 0x1f36f0
incq %rbp
movq %r15, %rdi
movq %r13, %rsi
callq 0x1f36c6
movq %rax, %r13
addq $0x2, %r13
xorl %r12d, %r12d
movzbl -0x1(%r15,%r13), %eax
cmpl $0xa, %eax
je 0x1f34fe
cmpl $0xd, %eax
je 0x1f34fe
incq %r12
incq %r13
jmp 0x1f34e6
leaq -0x1(%r13), %rax
cmpq %r14, %r13
jge 0x1f3516
movzbl (%r15,%r13), %ecx
cmpl $0xa, %ecx
je 0x1f3519
cmpl $0xd, %ecx
je 0x1f3519
movq %rax, %r13
movq %r12, %xmm1
punpckldq 0x3c2aea(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x3c2af2(%rip), %xmm1   # 0x5b6020
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
movq %rsp, %rdi
callq 0x1f36f0
cmpb $0x2b, 0x1(%r15,%r13)
jne 0x1f3675
incq %r13
movq %r15, %rdi
movq %r13, %rsi
callq 0x1f36c6
leaq 0x1(%rax), %rsi
movq %r15, %rdi
callq 0x1f36c6
movq %rax, %r13
incq %r13
addq $0x4, %rbx
movb $0x1, %al
jmp 0x1f348d
pushq $0x28
popq %rdi
callq 0x1f01f0
testq %rax, %rax
je 0x1f3699
movq %rax, %r14
movq %rbp, (%rax)
andq $0x0, 0x8(%rax)
movsd 0x20(%rsp), %xmm0
movsd 0x3f74e5(%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(%r14)
movsd 0x28(%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(%r14)
movupd 0x8(%rsp), %xmm3
movq (%rsp), %rax
decq %rax
movq %rax, %xmm1
punpckldq 0x3c2a0f(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x3c2a17(%rip), %xmm1   # 0x5b6020
movsd 0x10(%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 0x1f362f
sqrtsd %xmm0, %xmm0
jmp 0x1f3640
movapd %xmm3, 0x30(%rsp)
callq 0x1f0120
movapd 0x30(%rsp), %xmm3
unpcklpd %xmm0, %xmm3            # xmm3 = xmm3[0],xmm0[0]
cvtpd2ps %xmm3, %xmm0
movlpd %xmm0, 0x20(%r14)
movq %r14, %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x550971(%rip), %rax    # 0x743fd8
movq (%rax), %rcx
leaq 0x3f7856(%rip), %rdi    # 0x5eaec7
pushq $0x29
jmp 0x1f36b8
orq $0x2, %rbx
movq 0x550958(%rip), %rax    # 0x743fd8
movq (%rax), %rdi
leaq 0x3f7867(%rip), %rsi    # 0x5eaef1
xorl %r14d, %r14d
movq %rbx, %rdx
xorl %eax, %eax
callq 0x1f0220
jmp 0x1f364e
leaq 0x3f749f(%rip), %rdi    # 0x5eab3f
callq 0x1f0140
movq 0x55092c(%rip), %rax    # 0x743fd8
movq (%rax), %rcx
leaq 0x3f787e(%rip), %rdi    # 0x5eaf34
pushq $0x41
popq %rsi
pushq $0x1
popq %rdx
callq 0x1f02b0
xorl %r14d, %r14d
jmp 0x1f364e