// File: /workspace/github_c_makefile_star2_O3/nh13[P]ksw/src/parasail/src/nw_scan_avx2_256_16.c
// Function: parasail_nw_table_scan_profile_avx2_256_16
parasail_result_t* PNAME(
        const parasail_profile_t * const restrict profile,
        const char * const restrict s2, const int s2Len,
        const int open, const int gap)
{
    /* declare local variables */
    int32_t i = 0;
    int32_t j = 0;
    int32_t k = 0;
    int32_t s1Len = 0;
    int32_t end_query = 0;
    int32_t end_ref = 0;
    const parasail_matrix_t *matrix = NULL;
    int32_t segWidth = 0;
    int32_t segLen = 0;
    int32_t offset = 0;
    int32_t position = 0;
    __m256i* restrict pvP = NULL;
    __m256i* restrict pvE = NULL;
    int16_t* restrict boundary = NULL;
    __m256i* restrict pvHt = NULL;
    __m256i* restrict pvH = NULL;
    __m256i* restrict pvGapper = NULL;
    __m256i vGapO;
    __m256i vGapE;
    int16_t NEG_LIMIT = 0;
    int16_t POS_LIMIT = 0;
    __m256i vZero;
    int16_t score = 0;
    __m256i vNegLimit;
    __m256i vPosLimit;
    __m256i vSaturationCheckMin;
    __m256i vSaturationCheckMax;
    __m256i vNegInfFront;
    __m256i vSegLenXgap;
    parasail_result_t *result = NULL;

    /* validate inputs */
    PARASAIL_CHECK_NULL(profile);
    PARASAIL_CHECK_NULL(profile->profile16.score);
    PARASAIL_CHECK_NULL(profile->matrix);
    PARASAIL_CHECK_GT0(profile->s1Len);
    PARASAIL_CHECK_NULL(s2);
    PARASAIL_CHECK_GT0(s2Len);
    PARASAIL_CHECK_GE0(open);
    PARASAIL_CHECK_GE0(gap);

    /* initialize stack variables */
    i = 0;
    j = 0;
    k = 0;
    s1Len = profile->s1Len;
    end_query = s1Len-1;
    end_ref = s2Len-1;
    matrix = profile->matrix;
    segWidth = 16; /* number of values in vector unit */
    segLen = (s1Len + segWidth - 1) / segWidth;
    offset = (s1Len - 1) % segLen;
    position = (segWidth - 1) - (s1Len - 1) / segLen;
    pvP = (__m256i*)profile->profile16.score;
    vGapO = _mm256_set1_epi16(open);
    vGapE = _mm256_set1_epi16(gap);
    NEG_LIMIT = (-open < matrix->min ? INT16_MIN + open : INT16_MIN - matrix->min) + 1;
    POS_LIMIT = INT16_MAX - matrix->max - 1;
    vZero = _mm256_setzero_si256();
    score = NEG_LIMIT;
    vNegLimit = _mm256_set1_epi16(NEG_LIMIT);
    vPosLimit = _mm256_set1_epi16(POS_LIMIT);
    vSaturationCheckMin = vPosLimit;
    vSaturationCheckMax = vNegLimit;
    vNegInfFront = vZero;
    vNegInfFront = _mm256_insert_epi16_rpl(vNegInfFront, NEG_LIMIT, 0);
    vSegLenXgap = _mm256_adds_epi16(vNegInfFront,
            _mm256_slli_si256_rpl(_mm256_set1_epi16(-segLen*gap), 2));

    /* initialize result */
#ifdef PARASAIL_TABLE
    result = parasail_result_new_table1(segLen*segWidth, s2Len);
#else
#ifdef PARASAIL_ROWCOL
    result = parasail_result_new_rowcol1(segLen*segWidth, s2Len);
#else
    result = parasail_result_new();
#endif
#endif
    if (!result) return NULL;

    /* set known flags */
    result->flag |= PARASAIL_FLAG_NW | PARASAIL_FLAG_SCAN
        | PARASAIL_FLAG_BITS_16 | PARASAIL_FLAG_LANES_16;
#ifdef PARASAIL_TABLE
    result->flag |= PARASAIL_FLAG_TABLE;
#endif
#ifdef PARASAIL_ROWCOL
    result->flag |= PARASAIL_FLAG_ROWCOL;
#endif

    /* initialize heap variables */
    pvE = parasail_memalign___m256i(32, segLen);
    boundary = parasail_memalign_int16_t(32, s2Len+1);
    pvHt= parasail_memalign___m256i(32, segLen);
    pvH = parasail_memalign___m256i(32, segLen);
    pvGapper = parasail_memalign___m256i(32, segLen);

    /* validate heap variables */
    if (!pvE) return NULL;
    if (!boundary) return NULL;
    if (!pvHt) return NULL;
    if (!pvH) return NULL;
    if (!pvGapper) return NULL;

    /* initialize H and E */
    {
        int32_t index = 0;
        for (i=0; i<segLen; ++i) {
            int32_t segNum = 0;
            __m256i_16_t h;
            __m256i_16_t e;
            for (segNum=0; segNum<segWidth; ++segNum) {
                int64_t tmp = -open-gap*(segNum*segLen+i);
                h.v[segNum] = tmp < INT16_MIN ? INT16_MIN : tmp;
                tmp = tmp - open;
                e.v[segNum] = tmp < INT16_MIN ? INT16_MIN : tmp;
            }
            _mm256_store_si256(&pvH[index], h.m);
            _mm256_store_si256(&pvE[index], e.m);
            ++index;
        }
    }

    /* initialize uppder boundary */
    {
        boundary[0] = 0;
        for (i=1; i<=s2Len; ++i) {
            int64_t tmp = -open-gap*(i-1);
            boundary[i] = tmp < INT16_MIN ? INT16_MIN : tmp;
        }
    }

    {
        __m256i vGapper = _mm256_subs_epi16(vZero,vGapO);
        for (i=segLen-1; i>=0; --i) {
            _mm256_store_si256(pvGapper+i, vGapper);
            vGapper = _mm256_subs_epi16(vGapper, vGapE);
        }
    }

    /* outer loop over database sequence */
    for (j=0; j<s2Len; ++j) {
        __m256i vE;
        __m256i vHt;
        __m256i vF;
        __m256i vH;
        __m256i vHp;
        __m256i *pvW;
        __m256i vW;

        /* calculate E */
        /* calculate Ht */
        /* calculate F and H first pass */
        vHp = _mm256_load_si256(pvH+(segLen-1));
        vHp = _mm256_slli_si256_rpl(vHp, 2);
        vHp = _mm256_insert_epi16_rpl(vHp, boundary[j], 0);
        pvW = pvP + matrix->mapper[(unsigned char)s2[j]]*segLen;
        vHt = _mm256_subs_epi16(vNegLimit, pvGapper[0]);
        vF = vNegLimit;
        for (i=0; i<segLen; ++i) {
            vH = _mm256_load_si256(pvH+i);
            vE = _mm256_load_si256(pvE+i);
            vW = _mm256_load_si256(pvW+i);
            vE = _mm256_max_epi16(
                    _mm256_subs_epi16(vE, vGapE),
                    _mm256_subs_epi16(vH, vGapO));
            vHp = _mm256_adds_epi16(vHp, vW);
            vF = _mm256_max_epi16(vF, _mm256_adds_epi16(vHt, pvGapper[i]));
            vHt = _mm256_max_epi16(vE, vHp);
            _mm256_store_si256(pvE+i, vE);
            _mm256_store_si256(pvHt+i, vHt);
            vHp = vH;
        }

        /* pseudo prefix scan on F and H */
        vHt = _mm256_slli_si256_rpl(vHt, 2);
        vHt = _mm256_insert_epi16_rpl(vHt, boundary[j+1], 0);
        vF = _mm256_max_epi16(vF, _mm256_adds_epi16(vHt, pvGapper[0]));
        for (i=0; i<segWidth-2; ++i) {
            __m256i vFt = _mm256_slli_si256_rpl(vF, 2);
            vFt = _mm256_adds_epi16(vFt, vSegLenXgap);
            vF = _mm256_max_epi16(vF, vFt);
        }

        /* calculate final H */
        vF = _mm256_slli_si256_rpl(vF, 2);
        vF = _mm256_adds_epi16(vF, vNegInfFront);
        vH = _mm256_max_epi16(vHt, vF);
        for (i=0; i<segLen; ++i) {
            vHt = _mm256_load_si256(pvHt+i);
            vF = _mm256_max_epi16(
                    _mm256_subs_epi16(vF, vGapE),
                    _mm256_subs_epi16(vH, vGapO));
            vH = _mm256_max_epi16(vHt, vF);
            _mm256_store_si256(pvH+i, vH);
            vSaturationCheckMin = _mm256_min_epi16(vSaturationCheckMin, vH);
            vSaturationCheckMax = _mm256_max_epi16(vSaturationCheckMax, vH);
#ifdef PARASAIL_TABLE
            arr_store_si256(result->tables->score_table, vH, i, segLen, j, s2Len);
#endif
        } 


#ifdef PARASAIL_ROWCOL
        /* extract last value from the column */
        {
            vH = _mm256_load_si256(pvH + offset);
            for (k=0; k<position; ++k) {
                vH = _mm256_slli_si256_rpl(vH, 2);
            }
            result->rowcols->score_row[j] = (int16_t) _mm256_extract_epi16_rpl (vH, 15);
        }
#endif
    }

#ifdef PARASAIL_ROWCOL
    for (i=0; i<segLen; ++i) {
        __m256i vH = _mm256_load_si256(pvH+i);
        arr_store_col(result->rowcols->score_col, vH, i, segLen);
    }
#endif

    /* extract last value from the last column */
    {
        __m256i vH = _mm256_load_si256(pvH + offset);
        for (k=0; k<position; ++k) {
            vH = _mm256_slli_si256_rpl(vH, 2);
        }
        score = (int16_t) _mm256_extract_epi16_rpl (vH, 15);
    }

    if (_mm256_movemask_epi8(_mm256_or_si256(
            _mm256_cmplt_epi16_rpl(vSaturationCheckMin, vNegLimit),
            _mm256_cmpgt_epi16(vSaturationCheckMax, vPosLimit)))) {
        result->flag |= PARASAIL_FLAG_SATURATED;
        score = 0;
        end_query = 0;
        end_ref = 0;
    }

    result->score = score;
    result->end_query = end_query;
    result->end_ref = end_ref;

    parasail_free(pvGapper);
    parasail_free(pvH);
    parasail_free(pvHt);
    parasail_free(boundary);
    parasail_free(pvE);

    return result;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1f8, %rsp            # imm = 0x1F8
movq %rsi, 0x60(%rsp)
testq %rdi, %rdi
je 0x4f7226
movq 0x30(%rdi), %rax
movq %rax, 0x108(%rsp)
testq %rax, %rax
je 0x4f722d
movq 0x10(%rdi), %rax
movq %rax, 0x58(%rsp)
testq %rax, %rax
je 0x4f7234
movl 0x8(%rdi), %edi
testl %edi, %edi
jle 0x4f723b
cmpq $0x0, 0x60(%rsp)
je 0x4f7242
movl %edx, %r13d
testl %edx, %edx
jle 0x4f7249
testl %ecx, %ecx
js 0x4f7250
testl %r8d, %r8d
js 0x4f7257
movl %r8d, 0x150(%rsp)
leal -0x1(%rdi), %eax
addq $0xf, %rdi
movq %rdi, %rbp
shrq $0x4, %rbp
movl %eax, 0xc(%rsp)
xorl %edx, %edx
divl %ebp
movl %eax, %r15d
movl %edx, %r12d
movl %ecx, %edx
negl %edx
movq 0x58(%rsp), %rsi
movl 0x20(%rsi), %eax
movl %eax, %ebx
negl %ebx
movl %edx, 0x130(%rsp)
cmpl %edx, %eax
movl %ecx, 0x70(%rsp)
cmovgl %ecx, %ebx
movw $0x7ffe, %ax            # imm = 0x7FFE
subw 0x1c(%rsi), %ax
movl %eax, 0x90(%rsp)
andl $0x7ffffff0, %edi       # imm = 0x7FFFFFF0
movl %r13d, %esi
callq 0x20abc2
testq %rax, %rax
je 0x4f725c
movq %rax, %r14
movl %r12d, 0x4c(%rsp)
movl %r15d, 0x8(%rsp)
orl $0x10220401, 0xc(%rax)  # imm = 0x10220401
movl $0x20, %edi
movq %rbp, %rsi
callq 0x4f1904
movq %rax, 0x18(%rsp)
leal 0x1(%r13), %esi
movl $0x20, %edi
callq 0x20a625
movq %r13, 0x30(%rsp)
movq %rax, %r13
movl $0x20, %edi
movq %rbp, %rsi
callq 0x4f1904
movq %rax, %r15
movl $0x20, %edi
movq %rbp, %rsi
callq 0x4f1904
movq %rax, %r12
movl $0x20, %edi
movq %rbp, %rsi
callq 0x4f1904
movq 0x18(%rsp), %rsi
movq %rax, %r9
testq %rsi, %rsi
sete %al
testq %r13, %r13
sete %cl
orb %al, %cl
testq %r15, %r15
sete %al
testq %r12, %r12
sete %dl
orb %al, %dl
orb %cl, %dl
testq %r9, %r9
sete %al
orb %dl, %al
jne 0x4f725c
movq %r13, %r8
movq %r15, 0x38(%rsp)
movq 0x30(%rsp), %rax
movq %rax, %r15
decl %eax
movl %eax, 0x48(%rsp)
movl $0xf, %eax
subl 0x8(%rsp), %eax
movl %eax, 0x44(%rsp)
movl 0x70(%rsp), %ecx
vmovd %ecx, %xmm0
vpbroadcastw %xmm0, %ymm2
movl 0x150(%rsp), %r10d
vmovd %r10d, %xmm0
vpbroadcastw %xmm0, %ymm3
addl $0xffff8001, %ebx       # imm = 0xFFFF8001
vmovd %ebx, %xmm0
vpbroadcastw %xmm0, %ymm0
vmovdqu %ymm0, 0x1d0(%rsp)
vmovd 0x90(%rsp), %xmm0
vpbroadcastw %xmm0, %ymm0
vmovdqu %ymm0, 0x1b0(%rsp)
movzwl %bx, %eax
vmovd %eax, %xmm1
movl %ebp, %eax
imull %r10d, %eax
negl %eax
vmovd %eax, %xmm0
vpbroadcastw %xmm0, %ymm0
vpand 0x13774d(%rip), %ymm0, %ymm0 # 0x62ddc0
vmovdqu %ymm1, 0x190(%rsp)
vpaddsw %ymm0, %ymm1, %ymm5
movl %ecx, %eax
movl %ebp, %edi
movl %r10d, %ecx
movl 0x130(%rsp), %r11d
movslq %r11d, %rdx
vmovq %rcx, %xmm0
vpbroadcastq %xmm0, %ymm0
vmovq %rdx, %xmm1
vpbroadcastq %xmm1, %ymm1
vmovq %rax, %xmm9
movq %rdi, 0x100(%rsp)
vmovq %rdi, %xmm4
vpbroadcastq %xmm4, %ymm8
vpmuldq 0x13771a(%rip), %ymm8, %ymm4 # 0x62dde0
vmovdqu %ymm4, 0x70(%rsp)
vpmuldq 0x13772b(%rip), %ymm8, %ymm4 # 0x62de00
vmovdqu %ymm4, 0x90(%rsp)
vpmuldq 0x137559(%rip), %ymm8, %ymm4 # 0x62dc40
vmovdqu %ymm4, 0x170(%rsp)
vpmuldq 0x137447(%rip), %ymm8, %ymm8 # 0x62db40
vpbroadcastq %xmm9, %ymm9
xorl %eax, %eax
vpbroadcastq 0x137737(%rip), %ymm10 # 0x62de40
vpxor %xmm11, %xmm11, %xmm11
movq %r12, %rcx
movq %rsi, %rdx
movq %rbp, %r13
vmovq %rax, %xmm12
vpbroadcastq %xmm12, %ymm12
vpaddq 0x170(%rsp), %ymm12, %ymm13
vpaddq %ymm12, %ymm8, %ymm14
vpaddq 0x90(%rsp), %ymm12, %ymm15
vpaddq 0x70(%rsp), %ymm12, %ymm12
vpmuludq %ymm0, %ymm12, %ymm4
vpsrlq $0x20, %ymm12, %ymm12
vpmuludq %ymm0, %ymm12, %ymm12
vpsllq $0x20, %ymm12, %ymm12
vpaddq %ymm4, %ymm12, %ymm4
vpmuludq %ymm0, %ymm15, %ymm12
vpsrlq $0x20, %ymm15, %ymm15
vpmuludq %ymm0, %ymm15, %ymm15
vpsllq $0x20, %ymm15, %ymm15
vpaddq %ymm15, %ymm12, %ymm12
vpmuludq %ymm0, %ymm14, %ymm15
vpsrlq $0x20, %ymm14, %ymm14
vpmuludq %ymm0, %ymm14, %ymm14
vpsllq $0x20, %ymm14, %ymm14
vpaddq %ymm14, %ymm15, %ymm14
vpmuludq %ymm0, %ymm13, %ymm15
vpsrlq $0x20, %ymm13, %ymm13
vpmuludq %ymm0, %ymm13, %ymm13
vpsllq $0x20, %ymm13, %ymm13
vpaddq %ymm13, %ymm15, %ymm13
vpsubq %ymm4, %ymm1, %ymm4
vpcmpgtq %ymm10, %ymm4, %ymm15
vblendvpd %ymm15, %ymm4, %ymm10, %ymm15
vpsubq %ymm14, %ymm1, %ymm14
vpcmpgtq %ymm10, %ymm14, %ymm6
vblendvpd %ymm6, %ymm14, %ymm10, %ymm6
vpsubq %ymm13, %ymm1, %ymm13
vpcmpgtq %ymm10, %ymm13, %ymm7
vblendvpd %ymm7, %ymm13, %ymm10, %ymm7
vpsubq %ymm12, %ymm1, %ymm12
vpblendw $0x11, %ymm7, %ymm11, %ymm7 # ymm7 = ymm7[0],ymm11[1,2,3],ymm7[4],ymm11[5,6,7],ymm7[8],ymm11[9,10,11],ymm7[12],ymm11[13,14,15]
vpblendw $0x11, %ymm6, %ymm11, %ymm6 # ymm6 = ymm6[0],ymm11[1,2,3],ymm6[4],ymm11[5,6,7],ymm6[8],ymm11[9,10,11],ymm6[12],ymm11[13,14,15]
vpackusdw %ymm7, %ymm6, %ymm6
vpcmpgtq %ymm10, %ymm12, %ymm7
vblendvpd %ymm7, %ymm12, %ymm10, %ymm7
vpblendw $0x11, %ymm7, %ymm11, %ymm7 # ymm7 = ymm7[0],ymm11[1,2,3],ymm7[4],ymm11[5,6,7],ymm7[8],ymm11[9,10,11],ymm7[12],ymm11[13,14,15]
vpblendw $0x11, %ymm15, %ymm11, %ymm15 # ymm15 = ymm15[0],ymm11[1,2,3],ymm15[4],ymm11[5,6,7],ymm15[8],ymm11[9,10,11],ymm15[12],ymm11[13,14,15]
vpackusdw %ymm15, %ymm7, %ymm7
vpsubq %ymm9, %ymm13, %ymm13
vpsubq %ymm9, %ymm14, %ymm14
vpsubq %ymm9, %ymm4, %ymm4
vpcmpgtq %ymm10, %ymm4, %ymm15
vblendvpd %ymm15, %ymm4, %ymm10, %ymm4
vpsubq %ymm9, %ymm12, %ymm12
vpcmpgtq %ymm10, %ymm12, %ymm15
vblendvpd %ymm15, %ymm12, %ymm10, %ymm12
vpcmpgtq %ymm10, %ymm14, %ymm15
vblendvpd %ymm15, %ymm14, %ymm10, %ymm14
vpcmpgtq %ymm10, %ymm13, %ymm15
vblendvpd %ymm15, %ymm13, %ymm10, %ymm13
vpermq $0xd8, %ymm6, %ymm6     # ymm6 = ymm6[0,2,1,3]
vpermq $0xd8, %ymm7, %ymm7     # ymm7 = ymm7[0,2,1,3]
vpackusdw %ymm7, %ymm6, %ymm6
vpblendw $0x11, %ymm13, %ymm11, %ymm7 # ymm7 = ymm13[0],ymm11[1,2,3],ymm13[4],ymm11[5,6,7],ymm13[8],ymm11[9,10,11],ymm13[12],ymm11[13,14,15]
vpblendw $0x11, %ymm14, %ymm11, %ymm13 # ymm13 = ymm14[0],ymm11[1,2,3],ymm14[4],ymm11[5,6,7],ymm14[8],ymm11[9,10,11],ymm14[12],ymm11[13,14,15]
vpackusdw %ymm7, %ymm13, %ymm7
vpblendw $0x11, %ymm12, %ymm11, %ymm12 # ymm12 = ymm12[0],ymm11[1,2,3],ymm12[4],ymm11[5,6,7],ymm12[8],ymm11[9,10,11],ymm12[12],ymm11[13,14,15]
vpblendw $0x11, %ymm4, %ymm11, %ymm4 # ymm4 = ymm4[0],ymm11[1,2,3],ymm4[4],ymm11[5,6,7],ymm4[8],ymm11[9,10,11],ymm4[12],ymm11[13,14,15]
vpackusdw %ymm4, %ymm12, %ymm4
vpermq $0xd8, %ymm6, %ymm6     # ymm6 = ymm6[0,2,1,3]
vmovdqa %ymm6, (%rcx)
vpermq $0xd8, %ymm7, %ymm6     # ymm6 = ymm7[0,2,1,3]
vpermq $0xd8, %ymm4, %ymm4     # ymm4 = ymm4[0,2,1,3]
vpackusdw %ymm4, %ymm6, %ymm4
vpermq $0xd8, %ymm4, %ymm4     # ymm4 = ymm4[0,2,1,3]
vmovdqa %ymm4, (%rdx)
incq %rax
addq $0x20, %rdx
addq $0x20, %rcx
cmpq %rax, %r13
jne 0x4f6717
movq %r8, %rdi
movw $0x0, (%r8)
movq %r15, %rcx
movl %ecx, %eax
addl $0xf, %ecx
andl $-0x10, %ecx
movq %rax, 0x50(%rsp)
decq %rax
vmovq %rax, %xmm0
vpbroadcastq %xmm0, %ymm6
vmovd %r10d, %xmm0
vpbroadcastd %xmm0, %ymm0
vmovdqu %ymm0, 0x90(%rsp)
vmovd %r11d, %xmm0
vpbroadcastd %xmm0, %ymm0
vmovdqu %ymm0, 0x170(%rsp)
vpmovsxbd 0x137545(%rip), %ymm9 # 0x62de48
vpmovsxbd 0x1373c4(%rip), %ymm10 # 0x62dcd0
xorl %r8d, %r8d
vpbroadcastq 0x137268(%rip), %xmm15 # 0x62db80
vpcmpeqd %xmm1, %xmm1, %xmm1
vpcmpeqd %ymm4, %ymm4, %ymm4
vbroadcastss 0x137527(%rip), %ymm0 # 0x62de50
vmovups %ymm0, 0x150(%rsp)
vpbroadcastq 0x137245(%rip), %ymm13 # 0x62db80
vbroadcastss 0x13727c(%rip), %xmm0 # 0x62dbc0
vmovups %ymm0, 0x70(%rsp)
vpbroadcastd 0x137501(%rip), %ymm0 # 0x62de54
vmovdqu %ymm0, 0x130(%rsp)
vmovq %r8, %xmm7
vpbroadcastq %xmm7, %ymm12
vpor 0x1371d2(%rip), %ymm12, %ymm11 # 0x62db40
vpxor %xmm6, %xmm15, %xmm7
vpxor %xmm15, %xmm11, %xmm8
vpcmpgtq %xmm7, %xmm8, %xmm7
vpackssdw %xmm7, %xmm7, %xmm7
vpxor %xmm1, %xmm7, %xmm7
vpackssdw %xmm7, %xmm7, %xmm7
vpacksswb %xmm7, %xmm7, %xmm7
vpaddd %ymm4, %ymm10, %ymm8
vpaddd %ymm4, %ymm9, %ymm14
vmovdqu 0x90(%rsp), %ymm0
vpmulld %ymm0, %ymm14, %ymm14
vpmulld %ymm0, %ymm8, %ymm8
vmovdqu 0x170(%rsp), %ymm0
vpsubd %ymm8, %ymm0, %ymm8
vpsubd %ymm14, %ymm0, %ymm14
vmovdqu 0x150(%rsp), %ymm0
vpmaxsd %ymm0, %ymm14, %ymm14
vpmaxsd %ymm0, %ymm8, %ymm8
vpxor %xmm0, %xmm0, %xmm0
vpblendw $0xaa, %ymm0, %ymm8, %ymm8 # ymm8 = ymm8[0],ymm0[1],ymm8[2],ymm0[3],ymm8[4],ymm0[5],ymm8[6],ymm0[7],ymm8[8],ymm0[9],ymm8[10],ymm0[11],ymm8[12],ymm0[13],ymm8[14],ymm0[15]
vpblendw $0xaa, %ymm0, %ymm14, %ymm14 # ymm14 = ymm14[0],ymm0[1],ymm14[2],ymm0[3],ymm14[4],ymm0[5],ymm14[6],ymm0[7],ymm14[8],ymm0[9],ymm14[10],ymm0[11],ymm14[12],ymm0[13],ymm14[14],ymm0[15]
vpackusdw %ymm14, %ymm8, %ymm8
vpermq $0xd8, %ymm8, %ymm8     # ymm8 = ymm8[0,2,1,3]
vmovd %xmm7, %eax
testb $0x1, %al
je 0x4f69f8
vpextrw $0x0, %xmm8, 0x2(%rdi,%r8,2)
vpxor %xmm6, %xmm15, %xmm7
vpxor %xmm15, %xmm11, %xmm14
vpcmpgtq %xmm7, %xmm14, %xmm7
vpackssdw %xmm7, %xmm7, %xmm7
vpxor %xmm1, %xmm7, %xmm7
vpackssdw %xmm7, %xmm7, %xmm7
vpacksswb %xmm7, %xmm7, %xmm7
vpextrb $0x1, %xmm7, %eax
testb $0x1, %al
je 0x4f6a28
vpextrw $0x1, %xmm8, 0x4(%rdi,%r8,2)
vpxor %ymm6, %ymm13, %ymm7
vpxor %ymm13, %ymm11, %ymm11
vpcmpgtq %ymm7, %ymm11, %ymm11
vpshuflw $0xe8, %ymm11, %ymm14   # ymm14 = ymm11[0,2,2,3,4,5,6,7,8,10,10,11,12,13,14,15]
vpxor %ymm4, %ymm14, %ymm14
vmovdqu 0x70(%rsp), %ymm0
vpermd %ymm14, %ymm0, %ymm14
vpackssdw %xmm14, %xmm14, %xmm14
vpacksswb %xmm14, %xmm14, %xmm14
vpextrb $0x2, %xmm14, %eax
testb $0x1, %al
je 0x4f6a67
vpextrw $0x2, %xmm8, 0x6(%rdi,%r8,2)
vextracti128 $0x1, %ymm11, %xmm11
vpackssdw %xmm11, %xmm11, %xmm11
vpxor %xmm1, %xmm11, %xmm11
vpackssdw %xmm11, %xmm11, %xmm11
vpacksswb %xmm11, %xmm11, %xmm11
vpextrb $0x3, %xmm11, %eax
testb $0x1, %al
je 0x4f6a92
vpextrw $0x3, %xmm8, 0x8(%rdi,%r8,2)
vpor 0x1371a6(%rip), %ymm12, %ymm11 # 0x62dc40
vpxor %xmm6, %xmm15, %xmm14
vpxor %xmm15, %xmm11, %xmm0
vpcmpgtq %xmm14, %xmm0, %xmm0
vpackssdw %xmm0, %xmm0, %xmm0
vpxor %xmm1, %xmm0, %xmm0
vpermq $0x55, %ymm0, %ymm0     # ymm0 = ymm0[1,1,1,1]
vpackssdw %ymm0, %ymm0, %ymm0
vextracti128 $0x1, %ymm0, %xmm0
vpacksswb %xmm0, %xmm0, %xmm0
vpextrb $0x8, %xmm0, %eax
testb $0x1, %al
je 0x4f6ad6
vpextrw $0x4, %xmm8, 0xa(%rdi,%r8,2)
vpxor %xmm6, %xmm15, %xmm0
vpxor %xmm15, %xmm11, %xmm14
vpcmpgtq %xmm0, %xmm14, %xmm0
vpshufhw $0x84, %xmm0, %xmm0     # xmm0 = xmm0[0,1,2,3,4,5,4,6]
vpxor %xmm1, %xmm0, %xmm0
vpermq $0x55, %ymm0, %ymm0     # ymm0 = ymm0[1,1,1,1]
vpackssdw %ymm0, %ymm0, %ymm0
vextracti128 $0x1, %ymm0, %xmm0
vpacksswb %xmm0, %xmm0, %xmm0
vpextrb $0x9, %xmm0, %eax
testb $0x1, %al
je 0x4f6b13
vpextrw $0x5, %xmm8, 0xc(%rdi,%r8,2)
vpxor %ymm13, %ymm11, %ymm0
vpcmpgtq %ymm7, %ymm0, %ymm11
vpackssdw %ymm11, %ymm0, %ymm0
vpxor %ymm4, %ymm0, %ymm0
vpackssdw %ymm0, %ymm0, %ymm0
vextracti128 $0x1, %ymm0, %xmm0
vpacksswb %xmm0, %xmm0, %xmm0
vpextrb $0xa, %xmm0, %eax
testb $0x1, %al
je 0x4f6b46
vpextrw $0x6, %xmm8, 0xe(%rdi,%r8,2)
vpackssdw %ymm11, %ymm0, %ymm0
vpxor %ymm4, %ymm0, %ymm0
vpackssdw %ymm0, %ymm0, %ymm0
vextracti128 $0x1, %ymm0, %xmm0
vpacksswb %xmm0, %xmm0, %xmm0
vpextrb $0xb, %xmm0, %eax
testb $0x1, %al
je 0x4f6b6f
vpextrw $0x7, %xmm8, 0x10(%rdi,%r8,2)
vpor 0x137289(%rip), %ymm12, %ymm11 # 0x62de00
vpxor %xmm6, %xmm15, %xmm0
vpxor %xmm15, %xmm11, %xmm14
vpcmpgtq %xmm0, %xmm14, %xmm0
vpackssdw %xmm0, %xmm0, %xmm0
vpxor %xmm1, %xmm0, %xmm0
vpackssdw %xmm0, %xmm0, %xmm0
vpacksswb %xmm0, %xmm0, %xmm0
vpextrb $0x4, %xmm0, %eax
vextracti128 $0x1, %ymm8, %xmm8
testb $0x1, %al
je 0x4f6bad
vpextrw $0x0, %xmm8, 0x12(%rdi,%r8,2)
vpxor %xmm6, %xmm15, %xmm0
vpxor %xmm15, %xmm11, %xmm14
vpcmpgtq %xmm0, %xmm14, %xmm0
vpackssdw %xmm0, %xmm0, %xmm0
vpxor %xmm1, %xmm0, %xmm0
vpackssdw %xmm0, %xmm0, %xmm0
vpacksswb %xmm0, %xmm0, %xmm0
vpextrb $0x5, %xmm0, %eax
testb $0x1, %al
je 0x4f6bdd
vpextrw $0x1, %xmm8, 0x14(%rdi,%r8,2)
vpxor %ymm13, %ymm11, %ymm0
vpcmpgtq %ymm7, %ymm0, %ymm11
vpshuflw $0xe8, %ymm11, %ymm0    # ymm0 = ymm11[0,2,2,3,4,5,6,7,8,10,10,11,12,13,14,15]
vpxor %ymm4, %ymm0, %ymm0
vmovdqu 0x70(%rsp), %ymm14
vpermd %ymm0, %ymm14, %ymm0
vpackssdw %xmm0, %xmm0, %xmm0
vpacksswb %xmm0, %xmm0, %xmm0
vpextrb $0x6, %xmm0, %eax
testb $0x1, %al
je 0x4f6c16
vpextrw $0x2, %xmm8, 0x16(%rdi,%r8,2)
vextracti128 $0x1, %ymm11, %xmm0
vpackssdw %xmm0, %xmm0, %xmm0
vpxor %xmm1, %xmm0, %xmm0
vpackssdw %xmm0, %xmm0, %xmm0
vpacksswb %xmm0, %xmm0, %xmm0
vpextrb $0x7, %xmm0, %eax
testb $0x1, %al
je 0x4f6c3e
vpextrw $0x3, %xmm8, 0x18(%rdi,%r8,2)
vpor 0x13719a(%rip), %ymm12, %ymm11 # 0x62dde0
vpxor %xmm6, %xmm15, %xmm0
vpxor %xmm15, %xmm11, %xmm12
vpcmpgtq %xmm0, %xmm12, %xmm0
vpackssdw %xmm0, %xmm0, %xmm0
vpxor %xmm1, %xmm0, %xmm0
vpermq $0x55, %ymm0, %ymm0     # ymm0 = ymm0[1,1,1,1]
vpackssdw %ymm0, %ymm0, %ymm0
vextracti128 $0x1, %ymm0, %xmm0
vpacksswb %xmm0, %xmm0, %xmm0
vpextrb $0xc, %xmm0, %eax
testb $0x1, %al
je 0x4f6c82
vpextrw $0x4, %xmm8, 0x1a(%rdi,%r8,2)
vpxor %xmm6, %xmm15, %xmm0
vpxor %xmm15, %xmm11, %xmm12
vpcmpgtq %xmm0, %xmm12, %xmm0
vpshufhw $0x84, %xmm0, %xmm0     # xmm0 = xmm0[0,1,2,3,4,5,4,6]
vpxor %xmm1, %xmm0, %xmm0
vpermq $0x55, %ymm0, %ymm0     # ymm0 = ymm0[1,1,1,1]
vpackssdw %ymm0, %ymm0, %ymm0
vextracti128 $0x1, %ymm0, %xmm0
vpacksswb %xmm0, %xmm0, %xmm0
vpextrb $0xd, %xmm0, %eax
testb $0x1, %al
je 0x4f6cbf
vpextrw $0x5, %xmm8, 0x1c(%rdi,%r8,2)
vpxor %ymm13, %ymm11, %ymm0
vpcmpgtq %ymm7, %ymm0, %ymm7
vpackssdw %ymm7, %ymm0, %ymm0
vpxor %ymm4, %ymm0, %ymm0
vpackssdw %ymm0, %ymm0, %ymm0
vextracti128 $0x1, %ymm0, %xmm0
vpacksswb %xmm0, %xmm0, %xmm0
vpextrb $0xe, %xmm0, %eax
testb $0x1, %al
je 0x4f6cf1
vpextrw $0x6, %xmm8, 0x1e(%rdi,%r8,2)
vpackssdw %ymm7, %ymm0, %ymm0
vpxor %ymm4, %ymm0, %ymm0
vpackssdw %ymm0, %ymm0, %ymm0
vextracti128 $0x1, %ymm0, %xmm0
vpacksswb %xmm0, %xmm0, %xmm0
vpextrb $0xf, %xmm0, %eax
testb $0x1, %al
je 0x4f6d19
vpextrw $0x7, %xmm8, 0x20(%rdi,%r8,2)
addq $0x10, %r8
vmovdqu 0x130(%rsp), %ymm0
vpaddd %ymm0, %ymm10, %ymm10
vpaddd %ymm0, %ymm9, %ymm9
cmpq %r8, %rcx
jne 0x4f695c
vpxor %xmm0, %xmm0, %xmm0
vpsubsw %ymm2, %ymm0, %ymm0
leal -0x1(%r13), %eax
shlq $0x5, %rax
movq %r9, 0x10(%rsp)
addq %rax, %r9
movl %r13d, %edx
vmovdqu 0x1d0(%rsp), %ymm11
vmovdqu 0x1b0(%rsp), %ymm12
vmovdqa %ymm0, (%r9)
vpsubsw %ymm3, %ymm0, %ymm0
addq $-0x20, %r9
decl %edx
jg 0x4f6d64
movq %r12, 0x70(%rsp)
addq %rax, %r12
movq %r12, 0xf8(%rsp)
movq %r13, %r11
shlq $0x5, %r11
movq 0x50(%rsp), %rax
imulq %rax, %r13
leaq (,%r13,4), %rcx
leaq (,%rax,4), %rbp
leaq (,%r13,8), %r15
leaq (%rcx,%rcx,2), %rbx
movq %r13, %rdx
shlq $0x4, %rdx
leaq (%rcx,%rcx,4), %r10
leaq (%r15,%r15,2), %rax
movq %rax, 0x130(%rsp)
leaq (,%r13,8), %rax
addq %r13, %rax
leaq (%rax,%rax,2), %r9
addq %r13, %r9
movq %r13, %rax
shlq $0x5, %rax
movq %rax, 0xf0(%rsp)
imulq $0x2c, %r13, %rax
movq %rax, 0xe8(%rsp)
imulq $0x34, %r13, %rax
movq %rax, 0xe0(%rsp)
imulq $0x38, %r13, %rax
movq %rax, 0xd8(%rsp)
imulq $0x3c, %r13, %rax
movq %rax, 0xd0(%rsp)
vmovdqa %ymm11, %ymm0
vmovdqa %ymm12, %ymm1
movq %rcx, 0x170(%rsp)
leaq (%rcx,%rcx,8), %rax
movq %rax, 0xc8(%rsp)
leaq (%r15,%r15,4), %rax
movq %rax, 0xc0(%rsp)
movq %rdx, 0x150(%rsp)
leaq (%rdx,%rdx,2), %rax
movq %rax, 0xb8(%rsp)
movq $0x0, 0x68(%rsp)
xorl %eax, %eax
movq 0x38(%rsp), %r8
vmovdqu 0x190(%rsp), %ymm13
movq %rdi, 0x20(%rsp)
movq %r11, 0x90(%rsp)
movq %r9, 0x30(%rsp)
movq %rbp, 0x128(%rsp)
movq %r15, 0x120(%rsp)
movq %rbx, 0x118(%rsp)
movq %r10, 0x110(%rsp)
movq 0xf0(%rsp), %rbp
movq 0xe8(%rsp), %r15
movq 0xe0(%rsp), %r13
movq 0xc8(%rsp), %r9
movq 0xc0(%rsp), %rbx
movq 0xb8(%rsp), %r10
movq 0xf8(%rsp), %rcx
vmovdqa (%rcx), %ymm4
vinserti128 $0x1, %xmm4, %ymm0, %ymm6
vpalignr $0xe, %ymm6, %ymm4, %ymm4 # ymm4 = ymm6[14,15],ymm4[0,1,2,3,4,5,6,7,8,9,10,11,12,13],ymm6[30,31],ymm4[16,17,18,19,20,21,22,23,24,25,26,27,28,29]
vpinsrw $0x0, (%rdi,%rax,2), %xmm4, %xmm6
vpblendd $0xf, %ymm6, %ymm4, %ymm7 # ymm7 = ymm6[0,1,2,3],ymm4[4,5,6,7]
movq 0x58(%rsp), %rcx
movq 0x10(%rcx), %rcx
movq 0x60(%rsp), %rdx
movq %rax, 0x28(%rsp)
movzbl (%rdx,%rax), %edx
movslq (%rcx,%rdx,4), %rcx
imulq 0x100(%rsp), %rcx
shlq $0x5, %rcx
addq 0x108(%rsp), %rcx
movq 0x10(%rsp), %rdi
vpsubsw (%rdi), %ymm11, %ymm6
xorl %edx, %edx
vmovdqa %ymm11, %ymm4
movq 0x70(%rsp), %r12
vpaddsw (%rcx,%rdx), %ymm7, %ymm7
vmovdqa (%r12,%rdx), %ymm8
vmovdqa (%rsi,%rdx), %ymm9
vpsubsw %ymm3, %ymm9, %ymm9
vpsubsw %ymm2, %ymm8, %ymm10
vpmaxsw %ymm10, %ymm9, %ymm9
vpaddsw (%rdi,%rdx), %ymm6, %ymm6
vpmaxsw %ymm6, %ymm4, %ymm4
vpmaxsw %ymm7, %ymm9, %ymm6
vmovdqa %ymm9, (%rsi,%rdx)
vmovdqa %ymm6, (%r8,%rdx)
addq $0x20, %rdx
vmovdqa %ymm8, %ymm7
cmpq %rdx, %r11
jne 0x4f6f38
vinserti128 $0x1, %xmm6, %ymm0, %ymm7
vpalignr $0xe, %ymm7, %ymm6, %ymm6 # ymm6 = ymm7[14,15],ymm6[0,1,2,3,4,5,6,7,8,9,10,11,12,13],ymm7[30,31],ymm6[16,17,18,19,20,21,22,23,24,25,26,27,28,29]
movq 0x20(%rsp), %rcx
movq 0x28(%rsp), %rdx
vpinsrw $0x0, 0x2(%rcx,%rdx,2), %xmm6, %xmm7
incq %rdx
movq %rdx, 0x28(%rsp)
vpblendd $0xf, %ymm7, %ymm6, %ymm6 # ymm6 = ymm7[0,1,2,3],ymm6[4,5,6,7]
vpaddsw (%rdi), %ymm6, %ymm7
vpmaxsw %ymm7, %ymm4, %ymm4
movl $0xe, %ecx
vperm2i128 $0x28, %ymm4, %ymm4, %ymm7 # ymm7 = zero,zero,ymm4[0,1]
vpalignr $0xe, %ymm7, %ymm4, %ymm7 # ymm7 = ymm7[14,15],ymm4[0,1,2,3,4,5,6,7,8,9,10,11,12,13],ymm7[30,31],ymm4[16,17,18,19,20,21,22,23,24,25,26,27,28,29]
vpaddsw %ymm5, %ymm7, %ymm7
vpmaxsw %ymm7, %ymm4, %ymm4
decl %ecx
jne 0x4f6fb2
vperm2i128 $0x28, %ymm4, %ymm4, %ymm7 # ymm7 = zero,zero,ymm4[0,1]
vpalignr $0xe, %ymm7, %ymm4, %ymm4 # ymm4 = ymm7[14,15],ymm4[0,1,2,3,4,5,6,7,8,9,10,11,12,13],ymm7[30,31],ymm4[16,17,18,19,20,21,22,23,24,25,26,27,28,29]
vpaddsw %ymm4, %ymm13, %ymm4
vpmaxsw %ymm4, %ymm6, %ymm6
movq 0x68(%rsp), %rcx
xorl %edx, %edx
movq 0xd8(%rsp), %rax
movq 0xd0(%rsp), %r12
vpsubsw %ymm3, %ymm4, %ymm4
vpsubsw %ymm2, %ymm6, %ymm6
vpmaxsw %ymm6, %ymm4, %ymm4
vpmaxsw (%r8,%rdx), %ymm4, %ymm6
movq 0x70(%rsp), %rsi
vmovdqa %ymm6, (%rsi,%rdx)
movq 0x10(%r14), %rsi
movq (%rsi), %rsi
vmovd %xmm6, %edi
movswl %di, %edi
movl %edi, (%rsi,%rcx)
vpextrw $0x1, %xmm6, %edi
addq %rcx, %rsi
movswl %di, %edi
movq %r14, %r8
vpextrw $0x2, %xmm6, %r14d
movq 0x170(%rsp), %r11
movl %edi, (%r11,%rsi)
movswl %r14w, %edi
vpextrw $0x3, %xmm6, %r14d
movq 0x120(%rsp), %r11
movl %edi, (%r11,%rsi)
movswl %r14w, %edi
vpextrw $0x4, %xmm6, %r14d
movq 0x118(%rsp), %r11
movl %edi, (%r11,%rsi)
movswl %r14w, %edi
vpextrw $0x5, %xmm6, %r14d
movq 0x150(%rsp), %r11
movl %edi, (%r11,%rsi)
movswl %r14w, %edi
vpextrw $0x6, %xmm6, %r14d
movq 0x110(%rsp), %r11
movl %edi, (%r11,%rsi)
movswl %r14w, %edi
vpextrw $0x7, %xmm6, %r14d
movq 0x130(%rsp), %r11
movl %edi, (%r11,%rsi)
movswl %r14w, %edi
movq 0x30(%rsp), %r14
movl %edi, (%r14,%rsi)
vextracti128 $0x1, %ymm6, %xmm7
vmovd %xmm7, %edi
movswl %di, %edi
vpextrw $0x1, %xmm7, %r14d
movl %edi, (%rbp,%rsi)
movswl %r14w, %edi
vpextrw $0x2, %xmm7, %r14d
movl %edi, (%r9,%rsi)
movswl %r14w, %edi
vpextrw $0x3, %xmm7, %r14d
movl %edi, (%rbx,%rsi)
movswl %r14w, %edi
vpextrw $0x4, %xmm7, %r14d
movl %edi, (%r15,%rsi)
movswl %r14w, %edi
vpextrw $0x5, %xmm7, %r14d
movl %edi, (%r10,%rsi)
movswl %r14w, %edi
vpextrw $0x6, %xmm7, %r14d
movl %edi, (%r13,%rsi)
movswl %r14w, %edi
vpextrw $0x7, %xmm7, %r14d
movl %edi, (%rax,%rsi)
movswl %r14w, %edi
movq %r8, %r14
movq 0x38(%rsp), %r8
movl %edi, (%r12,%rsi)
vpminsw %ymm6, %ymm1, %ymm1
vpmaxsw %ymm6, %ymm0, %ymm0
addq $0x20, %rdx
addq 0x128(%rsp), %rcx
cmpq %rdx, 0x90(%rsp)
jne 0x4f6ff5
addq $0x4, 0x68(%rsp)
movq 0x28(%rsp), %rax
cmpq 0x50(%rsp), %rax
movq 0x18(%rsp), %rsi
movq 0x20(%rsp), %rdi
movq 0x90(%rsp), %r11
jne 0x4f6ed0
movl 0x4c(%rsp), %eax
shlq $0x5, %rax
movq 0x70(%rsp), %rbx
vmovdqa (%rbx,%rax), %ymm2
cmpl $0xe, 0x8(%rsp)
movl 0x48(%rsp), %edx
jg 0x4f71b4
xorl %eax, %eax
movl 0xc(%rsp), %ecx
movq 0x10(%rsp), %rdi
movl 0x44(%rsp), %esi
vperm2i128 $0x28, %ymm2, %ymm2, %ymm3 # ymm3 = zero,zero,ymm2[0,1]
vpalignr $0xe, %ymm3, %ymm2, %ymm2 # ymm2 = ymm3[14,15],ymm2[0,1,2,3,4,5,6,7,8,9,10,11,12,13],ymm3[30,31],ymm2[16,17,18,19,20,21,22,23,24,25,26,27,28,29]
incl %eax
cmpl %esi, %eax
jl 0x4f71a0
jmp 0x4f71bd
movl 0xc(%rsp), %ecx
movq 0x10(%rsp), %rdi
vpcmpgtw %ymm1, %ymm11, %ymm1
vpcmpgtw %ymm12, %ymm0, %ymm0
vpor %ymm1, %ymm0, %ymm0
vpmovmskb %ymm0, %eax
testl %eax, %eax
je 0x4f71df
orb $0x40, 0xc(%r14)
xorl %eax, %eax
xorl %edx, %edx
xorl %ecx, %ecx
jmp 0x4f71ea
vextracti128 $0x1, %ymm2, %xmm0
vpextrw $0x7, %xmm0, %eax
cwtl
movl %eax, (%r14)
movl %ecx, 0x4(%r14)
movl %edx, 0x8(%r14)
vzeroupper
callq 0x20a60d
movq %rbx, %rdi
callq 0x20a60d
movq 0x38(%rsp), %rdi
callq 0x20a60d
movq 0x20(%rsp), %rdi
callq 0x20a60d
movq 0x18(%rsp), %rdi
callq 0x20a60d
jmp 0x4f725f
callq 0x1e759d
jmp 0x4f725c
callq 0x1e7577
jmp 0x4f725c
callq 0x1e7551
jmp 0x4f725c
callq 0x1e752b
jmp 0x4f725c
callq 0x1e7505
jmp 0x4f725c
callq 0x1e74df
jmp 0x4f725c
callq 0x1e74b9
jmp 0x4f725c
callq 0x1e7493
xorl %r14d, %r14d
movq %r14, %rax
addq $0x1f8, %rsp            # imm = 0x1F8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq