// File: /workspace/github_c_makefile_star2_O3/nh13[P]ksw/src/parasail/src/io.c
// Function: parasail_matrix_from_file_internal
static parasail_matrix_t* parasail_matrix_from_file_internal(const char *filename, int case_sensitive)
{
    parasail_matrix_t *retval = NULL;
    int *matrix = NULL;
    size_t matrix_i = 0;
    size_t matrix_capacity = 0;
    int *mapper = NULL;
    char *alphabet = NULL;
    char *alphabet_query = NULL;
    size_t alphabet_query_i = 0;
    size_t alphabet_query_capacity = 0;
    parasail_file_t *pf = NULL;
    const char *T = NULL;
    off_t i = 0;
    off_t size = 0;
    int first_alpha = 1;
    size_t count = 0;
    size_t asize = 0;
    int max = INT_MIN;
    int min = INT_MAX;
    size_t c = 0;
    int type = PARASAIL_MATRIX_TYPE_SQUARE;

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

    pf = parasail_open(filename);
    if (NULL == pf) {
        fprintf(stderr, "parasail_matrix_from_file: "
                "parasail_open(%s) failed\n", filename);
        return NULL;
    }
    T = pf->buf;
    size = pf->size;

    while (i<size) {
        if (T[i] == '#') {
            /* ignore comments */
            i = skip_line(T, i);
        }
        else if (isalnum(T[i]) || T[i] == '*' || T[i] == '-') {
            if (first_alpha) {
                first_alpha = 0;
                alphabet = get_alphabet(T, i, size);
                if (NULL == alphabet) {
                    fprintf(stderr, "parasail_matrix_from_file: "
                            "poorly formed matrix file alphabet\n");
                    parasail_close(pf);
                    return NULL;
                }
                asize = strlen(alphabet);
                matrix_capacity = asize*asize;
                matrix = (int*)malloc(sizeof(int)*matrix_capacity);
                if (NULL == matrix) {
                    perror("malloc");
                    fprintf(stderr, "parasail_matrix_from_file: "
                            "cannont malloc buffer for matrix\n");
                    free(alphabet);
                    parasail_close(pf);
                    return NULL;
                }
                alphabet_query_capacity = asize;
                alphabet_query = (char*)malloc(sizeof(char)*(alphabet_query_capacity+1));
                if (NULL == alphabet_query) {
                    perror("malloc");
                    fprintf(stderr, "parasail_matrix_from_file: "
                            "cannont malloc buffer for matrix alphabet\n");
                    free(matrix);
                    free(alphabet);
                    parasail_close(pf);
                    return NULL;
                }
                i = skip_line(T, i);
            }
            else {
                size_t j=0;
                /* store the letter */
                if (alphabet_query_i >= alphabet_query_capacity) {
                    alphabet_query_capacity *= 2;
                    alphabet_query = realloc(alphabet_query, sizeof(char)*(alphabet_query_capacity+1));
                    if (NULL == alphabet_query) {
                        perror("realloc");
                        fprintf(stderr, "parasail_matrix_from_file: "
                                "couldn't grow query size\n");
                        if (alphabet) free(alphabet);
                        if (alphabet_query) free(alphabet_query);
                        if (matrix) free(matrix);
                        parasail_close(pf);
                        return NULL;
                    }
                }
                ++count;
                /* allow PSSM matrix to omit query */
                if (isalpha(T[i]) || T[i] == '*') {
                    alphabet_query[alphabet_query_i++] = T[i];
                    ++i; /* skip over the letter */
                }
                else {
                    alphabet_query[alphabet_query_i++] = '*';
                    /* don't increment read index i */
                }
                for (j=0; j<asize; ++j) {
                    int val = 0;
                    int retcode = get_num(T, &i, &val);
                    if (-1 == retcode) {
                        fprintf(stderr, "parasail_matrix_from_file: "
                                "poorly formed matrix file\n");
                        if (alphabet) free(alphabet);
                        if (alphabet_query) free(alphabet_query);
                        if (matrix) free(matrix);
                        parasail_close(pf);
                        return NULL;
                    }
                    if (matrix_i >= matrix_capacity) {
                        matrix_capacity *= 2;
                        matrix = realloc(matrix, sizeof(int)*matrix_capacity);
                        if (NULL == matrix) {
                            perror("realloc");
                            fprintf(stderr, "parasail_matrix_from_file: "
                                    "couldn't grow matrix size\n");
                            if (alphabet) free(alphabet);
                            if (alphabet_query) free(alphabet_query);
                            if (matrix) free(matrix);
                            parasail_close(pf);
                            return NULL;
                        }
                    }
                    matrix[matrix_i++] = val;
                    max = val > max ? val : max;
                    min = val < min ? val : min;
                }
            }
        }
        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 (T[i] == ' ' || T[i] == '\t') {
            /* ignore spaces and tabs */
        }
        else if (isprint(T[i])) {
            fprintf(stderr, "parasail_matrix_from_file: "
                    "non-alpha character in matrix file ('%c')\n", T[i]);
            if (alphabet) free(alphabet);
            if (alphabet_query) free(alphabet_query);
            if (matrix) free(matrix);
            parasail_close(pf);
            return NULL;
        }
        else {
            fprintf(stderr, "parasail_matrix_from_file: "
                    "non-printing character in matrix file ('%d')\n", T[i]);
            if (alphabet) free(alphabet);
            if (alphabet_query) free(alphabet_query);
            if (matrix) free(matrix);
            parasail_close(pf);
            return NULL;
        }
        ++i;
    }

    parasail_close(pf);

    /* we consider this a square matrix if alphabet sizes match and are identical */
    alphabet_query[alphabet_query_i] = '\0';
    if (asize == alphabet_query_i && 0 == strcmp(alphabet, alphabet_query)) {
        /* square */
        if (matrix_i != asize*asize) {
            fprintf(stderr, "parasail_matrix_from_file: "
                    "matrix is missing values\n");
            free(alphabet);
            free(alphabet_query);
            free(matrix);
            return NULL;
        }
        if (count != asize) {
            fprintf(stderr, "parasail_matrix_from_file: "
                    "matrix is missing rows\n");
            free(alphabet);
            free(alphabet_query);
            free(matrix);
            return NULL;
        }
    }
    else {
        /* PSSM */
        type = PARASAIL_MATRIX_TYPE_PSSM;
        if (matrix_i != asize*count) {
            fprintf(stderr, "parasail_matrix_from_file: "
                    "matrix is missing values\n");
            free(alphabet);
            free(alphabet_query);
            free(matrix);
            return NULL;
        }
    }

    mapper = (int*)malloc(sizeof(int)*256);
    if (NULL == mapper) {
        perror("malloc");
        fprintf(stderr, "parasail_matrix_from_file: "
                "cannont malloc mapper buffer for matrix file `%s'\n",
                filename);
        free(alphabet);
        free(alphabet_query);
        free(matrix);
        return NULL;
    }
    parasail_memset_int(mapper, asize-1, 256);
    if (case_sensitive) {
        for (c=0; c<asize; ++c) {
            mapper[(unsigned char)alphabet[c]] = (int)c;
        }
    }
    else {
        for (c=0; c<asize; ++c) {
            mapper[toupper((unsigned char)alphabet[c])] = (int)c;
            mapper[tolower((unsigned char)alphabet[c])] = (int)c;
        }
    }

    retval = (parasail_matrix_t*)malloc(sizeof(parasail_matrix_t));
    if (NULL == retval) {
        perror("malloc");
        fprintf(stderr, "parasail_matrix_from_file: "
                "cannont malloc buffer for matrix file `%s'\n", filename);
        free(matrix);
        return NULL;
    }

    retval->name = filename;
    retval->matrix = matrix;
    retval->mapper = mapper;
    retval->size = (int)asize;
    retval->max = max;
    retval->min = min;
    retval->user_matrix = matrix;
    retval->type = type;
    retval->length = (int)count;
    retval->alphabet = alphabet;
    retval->query = alphabet_query;
    return retval;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
testq %rdi, %rdi
je 0x25284d
movl %esi, %r14d
movq %rdi, %rbx
callq 0x251238
testq %rax, %rax
je 0x252857
movl %r14d, 0x70(%rsp)
movq %rbx, 0x58(%rsp)
movq 0x8(%rax), %r15
testq %r15, %r15
jle 0x2529e2
movq %rax, 0x28(%rsp)
movq 0x10(%rax), %r12
movl $0x1, %ebp
movl $0x80000000, 0x34(%rsp) # imm = 0x80000000
movl $0x7fffffff, 0x30(%rsp) # imm = 0x7FFFFFFF
movq $0x0, 0x8(%rsp)
xorl %r13d, %r13d
movq $0x0, 0x68(%rsp)
movq $0x0, 0x20(%rsp)
movq $0x0, 0x60(%rsp)
movq $0x0, 0x38(%rsp)
movq $0x0, 0x50(%rsp)
movq $0x0, 0x18(%rsp)
xorl %r14d, %r14d
xorl %ebx, %ebx
movq %r14, 0x10(%rsp)
movsbq (%r12,%rbx), %r14
cmpq $0x23, %r14
jne 0x2522dd
movb $0x23, %al
movq 0x10(%rsp), %r14
cmpb $0xa, %al
je 0x25247a
movzbl %al, %eax
cmpl $0xd, %eax
je 0x25247a
movb 0x1(%r12,%rbx), %al
incq %rbx
jmp 0x2522bf
callq 0x1f0190
movq %rax, 0x40(%rsp)
movq (%rax), %rax
movzwl (%rax,%r14,2), %ecx
movzwl %cx, %edx
testb $0x8, %dl
jne 0x25233d
movzbl %r14b, %esi
cmpl $0x2d, %esi
ja 0x252978
movl %esi, %esi
movl $0x2400, %edi           # imm = 0x2400
btq %rsi, %rdi
jb 0x252679
movabsq $0x100000200, %rdi      # imm = 0x100000200
btq %rsi, %rdi
jb 0x2526a9
movabsq $0x240000000000, %rdi   # imm = 0x240000000000
btq %rsi, %rdi
jae 0x252978
testl %ebp, %ebp
je 0x2524c2
xorl %edi, %edi
movq %rbx, %rcx
movabsq $0x100000200, %rsi      # imm = 0x100000200
movzbl (%r12,%rcx), %edx
cmpq $0x23, %rdx
ja 0x252375
btq %rdx, %rsi
jb 0x252391
movabsq $0x800002400, %r8       # imm = 0x800002400
btq %rdx, %r8
jb 0x252399
cmpb $0x2a, %dl
je 0x25238e
movsbq %dl, %rdx
movzwl (%rax,%rdx,2), %edx
andl $0x400, %edx            # imm = 0x400
je 0x252912
incq %rdi
incq %rcx
cmpq %rcx, %r15
jne 0x252354
testq %rdi, %rdi
je 0x252912
incq %rdi
callq 0x1f01f0
testq %rax, %rax
je 0x252906
movq %rax, %r14
xorl %eax, %eax
movq %rbx, %rcx
movabsq $0x100000200, %r8       # imm = 0x100000200
movzbl (%r12,%rcx), %edx
cmpq $0x23, %rdx
ja 0x2523e6
btq %rdx, %r8
jb 0x25240e
movabsq $0x800002400, %rsi      # imm = 0x800002400
btq %rdx, %rsi
jb 0x252416
cmpb $0x2a, %dl
je 0x252407
movsbq %dl, %rsi
movq 0x40(%rsp), %rdi
movq (%rdi), %rdi
movzwl (%rdi,%rsi,2), %esi
andl $0x400, %esi            # imm = 0x400
je 0x252912
movb %dl, (%r14,%rax)
incq %rax
incq %rcx
cmpq %rcx, %r15
jne 0x2523c5
movb $0x0, (%r14,%rax)
movq %r14, %rdi
callq 0x1f00a0
movq %rax, %rbp
imulq %rax, %rax
movq %rax, 0x68(%rsp)
leaq (,%rax,4), %rdi
callq 0x1f01f0
movq %rax, 0x8(%rsp)
testq %rax, %rax
je 0x252921
movq %rbp, 0x38(%rsp)
leaq 0x1(%rbp), %rdi
callq 0x1f01f0
movq %rax, 0x18(%rsp)
testq %rax, %rax
je 0x252933
movzbl (%r12,%rbx), %eax
cmpl $0xa, %eax
je 0x25249a
cmpl $0xd, %eax
je 0x25249a
incq %rbx
jmp 0x252466
leaq 0x1(%rbx), %rax
movzbl 0x1(%r12,%rbx), %ecx
cmpl $0xa, %ecx
je 0x252492
cmpl $0xd, %ecx
jne 0x2526ae
movq %rax, %rbx
jmp 0x2526ae
leaq 0x1(%rbx), %rax
movzbl 0x1(%r12,%rbx), %ecx
xorl %ebp, %ebp
cmpl $0xa, %ecx
je 0x2524b0
cmpl $0xd, %ecx
jne 0x2524b3
movq %rax, %rbx
movq 0x38(%rsp), %rax
movq %rax, 0x20(%rsp)
jmp 0x2526ae
movq 0x38(%rsp), %rbp
cmpq %rbp, 0x50(%rsp)
jb 0x252508
leaq 0x1(,%rbp,2), %rsi
movq 0x18(%rsp), %rdi
callq 0x1f0270
movq %rax, 0x18(%rsp)
testq %rax, %rax
je 0x25295f
addq %rbp, %rbp
movq %rbp, 0x38(%rsp)
movq 0x40(%rsp), %rax
movq (%rax), %rax
movsbq (%r12,%rbx), %r14
movzwl (%rax,%r14,2), %ecx
incq 0x60(%rsp)
shrl $0xa, %ecx
andl $0x1, %ecx
cmpb $0x2a, %r14b
sete %al
orb %cl, %al
movzbl %r14b, %edx
testl %ecx, %ecx
movl $0x2a, %ecx
cmovel %ecx, %edx
movzbl %al, %eax
addq %rax, %rbx
movq 0x18(%rsp), %rax
movq 0x50(%rsp), %rcx
movb %dl, (%rax,%rcx)
incq %rcx
movq %rcx, 0x50(%rsp)
xorl %ebp, %ebp
movq 0x20(%rsp), %rax
testq %rax, %rax
je 0x2526a0
addq %r13, %rax
movq %rax, 0x80(%rsp)
movl $0x0, 0x4c(%rsp)
movq %rbx, %rbp
movq 0x68(%rsp), %rbx
movzbl (%r12,%rbp), %ecx
cmpl $0x20, %ecx
je 0x25257f
cmpl $0x9, %ecx
jne 0x252584
incq %rbp
jmp 0x252570
movq 0x40(%rsp), %rax
movq (%rax), %rax
cmpb $0x2d, %cl
je 0x2525a5
movsbq %cl, %rdx
movzwl (%rax,%rdx,2), %edx
andl $0x800, %edx            # imm = 0x800
je 0x252761
movb %cl, 0x76(%rsp)
leaq (%r12,%rbp), %rcx
movl $0x1, %r14d
movsbq (%rcx,%r14), %rdx
testb $0x8, 0x1(%rax,%rdx,2)
je 0x2525d2
movb %dl, 0x76(%rsp,%r14)
incq %r14
cmpq $0xa, %r14
jne 0x2525b3
jmp 0x252761
movb $0x0, 0x76(%rsp,%r14)
leaq 0x76(%rsp), %rdi
leaq 0x3fb13b(%rip), %rsi    # 0x64d71f
leaq 0x4c(%rsp), %rdx
xorl %eax, %eax
callq 0x1f0160
cmpl $0x1, %eax
jne 0x252761
cmpq %rbx, %r13
jb 0x252626
leaq (,%rbx,8), %rsi
movq 0x8(%rsp), %rdi
callq 0x1f0270
movq %rax, 0x8(%rsp)
testq %rax, %rax
je 0x2528ef
addq %rbx, %rbx
movq %rbx, 0x68(%rsp)
leaq (%r14,%rbp), %rbx
movl 0x4c(%rsp), %eax
movq 0x8(%rsp), %rcx
movl %eax, (%rcx,%r13,4)
incq %r13
movl 0x34(%rsp), %ecx
cmpl %ecx, %eax
cmovgl %eax, %ecx
movl %ecx, 0x34(%rsp)
movl 0x30(%rsp), %ecx
cmpl %ecx, %eax
cmovll %eax, %ecx
movl %ecx, 0x30(%rsp)
cmpq 0x80(%rsp), %r13
jne 0x252560
addq %r14, %rbp
movq %rbp, %rbx
movq 0x80(%rsp), %r13
movq 0x10(%rsp), %r14
xorl %ebp, %ebp
jmp 0x2526ae
leaq 0x1(%rbx), %rax
cmpq %r15, %rax
jge 0x2526a9
movzbl (%r12,%rax), %ecx
cmpl $0xd, %ecx
movq 0x10(%rsp), %r14
je 0x252492
cmpl $0xa, %ecx
je 0x252492
jmp 0x2526ae
movq $0x0, 0x20(%rsp)
movq 0x10(%rsp), %r14
incq %rbx
cmpq %r15, %rbx
jl 0x2522a8
movq 0x28(%rsp), %rdi
callq 0x2512ee
movq 0x18(%rsp), %r12
movq 0x50(%rsp), %rbx
movb $0x0, (%r12,%rbx)
cmpq %rbx, 0x20(%rsp)
jne 0x2526ed
movq %r14, %rdi
movq %r12, %rsi
callq 0x1f0200
testl %eax, %eax
je 0x252877
movq 0x20(%rsp), %rax
movq 0x60(%rsp), %r15
imulq %r15, %rax
movl $0x1, %ebp
cmpq %rax, %r13
jne 0x2528da
movl $0x400, %edi            # imm = 0x400
callq 0x1f01f0
testq %rax, %rax
je 0x2528ac
movq %rax, %rbx
movl %ebp, 0x40(%rsp)
movq %r14, %r12
movq 0x20(%rsp), %rbp
leal -0x1(%rbp), %esi
movl $0x100, %edx            # imm = 0x100
movq %rax, %rdi
callq 0x252ad4
cmpl $0x0, 0x70(%rsp)
je 0x25279b
testq %rbp, %rbp
je 0x2527d7
movq %r12, %rdx
xorl %eax, %eax
movzbl (%rdx,%rax), %ecx
movl %eax, (%rbx,%rcx,4)
incq %rax
cmpq %rax, %rbp
jne 0x252750
jmp 0x2527d7
leaq 0x76(%rsp), %rdi
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
movq 0x8(%rsp), %rbx
movq %rbx, %rcx
callq 0x1f0d42
testb $0x1, %al
jne 0x252789
movq %rbx, %rdi
callq 0x1f01c0
movq 0x28(%rsp), %rdi
callq 0x2512ee
xorl %r14d, %r14d
jmp 0x252838
testq %rbp, %rbp
je 0x2527d7
movq %r12, %r13
callq 0x1f0050
movq (%rax), %r14
callq 0x1f0060
movq (%rax), %rax
xorl %ecx, %ecx
movzbl (%r13,%rcx), %edx
movslq (%r14,%rdx,4), %rdx
movl %ecx, (%rbx,%rdx,4)
movzbl (%r13,%rcx), %edx
movslq (%rax,%rdx,4), %rdx
movl %ecx, (%rbx,%rdx,4)
incq %rcx
cmpq %rcx, %rbp
jne 0x2527b5
movl $0x48, %edi
callq 0x1f01f0
testq %rax, %rax
je 0x2528c6
movq %rax, %r14
movq 0x58(%rsp), %rax
movq %rax, (%r14)
movq 0x8(%rsp), %rcx
movq %rcx, 0x8(%r14)
movq %rbx, 0x10(%r14)
movq 0x20(%rsp), %rax
movl %eax, 0x18(%r14)
movl 0x34(%rsp), %eax
movl %eax, 0x1c(%r14)
movl 0x30(%rsp), %eax
movl %eax, 0x20(%r14)
movq %rcx, 0x28(%r14)
movl 0x40(%rsp), %eax
movl %eax, 0x30(%r14)
movl %r15d, 0x34(%r14)
movq %r12, 0x38(%r14)
movq 0x18(%rsp), %rax
movq %rax, 0x40(%r14)
movq %r14, %rax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x1f0f60
jmp 0x252793
movq 0x58f77a(%rip), %rax    # 0x7e1fd8
movq (%rax), %rdi
leaq 0x3fab8b(%rip), %rsi    # 0x64d3f3
xorl %r14d, %r14d
movq %rbx, %rdx
xorl %eax, %eax
callq 0x1f0220
jmp 0x252838
movq %rbx, %rax
imulq %rbx, %rax
cmpq %rax, %r13
movq 0x60(%rsp), %r15
jne 0x25294a
xorl %ebp, %ebp
cmpq %rbx, %r15
je 0x252709
movq %r14, %rdi
movq %r12, %rsi
movq 0x8(%rsp), %rdx
callq 0x1f0e78
jmp 0x252793
movq 0x58(%rsp), %rdi
movq %r14, %rsi
movq %r12, %rdx
movq 0x8(%rsp), %rcx
callq 0x1f0f01
jmp 0x252793
movq 0x58(%rsp), %rdi
movq 0x8(%rsp), %rsi
callq 0x1f0ec0
jmp 0x252793
movq %r14, %rdi
movq %r12, %rsi
movq 0x8(%rsp), %rdx
callq 0x1f0de8
jmp 0x252793
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rbx
movq %rbx, %rsi
callq 0x1f0d96
jmp 0x25277d
leaq 0x3fa23a(%rip), %rdi    # 0x64cb47
callq 0x1f0140
movq 0x28(%rsp), %rdi
callq 0x1f0cba
jmp 0x252793
movq %r14, %rdi
movq 0x28(%rsp), %rsi
callq 0x1f0c70
jmp 0x252793
movq 0x8(%rsp), %rdi
movq %r14, %rsi
movq 0x28(%rsp), %rdx
callq 0x1f0c1c
jmp 0x252793
movq %r14, %rdi
movq %r12, %rsi
movq 0x8(%rsp), %rdx
callq 0x1f0e30
jmp 0x252793
movq 0x10(%rsp), %rdi
movq 0x8(%rsp), %rsi
movq 0x28(%rsp), %rdx
callq 0x1f0ce4
jmp 0x252793
btl $0xe, %edx
movq 0x58f655(%rip), %rax    # 0x7e1fd8
movq (%rax), %rdi
jb 0x252991
leaq 0x3fac4a(%rip), %rsi    # 0x64d5d9
jmp 0x252998
leaq 0x3fabfb(%rip), %rsi    # 0x64d593
movl %r14d, %edx
xorl %eax, %eax
callq 0x1f0220
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
movq 0x18(%rsp), %r14
movq 0x28(%rsp), %r15
je 0x2529bb
callq 0x1f01c0
testq %r14, %r14
movq 0x8(%rsp), %rbx
je 0x2529cd
movq %r14, %rdi
callq 0x1f01c0
testq %rbx, %rbx
je 0x2529da
movq %rbx, %rdi
callq 0x1f01c0
movq %r15, %rdi
jmp 0x25278e
movq %rax, %rdi
callq 0x2512ee