// File: /workspace/github_c_makefile_star2_O1/nh13[P]ksw/src/parasail/src/memory_avx2.c
// Function: parasail_profile_create_stats_avx_256_8
parasail_profile_t * parasail_profile_create_stats_avx_256_8(
        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 = 32; /* 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_8_t p;
            __m256i_8_t m;
            __m256i_8_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->profile8.score = vProfile;
    profile->profile8.matches = vProfileM;
    profile->profile8.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 $0xc0, %rsp
testq %rdx, %rdx
je 0x4c678b
movq %rdi, %r14
testq %rdi, %rdi
je 0x4c6792
movq %rdx, %rbx
movl %esi, %r15d
cmpl $0x0, 0x30(%rdx)
je 0x4c65a5
movl 0x34(%rbx), %r15d
movl 0x18(%rbx), %r13d
leal 0x1f(%r15), %eax
leal 0x3e(%r15), %ecx
testl %eax, %eax
cmovnsl %eax, %ecx
sarl $0x5, %ecx
movl %ecx, 0x10(%rsp)
movl %ecx, %eax
imull %r13d, %eax
movslq %eax, %r12
shlq $0x5, %r12
movl $0x20, %edi
movq %r12, %rsi
callq 0x20947c
movq %rax, 0x28(%rsp)
testq %rax, %rax
je 0x4c6797
movl $0x20, %edi
movq %r12, %rsi
callq 0x20947c
movq %rax, 0x20(%rsp)
testq %rax, %rax
je 0x4c6797
movl $0x20, %edi
movq %r12, %rsi
callq 0x20947c
movq %rax, 0x18(%rsp)
testq %rax, %rax
je 0x4c6797
movq %r14, %rdi
movl %r15d, %esi
movq %rbx, %rdx
callq 0x20a588
testq %rax, %rax
je 0x4c6797
movq %rax, 0x30(%rsp)
testl %r13d, %r13d
jle 0x4c675e
movl 0x10(%rsp), %edx
movl %edx, %ecx
cmpl $0x2, %edx
movl $0x1, %eax
cmovgel %edx, %eax
movq %rax, 0x38(%rsp)
xorl %edx, %edx
xorl %edi, %edi
testl %r15d, %r15d
jle 0x4c6752
movslq %edi, %rdi
xorl %r8d, %r8d
movq %rdi, 0x10(%rsp)
movl 0x30(%rbx), %r9d
movq %r8, %r10
xorl %r11d, %r11d
testl %r9d, %r9d
je 0x4c668e
cmpl %r10d, %r15d
jle 0x4c66bb
movq 0x38(%rbx), %r12
addq %rdx, %r12
movq %r10, %rsi
jmp 0x4c669a
cmpl %r10d, %r15d
jle 0x4c66bb
leaq (%r14,%r10), %r12
movq %rdx, %rsi
movq 0x8(%rbx), %rax
movq 0x10(%rbx), %rdi
movzbl (%r12), %r12d
movslq (%rdi,%r12,4), %rdi
imull %r13d, %esi
movslq %esi, %rsi
addq %rdi, %rsi
movb (%rax,%rsi,4), %sil
jmp 0x4c66bd
xorl %esi, %esi
movb %sil, 0x40(%rsp,%r11)
cmpl %r10d, %r15d
jle 0x4c66dc
movq 0x10(%rbx), %rax
movzbl (%r14,%r10), %esi
movl (%rax,%rsi,4), %eax
cmpq %rax, %rdx
sete %sil
jmp 0x4c66de
xorl %esi, %esi
cmpb $0x0, 0x40(%rsp,%r11)
setg 0x60(%rsp,%r11)
movb %sil, 0x80(%rsp,%r11)
addq %rcx, %r10
incq %r11
cmpq $0x20, %r11
jne 0x4c6678
movq 0x10(%rsp), %rdi
movq %rdi, %rax
shlq $0x5, %rax
vmovaps 0x40(%rsp), %ymm0
movq 0x28(%rsp), %rsi
vmovaps %ymm0, (%rsi,%rax)
vmovaps 0x80(%rsp), %ymm0
movq 0x20(%rsp), %rsi
vmovaps %ymm0, (%rsi,%rax)
vmovaps 0x60(%rsp), %ymm0
movq 0x18(%rsp), %rsi
vmovaps %ymm0, (%rsi,%rax)
incq %rdi
incq %r8
cmpq 0x38(%rsp), %r8
jne 0x4c6669
incq %rdx
cmpq %r13, %rdx
jne 0x4c665a
movq 0x30(%rsp), %rax
movq 0x28(%rsp), %rcx
movq %rcx, 0x18(%rax)
movq 0x20(%rsp), %rcx
movq %rcx, 0x20(%rax)
movq 0x18(%rsp), %rcx
movq %rcx, 0x28(%rax)
leaq -0x787(%rip), %rcx      # 0x4c5ffe
movq %rcx, 0x78(%rax)
jmp 0x4c6799
callq 0x1e652f
jmp 0x4c6797
callq 0x1e6509
xorl %eax, %eax
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
vzeroupper
retq