// File: /workspace/github_c_makefile_star2_O3/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 0x20b881
movq %rdi, %r14
movl $0x48, %edi
callq 0x19e150
testq %rax, %rax
je 0x20b888
movq %rax, %rbx
movq (%r14), %rax
movq %rax, (%rbx)
movq 0x18(%r14), %r15
movq %r15, 0x18(%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 0x20b786
testl %eax, %eax
jne 0x20b78f
movl %r15d, %r13d
imull %r13d, %r13d
jmp 0x20b792
imull %r15d, %ecx
movslq %ecx, %r13
jmp 0x20b792
xorl %r13d, %r13d
movl $0x400, %edi            # imm = 0x400
callq 0x19e150
testq %rax, %rax
je 0x20b88f
movq %rax, %rbp
movq 0x10(%r14), %rsi
movl $0x400, %edx            # imm = 0x400
movq %rax, %rdi
callq 0x19e0c0
shlq $0x2, %r13
movq %r13, %rdi
callq 0x19e150
testq %rax, %rax
je 0x20b898
movq %rax, %r12
movq %rbp, 0x10(%rsp)
incl %r15d
movslq %r15d, %rbp
movq 0x8(%r14), %rsi
movq %rax, %rdi
movq %r13, %rdx
callq 0x19e0c0
movq %rbp, %rdi
callq 0x19e150
testq %rax, %rax
je 0x20b8b7
movq %rax, %r13
movq 0x38(%r14), %rsi
movq %rax, %rdi
movq %rbp, %rdx
callq 0x19e0c0
movq 0x40(%r14), %r14
testq %r14, %r14
je 0x20b854
movq %r14, %rdi
callq 0x19e070
movq %rax, %r15
leaq 0x1(%rax), %rdi
movq %rdi, 0x8(%rsp)
callq 0x19e150
testq %rax, %rax
je 0x20b8d6
movq %rax, %rbp
movq %rax, %rdi
movq %r14, %rsi
movq 0x8(%rsp), %rdx
callq 0x19e0c0
movb $0x0, (%rbp,%r15)
jmp 0x20b856
xorl %ebp, %ebp
movq 0x10(%rsp), %rax
movq %rax, 0x10(%rbx)
movq %r12, 0x8(%rbx)
movq %r12, 0x28(%rbx)
movq %r13, 0x38(%rbx)
movq %rbp, 0x40(%rbx)
movq %rbx, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x19ece3
jmp 0x20b894
callq 0x19ecc1
jmp 0x20b894
callq 0x19ec9d
xorl %ebx, %ebx
jmp 0x20b86f
movq 0x5cc739(%rip), %rax    # 0x7d7fd8
movq (%rax), %rdi
leaq 0x41d694(%rip), %rsi    # 0x628f3d
leaq 0x41d7cb(%rip), %rdx    # 0x62907b
xorl %ebx, %ebx
movq %r13, %rcx
jmp 0x20b8f5
movq 0x5cc71a(%rip), %rax    # 0x7d7fd8
movq (%rax), %rdi
leaq 0x41d675(%rip), %rsi    # 0x628f3d
leaq 0x41d7ac(%rip), %rdx    # 0x62907b
xorl %ebx, %ebx
movq %rbp, %rcx
jmp 0x20b8f5
movq 0x5cc6fb(%rip), %rax    # 0x7d7fd8
movq (%rax), %rdi
leaq 0x41d656(%rip), %rsi    # 0x628f3d
leaq 0x41d78d(%rip), %rdx    # 0x62907b
xorl %ebx, %ebx
movq 0x8(%rsp), %rcx
xorl %eax, %eax
callq 0x19e180
jmp 0x20b86f