// File: /workspace/github_c_makefile_star2_O3/nh13[P]ksw/src/parasail/src/memory.c
// Function: parasail_matrix_pssm_create_internal
static parasail_matrix_t* parasail_matrix_pssm_create_internal(
        const char *alphabet, const int *values, const int length, int case_sensitive)
{
    parasail_matrix_t *retval = NULL;
    int *matrix = NULL;
    int *mapper = NULL;
    char *alphabet_copy = NULL;
    size_t size = 0;
    size_t size1 = 0;
    size_t i = 0;
    size_t j = 0;
    size_t c = 0;
    size_t v = 0;
    int min = INT_MAX;
    int max = INT_MIN;

    PARASAIL_CHECK_NULL(alphabet);
    PARASAIL_CHECK_NULL(values);
    if (length <= 0) {
        fprintf(stderr, "%s: length must be > 0\n", __func__);
        return NULL;
    }

    size = strlen(alphabet);
    if (size >= INT_MAX) {
        fprintf(stderr, "%s: alphabet is too large\n", __func__);
        return NULL;
    }
    size1 = size + 1;

    PARASAIL_CALLOC(matrix, int, size1*length);

    /* find min and max values */
    for (i=0; i<size*length; ++i) {
        min = values[i] < min ? values[i] : min;
        max = values[i] > max ? values[i] : max;
    }

    for (i=0; i<(size_t)length; ++i) {
        for (j=0; j<size; ++j) {
            matrix[c++] = values[v++];
        }
        matrix[c++] = min;
    }

    PARASAIL_CALLOC(mapper, int, 256);
    parasail_memset_int(mapper, (int)size, 256);
    if (case_sensitive) {
        for (i=0; i<size; ++i) {
            mapper[(unsigned char)alphabet[i]] = (int)i;
        }
    }
    else {
        for (i=0; i<size; ++i) {
            mapper[toupper((unsigned char)alphabet[i])] = (int)i;
            mapper[tolower((unsigned char)alphabet[i])] = (int)i;
        }
    }

    PARASAIL_CALLOC(alphabet_copy, char, size1+1);
    (void)memcpy(alphabet_copy, alphabet, sizeof(char) * size);
    alphabet_copy[size] = '*';
    alphabet_copy[size1] = '\0';

    PARASAIL_NEW(retval, parasail_matrix_t);
    retval->name = "";
    retval->matrix = matrix;
    retval->mapper = mapper;
    retval->size = (int)size1;
    retval->max = max;
    retval->min = min;
    retval->user_matrix = matrix;
    retval->type = PARASAIL_MATRIX_TYPE_PSSM;
    retval->length = length;
    retval->alphabet = alphabet_copy;
    retval->query = NULL;
    return retval;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
testq %rdi, %rdi
je 0x20b693
movq %rsi, %rbp
testq %rsi, %rsi
je 0x20b69a
movl %edx, %r14d
testl %edx, %edx
jle 0x20b6a1
movl %ecx, %ebx
movq %rdi, %r12
callq 0x19e070
cmpq $0x7fffffff, %rax       # imm = 0x7FFFFFFF
jae 0x20b6a8
movl %ebx, 0x1c(%rsp)
leaq 0x1(%rax), %r13
movl %r14d, %ebx
movl %r14d, %r14d
movq %r14, (%rsp)
imulq %r13, %r14
shlq $0x2, %r14
movq %rax, %r15
movq %r14, %rdi
callq 0x19e150
movq %rax, 0x20(%rsp)
testq %rax, %rax
je 0x20b6af
movq %r13, 0x28(%rsp)
testq %r15, %r15
movq %r15, %rsi
movl %ebx, 0x18(%rsp)
movq %r12, 0x38(%rsp)
je 0x20b4da
movq %rsi, %rax
movq (%rsp), %r8
imulq %r8, %rax
movl $0x7fffffff, %r13d      # imm = 0x7FFFFFFF
movl $0x80000000, %edi       # imm = 0x80000000
xorl %ecx, %ecx
movl (%rbp,%rcx,4), %edx
cmpl %r13d, %edx
cmovll %edx, %r13d
cmpl %edi, %edx
cmovgl %edx, %edi
incq %rcx
cmpq %rcx, %rax
jne 0x20b4c0
jmp 0x20b4e9
movl $0x80000000, %edi       # imm = 0x80000000
movl $0x7fffffff, %r13d      # imm = 0x7FFFFFFF
movq (%rsp), %r8
movl %edi, 0x14(%rsp)
movq %rsi, 0x30(%rsp)
leaq (,%rsi,4), %rbx
leaq 0x4(,%rsi,4), %rax
movq %rax, 0x40(%rsp)
xorl %eax, %eax
movq 0x20(%rsp), %r15
xorl %r14d, %r14d
movq %rsi, 0x8(%rsp)
testq %rsi, %rsi
je 0x20b54e
movq %r15, %rdi
movq %rbp, %rsi
movq %rbx, %rdx
movl %r13d, %r12d
movq %rax, %r13
movq %rbp, (%rsp)
movq %r8, %rbp
callq 0x19e0c0
movq %rbp, %r8
movq (%rsp), %rbp
movq %r13, %rax
movl %r12d, %r13d
movq 0x8(%rsp), %rsi
addq %rsi, %rax
addq %rsi, %r14
incq %r14
movl %r13d, (%r15,%rbx)
addq %rbx, %rbp
addq 0x40(%rsp), %r15
decq %r8
jne 0x20b516
movl $0x400, %edi            # imm = 0x400
callq 0x19e150
testq %rax, %rax
movq 0x38(%rsp), %r14
je 0x20b6cf
movq %rax, %rbp
movq 0x30(%rsp), %r15
movd %r15d, %xmm0
pshufd $0x0, %xmm0, %xmm0      # xmm0 = xmm0[0,0,0,0]
xorl %eax, %eax
movdqu %xmm0, (%rbp,%rax,4)
addq $0x4, %rax
cmpq $0x100, %rax            # imm = 0x100
jne 0x20b58e
cmpl $0x0, 0x1c(%rsp)
movq 0x8(%rsp), %r12
je 0x20b5c6
testq %r12, %r12
je 0x20b602
xorl %eax, %eax
movzbl (%r14,%rax), %ecx
movl %eax, (%rbp,%rcx,4)
incq %rax
cmpq %rax, %r12
jne 0x20b5b3
jmp 0x20b602
testq %r12, %r12
je 0x20b602
callq 0x19e030
movq (%rax), %rbx
callq 0x19e040
movq 0x8(%rsp), %r12
movq (%rax), %rax
xorl %ecx, %ecx
movzbl (%r14,%rcx), %edx
shll $0x2, %edx
movslq (%rbx,%rdx), %rsi
movl %ecx, (%rbp,%rsi,4)
movslq (%rax,%rdx), %rdx
movl %ecx, (%rbp,%rdx,4)
incq %rcx
cmpq %rcx, %r12
jne 0x20b5e2
addq $0x2, %r12
movq %r12, %rdi
callq 0x19e150
testq %rax, %rax
je 0x20b6d6
movq %rax, %rbx
movq %rax, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x19e0c0
movw $0x2a, (%rbx,%r15)
movl $0x48, %edi
callq 0x19e150
testq %rax, %rax
je 0x20b6fd
movq %rax, %r15
leaq 0x3bee66(%rip), %rax    # 0x5ca4b2
movq %rax, (%r15)
movq 0x20(%rsp), %rcx
movq %rcx, 0x8(%r15)
movq %rbp, 0x10(%r15)
movq 0x28(%rsp), %rax
movl %eax, 0x18(%r15)
movl 0x14(%rsp), %eax
movl %eax, 0x1c(%r15)
movl %r13d, 0x20(%r15)
movq %rcx, 0x28(%r15)
movl $0x1, 0x30(%r15)
movl 0x18(%rsp), %eax
movl %eax, 0x34(%r15)
movq %rbx, 0x38(%r15)
movq $0x0, 0x40(%r15)
jmp 0x20b705
callq 0x19ec77
jmp 0x20b702
callq 0x19ec51
jmp 0x20b702
callq 0x19ec32
jmp 0x20b702
callq 0x19ec13
jmp 0x20b702
movq 0x5cc922(%rip), %rax    # 0x7d7fd8
movq (%rax), %rdi
leaq 0x41d87d(%rip), %rsi    # 0x628f3d
leaq 0x41e072(%rip), %rdx    # 0x629739
xorl %r15d, %r15d
movq %r14, %rcx
jmp 0x20b6f4
callq 0x19ebef
jmp 0x20b702
movq 0x5cc8fb(%rip), %rax    # 0x7d7fd8
movq (%rax), %rdi
leaq 0x41d856(%rip), %rsi    # 0x628f3d
leaq 0x41e04b(%rip), %rdx    # 0x629739
xorl %r15d, %r15d
movq %r12, %rcx
xorl %eax, %eax
callq 0x19e180
jmp 0x20b705
callq 0x19ebcd
xorl %r15d, %r15d
movq %r15, %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq