// File: /workspace/github_c_makefile_star2_O2/nh13[P]ksw/src/parasail/src/memory_sse.c
// Function: parasail_profile_create_sse_128_32
parasail_profile_t * parasail_profile_create_sse_128_32(
        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 = 4; /* 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_32_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->profile32.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 0x2982d4
movq %rdx, %rbx
movq %rdi, %r14
movl 0x30(%rdx), %eax
testl %eax, %eax
setne %cl
testq %rdi, %rdi
setne %dl
orb %cl, %dl
je 0x2982f5
movl %esi, %ebp
testl %eax, %eax
je 0x298159
movl 0x34(%rbx), %ebp
movslq 0x18(%rbx), %rsi
leal 0x3(%rbp), %eax
pushq $0x4
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 0x2982b5
movq %r14, %rdi
movl %ebp, %esi
movq %rbx, %rdx
callq 0x1acaf8
xorl %r8d, %r8d
movq %rax, 0x18(%rsp)
testq %rax, %rax
je 0x2982b5
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 0x2982b9
movq %r8, %rax
imulq 0x8(%rsp), %rax
movslq %r9d, %r9
shlq $0x2, %rax
xorl %ecx, %ecx
xorl %ebp, %ebp
cmpq 0x30(%rsp), %rbp
je 0x2982ad
movq %r9, 0x38(%rsp)
movl 0x30(%rbx), %r11d
movq %rcx, %r9
xorl %r12d, %r12d
movq %rbp, %r10
cmpq $0x4, %r12
je 0x298283
testl %r11d, %r11d
je 0x298250
cmpq %rdx, %r10
jge 0x298271
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 0x29826d
cmpq %rdx, %r10
jge 0x298271
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
movl (%rsi), %esi
jmp 0x298273
xorl %esi, %esi
movl %esi, 0x40(%rsp,%r12,4)
addq %r15, %r10
incq %r12
addq %r13, %r9
jmp 0x298222
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 0x298205
incq %r8
jmp 0x2981e6
xorl %ebx, %ebx
jmp 0x29831d
movq 0x18(%rsp), %rbx
movq 0x10(%rsp), %rax
movq %rax, 0x48(%rbx)
leaq -0x3ca(%rip), %rax      # 0x297f04
movq %rax, 0x78(%rbx)
jmp 0x29831d
movq 0x4a2cfd(%rip), %rax    # 0x73afd8
movq (%rax), %rdi
leaq 0x32ed06(%rip), %rsi    # 0x5c6feb
leaq 0x33025f(%rip), %rdx    # 0x5c854b
leaq 0x32f64f(%rip), %rcx    # 0x5c7942
jmp 0x298314
movq 0x4a2cdc(%rip), %rax    # 0x73afd8
movq (%rax), %rdi
leaq 0x32ece5(%rip), %rsi    # 0x5c6feb
leaq 0x33023e(%rip), %rdx    # 0x5c854b
leaq 0x32f426(%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