// File: /workspace/github_c_makefile_star2_O2/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 0x1ac6ec
movq %rdi, %r14
pushq $0x48
popq %rdi
callq 0x19e150
testq %rax, %rax
je 0x1ac712
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 0x1ac5fe
testl %eax, %eax
jne 0x1ac607
movl %r15d, %r13d
imull %r13d, %r13d
jmp 0x1ac60a
imull %r15d, %ecx
movslq %ecx, %r13
jmp 0x1ac60a
xorl %r13d, %r13d
movl $0x400, %edi            # imm = 0x400
callq 0x19e150
testq %rax, %rax
je 0x1ac731
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 0x1ac752
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 0x1ac771
movq %rax, %r13
movq 0x38(%r14), %rsi
movq %rax, %rdi
movq %rbp, %rdx
callq 0x19e0c0
movq 0x40(%r14), %r14
testq %r14, %r14
je 0x1ac6cc
movq %r14, %rdi
callq 0x19e070
movq %rax, %r15
leaq 0x1(%rax), %rdi
movq %rdi, 0x8(%rsp)
callq 0x19e150
testq %rax, %rax
je 0x1ac790
movq %rax, %rbp
movq %rax, %rdi
movq %r14, %rsi
movq 0x8(%rsp), %rdx
callq 0x19e0c0
movb $0x0, (%rbp,%r15)
jmp 0x1ac6ce
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)
jmp 0x1ac7b6
movq 0x58e8e5(%rip), %rax    # 0x73afd8
movq (%rax), %rdi
leaq 0x41a8ee(%rip), %rsi    # 0x5c6feb
leaq 0x41a8f7(%rip), %rdx    # 0x5c6ffb
leaq 0x41b237(%rip), %rcx    # 0x5c7942
xorl %ebx, %ebx
jmp 0x1ac7af
movq 0x58e8bf(%rip), %rax    # 0x73afd8
movq (%rax), %rdi
leaq 0x41a79a(%rip), %rsi    # 0x5c6ebd
leaq 0x41a8d1(%rip), %rdx    # 0x5c6ffb
xorl %ebx, %ebx
pushq $0x48
popq %rcx
jmp 0x1ac7af
movq 0x58e8a0(%rip), %rax    # 0x73afd8
movq (%rax), %rdi
leaq 0x41a77b(%rip), %rsi    # 0x5c6ebd
leaq 0x41a8b2(%rip), %rdx    # 0x5c6ffb
xorl %ebx, %ebx
movl $0x400, %ecx            # imm = 0x400
jmp 0x1ac7af
movq 0x58e87f(%rip), %rax    # 0x73afd8
movq (%rax), %rdi
leaq 0x41a75a(%rip), %rsi    # 0x5c6ebd
leaq 0x41a891(%rip), %rdx    # 0x5c6ffb
xorl %ebx, %ebx
movq %r13, %rcx
jmp 0x1ac7af
movq 0x58e860(%rip), %rax    # 0x73afd8
movq (%rax), %rdi
leaq 0x41a73b(%rip), %rsi    # 0x5c6ebd
leaq 0x41a872(%rip), %rdx    # 0x5c6ffb
xorl %ebx, %ebx
movq %rbp, %rcx
jmp 0x1ac7af
movq 0x58e841(%rip), %rax    # 0x73afd8
movq (%rax), %rdi
leaq 0x41a71c(%rip), %rsi    # 0x5c6ebd
leaq 0x41a853(%rip), %rdx    # 0x5c6ffb
xorl %ebx, %ebx
movq 0x8(%rsp), %rcx
xorl %eax, %eax
callq 0x19e180
movq %rbx, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq