// File: /workspace/github_c_makefile_star2_O2/nh13[P]ksw/src/parasail/src/memory_sse.c
// Function: parasail_profile_create_sse_128_16
parasail_profile_t * parasail_profile_create_sse_128_16(
        const char * const restrict s1, const int _s1Len,
        const parasail_matrix_t *matrix)
{
    int s1Len = 0;
    int32_t i = 0;
    int32_t j = 0;
    int32_t k = 0;
    int32_t segNum = 0;
    int32_t n = 0; /* number of amino acids in table */
    const int32_t segWidth = 8; /* number of values in vector unit */
    int32_t segLen = 0;
    __m128i* restrict vProfile = NULL;
    int32_t index = 0;
    parasail_profile_t *profile = NULL;

    PARASAIL_CHECK_NULL(matrix);
    /* s1 is ignored for pssm, required for square */
    if (matrix->type == PARASAIL_MATRIX_TYPE_SQUARE) {
        PARASAIL_CHECK_NULL(s1);
    }

    s1Len = matrix->type == PARASAIL_MATRIX_TYPE_SQUARE ? _s1Len : matrix->length;
    n = matrix->size;
    segLen = (s1Len + segWidth - 1) / segWidth;
    vProfile = parasail_memalign___m128i(16, n * segLen);
    if (!vProfile) return NULL;
    profile = parasail_profile_new(s1, s1Len, matrix);
    if (!profile) return NULL;

    for (k=0; k<n; ++k) {
        for (i=0; i<segLen; ++i) {
            __m128i_16_t t;
            j = i;
            for (segNum=0; segNum<segWidth; ++segNum) {
                if (matrix->type == PARASAIL_MATRIX_TYPE_SQUARE) {
                    t.v[segNum] = j >= s1Len ? 0 : matrix->matrix[n*k+matrix->mapper[(unsigned char)s1[j]]];
                }
                else {
                    t.v[segNum] = j >= s1Len ? 0 : matrix->matrix[n*j+matrix->mapper[(unsigned char)matrix->alphabet[k]]];
                }
                j += segLen;
            }
            _mm_store_si128(&vProfile[index], t.m);
            ++index;
        }
    }

    profile->profile16.score = vProfile;
    profile->free = &parasail_free___m128i;
    return profile;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
testq %rdx, %rdx
je 0x2980c2
movq %rdx, %rbx
movq %rdi, %r14
movl 0x30(%rdx), %eax
testl %eax, %eax
setne %cl
testq %rdi, %rdi
setne %dl
orb %cl, %dl
je 0x2980e3
movl %esi, %ebp
testl %eax, %eax
je 0x297f45
movl 0x34(%rbx), %ebp
movslq 0x18(%rbx), %rsi
leal 0x7(%rbp), %eax
pushq $0x8
popq %rcx
cltd
idivl %ecx
movq %rax, %r12
movslq %eax, %r15
movq %r15, %r13
movq %rsi, 0x8(%rsp)
imulq %rsi, %r13
pushq $0x10
popq %rdi
movq %r13, %rsi
callq 0x297cd8
movq %rax, 0x10(%rsp)
testq %rax, %rax
je 0x2980a3
movq %r14, %rdi
movl %ebp, %esi
movq %rbx, %rdx
callq 0x1acaf8
xorl %r8d, %r8d
movq %rax, 0x18(%rsp)
testq %rax, %rax
je 0x2980a3
testl %r12d, %r12d
cmovlel %r8d, %r12d
movq %r12, 0x30(%rsp)
movq 0x8(%rsp), %rax
testl %eax, %eax
movl $0x0, %ecx
cmovgl %eax, %ecx
movq %rcx, 0x20(%rsp)
movslq %ebp, %rdx
leaq (,%rax,4), %rax
movq %rax, 0x28(%rsp)
shlq $0x2, %r13
xorl %r9d, %r9d
cmpq 0x20(%rsp), %r8
je 0x2980a7
movq %r8, %rax
imulq 0x8(%rsp), %rax
movslq %r9d, %r9
shlq $0x2, %rax
xorl %ecx, %ecx
xorl %ebp, %ebp
cmpq 0x30(%rsp), %rbp
je 0x29809b
movq %r9, 0x38(%rsp)
movl 0x30(%rbx), %r11d
movq %rcx, %r9
xorl %r12d, %r12d
movq %rbp, %r10
cmpq $0x8, %r12
je 0x298071
testl %r11d, %r11d
je 0x29803c
cmpq %rdx, %r10
jge 0x29805e
movq 0x10(%rbx), %rsi
movq 0x38(%rbx), %rdi
movzbl (%rdi,%r8), %edi
movslq (%rsi,%rdi,4), %rsi
shlq $0x2, %rsi
addq 0x8(%rbx), %rsi
addq %r9, %rsi
jmp 0x298059
cmpq %rdx, %r10
jge 0x29805e
movq 0x10(%rbx), %rsi
movzbl (%r14,%r10), %edi
movslq (%rsi,%rdi,4), %rsi
movq 0x8(%rbx), %rdi
addq %rax, %rdi
leaq (%rdi,%rsi,4), %rsi
movzwl (%rsi), %esi
jmp 0x298060
xorl %esi, %esi
movw %si, 0x40(%rsp,%r12,2)
addq %r15, %r10
incq %r12
addq %r13, %r9
jmp 0x29800e
movq 0x38(%rsp), %r9
movq %r9, %rsi
shlq $0x4, %rsi
movaps 0x40(%rsp), %xmm0
movq 0x10(%rsp), %rdi
movaps %xmm0, (%rdi,%rsi)
incq %r9
incq %rbp
addq 0x28(%rsp), %rcx
jmp 0x297ff1
incq %r8
jmp 0x297fd2
xorl %ebx, %ebx
jmp 0x29810b
movq 0x18(%rsp), %rbx
movq 0x10(%rsp), %rax
movq %rax, 0x30(%rbx)
leaq -0x1b8(%rip), %rax      # 0x297f04
movq %rax, 0x78(%rbx)
jmp 0x29810b
movq 0x4a2f0f(%rip), %rax    # 0x73afd8
movq (%rax), %rdi
leaq 0x32ef18(%rip), %rsi    # 0x5c6feb
leaq 0x33044e(%rip), %rdx    # 0x5c8528
leaq 0x32f861(%rip), %rcx    # 0x5c7942
jmp 0x298102
movq 0x4a2eee(%rip), %rax    # 0x73afd8
movq (%rax), %rdi
leaq 0x32eef7(%rip), %rsi    # 0x5c6feb
leaq 0x33042d(%rip), %rdx    # 0x5c8528
leaq 0x32f638(%rip), %rcx    # 0x5c773a
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x19e180
movq %rbx, %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq