// File: /workspace/github_c_makefile_star2_O3/nh13[P]ksw/src/parasail/src/memory_avx2.c
// Function: parasail_profile_create_stats_avx_256_64
parasail_profile_t * parasail_profile_create_stats_avx_256_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 = 4; /* number of values in vector unit */
    int32_t segLen = 0;
    __m256i* restrict vProfile = NULL;
    __m256i* restrict vProfileM = NULL;
    __m256i* 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___m256i(32, n * segLen);
    if (!vProfile) return NULL;
    vProfileM = parasail_memalign___m256i(32, n * segLen);
    if (!vProfileM) return NULL;
    vProfileS = parasail_memalign___m256i(32, 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) {
            __m256i_64_t p;
            __m256i_64_t m;
            __m256i_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;
            }
            _mm256_store_si256(&vProfile[index], p.m);
            _mm256_store_si256(&vProfileM[index], m.m);
            _mm256_store_si256(&vProfileS[index], s.m);
            ++index;
        }
    }

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

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
andq $-0x20, %rsp
subq $0xe0, %rsp
testq %rdx, %rdx
je 0x4f2abf
movq %rdi, %r14
testq %rdi, %rdi
je 0x4f2ac6
movq %rdx, %rbx
movl %esi, %r15d
cmpl $0x0, 0x30(%rdx)
je 0x4f28a1
movl 0x34(%rbx), %r15d
movl 0x18(%rbx), %ecx
leal 0x3(%r15), %eax
leal 0x6(%r15), %r13d
testl %eax, %eax
cmovnsl %eax, %r13d
sarl $0x2, %r13d
movl %r13d, %eax
movq %rcx, 0x18(%rsp)
imull %ecx, %eax
movslq %eax, %r12
shlq $0x5, %r12
movl $0x20, %edi
movq %r12, %rsi
callq 0x20a5b8
movq %rax, 0x38(%rsp)
testq %rax, %rax
je 0x4f2acb
movl $0x20, %edi
movq %r12, %rsi
callq 0x20a5b8
movq %rax, 0x30(%rsp)
testq %rax, %rax
je 0x4f2acb
movl $0x20, %edi
movq %r12, %rsi
callq 0x20a5b8
movq %rax, 0x28(%rsp)
testq %rax, %rax
je 0x4f2acb
movq %r14, %rdi
movl %r15d, %esi
movq %rbx, %rdx
callq 0x20bbb5
testq %rax, %rax
je 0x4f2acb
movq %rax, 0x40(%rsp)
cmpl $0x0, 0x18(%rsp)
jle 0x4f2a92
cmpl $0x2, %r13d
movl $0x1, %eax
cmovgel %r13d, %eax
movq %rax, 0x48(%rsp)
movl %r13d, %edx
imull 0x18(%rsp), %r13d
xorl %esi, %esi
xorl %r8d, %r8d
testl %r15d, %r15d
jle 0x4f2a84
movslq %r8d, %r8
movl %esi, %eax
imull 0x18(%rsp), %eax
movl %eax, 0x24(%rsp)
xorl %eax, %eax
xorl %ecx, %ecx
movq %r8, 0x58(%rsp)
movl 0x30(%rbx), %r11d
movq %rax, 0x50(%rsp)
movl %eax, %r12d
movq %rcx, %r10
xorl %eax, %eax
testl %r11d, %r11d
je 0x4f29b1
cmpl %r10d, %r15d
jle 0x4f29d5
movq 0x10(%rbx), %rdi
movq 0x38(%rbx), %r8
movzbl (%r8,%rsi), %r8d
movl (%rdi,%r8,4), %r8d
addl %r12d, %r8d
jmp 0x4f29c8
cmpl %r10d, %r15d
jle 0x4f29d5
movq 0x10(%rbx), %rdi
movzbl (%r14,%r10), %r8d
movl (%rdi,%r8,4), %r8d
addl 0x24(%rsp), %r8d
movq 0x8(%rbx), %rdi
movslq %r8d, %r8
movslq (%rdi,%r8,4), %r8
jmp 0x4f29d8
xorl %r8d, %r8d
movq %r8, 0xa0(%rsp,%rax,8)
cmpl %r10d, %r15d
jle 0x4f29fd
movq 0x10(%rbx), %rdi
movzbl (%r14,%r10), %r9d
movl (%rdi,%r9,4), %r9d
xorl %edi, %edi
cmpq %r9, %rsi
sete %dil
jmp 0x4f29ff
xorl %edi, %edi
movq %rdi, 0x80(%rsp,%rax,8)
xorl %edi, %edi
testq %r8, %r8
setg %dil
movq %rdi, 0x60(%rsp,%rax,8)
addq %rdx, %r10
incq %rax
addl %r13d, %r12d
cmpq $0x4, %rax
jne 0x4f2991
movq 0x58(%rsp), %r8
movq %r8, %rax
shlq $0x5, %rax
vmovaps 0xa0(%rsp), %ymm0
movq 0x38(%rsp), %rdi
vmovaps %ymm0, (%rdi,%rax)
vmovaps 0x80(%rsp), %ymm0
movq 0x30(%rsp), %rdi
vmovaps %ymm0, (%rdi,%rax)
vmovaps 0x60(%rsp), %ymm0
movq 0x28(%rsp), %rdi
vmovaps %ymm0, (%rdi,%rax)
incq %r8
incq %rcx
movq 0x50(%rsp), %rax
addl 0x18(%rsp), %eax
cmpq 0x48(%rsp), %rcx
jne 0x4f297b
incq %rsi
cmpq 0x18(%rsp), %rsi
jne 0x4f2960
movq 0x40(%rsp), %rax
movq 0x38(%rsp), %rcx
movq %rcx, 0x60(%rax)
movq 0x30(%rsp), %rcx
movq %rcx, 0x68(%rax)
movq 0x28(%rsp), %rcx
movq %rcx, 0x70(%rax)
leaq -0xfc0(%rip), %rcx      # 0x4f1af9
movq %rcx, 0x78(%rax)
jmp 0x4f2acd
callq 0x1e6607
jmp 0x4f2acb
callq 0x1e65e1
xorl %eax, %eax
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
vzeroupper
retq