// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rdi, -0x10(%rbp)
movl $0x0, -0x1c(%rbp)
movq $0x0, -0x28(%rbp)
movl $0x0, -0x2c(%rbp)
movq $0x0, -0x38(%rbp)
movq $0x0, -0x40(%rbp)
movq $0x0, -0x48(%rbp)
movq $0x3e8, -0x50(%rbp)     # imm = 0x3E8
movq $0x0, -0x58(%rbp)
movl $0x0, -0x8c(%rbp)
leaq -0x88(%rbp), %rdi
callq 0x138f70
movl $0x30, %edi
callq 0x129170
movq %rax, -0x38(%rbp)
xorl %eax, %eax
cmpq -0x38(%rbp), %rax
jne 0x1389da
leaq 0xaf820d(%rip), %rdi    # 0xc30bbd
callq 0x1290f0
movq 0xb90624(%rip), %rax    # 0xcc8fe0
movq (%rax), %rdi
leaq 0xaf81fe(%rip), %rsi    # 0xc30bc4
movb $0x0, %al
callq 0x1291a0
movq $0x0, -0x8(%rbp)
jmp 0x138f5b
movq -0x50(%rbp), %rdi
shlq $0x6, %rdi
callq 0x129170
movq %rax, -0x40(%rbp)
xorl %eax, %eax
cmpq -0x40(%rbp), %rax
jne 0x138a2d
leaq 0xaf81c3(%rip), %rdi    # 0xc30bbd
callq 0x1290f0
movq 0xb905da(%rip), %rax    # 0xcc8fe0
movq (%rax), %rdi
leaq 0xaf81b4(%rip), %rsi    # 0xc30bc4
movb $0x0, %al
callq 0x1291a0
movq -0x38(%rbp), %rdi
callq 0x129150
movq $0x0, -0x8(%rbp)
jmp 0x138f5b
movq -0x10(%rbp), %rsi
leaq 0xaf81b2(%rip), %rdi    # 0xc30bea
movl $0x5, %edx
callq 0x129090
movl %eax, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jne 0x138a61
movq 0xb9057f(%rip), %rax    # 0xcc8fd0
movq (%rax), %rax
movq %rax, -0x18(%rbp)
movl $0x1, -0x1c(%rbp)
jmp 0x138acc
callq 0x129030
movl $0x0, (%rax)
movq -0x10(%rbp), %rdi
leaq 0xaf7dfa(%rip), %rsi    # 0xc30871
callq 0x129140
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x138aca
leaq 0xaf8162(%rip), %rdi    # 0xc30bf0
callq 0x1290f0
movq 0xb90546(%rip), %rax    # 0xcc8fe0
movq (%rax), %rdi
leaq 0xaf8120(%rip), %rsi    # 0xc30bc4
movb $0x0, %al
callq 0x1291a0
movq -0x40(%rbp), %rdi
callq 0x129150
movq -0x38(%rbp), %rdi
callq 0x129150
movq $0x0, -0x8(%rbp)
jmp 0x138f5b
jmp 0x138acc
movq -0x18(%rbp), %rdi
callq 0x129120
movl %eax, %edi
callq 0x138fd0
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rdi
callq 0x139010
movl %eax, -0x2c(%rbp)
cmpl $0x0, %eax
jl 0x138e3d
callq 0x129030
movl $0x0, (%rax)
movq -0x28(%rbp), %rax
movq (%rax), %rdx
movq -0x40(%rbp), %rax
movq -0x48(%rbp), %rcx
shlq $0x6, %rcx
movq %rdx, (%rax,%rcx)
movq -0x28(%rbp), %rax
movq 0x18(%rax), %rdx
movq -0x40(%rbp), %rax
movq -0x48(%rbp), %rcx
shlq $0x6, %rcx
movq %rdx, 0x10(%rax,%rcx)
movq -0x28(%rbp), %rax
movq 0x30(%rax), %rdx
movq -0x40(%rbp), %rax
movq -0x48(%rbp), %rcx
shlq $0x6, %rcx
movq %rdx, 0x20(%rax,%rcx)
movq -0x28(%rbp), %rax
movq 0x48(%rax), %rdx
movq -0x40(%rbp), %rax
movq -0x48(%rbp), %rcx
shlq $0x6, %rcx
movq %rdx, 0x30(%rax,%rcx)
movq -0x40(%rbp), %rax
movq -0x48(%rbp), %rcx
shlq $0x6, %rcx
movq $0x0, 0x8(%rax,%rcx)
movq -0x40(%rbp), %rax
movq -0x48(%rbp), %rcx
shlq $0x6, %rcx
movq $0x0, 0x18(%rax,%rcx)
movq -0x40(%rbp), %rax
movq -0x48(%rbp), %rcx
shlq $0x6, %rcx
movq $0x0, 0x28(%rax,%rcx)
movq -0x40(%rbp), %rax
movq -0x48(%rbp), %rcx
shlq $0x6, %rcx
movq $0x0, 0x38(%rax,%rcx)
movq -0x28(%rbp), %rax
movq 0x30(%rax), %xmm0
movaps 0xac9f4a(%rip), %xmm1   # 0xc02b10
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0xac9f4e(%rip), %xmm1   # 0xc02b20
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
leaq -0x88(%rbp), %rdi
callq 0x139400
movq -0x28(%rbp), %rax
movq 0x30(%rax), %rax
addq -0x58(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x40(%rbp), %rax
movq -0x48(%rbp), %rcx
shlq $0x6, %rcx
addq %rcx, %rax
cmpq $0x0, (%rax)
je 0x138c69
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x139570
movq %rax, %rcx
movq -0x40(%rbp), %rax
movq -0x48(%rbp), %rdx
shlq $0x6, %rdx
addq %rdx, %rax
movq %rcx, 0x8(%rax)
movq -0x40(%rbp), %rcx
movq -0x48(%rbp), %rax
shlq $0x6, %rax
addq %rax, %rcx
xorl %eax, %eax
cmpq 0x8(%rcx), %rax
jne 0x138c67
leaq 0xaf7fa3(%rip), %rdi    # 0xc30bf6
callq 0x1290f0
movl $0x1, -0x8c(%rbp)
jmp 0x138e3d
jmp 0x138c69
movq -0x40(%rbp), %rax
movq -0x48(%rbp), %rcx
shlq $0x6, %rcx
addq %rcx, %rax
cmpq $0x0, 0x10(%rax)
je 0x138cd6
movq -0x28(%rbp), %rax
movq 0x28(%rax), %rdi
callq 0x139570
movq %rax, %rcx
movq -0x40(%rbp), %rax
movq -0x48(%rbp), %rdx
shlq $0x6, %rdx
addq %rdx, %rax
movq %rcx, 0x18(%rax)
movq -0x40(%rbp), %rcx
movq -0x48(%rbp), %rax
shlq $0x6, %rax
addq %rax, %rcx
xorl %eax, %eax
cmpq 0x18(%rcx), %rax
jne 0x138cd4
leaq 0xaf7f42(%rip), %rdi    # 0xc30c02
callq 0x1290f0
movl $0x1, -0x8c(%rbp)
jmp 0x138e3d
jmp 0x138cd6
movq -0x40(%rbp), %rax
movq -0x48(%rbp), %rcx
shlq $0x6, %rcx
addq %rcx, %rax
cmpq $0x0, 0x20(%rax)
je 0x138d43
movq -0x28(%rbp), %rax
movq 0x40(%rax), %rdi
callq 0x139570
movq %rax, %rcx
movq -0x40(%rbp), %rax
movq -0x48(%rbp), %rdx
shlq $0x6, %rdx
addq %rdx, %rax
movq %rcx, 0x28(%rax)
movq -0x40(%rbp), %rcx
movq -0x48(%rbp), %rax
shlq $0x6, %rax
addq %rax, %rcx
xorl %eax, %eax
cmpq 0x28(%rcx), %rax
jne 0x138d41
leaq 0xaf7ee4(%rip), %rdi    # 0xc30c11
callq 0x1290f0
movl $0x1, -0x8c(%rbp)
jmp 0x138e3d
jmp 0x138d43
movq -0x40(%rbp), %rax
movq -0x48(%rbp), %rcx
shlq $0x6, %rcx
addq %rcx, %rax
cmpq $0x0, 0x30(%rax)
je 0x138db0
movq -0x28(%rbp), %rax
movq 0x58(%rax), %rdi
callq 0x139570
movq %rax, %rcx
movq -0x40(%rbp), %rax
movq -0x48(%rbp), %rdx
shlq $0x6, %rdx
addq %rdx, %rax
movq %rcx, 0x38(%rax)
movq -0x40(%rbp), %rcx
movq -0x48(%rbp), %rax
shlq $0x6, %rax
addq %rax, %rcx
xorl %eax, %eax
cmpq 0x38(%rcx), %rax
jne 0x138dae
leaq 0xaf7e82(%rip), %rdi    # 0xc30c1c
callq 0x1290f0
movl $0x1, -0x8c(%rbp)
jmp 0x138e3d
jmp 0x138db0
movq -0x48(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
cmpq -0x50(%rbp), %rax
jb 0x138e38
movq $0x0, -0x98(%rbp)
movq -0x50(%rbp), %rax
shlq %rax
movq %rax, -0x50(%rbp)
callq 0x129030
movl $0x0, (%rax)
movq -0x40(%rbp), %rdi
movq -0x50(%rbp), %rsi
shlq $0x6, %rsi
callq 0x1291e0
movq %rax, -0x98(%rbp)
xorl %eax, %eax
cmpq -0x98(%rbp), %rax
jne 0x138e22
leaq 0xaf7e17(%rip), %rdi    # 0xc30c28
callq 0x1290f0
movl $0x2, -0x8c(%rbp)
jmp 0x138e3d
movq -0x98(%rbp), %rax
movq %rax, -0x40(%rbp)
callq 0x129030
movl $0x0, (%rax)
jmp 0x138ae0
movq -0x28(%rbp), %rdi
callq 0x1395e0
cmpl $0x0, -0x1c(%rbp)
jne 0x138e55
movq -0x18(%rbp), %rdi
callq 0x129110
movq -0x40(%rbp), %rcx
movq -0x38(%rbp), %rax
movq %rcx, (%rax)
movq -0x48(%rbp), %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x58(%rbp), %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x10(%rax)
movsd -0x68(%rbp), %xmm0
movsd 0xac9c7b(%rip), %xmm2   # 0xc02b00
movaps %xmm0, %xmm1
subsd %xmm2, %xmm1
cvttsd2si %xmm1, %rax
cvttsd2si %xmm0, %rcx
movq %rcx, %rdx
sarq $0x3f, %rdx
andq %rdx, %rax
orq %rax, %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x18(%rax)
movsd -0x60(%rbp), %xmm0
movaps %xmm0, %xmm1
subsd %xmm2, %xmm1
cvttsd2si %xmm1, %rax
cvttsd2si %xmm0, %rcx
movq %rcx, %rdx
sarq $0x3f, %rdx
andq %rdx, %rax
orq %rax, %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x20(%rax)
movsd -0x80(%rbp), %xmm0
cvtsd2ss %xmm0, %xmm0
movq -0x38(%rbp), %rax
movss %xmm0, 0x28(%rax)
leaq -0x88(%rbp), %rdi
callq 0x139650
cvtsd2ss %xmm0, %xmm0
movq -0x38(%rbp), %rax
movss %xmm0, 0x2c(%rax)
xorl %eax, %eax
cmpl -0x8c(%rbp), %eax
je 0x138f53
movq 0xb900ce(%rip), %rax    # 0xcc8fe0
movq (%rax), %rdi
leaq 0xaf7ca8(%rip), %rsi    # 0xc30bc4
movb $0x0, %al
callq 0x1291a0
movl $0x1, %eax
cmpl -0x8c(%rbp), %eax
jne 0x138f40
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x8(%rax)
movq -0x38(%rbp), %rdi
callq 0x139670
movq $0x0, -0x8(%rbp)
jmp 0x138f5b
movq -0x38(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0xa0, %rsp
popq %rbp
retq
nopl (%rax,%rax)