// File: /workspace/github_c_makefile_star2_O0/nh13[P]ksw/src/parasail/src/memory.c
// Function: parasail_matrix_convert_square_to_pssm
parasail_matrix_t* parasail_matrix_convert_square_to_pssm(
        const parasail_matrix_t *matrix,
        const char *s1,
        int s1Len)
{
    parasail_matrix_t *retval = NULL;
    size_t matrix_size = matrix->size*s1Len;
    size_t alphabet_size = matrix->size+1;
    int *new_mapper = NULL;
    int *new_matrix = NULL;
    char *new_alphabet = NULL;
    char *new_query = NULL;
    int i;

    PARASAIL_CHECK_NULL(matrix);

    if (matrix->type != PARASAIL_MATRIX_TYPE_SQUARE) {
        fprintf(stderr, "%s: attempted to convert non-square matrix to pssm\n", __func__);
        return NULL;
    }

    PARASAIL_NEW(retval, parasail_matrix_t);

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

    PARASAIL_CALLOC(new_matrix, int, matrix_size);

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

    PARASAIL_CALLOC(new_query, char, s1Len+1);
    (void)memcpy(new_query, s1, sizeof(char)*(s1Len+1));

    for (i=0; i<s1Len; ++i) {
        (void)memcpy(
                &new_matrix[matrix->size*i],
                &matrix->matrix[matrix->size*matrix->mapper[(unsigned char)s1[i]]],
                sizeof(int)*matrix->size);
    }

    retval->name = matrix->name;
    retval->matrix = new_matrix;
    retval->mapper = new_mapper;
    retval->size = matrix->size;
    retval->max = matrix->max;
    retval->min = matrix->min;
    retval->user_matrix = new_matrix;
    retval->type = PARASAIL_MATRIX_TYPE_PSSM;
    retval->length = s1Len;
    retval->alphabet = new_alphabet;
    retval->query = new_query;

    return retval;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movq $0x0, -0x28(%rbp)
movq -0x10(%rbp), %rax
movl 0x18(%rax), %eax
imull -0x1c(%rbp), %eax
cltq
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rax
movl 0x18(%rax), %eax
addl $0x1, %eax
cltq
movq %rax, -0x38(%rbp)
movq $0x0, -0x40(%rbp)
movq $0x0, -0x48(%rbp)
movq $0x0, -0x50(%rbp)
movq $0x0, -0x58(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x1c5829
movq 0xc617db(%rip), %rax    # 0xe26fd8
movq (%rax), %rdi
leaq 0xb267e4(%rip), %rsi    # 0xcebfeb
leaq 0xb26802(%rip), %rdx    # 0xcec010
leaq 0xb27110(%rip), %rcx    # 0xcec925
movb $0x0, %al
callq 0x19e180
movq $0x0, -0x8(%rbp)
jmp 0x1c5b54
jmp 0x1c582b
movq -0x10(%rbp), %rax
cmpl $0x0, 0x30(%rax)
je 0x1c5861
movq 0xc6179c(%rip), %rax    # 0xe26fd8
movq (%rax), %rdi
leaq 0xb267f1(%rip), %rsi    # 0xcec037
leaq 0xb267c3(%rip), %rdx    # 0xcec010
movb $0x0, %al
callq 0x19e180
movq $0x0, -0x8(%rbp)
jmp 0x1c5b54
jmp 0x1c5863
movq $0x48, -0x68(%rbp)
movq -0x68(%rbp), %rdi
callq 0x19e150
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0x1c58af
movq 0xc61752(%rip), %rax    # 0xe26fd8
movq (%rax), %rdi
movq -0x68(%rbp), %rcx
leaq 0xb26629(%rip), %rsi    # 0xcebebd
leaq 0xb26775(%rip), %rdx    # 0xcec010
movb $0x0, %al
callq 0x19e180
movq $0x0, -0x8(%rbp)
jmp 0x1c5b54
jmp 0x1c58b1
jmp 0x1c58b3
movq $0x400, -0x70(%rbp)     # imm = 0x400
movq -0x70(%rbp), %rdi
callq 0x19e150
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0x1c58ff
movq 0xc61702(%rip), %rax    # 0xe26fd8
movq (%rax), %rdi
movq -0x70(%rbp), %rcx
leaq 0xb265d9(%rip), %rsi    # 0xcebebd
leaq 0xb26725(%rip), %rdx    # 0xcec010
movb $0x0, %al
callq 0x19e180
movq $0x0, -0x8(%rbp)
jmp 0x1c5b54
jmp 0x1c5901
movq -0x40(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rsi
movl $0x400, %edx            # imm = 0x400
callq 0x19e0a0
movq -0x30(%rbp), %rax
shlq $0x2, %rax
movq %rax, -0x78(%rbp)
movq -0x78(%rbp), %rdi
callq 0x19e150
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
jne 0x1c5967
movq 0xc6169a(%rip), %rax    # 0xe26fd8
movq (%rax), %rdi
movq -0x78(%rbp), %rcx
leaq 0xb26571(%rip), %rsi    # 0xcebebd
leaq 0xb266bd(%rip), %rdx    # 0xcec010
movb $0x0, %al
callq 0x19e180
movq $0x0, -0x8(%rbp)
jmp 0x1c5b54
jmp 0x1c5969
jmp 0x1c596b
movq -0x38(%rbp), %rax
shlq $0x0, %rax
movq %rax, -0x80(%rbp)
movq -0x80(%rbp), %rdi
callq 0x19e150
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x50(%rbp)
jne 0x1c59bb
movq 0xc61646(%rip), %rax    # 0xe26fd8
movq (%rax), %rdi
movq -0x80(%rbp), %rcx
leaq 0xb2651d(%rip), %rsi    # 0xcebebd
leaq 0xb26669(%rip), %rdx    # 0xcec010
movb $0x0, %al
callq 0x19e180
movq $0x0, -0x8(%rbp)
jmp 0x1c5b54
jmp 0x1c59bd
movq -0x50(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rsi
movq -0x38(%rbp), %rdx
shlq $0x0, %rdx
callq 0x19e0a0
movl -0x1c(%rbp), %eax
addl $0x1, %eax
cltq
shlq $0x0, %rax
movq %rax, -0x88(%rbp)
movq -0x88(%rbp), %rdi
callq 0x19e150
movq %rax, -0x58(%rbp)
cmpq $0x0, -0x58(%rbp)
jne 0x1c5a33
movq 0xc615d1(%rip), %rax    # 0xe26fd8
movq (%rax), %rdi
movq -0x88(%rbp), %rcx
leaq 0xb264a5(%rip), %rsi    # 0xcebebd
leaq 0xb265f1(%rip), %rdx    # 0xcec010
movb $0x0, %al
callq 0x19e180
movq $0x0, -0x8(%rbp)
jmp 0x1c5b54
jmp 0x1c5a35
movq -0x58(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rdx
shlq $0x0, %rdx
callq 0x19e0a0
movl $0x0, -0x5c(%rbp)
movl -0x5c(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jge 0x1c5ac3
movq -0x48(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0x18(%rax), %eax
imull -0x5c(%rbp), %eax
cltq
shlq $0x2, %rax
addq %rax, %rdi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rsi
movq -0x10(%rbp), %rax
movl 0x18(%rax), %eax
movq -0x10(%rbp), %rcx
movq 0x10(%rcx), %rcx
movq -0x18(%rbp), %rdx
movslq -0x5c(%rbp), %r8
movzbl (%rdx,%r8), %edx
imull (%rcx,%rdx,4), %eax
cltq
shlq $0x2, %rax
addq %rax, %rsi
movq -0x10(%rbp), %rax
movslq 0x18(%rax), %rdx
shlq $0x2, %rdx
callq 0x19e0a0
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
jmp 0x1c5a56
movq -0x10(%rbp), %rax
movq (%rax), %rcx
movq -0x28(%rbp), %rax
movq %rcx, (%rax)
movq -0x48(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x40(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x10(%rbp), %rax
movl 0x18(%rax), %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x18(%rax)
movq -0x10(%rbp), %rax
movl 0x1c(%rax), %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x1c(%rax)
movq -0x10(%rbp), %rax
movl 0x20(%rax), %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x20(%rax)
movq -0x48(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x28(%rbp), %rax
movl $0x1, 0x30(%rax)
movl -0x1c(%rbp), %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x34(%rax)
movq -0x50(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x38(%rax)
movq -0x58(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x40(%rax)
movq -0x28(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x90, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)