// File: /workspace/github_c_makefile_star2_O1/nh13[P]ksw/src/parasail/src/memory.c
// Function: parasail_matrix_create_internal
static parasail_matrix_t* parasail_matrix_create_internal(
        const char *alphabet, const int match, const int mismatch, 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;

    PARASAIL_CHECK_NULL(alphabet);

    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*size1);

    for (i=0; i<size; ++i) {
        for (j=0; j<size; ++j) {
            if (i == j) {
                matrix[c++] = match;
            }
            else {
                matrix[c++] = mismatch;
            }
        }
        matrix[c++] = 0;
    }
    for (j=0; j<size1; ++j) {
        matrix[c++] = 0;
    }

    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 = match > mismatch ? match : mismatch;
    retval->min = match > mismatch ? mismatch : match;
    retval->user_matrix = matrix;
    retval->type = PARASAIL_MATRIX_TYPE_SQUARE;
    retval->length = retval->size;
    retval->alphabet = alphabet_copy;
    retval->query = NULL;
    return retval;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
testq %rdi, %rdi
je 0x209d58
movl %ecx, %r14d
movl %edx, %ebx
movl %esi, %ebp
movq %rdi, 0x8(%rsp)
callq 0x19e070
cmpq $0x7fffffff, %rax       # imm = 0x7FFFFFFF
jae 0x209d5f
movq %rax, %r12
movl %r14d, (%rsp)
leaq 0x1(%rax), %r15
movq %r15, %r13
imulq %r15, %r13
shlq $0x2, %r13
movq %r13, %rdi
callq 0x19e150
testq %rax, %rax
je 0x209d66
movq %rax, %r14
testq %r12, %r12
je 0x209c14
xorl %eax, %eax
xorl %edx, %edx
leaq 0x4(,%rdx,4), %rcx
xorl %esi, %esi
movq %rax, %rdi
addq %rsi, %rdi
movl %ebx, %edi
cmovel %ebp, %edi
movl %edi, -0x4(%r14,%rcx)
addq $0x4, %rcx
decq %rsi
movq %r12, %rdi
addq %rsi, %rdi
jne 0x209bdc
subq %rsi, %rdx
incq %rdx
movl $0x0, -0x4(%r14,%rcx)
incq %rax
cmpq %r12, %rax
jne 0x209bd2
jmp 0x209c16
xorl %ecx, %ecx
movq %r14, %rdi
addq %rcx, %rdi
leaq 0x4(,%r12,4), %rdx
xorl %esi, %esi
callq 0x19e090
movl $0x400, %edi            # imm = 0x400
callq 0x19e150
testq %rax, %rax
je 0x209d86
movq %rax, %r13
movq %r15, 0x10(%rsp)
movq %r12, %r15
xorl %eax, %eax
movl %r15d, (%r13,%rax,4)
incq %rax
cmpq $0x100, %rax            # imm = 0x100
jne 0x209c4b
cmpl $0x0, (%rsp)
movq 0x8(%rsp), %rdx
je 0x209c80
testq %r12, %r12
je 0x209cc5
xorl %eax, %eax
movzbl (%rdx,%rax), %ecx
movl %eax, (%r13,%rcx,4)
incq %rax
cmpq %rax, %r12
jne 0x209c6d
jmp 0x209cc5
testq %r12, %r12
je 0x209cc5
callq 0x19e030
movq (%rax), %rax
movq %rax, (%rsp)
callq 0x19e040
movq (%rsp), %r8
movq 0x8(%rsp), %rdi
movq (%rax), %rax
xorl %ecx, %ecx
movzbl (%rdi,%rcx), %edx
shll $0x2, %edx
movslq (%r8,%rdx), %rsi
movl %ecx, (%r13,%rsi,4)
movslq (%rax,%rdx), %rdx
movl %ecx, (%r13,%rdx,4)
incq %rcx
cmpq %rcx, %r12
jne 0x209ca4
addq $0x2, %r12
movq %r12, %rdi
callq 0x19e150
testq %rax, %rax
je 0x209d8d
movq %rax, %rcx
movq %rax, %r12
movq %rcx, %rdi
movq 0x8(%rsp), %rsi
movq %r15, %rdx
callq 0x19e0c0
movw $0x2a, (%r12,%r15)
movl $0x48, %edi
callq 0x19e150
testq %rax, %rax
je 0x209db4
movq %rax, %r15
leaq 0x38c79e(%rip), %rax    # 0x5964b2
movq %rax, (%r15)
movq %r14, 0x8(%r15)
movq %r13, 0x10(%r15)
movq 0x10(%rsp), %rcx
movl %ecx, 0x18(%r15)
cmpl %ebx, %ebp
movl %ebx, %eax
cmovgl %ebp, %eax
movl %eax, 0x1c(%r15)
cmovll %ebp, %ebx
movl %ebx, 0x20(%r15)
movq %r14, 0x28(%r15)
movl $0x0, 0x30(%r15)
movl %ecx, 0x34(%r15)
movq %r12, 0x38(%r15)
movq $0x0, 0x40(%r15)
jmp 0x209dbc
callq 0x19eb8d
jmp 0x209db9
callq 0x19eb6e
jmp 0x209db9
movq 0x59826b(%rip), %rax    # 0x7a1fd8
movq (%rax), %rdi
leaq 0x3eb136(%rip), %rsi    # 0x5f4ead
leaq 0x3eb8e7(%rip), %rdx    # 0x5f5665
xorl %r15d, %r15d
movq %r13, %rcx
jmp 0x209dab
callq 0x19eb4a
jmp 0x209db9
movq 0x598244(%rip), %rax    # 0x7a1fd8
movq (%rax), %rdi
leaq 0x3eb10f(%rip), %rsi    # 0x5f4ead
leaq 0x3eb8c0(%rip), %rdx    # 0x5f5665
xorl %r15d, %r15d
movq %r12, %rcx
xorl %eax, %eax
callq 0x19e180
jmp 0x209dbc
callq 0x19eb28
xorl %r15d, %r15d
movq %r15, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq