// File: /workspace/github_c_makefile_star2_O3/nh13[P]ksw/src/parasail/src/memory_sse.c
// Function: parasail_profile_create_stats_sse_128_16
parasail_profile_t * parasail_profile_create_stats_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;
    const int32_t segWidth = 8; /* number of values in vector unit */
    int32_t segLen = 0;
    __m128i* restrict vProfile = NULL;
    __m128i* restrict vProfileM = NULL;
    __m128i* restrict vProfileS = NULL;
    int32_t index = 0;
    parasail_profile_t *profile = NULL;

    PARASAIL_CHECK_NULL(matrix);
    /* s1 is required for both pssm and square */
    PARASAIL_CHECK_NULL(s1);

    s1Len = matrix->type == PARASAIL_MATRIX_TYPE_SQUARE ? _s1Len : matrix->length;
    n = matrix->size; /* number of amino acids in table */
    segLen = (s1Len + segWidth - 1) / segWidth;
    vProfile = parasail_memalign___m128i(16, n * segLen);
    if (!vProfile) return NULL;
    vProfileM = parasail_memalign___m128i(16, n * segLen);
    if (!vProfileM) return NULL;
    vProfileS = parasail_memalign___m128i(16, n * segLen);
    if (!vProfileS) 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 p;
            __m128i_16_t m;
            __m128i_16_t s;
            j = i;
            for (segNum=0; segNum<segWidth; ++segNum) {
                if (matrix->type == PARASAIL_MATRIX_TYPE_SQUARE) {
                    p.v[segNum] = j >= s1Len ? 0 : matrix->matrix[n*k+matrix->mapper[(unsigned char)s1[j]]];
                }
                else {
                    p.v[segNum] = j >= s1Len ? 0 : matrix->matrix[n*j+matrix->mapper[(unsigned char)matrix->alphabet[k]]];
                }
                m.v[segNum] = j >= s1Len ? 0 : (k == matrix->mapper[(unsigned char)s1[j]]);
                s.v[segNum] = p.v[segNum] > 0;
                j += segLen;
            }
            _mm_store_si128(&vProfile[index], p.m);
            _mm_store_si128(&vProfileM[index], m.m);
            _mm_store_si128(&vProfileS[index], s.m);
            ++index;
        }
    }

    profile->profile16.score = vProfile;
    profile->profile16.matches = vProfileM;
    profile->profile16.similar = vProfileS;
    profile->free = &parasail_free___m128i;
    return profile;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
testq %rdx, %rdx
je 0x2f6c1b
movq %rdi, %r14
testq %rdi, %rdi
je 0x2f6c22
movq %rdx, %rbx
movl %esi, %r15d
cmpl $0x0, 0x30(%rdx)
je 0x2f6a1d
movl 0x34(%rbx), %r15d
movl 0x18(%rbx), %ecx
leal 0x7(%r15), %eax
leal 0xe(%r15), %r12d
testl %eax, %eax
cmovnsl %eax, %r12d
sarl $0x3, %r12d
movl %r12d, %eax
movq %rcx, (%rsp)
imull %ecx, %eax
movslq %eax, %rbp
shlq $0x4, %rbp
movl $0x10, %edi
movq %rbp, %rsi
callq 0x20a5b8
movq %rax, 0x20(%rsp)
testq %rax, %rax
je 0x2f6c27
movl $0x10, %edi
movq %rbp, %rsi
callq 0x20a5b8
movq %rax, 0x18(%rsp)
testq %rax, %rax
je 0x2f6c27
movl $0x10, %edi
movq %rbp, %rsi
callq 0x20a5b8
movq %rax, 0x10(%rsp)
testq %rax, %rax
je 0x2f6c27
movq %r14, %rdi
movl %r15d, %esi
movq %rbx, %rdx
callq 0x20bbb5
testq %rax, %rax
je 0x2f6c27
movq %rax, 0x28(%rsp)
cmpl $0x0, (%rsp)
jle 0x2f6bee
cmpl $0x2, %r12d
movl $0x1, %eax
cmovgel %r12d, %eax
movq %rax, 0x30(%rsp)
movl %r12d, %edx
imull (%rsp), %r12d
xorl %esi, %esi
xorl %edi, %edi
testl %r15d, %r15d
jle 0x2f6be1
movslq %edi, %rdi
movl %esi, %eax
imull (%rsp), %eax
movl %eax, 0xc(%rsp)
xorl %r9d, %r9d
xorl %ebp, %ebp
movq %rdi, 0x38(%rsp)
movl 0x30(%rbx), %r11d
movl %r9d, %r13d
movq %rbp, %r10
xorl %ecx, %ecx
testl %r11d, %r11d
je 0x2f6b24
cmpl %r10d, %r15d
jle 0x2f6b47
movq 0x10(%rbx), %rax
movq 0x38(%rbx), %r8
movzbl (%r8,%rsi), %r8d
movl (%rax,%r8,4), %eax
addl %r13d, %eax
jmp 0x2f6b3a
cmpl %r10d, %r15d
jle 0x2f6b47
movq 0x10(%rbx), %rax
movzbl (%r14,%r10), %r8d
movl (%rax,%r8,4), %eax
addl 0xc(%rsp), %eax
movq 0x8(%rbx), %r8
cltq
movzwl (%r8,%rax,4), %eax
jmp 0x2f6b49
xorl %eax, %eax
movw %ax, 0x60(%rsp,%rcx,2)
cmpl %r10d, %r15d
jle 0x2f6b6c
movq 0x10(%rbx), %r8
movzbl (%r14,%r10), %edi
movl (%r8,%rdi,4), %edi
xorl %r8d, %r8d
cmpq %rdi, %rsi
sete %r8b
jmp 0x2f6b6f
xorl %r8d, %r8d
movw %r8w, 0x50(%rsp,%rcx,2)
xorl %edi, %edi
testw %ax, %ax
setg %dil
movw %di, 0x40(%rsp,%rcx,2)
addq %rdx, %r10
incq %rcx
addl %r12d, %r13d
cmpq $0x8, %rcx
jne 0x2f6b04
movq 0x38(%rsp), %rdi
movq %rdi, %rax
shlq $0x4, %rax
movaps 0x60(%rsp), %xmm0
movq 0x20(%rsp), %rcx
movaps %xmm0, (%rcx,%rax)
movaps 0x50(%rsp), %xmm0
movq 0x18(%rsp), %rcx
movaps %xmm0, (%rcx,%rax)
movaps 0x40(%rsp), %xmm0
movq 0x10(%rsp), %rcx
movaps %xmm0, (%rcx,%rax)
incq %rdi
incq %rbp
addl (%rsp), %r9d
cmpq 0x30(%rsp), %rbp
jne 0x2f6af3
incq %rsi
cmpq (%rsp), %rsi
jne 0x2f6ad8
movq 0x28(%rsp), %rax
movq 0x20(%rsp), %rcx
movq %rcx, 0x30(%rax)
movq 0x18(%rsp), %rcx
movq %rcx, 0x38(%rax)
movq 0x10(%rsp), %rcx
movq %rcx, 0x40(%rax)
leaq -0xa3b(%rip), %rcx      # 0x2f61da
movq %rcx, 0x78(%rax)
jmp 0x2f6c29
callq 0x1aae37
jmp 0x2f6c27
callq 0x1aae11
xorl %eax, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq