// File: /workspace/github_c_makefile_star2_O1/nh13[P]ksw/src/parasail/src/memory.c
// Function: parasail_matrix_copy
parasail_matrix_t* parasail_matrix_copy(const parasail_matrix_t *matrix)
{
    parasail_matrix_t *retval = NULL;

    PARASAIL_CHECK_NULL(matrix);

    PARASAIL_NEW(retval, parasail_matrix_t);
    retval->name = matrix->name;
    retval->size = matrix->size;
    retval->max = matrix->max;
    retval->min = matrix->min;
    retval->type = matrix->type;
    retval->length = matrix->length;

    {
        size_t matrix_size = 0;
        size_t alphabet_size = (matrix->size+1);
        int *new_mapper = NULL;
        int *new_matrix = NULL;
        char *new_alphabet = NULL;
        char *new_query = NULL;

        if (matrix->type == PARASAIL_MATRIX_TYPE_SQUARE) {
            matrix_size = matrix->size*matrix->size;
        }
        else if (matrix->type == PARASAIL_MATRIX_TYPE_PSSM) {
            matrix_size = matrix->size*matrix->length;
        }

        PARASAIL_CALLOC(new_mapper, int, 256);
        (void)memcpy(new_mapper, matrix->mapper, sizeof(int)*256);

        PARASAIL_CALLOC(new_matrix, int, matrix_size);
        (void)memcpy(new_matrix, matrix->matrix, sizeof(int)*matrix_size);

        PARASAIL_CALLOC(new_alphabet, char, alphabet_size);
        (void)memcpy(new_alphabet, matrix->alphabet, sizeof(char)*alphabet_size);

        if (matrix->query) {
            size_t query_size = strlen(matrix->query);
            PARASAIL_CALLOC(new_query, char, query_size+1);
            (void)memcpy(new_query, matrix->query, sizeof(char)*(query_size+1));
            new_query[query_size] = '\0';
        }

        retval->mapper = new_mapper;
        retval->matrix = new_matrix;
        retval->user_matrix = new_matrix;
        retval->alphabet = new_alphabet;
        retval->query = new_query;
    }

    return retval;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
testq %rdi, %rdi
je 0x20a240
movq %rdi, %r14
movl $0x48, %edi
callq 0x19e150
testq %rax, %rax
je 0x20a247
movq %rax, %rbx
movq (%r14), %rax
movq %rax, (%rbx)
movslq 0x18(%r14), %r15
movl %r15d, 0x18(%rbx)
movl 0x1c(%r14), %eax
movl %eax, 0x1c(%rbx)
movl 0x20(%r14), %eax
movl %eax, 0x20(%rbx)
movl 0x30(%r14), %eax
movl %eax, 0x30(%rbx)
movl 0x34(%r14), %ecx
movl %ecx, 0x34(%rbx)
cmpl $0x1, %eax
je 0x20a149
testl %eax, %eax
jne 0x20a152
movl %r15d, %ebp
imull %ebp, %ebp
jmp 0x20a154
imull %r15d, %ecx
movslq %ecx, %rbp
jmp 0x20a154
xorl %ebp, %ebp
movl $0x400, %edi            # imm = 0x400
callq 0x19e150
testq %rax, %rax
je 0x20a24e
movq %rax, %r12
movq 0x10(%r14), %rsi
movl $0x400, %edx            # imm = 0x400
movq %rax, %rdi
callq 0x19e0c0
shlq $0x2, %rbp
movq %rbp, %rdi
callq 0x19e150
testq %rax, %rax
je 0x20a257
movq %rax, %r13
incq %r15
movq 0x8(%r14), %rsi
movq %rax, %rdi
movq %rbp, %rdx
callq 0x19e0c0
movq %r15, %rdi
callq 0x19e150
testq %rax, %rax
je 0x20a276
movq %rax, %rbp
movq 0x38(%r14), %rsi
movq %rax, %rdi
movq %r15, %rdx
callq 0x19e0c0
movq 0x40(%r14), %r14
testq %r14, %r14
je 0x20a217
movq %r12, 0x10(%rsp)
movq %r14, %rdi
callq 0x19e070
movq %rax, %r12
leaq 0x1(%rax), %rdi
movq %rdi, 0x8(%rsp)
callq 0x19e150
testq %rax, %rax
je 0x20a295
movq %rax, %r15
movq %rax, %rdi
movq %r14, %rsi
movq 0x8(%rsp), %rdx
callq 0x19e0c0
movb $0x0, (%r15,%r12)
movq 0x10(%rsp), %r12
jmp 0x20a21a
xorl %r15d, %r15d
movq %r12, 0x10(%rbx)
movq %r13, 0x8(%rbx)
movq %r13, 0x28(%rbx)
movq %rbp, 0x38(%rbx)
movq %r15, 0x40(%rbx)
movq %rbx, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x19ecc9
jmp 0x20a253
callq 0x19eca7
jmp 0x20a253
callq 0x19ec83
xorl %ebx, %ebx
jmp 0x20a22e
movq 0x597d7a(%rip), %rax    # 0x7a1fd8
movq (%rax), %rdi
leaq 0x3eac45(%rip), %rsi    # 0x5f4ead
leaq 0x3ead7c(%rip), %rdx    # 0x5f4feb
xorl %ebx, %ebx
movq %rbp, %rcx
jmp 0x20a2b4
movq 0x597d5b(%rip), %rax    # 0x7a1fd8
movq (%rax), %rdi
leaq 0x3eac26(%rip), %rsi    # 0x5f4ead
leaq 0x3ead5d(%rip), %rdx    # 0x5f4feb
xorl %ebx, %ebx
movq %r15, %rcx
jmp 0x20a2b4
movq 0x597d3c(%rip), %rax    # 0x7a1fd8
movq (%rax), %rdi
leaq 0x3eac07(%rip), %rsi    # 0x5f4ead
leaq 0x3ead3e(%rip), %rdx    # 0x5f4feb
xorl %ebx, %ebx
movq 0x8(%rsp), %rcx
xorl %eax, %eax
callq 0x19e180
jmp 0x20a22e