// File: /workspace/github_c_makefile_star2_O3/nh13[P]ksw/src/parasail/src/memory_sse.c
// Function: parasail_profile_create_stats_sse_128_64
parasail_profile_t * parasail_profile_create_stats_sse_128_64(
        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 = 2; /* 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_64_t p;
            __m128i_64_t m;
            __m128i_64_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->profile64.score = vProfile;
    profile->profile64.matches = vProfileM;
    profile->profile64.similar = vProfileS;
    profile->free = &parasail_free___m128i;
    return profile;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
testq %rdx, %rdx
je 0x2f7112
movq %rdi, %r14
testq %rdi, %rdi
je 0x2f7119
movq %rdx, %rbx
movl %esi, %r15d
cmpl $0x0, 0x30(%rdx)
je 0x2f6eb5
movl 0x34(%rbx), %r15d
movl 0x18(%rbx), %ecx
leal 0x1(%r15), %eax
shrl $0x1f, %eax
addl %r15d, %eax
incl %eax
sarl %eax
movl %eax, %r12d
movq %rcx, (%rsp)
imull %ecx, %eax
movslq %eax, %rbp
shlq $0x4, %rbp
movl $0x10, %edi
movq %rbp, %rsi
callq 0x20a5b8
movq %rax, 0x28(%rsp)
testq %rax, %rax
je 0x2f711e
movl $0x10, %edi
movq %rbp, %rsi
callq 0x20a5b8
movq %rax, 0x20(%rsp)
testq %rax, %rax
je 0x2f711e
movl $0x10, %edi
movq %rbp, %rsi
callq 0x20a5b8
movq %rax, 0x18(%rsp)
testq %rax, %rax
je 0x2f711e
movq %r14, %rdi
movl %r15d, %esi
movq %rbx, %rdx
callq 0x20bbb5
testq %rax, %rax
je 0x2f711e
movq %rax, 0x30(%rsp)
cmpl $0x0, (%rsp)
jle 0x2f70e5
movl %r12d, %eax
movq %rax, 0x58(%rsp)
cmpl $0x2, %r12d
movl $0x1, %eax
cmovgel %r12d, %eax
movq %rax, 0x40(%rsp)
imull (%rsp), %r12d
movl %r12d, 0x14(%rsp)
movq $0x0, 0x8(%rsp)
xorl %edx, %edx
movq %r14, 0x38(%rsp)
testl %r15d, %r15d
jle 0x2f70ce
movslq %edx, %rdx
movq 0x8(%rsp), %rax
imull (%rsp), %eax
movl %eax, 0x10(%rsp)
xorl %eax, %eax
movq %r14, %r12
xorl %r13d, %r13d
movq %rdx, 0x50(%rsp)
movl 0x30(%rbx), %ebp
movb $0x1, %r8b
xorl %r11d, %r11d
movq %rax, 0x48(%rsp)
leaq 0x60(%rsp), %rcx
leaq 0x70(%rsp), %rdx
leaq 0x80(%rsp), %rsi
leaq (%r11,%r13), %r10
testl %ebp, %ebp
je 0x2f6ff0
cmpl %r10d, %r15d
jle 0x2f7014
movq 0x10(%rbx), %r9
movq 0x38(%rbx), %r14
movq 0x8(%rsp), %rdi
movzbl (%r14,%rdi), %r14d
movl (%r9,%r14,4), %r14d
addl %eax, %r14d
jmp 0x2f7007
cmpl %r10d, %r15d
jle 0x2f7014
movq 0x10(%rbx), %r14
movzbl (%r12,%r11), %r9d
movl (%r14,%r9,4), %r14d
addl 0x10(%rsp), %r14d
movq 0x8(%rbx), %r9
movslq %r14d, %r14
movslq (%r9,%r14,4), %r14
jmp 0x2f7017
xorl %r14d, %r14d
movq %r14, (%rsi)
cmpl %r10d, %r15d
jle 0x2f7039
movq 0x10(%rbx), %rsi
movzbl (%r12,%r11), %r9d
movl (%rsi,%r9,4), %r9d
xorl %esi, %esi
cmpq %r9, 0x8(%rsp)
sete %sil
jmp 0x2f703b
xorl %esi, %esi
movq %rsi, (%rdx)
xorl %edx, %edx
testq %r14, %r14
setg %dl
movq %rdx, (%rcx)
addl 0x14(%rsp), %eax
addq 0x58(%rsp), %r11
leaq 0x68(%rsp), %rcx
leaq 0x78(%rsp), %rdx
leaq 0x88(%rsp), %rsi
testb $0x1, %r8b
movl $0x0, %r8d
jne 0x2f6fc8
movq 0x50(%rsp), %rdx
movq %rdx, %rax
shlq $0x4, %rax
movaps 0x80(%rsp), %xmm0
movq 0x28(%rsp), %rcx
movaps %xmm0, (%rcx,%rax)
movaps 0x70(%rsp), %xmm0
movq 0x20(%rsp), %rcx
movaps %xmm0, (%rcx,%rax)
movaps 0x60(%rsp), %xmm0
movq 0x18(%rsp), %rcx
movaps %xmm0, (%rcx,%rax)
incq %rdx
incq %r13
movq 0x48(%rsp), %rax
addl (%rsp), %eax
incq %r12
cmpq 0x40(%rsp), %r13
jne 0x2f6fa3
movq 0x38(%rsp), %r14
movq 0x8(%rsp), %rcx
incq %rcx
movq %rcx, 0x8(%rsp)
cmpq (%rsp), %rcx
jne 0x2f6f82
movq 0x30(%rsp), %rax
movq 0x28(%rsp), %rcx
movq %rcx, 0x60(%rax)
movq 0x20(%rsp), %rcx
movq %rcx, 0x68(%rax)
movq 0x18(%rsp), %rcx
movq %rcx, 0x70(%rax)
leaq -0xf32(%rip), %rcx      # 0x2f61da
movq %rcx, 0x78(%rax)
jmp 0x2f7120
callq 0x1aaecf
jmp 0x2f711e
callq 0x1aaea9
xorl %eax, %eax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq