// File: /workspace/github_c_makefile_star2_O1/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 0x20a050
movq %rsi, %rbp
testq %rsi, %rsi
je 0x20a057
movl %edx, %r15d
testl %edx, %edx
jle 0x20a05e
movl %ecx, %ebx
movq %rdi, %r12
callq 0x19e070
cmpq $0x7fffffff, %rax       # imm = 0x7FFFFFFF
jae 0x20a065
movl %ebx, 0x14(%rsp)
leaq 0x1(%rax), %rcx
movl %r15d, %r14d
movq %r14, %rbx
movq %rcx, 0x20(%rsp)
imulq %rcx, %r14
shlq $0x2, %r14
movq %rax, %r13
movq %r14, %rdi
callq 0x19e150
testq %rax, %rax
je 0x20a06c
testq %r13, %r13
movq %r13, %rdi
movl %r15d, 0x10(%rsp)
movq %r12, 0x30(%rsp)
je 0x209e95
movq %rdi, %rsi
movq %rbx, %r9
imulq %rbx, %rsi
movl $0x7fffffff, %r14d      # imm = 0x7FFFFFFF
movl $0x80000000, %r8d       # imm = 0x80000000
xorl %ecx, %ecx
movl (%rbp,%rcx,4), %edx
cmpl %r14d, %edx
cmovll %edx, %r14d
cmpl %r8d, %edx
cmovgl %edx, %r8d
incq %rcx
cmpq %rcx, %rsi
jne 0x209e79
jmp 0x209ea4
movl $0x80000000, %r8d       # imm = 0x80000000
movl $0x7fffffff, %r14d      # imm = 0x7FFFFFFF
movq %rbx, %r9
movl %r8d, 0xc(%rsp)
movq %rdi, 0x18(%rsp)
leaq (,%rdi,4), %rbx
cmpq $0x1, %r9
adcq $0x0, %r9
leaq 0x4(,%rdi,4), %rcx
movq %rcx, 0x38(%rsp)
xorl %ecx, %ecx
movq %rax, 0x28(%rsp)
movq %rax, %r15
xorl %r13d, %r13d
movq %rdi, (%rsp)
testq %rdi, %rdi
je 0x209f15
movq %r15, %rdi
movq %rbp, %rsi
movq %rbx, %rdx
movl %r14d, %r12d
movq %rcx, %r14
movq %rbp, 0x40(%rsp)
movq %r9, %rbp
callq 0x19e0c0
movq %rbp, %r9
movq 0x40(%rsp), %rbp
movq %r14, %rcx
movl %r12d, %r14d
movq (%rsp), %rdi
addq %rdi, %rcx
addq %rdi, %r13
incq %r13
movl %r14d, (%r15,%rbx)
addq %rbx, %rbp
addq 0x38(%rsp), %r15
decq %r9
jne 0x209edc
movl $0x400, %edi            # imm = 0x400
callq 0x19e150
testq %rax, %rax
movq 0x30(%rsp), %r15
je 0x20a08c
movq %rax, %rbp
xorl %eax, %eax
movq 0x18(%rsp), %rcx
movl %ecx, (%rbp,%rax,4)
incq %rax
cmpq $0x100, %rax            # imm = 0x100
jne 0x209f4b
cmpl $0x0, 0x14(%rsp)
movq 0x28(%rsp), %r12
movq (%rsp), %r13
je 0x209f84
testq %r13, %r13
je 0x209fbf
xorl %eax, %eax
movzbl (%r15,%rax), %ecx
movl %eax, (%rbp,%rcx,4)
incq %rax
cmpq %rax, %r13
jne 0x209f71
jmp 0x209fbf
testq %r13, %r13
je 0x209fbf
callq 0x19e030
movq (%rax), %rbx
callq 0x19e040
movq (%rsp), %r13
movq (%rax), %rax
xorl %ecx, %ecx
movzbl (%r15,%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, %r13
jne 0x209f9f
addq $0x2, %r13
movq %r13, %rdi
callq 0x19e150
testq %rax, %rax
je 0x20a093
movq %rax, %rbx
movq %rax, %rdi
movq %r15, %rsi
movq 0x18(%rsp), %r15
movq %r15, %rdx
callq 0x19e0c0
movw $0x2a, (%rbx,%r15)
movl $0x48, %edi
callq 0x19e150
testq %rax, %rax
je 0x20a0ba
movq %rax, %r15
leaq 0x38c4a4(%rip), %rax    # 0x5964b2
movq %rax, (%r15)
movq %r12, 0x8(%r15)
movq %rbp, 0x10(%r15)
movq 0x20(%rsp), %rax
movl %eax, 0x18(%r15)
movl 0xc(%rsp), %eax
movl %eax, 0x1c(%r15)
movl %r14d, 0x20(%r15)
movq %r12, 0x28(%r15)
movl $0x1, 0x30(%r15)
movl 0x10(%rsp), %eax
movl %eax, 0x34(%r15)
movq %rbx, 0x38(%r15)
movq $0x0, 0x40(%r15)
jmp 0x20a0c2
callq 0x19ec5d
jmp 0x20a0bf
callq 0x19ec37
jmp 0x20a0bf
callq 0x19ec18
jmp 0x20a0bf
callq 0x19ebf9
jmp 0x20a0bf
movq 0x597f65(%rip), %rax    # 0x7a1fd8
movq (%rax), %rdi
leaq 0x3eae30(%rip), %rsi    # 0x5f4ead
leaq 0x3eb625(%rip), %rdx    # 0x5f56a9
xorl %r15d, %r15d
movq %r14, %rcx
jmp 0x20a0b1
callq 0x19ebd5
jmp 0x20a0bf
movq 0x597f3e(%rip), %rax    # 0x7a1fd8
movq (%rax), %rdi
leaq 0x3eae09(%rip), %rsi    # 0x5f4ead
leaq 0x3eb5fe(%rip), %rdx    # 0x5f56a9
xorl %r15d, %r15d
movq %r13, %rcx
xorl %eax, %eax
callq 0x19e180
jmp 0x20a0c2
callq 0x19ebb3
xorl %r15d, %r15d
movq %r15, %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq