// File: /workspace/github_c_makefile_star2_O2/nh13[P]ksw/src/parasail/src/parser.c
// Function: parasail_sequences_from_file
parasail_sequences_t* parasail_sequences_from_file(const char *filename)
{
#if HAVE_ZLIB
    gzFile fp;
#else
    FILE* fp;
    int is_stdin = 0;
#endif
    kseq_t *seq = NULL;
    int l = 0;
    parasail_sequences_t *retval = NULL;
    parasail_sequence_t *sequences = NULL;
    unsigned long count = 0;
    unsigned long capacity = 1000;
    size_t chars = 0;
    stats_t stats;
    int error_during_kseq = 0;

    stats_clear(&stats);

    retval = (parasail_sequences_t*)malloc(sizeof(parasail_sequences_t));
    if (NULL == retval) {
        perror("malloc");
        fprintf(stderr, "parasail_sequences_from_file: failed\n");
        return NULL;
    }
    sequences = (parasail_sequence_t*)malloc(sizeof(parasail_sequence_t) * capacity);
    if (NULL == sequences) {
        perror("malloc");
        fprintf(stderr, "parasail_sequences_from_file: failed\n");
        free(retval);
        return NULL;
    }

    /* check for stdin instead of a normal filename */
    if (0 == strncmp("stdin", filename, 5)) {
#if HAVE_ZLIB
        fp = gzdopen(fileno(stdin), "r");
        if (fp == Z_NULL) {
            perror("gzdopen");
            fprintf(stderr, "parasail_sequences_from_file: failed\n");
            free(sequences);
            free(retval);
            return NULL;
        }
#else
        fp = stdin;
        is_stdin = 1;
#endif
    }
    else {
        /* open the file */
        errno = 0;
#if HAVE_ZLIB
        fp = gzopen(filename, "r");
        if (fp == Z_NULL) {
            perror("gzopen");
            fprintf(stderr, "parasail_sequences_from_file: failed\n");
            free(sequences);
            free(retval);
            return NULL;
        }
#else
        fp = fopen(filename, "r");
        if (fp == NULL) {
            perror("fopen");
            fprintf(stderr, "parasail_sequences_from_file: failed\n");
            free(sequences);
            free(retval);
            return NULL;
        }
#endif
    }
    
    /* initialize kseq structures */
#if HAVE_ZLIB
    seq = kseq_init(fp);
#else
    seq = kseq_init(fileno(fp));
#endif

    /* parse file */
    while ((l = kseq_read(seq)) >= 0) {
        errno = 0;
        sequences[count].name.l = seq->name.l;
        sequences[count].comment.l = seq->comment.l;
        sequences[count].seq.l = seq->seq.l;
        sequences[count].qual.l = seq->qual.l;
        sequences[count].name.s = NULL;
        sequences[count].comment.s = NULL;
        sequences[count].seq.s = NULL;
        sequences[count].qual.s = NULL;

        stats_sample_value(&stats, seq->seq.l);
        chars += seq->seq.l;

        if (sequences[count].name.l) {
            sequences[count].name.s = strdup_rpl(seq->name.s);
            if (NULL == sequences[count].name.s) {
                perror("strdup name");
                error_during_kseq = 1;
                break;
            }
        }
        if (sequences[count].comment.l) {
            sequences[count].comment.s = strdup_rpl(seq->comment.s);
            if (NULL == sequences[count].comment.s) {
                perror("strdup comment");
                error_during_kseq = 1;
                break;
            }
        }
        if (sequences[count].seq.l) {
            sequences[count].seq.s = strdup_rpl(seq->seq.s);
            if (NULL == sequences[count].seq.s) {
                perror("strdup seq");
                error_during_kseq = 1;
                break;
            }
        }
        if (sequences[count].qual.l) {
            sequences[count].qual.s = strdup_rpl(seq->qual.s);
            if (NULL == sequences[count].qual.s) {
                perror("strdup qual");
                error_during_kseq = 1;
                break;
            }
        }
        ++count;

        /* allocate more space for sequences if we ran out */
        if (count >= capacity) {
            parasail_sequence_t *new_sequences = NULL;
            capacity *= 2;
            errno = 0;
            new_sequences = (parasail_sequence_t*)realloc(sequences, sizeof(parasail_sequence_t) * capacity);
            if (NULL == new_sequences) {
                perror("realloc");
                error_during_kseq = 2;
                break;
            }
            sequences = new_sequences;
            errno = 0;
        }
    }
    kseq_destroy(seq);
#if HAVE_ZLIB
    gzclose(fp);
#else
    if (!is_stdin) {
        fclose(fp);
    }
#endif

    retval->seqs = sequences;
    retval->l = count;
    retval->characters = chars;
    retval->shortest = stats._min;
    retval->longest = stats._max;
    retval->mean = stats._mean;
    retval->stddev = stats_stddev(&stats);

    if (0 != error_during_kseq) {
        fprintf(stderr, "parasail_sequences_from_file: failed\n");
        if (1 == error_during_kseq) {
            retval->l++;
        }
        parasail_sequences_free(retval);
        return NULL;
    }

    return retval;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %rdi, %rbx
pushq $0x30
popq %rdi
callq 0x129190
testq %rax, %rax
je 0x130f58
movq %rax, %r14
movl $0xfa00, %edi           # imm = 0xFA00
callq 0x129190
testq %rax, %rax
je 0x130f82
movq %rax, 0x40(%rsp)
leaq 0x3fe21e(%rip), %rdi    # 0x52eb4d
pushq $0x5
popq %rdx
movq %rbx, %rsi
callq 0x1290b0
movl %eax, %ebp
testl %eax, %eax
je 0x130993
callq 0x129030
andl $0x0, (%rax)
leaq 0x3fde62(%rip), %rsi    # 0x52e7b1
movq %rbx, %rdi
callq 0x129160
testq %rax, %rax
jne 0x13099d
leaq 0x3fe1f0(%rip), %rdi    # 0x52eb53
callq 0x129110
movq 0x4cd671(%rip), %rax    # 0x5fdfe0
movq (%rax), %rcx
leaq 0x3fe1ae(%rip), %rdi    # 0x52eb27
pushq $0x25
popq %rsi
pushq $0x1
popq %rdx
callq 0x129220
movq 0x40(%rsp), %rdi
callq 0x129170
jmp 0x130faa
movq 0x4cd636(%rip), %rax    # 0x5fdfd0
movq (%rax), %rax
movl %ebp, (%rsp)
movq %r14, 0x18(%rsp)
movq %rax, 0x70(%rsp)
movq %rax, %rdi
callq 0x129140
movl %eax, %ebx
pushq $0x1
popq %r14
pushq $0x70
popq %rsi
movq %r14, %rdi
callq 0x1290e0
movq %rax, %r13
pushq $0x18
popq %rsi
movq %r14, %rdi
callq 0x1290e0
movq %rax, %r14
movl %ebx, 0x14(%rax)
movl $0x4000, %edi           # imm = 0x4000
callq 0x129190
movq %rax, (%r14)
movq %r14, 0x68(%r13)
leaq 0x48(%r13), %r15
leaq 0x30(%r13), %r12
leaq 0x18(%r13), %rax
movq %rax, 0x78(%rsp)
movl $0x3e8, %eax            # imm = 0x3E8
movq %rax, 0x48(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x60(%rsp)
xorl %eax, %eax
movq $0x0, 0x10(%rsp)
movaps %xmm0, 0x50(%rsp)
movaps %xmm0, 0x20(%rsp)
movaps %xmm0, 0x30(%rsp)
movq $0x0, 0x8(%rsp)
testl %eax, %eax
jne 0x130a54
movq %r14, %rdi
callq 0x1311ea
testl %eax, %eax
js 0x130de5
cmpl $0x40, %eax
je 0x130a4c
cmpl $0x3e, %eax
jne 0x130a32
movl %eax, 0x4(%rsp)
movl %eax, 0x60(%r13)
andq $0x0, 0x48(%r13)
andq $0x0, 0x30(%r13)
andq $0x0, 0x18(%r13)
movq %r14, %rdi
xorl %esi, %esi
movq %r13, %rdx
leaq 0x4(%rsp), %rcx
callq 0x13126b
testl %eax, %eax
js 0x130e00
cmpl $0xa, 0x4(%rsp)
je 0x130a96
movq %r14, %rdi
pushq $0x2
popq %rsi
movq 0x78(%rsp), %rdx
xorl %ecx, %ecx
callq 0x13126b
cmpq $0x0, 0x40(%r13)
pushq $0x1
popq %rbx
jne 0x130ab6
movq $0x100, 0x38(%r13)      # imm = 0x100
movl $0x100, %edi            # imm = 0x100
callq 0x129190
movq %rax, 0x40(%r13)
movq %r14, %rdi
callq 0x1311ea
movl %eax, 0x4(%rsp)
testl %eax, %eax
js 0x130b06
cmpl $0xa, %eax
je 0x130ab6
cmpl $0x2b, %eax
je 0x130b06
cmpl $0x3e, %eax
je 0x130b02
cmpl $0x40, %eax
je 0x130b02
movq 0x30(%r13), %rcx
movq 0x40(%r13), %rdx
leaq 0x1(%rcx), %rsi
movq %rsi, 0x30(%r13)
movb %al, (%rdx,%rcx)
movq %r14, %rdi
pushq $0x2
popq %rsi
movq %r12, %rdx
xorl %ecx, %ecx
movl %ebx, %r8d
callq 0x131270
jmp 0x130ab6
movl %eax, 0x60(%r13)
movq 0x30(%r13), %rbp
movq 0x38(%r13), %rbx
leaq 0x1(%rbp), %rcx
movq 0x40(%r13), %rax
cmpq %rbx, %rcx
jb 0x130b62
movq %rcx, %rdx
shrq %rdx
orq %rcx, %rdx
movq %rdx, %rcx
shrq $0x2, %rcx
orq %rdx, %rcx
movq %rcx, %rdx
shrq $0x4, %rdx
orq %rcx, %rdx
movq %rdx, %rcx
shrq $0x8, %rcx
orq %rdx, %rcx
movq %rcx, %rbx
shrq $0x10, %rbx
orq %rcx, %rbx
incq %rbx
movq %rbx, 0x38(%r13)
movq %rax, %rdi
movq %rbx, %rsi
callq 0x1291f0
movq %rax, 0x40(%r13)
movb $0x0, (%rax,%rbp)
cmpl $0x2b, 0x4(%rsp)
jne 0x130beb
cmpq %rbx, 0x50(%r13)
jae 0x130b87
movq %rbx, 0x50(%r13)
movq 0x58(%r13), %rdi
movq %rbx, %rsi
callq 0x1291f0
movq %rax, 0x58(%r13)
movq %r14, %rdi
callq 0x1311ea
movl %eax, 0x4(%rsp)
testl %eax, %eax
js 0x130b9c
cmpl $0xa, %eax
jne 0x130b87
cmpl $-0x1, %eax
pushq $0x1
popq %rbx
je 0x130de5
movq %r14, %rdi
pushq $0x2
popq %rsi
movq %r15, %rdx
xorl %ecx, %ecx
movl %ebx, %r8d
callq 0x131270
testl %eax, %eax
js 0x130bd6
movq (%r15), %rbp
movq (%r12), %rax
xorl %ecx, %ecx
cmpq %rax, %rbp
setb %cl
movl %ecx, 0x4(%rsp)
jb 0x130ba8
jmp 0x130bdd
movq (%r12), %rax
movq (%r15), %rbp
andl $0x0, 0x60(%r13)
cmpq %rbp, %rax
jne 0x130e00
testl %ebp, %ebp
js 0x130e00
callq 0x129030
movq %rax, 0x80(%rsp)
andl $0x0, (%rax)
movq (%r13), %rcx
movq 0x10(%rsp), %rdi
movq %rdi, %rbx
shlq $0x6, %rbx
movq 0x40(%rsp), %rsi
movq %rcx, (%rsi,%rbx)
movq 0x18(%r13), %rax
movq %rax, 0x10(%rsi,%rbx)
movq %rbp, 0x20(%rsi,%rbx)
movq 0x48(%r13), %rdx
movq %rdx, 0x30(%rsi,%rbx)
andq $0x0, 0x8(%rsi,%rbx)
andq $0x0, 0x18(%rsi,%rbx)
andq $0x0, 0x28(%rsi,%rbx)
andq $0x0, 0x38(%rsi,%rbx)
movq %rbp, %xmm1
punpckldq 0x3fdea8(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x3fdeb0(%rip), %xmm1   # 0x52eb10
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
movapd %xmm0, %xmm2
movapd %xmm0, %xmm1
testq %rdi, %rdi
je 0x130c8d
movapd 0x20(%rsp), %xmm2
minsd %xmm0, %xmm2
movapd 0x30(%rsp), %xmm1
maxsd %xmm0, %xmm1
movsd %xmm1, 0x30(%rsp)
movsd %xmm2, 0x20(%rsp)
addq %rsi, %rbx
movq 0x10(%rsp), %rdx
incq %rdx
movapd %xmm0, %xmm1
movapd 0x60(%rsp), %xmm4
subsd %xmm4, %xmm1
movq %rdx, %r14
movq %rdx, %xmm2
punpckldq 0x3fde3e(%rip), %xmm2 # xmm2 = xmm2[0],mem[0],xmm2[1],mem[1]
subpd 0x3fde46(%rip), %xmm2   # 0x52eb10
movapd %xmm2, %xmm3
unpckhpd %xmm2, %xmm3            # xmm3 = xmm3[1],xmm2[1]
addsd %xmm2, %xmm3
movapd %xmm1, %xmm2
divsd %xmm3, %xmm2
addsd %xmm2, %xmm4
movapd %xmm4, 0x60(%rsp)
subsd %xmm4, %xmm0
mulsd %xmm1, %xmm0
movapd 0x50(%rsp), %xmm1
addsd %xmm0, %xmm1
movapd %xmm1, 0x50(%rsp)
addq %rbp, 0x8(%rsp)
testq %rcx, %rcx
je 0x130d24
movq 0x10(%r13), %rdi
callq 0x13109b
movq %rax, 0x8(%rbx)
testq %rax, %rax
je 0x130ff1
movq 0x10(%rbx), %rax
testq %rax, %rax
je 0x130d3f
movq 0x28(%r13), %rdi
callq 0x13109b
movq %rax, 0x18(%rbx)
testq %rax, %rax
je 0x130ffa
cmpq $0x0, 0x20(%rbx)
movq %r14, %rbp
je 0x130d5f
movq 0x40(%r13), %rdi
callq 0x13109b
movq %rax, 0x28(%rbx)
testq %rax, %rax
je 0x131034
cmpq $0x0, 0x30(%rbx)
je 0x130d7c
movq 0x58(%r13), %rdi
callq 0x13109b
movq %rax, 0x38(%rbx)
testq %rax, %rax
je 0x13103d
movq 0x48(%rsp), %rbx
cmpq %rbx, %rbp
jb 0x130db8
movq 0x80(%rsp), %r14
andl $0x0, (%r14)
movq %rbx, %rsi
shlq $0x7, %rsi
movq 0x40(%rsp), %rdi
callq 0x1291f0
testq %rax, %rax
je 0x13106c
addq %rbx, %rbx
andl $0x0, (%r14)
movq %rax, 0x40(%rsp)
movq %rbx, 0x48(%rsp)
movq 0x68(%r13), %r14
movl 0x60(%r13), %eax
movq %rbp, 0x10(%rsp)
movsd 0x20(%rsp), %xmm0
movaps %xmm0, 0x20(%rsp)
movsd 0x30(%rsp), %xmm0
movaps %xmm0, 0x30(%rsp)
jmp 0x130a2e
xorl %ebx, %ebx
movq 0x10(%rsp), %rbp
testq %r13, %r13
movq 0x18(%rsp), %r15
movl (%rsp), %eax
movq 0x8(%rsp), %r12
jne 0x130e14
jmp 0x130e73
xorl %ebx, %ebx
movq 0x10(%rsp), %rbp
movq 0x18(%rsp), %r15
movl (%rsp), %eax
movq 0x8(%rsp), %r12
movq %r12, 0x8(%rsp)
movl %eax, %r12d
movq %rbp, %r14
movl %ebx, %ebp
movq 0x10(%r13), %rdi
callq 0x129170
movq 0x28(%r13), %rdi
callq 0x129170
movq 0x40(%r13), %rdi
callq 0x129170
movq 0x58(%r13), %rdi
callq 0x129170
movq 0x68(%r13), %rbx
testq %rbx, %rbx
je 0x130e5e
movq (%rbx), %rdi
callq 0x129170
movq %rbx, %rdi
callq 0x129170
movq %r13, %rdi
callq 0x129170
movl %ebp, %ebx
movq %r14, %rbp
movl %r12d, %eax
movq 0x8(%rsp), %r12
testl %eax, %eax
je 0x130e81
movq 0x70(%rsp), %rdi
callq 0x129130
movq 0x40(%rsp), %rax
movq %rax, (%r15)
movq 0x10(%rsp), %rax
movq %rax, 0x8(%r15)
movq %r12, 0x10(%r15)
movapd 0x20(%rsp), %xmm1
cvttsd2si %xmm1, %rax
movsd 0x3cfbaf(%rip), %xmm0   # 0x500a58
subsd %xmm0, %xmm1
cvttsd2si %xmm1, %rcx
movq %rax, %rdx
sarq $0x3f, %rdx
andq %rcx, %rdx
orq %rax, %rdx
movq %rdx, 0x18(%r15)
movapd 0x30(%rsp), %xmm1
cvttsd2si %xmm1, %rax
subsd %xmm0, %xmm1
cvttsd2si %xmm1, %rcx
movq %rax, %rdx
sarq $0x3f, %rdx
andq %rcx, %rdx
orq %rax, %rdx
decq %rbp
movq %rbp, %xmm0
punpckldq 0x3fdc0c(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x3fdc14(%rip), %xmm0   # 0x52eb10
movq %rdx, 0x20(%r15)
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
movapd 0x50(%rsp), %xmm0
divsd %xmm1, %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x130f26
sqrtsd %xmm0, %xmm0
jmp 0x130f2b
callq 0x1290f0
movapd 0x60(%rsp), %xmm1
unpcklpd %xmm0, %xmm1            # xmm1 = xmm1[0],xmm0[0]
cvtpd2ps %xmm1, %xmm0
movlpd %xmm0, 0x28(%r15)
testl %ebx, %ebx
jne 0x130fb4
movq %r15, %rax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x3fdbc1(%rip), %rdi    # 0x52eb20
callq 0x129110
movq 0x4cd075(%rip), %rax    # 0x5fdfe0
movq (%rax), %rcx
leaq 0x3fdbb2(%rip), %rdi    # 0x52eb27
pushq $0x25
popq %rsi
pushq $0x1
popq %rdx
callq 0x129220
jmp 0x130fe9
leaq 0x3fdb97(%rip), %rdi    # 0x52eb20
callq 0x129110
movq 0x4cd04b(%rip), %rax    # 0x5fdfe0
movq (%rax), %rcx
leaq 0x3fdb88(%rip), %rdi    # 0x52eb27
pushq $0x25
popq %rsi
pushq $0x1
popq %rdx
callq 0x129220
movq %r14, %rdi
callq 0x129170
jmp 0x130fe9
movq 0x4cd025(%rip), %rax    # 0x5fdfe0
movq (%rax), %rcx
leaq 0x3fdb62(%rip), %rdi    # 0x52eb27
pushq $0x25
popq %rsi
pushq $0x1
popq %rdx
callq 0x129220
cmpl $0x1, %ebx
jne 0x130fe1
movq 0x10(%rsp), %rax
incq %rax
movq %rax, 0x8(%r15)
movq %r15, %rdi
callq 0x1310d8
xorl %r15d, %r15d
jmp 0x130f43
leaq 0x3fdb61(%rip), %rdi    # 0x52eb59
jmp 0x131001
leaq 0x3fdb64(%rip), %rdi    # 0x52eb65
callq 0x129110
movsd 0x30(%rsp), %xmm0
movaps %xmm0, 0x30(%rsp)
movsd 0x20(%rsp), %xmm0
movaps %xmm0, 0x20(%rsp)
movq 0x18(%rsp), %r15
pushq $0x1
popq %rbx
movl (%rsp), %eax
movq 0x8(%rsp), %r12
movq %r14, %rbp
jmp 0x130e14
leaq 0x3fdb39(%rip), %rdi    # 0x52eb74
jmp 0x131044
leaq 0x3fdb3b(%rip), %rdi    # 0x52eb7f
callq 0x129110
movsd 0x30(%rsp), %xmm0
movaps %xmm0, 0x30(%rsp)
movsd 0x20(%rsp), %xmm0
movaps %xmm0, 0x20(%rsp)
movq 0x18(%rsp), %r15
pushq $0x1
popq %rbx
jmp 0x130e0c
leaq 0x3fdb18(%rip), %rdi    # 0x52eb8b
callq 0x129110
pushq $0x2
popq %rbx
movq %rbp, 0x10(%rsp)
movsd 0x30(%rsp), %xmm0
movaps %xmm0, 0x30(%rsp)
movsd 0x20(%rsp), %xmm0
movaps %xmm0, 0x20(%rsp)
jmp 0x130e07