// File: /workspace/github_c_makefile_star2_O2/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 $0x28, %rsp
testq %rdi, %rdi
je 0x1ac478
movq %rsi, %rbp
testq %rsi, %rsi
je 0x1ac499
movl %edx, %r14d
testl %edx, %edx
jle 0x1ac4c0
movl %ecx, %ebx
movq %rdi, %r15
callq 0x19e070
cmpq $0x7fffffff, %rax       # imm = 0x7FFFFFFF
jae 0x1ac4d3
movq %rax, %r12
movl %ebx, 0xc(%rsp)
leaq 0x1(%rax), %rcx
movl %r14d, %r13d
movq %r13, %rbx
movq %rcx, 0x20(%rsp)
imulq %rcx, %rbx
shlq $0x2, %rbx
movq %rbx, %rdi
callq 0x19e150
testq %rax, %rax
je 0x1ac4fa
movl %r14d, 0x8(%rsp)
movq %r12, 0x10(%rsp)
movq %r12, %rsi
imulq %r13, %rsi
movl $0x80000000, %edi       # imm = 0x80000000
movl $0x7fffffff, %ebx       # imm = 0x7FFFFFFF
xorl %ecx, %ecx
cmpq %rcx, %rsi
je 0x1ac304
movl (%rbp,%rcx,4), %edx
cmpl %ebx, %edx
cmovll %edx, %ebx
cmpl %edi, %edx
cmovgl %edx, %edi
incq %rcx
jmp 0x1ac2ec
movl %edi, 0x4(%rsp)
leaq 0x4(,%r12,4), %r11
xorl %ecx, %ecx
movq %rax, %rdx
xorl %esi, %esi
xorl %edi, %edi
cmpq %r13, %rdi
je 0x1ac352
addq %r12, %rcx
leaq (,%rsi,4), %r9
addq %rbp, %r9
xorl %r8d, %r8d
cmpq %r8, %r12
je 0x1ac341
movl (%r9,%r8,4), %r10d
movl %r10d, (%rdx,%r8,4)
incq %r8
jmp 0x1ac32f
movl %ebx, (%rax,%rcx,4)
incq %rcx
incq %rdi
addq %r11, %rdx
addq %r8, %rsi
jmp 0x1ac319
movq %rax, 0x18(%rsp)
movl $0x400, %edi            # imm = 0x400
callq 0x19e150
testq %rax, %rax
je 0x1ac51a
movq %rax, %rbp
xorl %eax, %eax
movq 0x10(%rsp), %rcx
cmpq $0x100, %rax            # imm = 0x100
je 0x1ac385
movl %ecx, (%rbp,%rax,4)
incq %rax
jmp 0x1ac374
cmpl $0x0, 0xc(%rsp)
je 0x1ac3a1
xorl %eax, %eax
cmpq %rax, %r12
je 0x1ac3df
movzbl (%r15,%rax), %ecx
movl %eax, (%rbp,%rcx,4)
incq %rax
jmp 0x1ac38e
xorl %r13d, %r13d
cmpq %r13, %r12
je 0x1ac3df
callq 0x19e030
movq (%rax), %rax
movq %r15, %r14
movzbl (%r15,%r13), %r15d
shll $0x2, %r15d
movslq (%rax,%r15), %rax
movl %r13d, (%rbp,%rax,4)
callq 0x19e040
movq (%rax), %rax
movslq (%rax,%r15), %rax
movq %r14, %r15
movl %r13d, (%rbp,%rax,4)
incq %r13
jmp 0x1ac3a4
addq $0x2, %r12
movq %r12, %rdi
callq 0x19e150
testq %rax, %rax
je 0x1ac53c
movq %rax, %r13
movq %rax, %rdi
movq %r15, %rsi
movq 0x10(%rsp), %r14
movq %r14, %rdx
callq 0x19e0c0
movq %r13, %r15
movw $0x2a, (%r13,%r14)
pushq $0x48
popq %rdi
callq 0x19e150
testq %rax, %rax
je 0x1ac55c
movq %rax, %r13
leaq 0x3bc082(%rip), %rax    # 0x5684b2
movq %rax, (%r13)
movq 0x18(%rsp), %rcx
movq %rcx, 0x8(%r13)
movq %rbp, 0x10(%r13)
movq 0x20(%rsp), %rax
movl %eax, 0x18(%r13)
movl 0x4(%rsp), %eax
movl %eax, 0x1c(%r13)
movl %ebx, 0x20(%r13)
movq %rcx, 0x28(%r13)
movl $0x1, 0x30(%r13)
movl 0x8(%rsp), %eax
movl %eax, 0x34(%r13)
movq %r15, 0x38(%r13)
andq $0x0, 0x40(%r13)
jmp 0x1ac581
movq 0x58eb59(%rip), %rax    # 0x73afd8
movq (%rax), %rdi
leaq 0x41ab62(%rip), %rsi    # 0x5c6feb
leaq 0x41b229(%rip), %rdx    # 0x5c76b9
leaq 0x41b1fe(%rip), %rcx    # 0x5c7695
jmp 0x1ac4b8
movq 0x58eb38(%rip), %rax    # 0x73afd8
movq (%rax), %rdi
leaq 0x41ab41(%rip), %rsi    # 0x5c6feb
leaq 0x41b208(%rip), %rdx    # 0x5c76b9
leaq 0x41b226(%rip), %rcx    # 0x5c76de
xorl %r13d, %r13d
jmp 0x1ac57a
movq 0x58eb11(%rip), %rax    # 0x73afd8
movq (%rax), %rdi
leaq 0x41b214(%rip), %rsi    # 0x5c76e5
jmp 0x1ac4e4
movq 0x58eafe(%rip), %rax    # 0x73afd8
movq (%rax), %rdi
leaq 0x41b1ba(%rip), %rsi    # 0x5c769e
leaq 0x41b1ce(%rip), %rdx    # 0x5c76b9
xorl %r13d, %r13d
xorl %eax, %eax
callq 0x19e180
jmp 0x1ac581
movq 0x58ead7(%rip), %rax    # 0x73afd8
movq (%rax), %rdi
leaq 0x41a9b2(%rip), %rsi    # 0x5c6ebd
leaq 0x41b1a7(%rip), %rdx    # 0x5c76b9
xorl %r13d, %r13d
movq %rbx, %rcx
jmp 0x1ac57a
movq 0x58eab7(%rip), %rax    # 0x73afd8
movq (%rax), %rdi
leaq 0x41a992(%rip), %rsi    # 0x5c6ebd
leaq 0x41b187(%rip), %rdx    # 0x5c76b9
xorl %r13d, %r13d
movl $0x400, %ecx            # imm = 0x400
jmp 0x1ac57a
movq 0x58ea95(%rip), %rax    # 0x73afd8
movq (%rax), %rdi
leaq 0x41a970(%rip), %rsi    # 0x5c6ebd
leaq 0x41b165(%rip), %rdx    # 0x5c76b9
xorl %r13d, %r13d
movq %r12, %rcx
jmp 0x1ac57a
movq 0x58ea75(%rip), %rax    # 0x73afd8
movq (%rax), %rdi
leaq 0x41a950(%rip), %rsi    # 0x5c6ebd
leaq 0x41b145(%rip), %rdx    # 0x5c76b9
xorl %r13d, %r13d
pushq $0x48
popq %rcx
xorl %eax, %eax
callq 0x19e180
movq %r13, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq