// File: /workspace/github_c_makefile_star2_O3/nh13[P]ksw/src/parasail/src/nw_striped_sse2_128_16.c
// Function: parasail_nw_table_striped_profile_sse2_128_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;
    int 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;
    __m128i* restrict vProfile = NULL;
    __m128i* restrict pvHStore = NULL;
    __m128i* restrict pvHLoad = NULL;
    __m128i* restrict pvE = NULL;
    int16_t* restrict boundary = NULL;
    __m128i vGapO;
    __m128i vGapE;
    int16_t NEG_LIMIT = 0;
    int16_t POS_LIMIT = 0;
    int16_t score = 0;
    __m128i vNegLimit;
    __m128i vPosLimit;
    __m128i vSaturationCheckMin;
    __m128i vSaturationCheckMax;
    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 = 8; /* number of values in vector unit */
    segLen = (s1Len + segWidth - 1) / segWidth;
    offset = (s1Len - 1) % segLen;
    position = (segWidth - 1) - (s1Len - 1) / segLen;
    vProfile = (__m128i*)profile->profile16.score;
    vGapO = _mm_set1_epi16(open);
    vGapE = _mm_set1_epi16(gap);
    NEG_LIMIT = (-open < matrix->min ? INT16_MIN + open : INT16_MIN - matrix->min) + 1;
    POS_LIMIT = INT16_MAX - matrix->max - 1;
    score = NEG_LIMIT;
    vNegLimit = _mm_set1_epi16(NEG_LIMIT);
    vPosLimit = _mm_set1_epi16(POS_LIMIT);
    vSaturationCheckMin = vPosLimit;
    vSaturationCheckMax = vNegLimit;

    /* 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_STRIPED
        | PARASAIL_FLAG_BITS_16 | PARASAIL_FLAG_LANES_8;
#ifdef PARASAIL_TABLE
    result->flag |= PARASAIL_FLAG_TABLE;
#endif
#ifdef PARASAIL_ROWCOL
    result->flag |= PARASAIL_FLAG_ROWCOL;
#endif

    /* initialize heap variables */
    pvHStore = parasail_memalign___m128i(16, segLen);
    pvHLoad  = parasail_memalign___m128i(16, segLen);
    pvE      = parasail_memalign___m128i(16, segLen);
    boundary = parasail_memalign_int16_t(16, s2Len+1);

    /* validate heap variables */
    if (!pvHStore) return NULL;
    if (!pvHLoad) return NULL;
    if (!pvE) return NULL;
    if (!boundary) return NULL;

    /* initialize H and E */
    {
        int32_t index = 0;
        for (i=0; i<segLen; ++i) {
            int32_t segNum = 0;
            __m128i_16_t h;
            __m128i_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;
            }
            _mm_store_si128(&pvHStore[index], h.m);
            _mm_store_si128(&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;
        }
    }

    /* outer loop over database sequence */
    for (j=0; j<s2Len; ++j) {
        __m128i vE;
        /* Initialize F value to -inf.  Any errors to vH values will be
         * corrected in the Lazy_F loop.  */
        __m128i vF = vNegLimit;

        /* load final segment of pvHStore and shift left by 2 bytes */
        __m128i vH = _mm_slli_si128(pvHStore[segLen - 1], 2);

        /* Correct part of the vProfile */
        const __m128i* vP = vProfile + matrix->mapper[(unsigned char)s2[j]] * segLen;

        /* Swap the 2 H buffers. */
        __m128i* pv = pvHLoad;
        pvHLoad = pvHStore;
        pvHStore = pv;

        /* insert upper boundary condition */
        vH = _mm_insert_epi16(vH, boundary[j], 0);

        /* inner loop to process the query sequence */
        for (i=0; i<segLen; ++i) {
            vH = _mm_adds_epi16(vH, _mm_load_si128(vP + i));
            vE = _mm_load_si128(pvE + i);

            /* Get max from vH, vE and vF. */
            vH = _mm_max_epi16(vH, vE);
            vH = _mm_max_epi16(vH, vF);
            /* Save vH values. */
            _mm_store_si128(pvHStore + i, vH);
            vSaturationCheckMax = _mm_max_epi16(vSaturationCheckMax, vH);
            vSaturationCheckMin = _mm_min_epi16(vSaturationCheckMin, vH);
            vSaturationCheckMin = _mm_min_epi16(vSaturationCheckMin, vE);
            vSaturationCheckMin = _mm_min_epi16(vSaturationCheckMin, vF);
#ifdef PARASAIL_TABLE
            arr_store_si128(result->tables->score_table, vH, i, segLen, j, s2Len);
#endif

            /* Update vE value. */
            vH = _mm_subs_epi16(vH, vGapO);
            vE = _mm_subs_epi16(vE, vGapE);
            vE = _mm_max_epi16(vE, vH);
            _mm_store_si128(pvE + i, vE);

            /* Update vF value. */
            vF = _mm_subs_epi16(vF, vGapE);
            vF = _mm_max_epi16(vF, vH);

            /* Load the next vH. */
            vH = _mm_load_si128(pvHLoad + i);
        }

        /* Lazy_F loop: has been revised to disallow adjecent insertion and
         * then deletion, so don't update E(i, i), learn from SWPS3 */
        for (k=0; k<segWidth; ++k) {
            int64_t tmp = boundary[j+1]-open;
            int16_t tmp2 = tmp < INT16_MIN ? INT16_MIN : tmp;
            vF = _mm_slli_si128(vF, 2);
            vF = _mm_insert_epi16(vF, tmp2, 0);
            for (i=0; i<segLen; ++i) {
                vH = _mm_load_si128(pvHStore + i);
                vH = _mm_max_epi16(vH,vF);
                _mm_store_si128(pvHStore + i, vH);
                vSaturationCheckMin = _mm_min_epi16(vSaturationCheckMin, vH);
                vSaturationCheckMax = _mm_max_epi16(vSaturationCheckMax, vH);
#ifdef PARASAIL_TABLE
                arr_store_si128(result->tables->score_table, vH, i, segLen, j, s2Len);
#endif
                vH = _mm_subs_epi16(vH, vGapO);
                vF = _mm_subs_epi16(vF, vGapE);
                if (! _mm_movemask_epi8(_mm_cmpgt_epi16(vF, vH))) goto end;
                /*vF = _mm_max_epi16(vF, vH);*/
            }
        }
end:
        {
        }

#ifdef PARASAIL_ROWCOL
        /* extract last value from the column */
        {
            vH = _mm_load_si128(pvHStore + offset);
            for (k=0; k<position; ++k) {
                vH = _mm_slli_si128(vH, 2);
            }
            result->rowcols->score_row[j] = (int16_t) _mm_extract_epi16 (vH, 7);
        }
#endif
    }

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

    /* extract last value from the last column */
    {
        __m128i vH = _mm_load_si128(pvHStore + offset);
        for (k=0; k<position; ++k) {
            vH = _mm_slli_si128 (vH, 2);
        }
        score = (int16_t) _mm_extract_epi16 (vH, 7);
    }

    if (_mm_movemask_epi8(_mm_or_si128(
            _mm_cmplt_epi16(vSaturationCheckMin, vNegLimit),
            _mm_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(boundary);
    parasail_free(pvE);
    parasail_free(pvHLoad);
    parasail_free(pvHStore);

    return result;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x108, %rsp            # imm = 0x108
movl %ecx, 0x4(%rsp)
movq %rsi, 0x68(%rsp)
testq %rdi, %rdi
je 0x31021e
movq 0x30(%rdi), %rax
movq %rax, 0xb8(%rsp)
testq %rax, %rax
je 0x310228
movq 0x10(%rdi), %rax
movq %rax, 0x60(%rsp)
testq %rax, %rax
je 0x310268
movl 0x8(%rdi), %edi
testl %edi, %edi
jle 0x310272
cmpq $0x0, 0x68(%rsp)
je 0x31027c
movl %r8d, %r15d
movl %edx, %r8d
testl %edx, %edx
jle 0x310286
cmpl $0x0, 0x4(%rsp)
js 0x310290
testl %r15d, %r15d
js 0x31029a
leal -0x1(%rdi), %eax
addq $0x7, %rdi
movq %rdi, %r12
shrq $0x3, %r12
movl %eax, 0xc(%rsp)
xorl %edx, %edx
divl %r12d
movl %eax, 0x10(%rsp)
movl %edx, 0x54(%rsp)
movl 0x4(%rsp), %ecx
movl %ecx, %ebp
negl %ebp
movq 0x60(%rsp), %rdx
movl 0x20(%rdx), %eax
movl %eax, %ebx
negl %ebx
cmpl %ebp, %eax
cmovgl %ecx, %ebx
movw $0x7ffe, %r14w          # imm = 0x7FFE
subw 0x1c(%rdx), %r14w
andl $0x7ffffff8, %edi       # imm = 0x7FFFFFF8
movl %r8d, %esi
movq %r8, 0x40(%rsp)
callq 0x20abc2
testq %rax, %rax
je 0x30f945
movq %rax, %r13
movl %r14d, 0x30(%rsp)
orl $0x8220801, 0xc(%rax)   # imm = 0x8220801
movl $0x10, %edi
movq %r12, %rsi
callq 0x2f600c
movq %rax, 0x38(%rsp)
movl $0x10, %edi
movq %r12, %rsi
callq 0x2f600c
movq %rax, %r14
movl $0x10, %edi
movq %r12, %rsi
callq 0x2f600c
movq %r12, 0x20(%rsp)
movq %rax, %r12
movq 0x40(%rsp), %rax
leal 0x1(%rax), %esi
movl $0x10, %edi
callq 0x20a625
movq 0x38(%rsp), %r10
movq %rax, %rdi
movq %r10, %xmm0
movq %r14, %xmm1
punpcklqdq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0]
movq %r12, %xmm1
movq %rax, %xmm2
punpcklqdq %xmm2, %xmm1    # xmm1 = xmm1[0],xmm2[0]
pxor %xmm2, %xmm2
pcmpeqd %xmm2, %xmm0
pcmpeqd %xmm2, %xmm1
movdqa %xmm0, %xmm2
shufps $0xdd, %xmm1, %xmm2     # xmm2 = xmm2[1,3],xmm1[1,3]
shufps $0x88, %xmm1, %xmm0     # xmm0 = xmm0[0,2],xmm1[0,2]
andps %xmm2, %xmm0
movmskps %xmm0, %eax
testl %eax, %eax
je 0x30f95d
xorl %r13d, %r13d
movq %r13, %rax
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r14, 0x28(%rsp)
movq %r12, 0x18(%rsp)
movq 0x40(%rsp), %rax
decl %eax
movl %eax, 0x8(%rsp)
movl $0x7, %eax
subl 0x10(%rsp), %eax
movl %eax, 0x50(%rsp)
movl 0x4(%rsp), %eax
movd %eax, %xmm0
movdqa %xmm0, 0x90(%rsp)
pshuflw $0x0, %xmm0, %xmm0      # xmm0 = xmm0[0,0,0,0,4,5,6,7]
pshufd $0x0, %xmm0, %xmm2      # xmm2 = xmm0[0,0,0,0]
movd %r15d, %xmm0
pshuflw $0x0, %xmm0, %xmm1      # xmm1 = xmm0[0,0,0,0,4,5,6,7]
pshufd $0x0, %xmm1, %xmm3      # xmm3 = xmm1[0,0,0,0]
addl $0xffff8001, %ebx       # imm = 0xFFFF8001
movd %ebx, %xmm1
pshuflw $0x0, %xmm1, %xmm1      # xmm1 = xmm1[0,0,0,0,4,5,6,7]
pshufd $0x0, %xmm1, %xmm4      # xmm4 = xmm1[0,0,0,0]
movd 0x30(%rsp), %xmm1
pshuflw $0x0, %xmm1, %xmm1      # xmm1 = xmm1[0,0,0,0,4,5,6,7]
pshufd $0x0, %xmm1, %xmm5      # xmm5 = xmm1[0,0,0,0]
movl %eax, %eax
movl %r15d, %ecx
movslq %ebp, %rdx
negq %rax
movq 0x20(%rsp), %rsi
imulq %rcx, %rsi
xorl %r12d, %r12d
movq $-0x7fff, %r8           # imm = 0x8001
movq $-0x8000, %r9           # imm = 0x8000
movq %r10, %r14
movq %rdx, %r10
xorl %r11d, %r11d
cmpq %r8, %r10
movq $-0x8000, %rbx          # imm = 0x8000
cmovgeq %r10, %rbx
movw %bx, 0xf0(%rsp,%r11,2)
leaq (%rax,%r10), %rbx
cmpq %r8, %rbx
cmovlq %r9, %rbx
movw %bx, 0xe0(%rsp,%r11,2)
incq %r11
subq %rsi, %r10
cmpq $0x8, %r11
jne 0x30f9fb
movq %r12, %r10
shlq $0x4, %r10
movaps 0xf0(%rsp), %xmm1
movaps %xmm1, (%r14,%r10)
movdqa 0xe0(%rsp), %xmm1
movq 0x18(%rsp), %r11
movdqa %xmm1, (%r11,%r10)
incq %r12
subq %rcx, %rdx
cmpq 0x20(%rsp), %r12
jne 0x30f9f5
movdqa %xmm5, 0xc0(%rsp)
movdqa %xmm4, 0xd0(%rsp)
movw $0x0, (%rdi)
movq 0x40(%rsp), %rdx
movl %edx, %eax
addl $0x7, %edx
andl $-0x8, %edx
movq %rax, 0x58(%rsp)
decq %rax
movq %rax, %xmm1
pshufd $0x44, %xmm1, %xmm5     # xmm5 = xmm1[0,1,0,1]
movd %ebp, %xmm6
pshufd $0x0, %xmm6, %xmm1      # xmm1 = xmm6[0,0,0,0]
movdqa %xmm1, 0x40(%rsp)
pshufd $0x0, %xmm0, %xmm8      # xmm8 = xmm0[0,0,0,0]
movl %r15d, %ecx
negl %ecx
leal (,%r15,8), %r8d
leal (%r15,%r15,2), %r9d
negl %r9d
addl %r15d, %r15d
xorl %r10d, %r10d
movdqa 0x3193cb(%rip), %xmm13  # 0x628ea0
pxor %xmm13, %xmm5
pcmpeqd %xmm14, %xmm14
movdqa 0x31a029(%rip), %xmm1   # 0x629b10
movq 0x20(%rsp), %r12
movq 0x28(%rsp), %rbx
movq %r10, %xmm0
pshufd $0x44, %xmm0, %xmm0     # xmm0 = xmm0[0,1,0,1]
movdqa %xmm0, %xmm9
por 0x319387(%rip), %xmm9   # 0x628e90
pxor %xmm13, %xmm9
movdqa %xmm9, %xmm12
pcmpgtd %xmm5, %xmm12
pshufd $0xa0, %xmm12, %xmm11   # xmm11 = xmm12[0,0,2,2]
pshuflw $0xe8, %xmm11, %xmm15   # xmm15 = xmm11[0,2,2,3,4,5,6,7]
pcmpeqd %xmm5, %xmm9
pshufd $0xf5, %xmm9, %xmm10    # xmm10 = xmm9[1,1,3,3]
pshuflw $0xe8, %xmm10, %xmm9    # xmm9 = xmm10[0,2,2,3,4,5,6,7]
pand %xmm15, %xmm9
pshufd $0xf5, %xmm12, %xmm12   # xmm12 = xmm12[1,1,3,3]
pshuflw $0xe8, %xmm12, %xmm15   # xmm15 = xmm12[0,2,2,3,4,5,6,7]
por %xmm9, %xmm15
pxor %xmm14, %xmm15
packssdw %xmm15, %xmm15
movd %ecx, %xmm9
punpckldq %xmm6, %xmm9    # xmm9 = xmm9[0],xmm6[0],xmm9[1],xmm6[1]
movd %r15d, %xmm4
movdqa 0x90(%rsp), %xmm7
punpckldq %xmm4, %xmm7    # xmm7 = xmm7[0],xmm4[0],xmm7[1],xmm4[1]
psubd %xmm7, %xmm9
leal (%r9,%rbp), %eax
movd %ebp, %xmm4
movd %eax, %xmm7
shufps $0xd4, %xmm9, %xmm7     # xmm7 = xmm7[0,1],xmm9[1,3]
punpckldq %xmm4, %xmm9    # xmm9 = xmm9[0],xmm4[0],xmm9[1],xmm4[1]
shufps $0x21, %xmm7, %xmm9     # xmm9 = xmm9[1,0],xmm7[2,0]
movaps %xmm9, %xmm4
pcmpgtd %xmm1, %xmm4
andps %xmm4, %xmm9
pandn %xmm1, %xmm4
por %xmm9, %xmm4
movd %xmm15, %eax
testb $0x1, %al
je 0x30fbb9
movd %xmm4, %eax
movw %ax, 0x2(%rdi,%r10,2)
pand %xmm11, %xmm10
por %xmm12, %xmm10
packssdw %xmm10, %xmm10
pxor %xmm14, %xmm10
packssdw %xmm10, %xmm10
movd %xmm10, %eax
shrl $0x10, %eax
testb $0x1, %al
je 0x30fbe9
pextrw $0x2, %xmm4, %eax
movw %ax, 0x4(%rdi,%r10,2)
movdqa %xmm0, %xmm7
por 0x31928b(%rip), %xmm7   # 0x628e80
pxor %xmm13, %xmm7
movdqa %xmm7, %xmm9
pcmpgtd %xmm5, %xmm9
pshufd $0xa0, %xmm9, %xmm10    # xmm10 = xmm9[0,0,2,2]
pcmpeqd %xmm5, %xmm7
pshufd $0xf5, %xmm7, %xmm11    # xmm11 = xmm7[1,1,3,3]
movdqa %xmm11, %xmm7
pand %xmm10, %xmm7
pshufd $0xf5, %xmm9, %xmm12    # xmm12 = xmm9[1,1,3,3]
por %xmm12, %xmm7
packssdw %xmm7, %xmm7
pxor %xmm14, %xmm7
packssdw %xmm7, %xmm7
pextrw $0x2, %xmm7, %eax
testb $0x1, %al
je 0x30fc4a
pextrw $0x4, %xmm4, %eax
movw %ax, 0x6(%rdi,%r10,2)
pshufhw $0x84, %xmm10, %xmm7    # xmm7 = xmm10[0,1,2,3,4,5,4,6]
pshufhw $0x84, %xmm11, %xmm9    # xmm9 = xmm11[0,1,2,3,4,5,4,6]
pand %xmm7, %xmm9
pshufhw $0x84, %xmm12, %xmm7    # xmm7 = xmm12[0,1,2,3,4,5,4,6]
por %xmm9, %xmm7
pxor %xmm14, %xmm7
packssdw %xmm7, %xmm7
pextrw $0x3, %xmm7, %eax
testb $0x1, %al
je 0x30fc83
pextrw $0x6, %xmm4, %eax
movw %ax, 0x8(%rdi,%r10,2)
movdqa %xmm0, %xmm10
por 0x31923f(%rip), %xmm10  # 0x628ed0
movd %r10d, %xmm4
pshufd $0x0, %xmm4, %xmm4      # xmm4 = xmm4[0,0,0,0]
por 0x319e5d(%rip), %xmm4   # 0x629b00
pshufd $0xf5, %xmm4, %xmm7     # xmm7 = xmm4[1,1,3,3]
pmuludq %xmm8, %xmm4
pshufd $0xe8, %xmm4, %xmm4     # xmm4 = xmm4[0,2,2,3]
pshufd $0xf5, %xmm8, %xmm9     # xmm9 = xmm8[1,1,3,3]
pmuludq %xmm7, %xmm9
pshufd $0xe8, %xmm9, %xmm7     # xmm7 = xmm9[0,2,2,3]
punpckldq %xmm7, %xmm4    # xmm4 = xmm4[0],xmm7[0],xmm4[1],xmm7[1]
movdqa 0x40(%rsp), %xmm7
psubd %xmm4, %xmm7
movdqa %xmm7, %xmm9
pcmpgtd %xmm1, %xmm9
pand %xmm9, %xmm7
pandn %xmm1, %xmm9
por %xmm7, %xmm9
pxor %xmm13, %xmm10
movdqa %xmm10, %xmm4
pcmpgtd %xmm5, %xmm4
pshufd $0xa0, %xmm4, %xmm11    # xmm11 = xmm4[0,0,2,2]
pshuflw $0xe8, %xmm11, %xmm7    # xmm7 = xmm11[0,2,2,3,4,5,6,7]
pcmpeqd %xmm5, %xmm10
pshufd $0xf5, %xmm10, %xmm10   # xmm10 = xmm10[1,1,3,3]
pshuflw $0xe8, %xmm10, %xmm15   # xmm15 = xmm10[0,2,2,3,4,5,6,7]
pand %xmm7, %xmm15
pshufd $0xf5, %xmm4, %xmm12    # xmm12 = xmm4[1,1,3,3]
pshuflw $0xe8, %xmm12, %xmm4    # xmm4 = xmm12[0,2,2,3,4,5,6,7]
por %xmm15, %xmm4
pxor %xmm14, %xmm4
packssdw %xmm4, %xmm4
pextrw $0x4, %xmm4, %eax
testb $0x1, %al
je 0x30fd48
movd %xmm9, %eax
movw %ax, 0xa(%rdi,%r10,2)
pand %xmm11, %xmm10
por %xmm12, %xmm10
packssdw %xmm10, %xmm10
pxor %xmm14, %xmm10
packssdw %xmm10, %xmm4
pextrw $0x5, %xmm4, %eax
testb $0x1, %al
je 0x30fd76
pextrw $0x2, %xmm9, %eax
movw %ax, 0xc(%rdi,%r10,2)
por 0x319142(%rip), %xmm0   # 0x628ec0
pxor %xmm13, %xmm0
movdqa %xmm0, %xmm4
pcmpgtd %xmm5, %xmm4
pshufd $0xa0, %xmm4, %xmm10    # xmm10 = xmm4[0,0,2,2]
pcmpeqd %xmm5, %xmm0
pshufd $0xf5, %xmm0, %xmm0     # xmm0 = xmm0[1,1,3,3]
movdqa %xmm0, %xmm7
pand %xmm10, %xmm7
pshufd $0xf5, %xmm4, %xmm11    # xmm11 = xmm4[1,1,3,3]
por %xmm11, %xmm7
packssdw %xmm7, %xmm4
pxor %xmm14, %xmm4
packssdw %xmm4, %xmm4
pextrw $0x6, %xmm4, %eax
testb $0x1, %al
je 0x30fdd0
pextrw $0x4, %xmm9, %eax
movw %ax, 0xe(%rdi,%r10,2)
pshufhw $0x84, %xmm10, %xmm4    # xmm4 = xmm10[0,1,2,3,4,5,4,6]
pshufhw $0x84, %xmm0, %xmm0     # xmm0 = xmm0[0,1,2,3,4,5,4,6]
pand %xmm4, %xmm0
pshufhw $0x84, %xmm11, %xmm4    # xmm4 = xmm11[0,1,2,3,4,5,4,6]
por %xmm0, %xmm4
pxor %xmm14, %xmm4
packssdw %xmm4, %xmm0
pextrw $0x7, %xmm0, %eax
testb $0x1, %al
je 0x30fe07
pextrw $0x6, %xmm9, %eax
movw %ax, 0x10(%rdi,%r10,2)
addq $0x8, %r10
subl %r8d, %ecx
subl %r8d, %ebp
addl %r8d, %r15d
cmpq %r10, %rdx
jne 0x30faf1
leal -0x1(%r12), %r8d
movq %r12, %r9
movq 0x58(%rsp), %rax
imulq %rax, %r9
leaq (,%r9,4), %rdx
leaq (,%rax,4), %rax
movq %rax, 0x70(%rsp)
leaq (,%r9,8), %rsi
leaq (%rdx,%rdx,2), %rax
movq %rax, 0x90(%rsp)
leaq (%r9,%r9,8), %rax
leaq (%rax,%rax,2), %rax
addq %r9, %rax
movq %rax, 0xa0(%rsp)
shlq $0x4, %r9
movq %rdx, 0xa8(%rsp)
leaq (%rdx,%rdx,4), %rbp
movq %rsi, 0x40(%rsp)
leaq (%rsi,%rsi,2), %rsi
movq %r12, %rcx
shlq $0x4, %rcx
xorl %edx, %edx
shlq $0x4, %r8
movq %r8, 0xb0(%rsp)
xorl %r8d, %r8d
movdqa 0xd0(%rsp), %xmm8
movdqa %xmm8, %xmm4
movdqa 0xc0(%rsp), %xmm9
movdqa %xmm9, %xmm5
movq %rdi, 0x80(%rsp)
movq %rbp, 0x30(%rsp)
movq %rbx, 0x38(%rsp)
movq 0xb0(%rsp), %rax
movdqa (%r14,%rax), %xmm7
movq 0x60(%rsp), %rax
movq 0x10(%rax), %rax
movq 0x68(%rsp), %rbx
movzbl (%rbx,%r8), %ebx
movslq (%rax,%rbx,4), %rbx
movl %r12d, %eax
imulq %rbx, %rax
shlq $0x4, %rax
pslldq $0x2, %xmm7             # xmm7 = zero,zero,xmm7[0,1,2,3,4,5,6,7,8,9,10,11,12,13]
movq %r8, 0x88(%rsp)
pinsrw $0x0, (%rdi,%r8,2), %xmm7
movq %r14, %r15
addq 0xb8(%rsp), %rax
movq %rdx, 0x28(%rsp)
movq %rdx, %r14
xorl %ebx, %ebx
movdqa %xmm8, %xmm0
movq 0x18(%rsp), %r8
movq 0xa8(%rsp), %rdi
movq 0x70(%rsp), %r11
movq 0xa0(%rsp), %rdx
paddsw (%rax,%rbx), %xmm7
movdqa (%r8,%rbx), %xmm6
movdqa %xmm6, %xmm1
pmaxsw %xmm0, %xmm1
pmaxsw %xmm7, %xmm1
movq 0x38(%rsp), %r10
movdqa %xmm1, (%r10,%rbx)
movq %r13, %r12
movq 0x10(%r13), %r13
movq (%r13), %r13
movq %r15, %r10
movd %xmm1, %r15d
movswl %r15w, %r15d
movl %r15d, (%r13,%r14)
addq %r14, %r13
pextrw $0x1, %xmm1, %r15d
movswl %r15w, %r15d
movl %r15d, (%rdi,%r13)
pextrw $0x2, %xmm1, %r15d
movswl %r15w, %r15d
movq 0x40(%rsp), %rbp
movl %r15d, (%rbp,%r13)
pextrw $0x3, %xmm1, %r15d
movswl %r15w, %r15d
movq 0x90(%rsp), %rbp
movl %r15d, (%rbp,%r13)
pextrw $0x4, %xmm1, %r15d
movswl %r15w, %r15d
movl %r15d, (%r9,%r13)
pextrw $0x5, %xmm1, %r15d
movswl %r15w, %r15d
movq 0x30(%rsp), %rbp
movl %r15d, (%rbp,%r13)
pextrw $0x6, %xmm1, %r15d
movswl %r15w, %r15d
movl %r15d, (%rsi,%r13)
pextrw $0x7, %xmm1, %r15d
movswl %r15w, %r15d
movl %r15d, (%rdx,%r13)
movq %r10, %r15
movq %r12, %r13
pmaxsw %xmm1, %xmm4
pminsw %xmm6, %xmm5
pminsw %xmm0, %xmm5
pminsw %xmm1, %xmm5
psubsw %xmm2, %xmm1
psubsw %xmm3, %xmm6
pmaxsw %xmm1, %xmm6
movdqa %xmm6, (%r8,%rbx)
psubsw %xmm3, %xmm0
pmaxsw %xmm1, %xmm0
movdqa (%r10,%rbx), %xmm7
addq $0x10, %rbx
addq %r11, %r14
cmpq %rbx, %rcx
jne 0x30ff43
movq 0x38(%rsp), %rax
movl $0x0, 0x14(%rsp)
movq %rdi, %r8
movq 0x30(%rsp), %rbp
movq %r15, 0x78(%rsp)
movq 0x80(%rsp), %rdi
movq 0x88(%rsp), %rbx
movswl 0x2(%rdi,%rbx,2), %ebx
movq 0x70(%rsp), %rdi
movq 0x78(%rsp), %r15
subl 0x4(%rsp), %ebx
cmpl $0xffff8001, %ebx       # imm = 0xFFFF8001
movl $0xffff8000, %r14d      # imm = 0xFFFF8000
cmovll %r14d, %ebx
pslldq $0x2, %xmm0             # xmm0 = zero,zero,xmm0[0,1,2,3,4,5,6,7,8,9,10,11,12,13]
pinsrw $0x0, %ebx, %xmm0
movq 0x28(%rsp), %rbx
xorl %r14d, %r14d
movq %r15, %r11
movdqa (%rax,%r14), %xmm1
pmaxsw %xmm0, %xmm1
movdqa %xmm1, (%rax,%r14)
pminsw %xmm1, %xmm5
pmaxsw %xmm1, %xmm4
movq 0x10(%r13), %r15
movq (%r15), %r13
movd %xmm1, %r15d
movswl %r15w, %r15d
movl %r15d, (%r13,%rbx)
addq %rbx, %r13
pextrw $0x1, %xmm1, %r15d
movswl %r15w, %r15d
movl %r15d, (%r8,%r13)
pextrw $0x2, %xmm1, %r15d
movswl %r15w, %r15d
movq 0x40(%rsp), %r10
movl %r15d, (%r10,%r13)
pextrw $0x3, %xmm1, %r15d
movswl %r15w, %r15d
movq 0x90(%rsp), %r10
movl %r15d, (%r10,%r13)
pextrw $0x4, %xmm1, %r15d
movswl %r15w, %r15d
movl %r15d, (%r9,%r13)
pextrw $0x5, %xmm1, %r15d
movswl %r15w, %r15d
movl %r15d, (%rbp,%r13)
pextrw $0x6, %xmm1, %r15d
movswl %r15w, %r15d
movl %r15d, (%rsi,%r13)
pextrw $0x7, %xmm1, %r15d
movswl %r15w, %r15d
movl %r15d, (%rdx,%r13)
movq %r12, %r13
psubsw %xmm2, %xmm1
psubsw %xmm3, %xmm0
movdqa %xmm0, %xmm6
pcmpgtw %xmm1, %xmm6
pmovmskb %xmm6, %r15d
testl %r15d, %r15d
movq %r11, %r15
je 0x310186
addq $0x10, %r14
addq %rdi, %rbx
cmpq %r14, %rcx
jne 0x3100a0
movl 0x14(%rsp), %edi
incl %edi
movl %edi, 0x14(%rsp)
cmpl $0x8, %edi
jne 0x31005b
movq 0x88(%rsp), %r8
incq %r8
movq 0x28(%rsp), %rdx
addq $0x4, %rdx
movq %r15, %rbx
cmpq 0x58(%rsp), %r8
movq %rax, %r14
movq 0x80(%rsp), %rdi
movq 0x20(%rsp), %r12
jne 0x30fec6
movl 0x54(%rsp), %eax
shlq $0x4, %rax
movdqa (%r14,%rax), %xmm0
cmpl $0x6, 0x10(%rsp)
jg 0x3101ed
xorl %eax, %eax
movl 0xc(%rsp), %ecx
movq 0x18(%rsp), %rbx
movl 0x8(%rsp), %edx
movl 0x50(%rsp), %esi
pslldq $0x2, %xmm0             # xmm0 = zero,zero,xmm0[0,1,2,3,4,5,6,7,8,9,10,11,12,13]
incl %eax
cmpl %esi, %eax
jl 0x3101e0
jmp 0x3101fa
movl 0xc(%rsp), %ecx
movq 0x18(%rsp), %rbx
movl 0x8(%rsp), %edx
pcmpgtw %xmm5, %xmm8
pcmpgtw %xmm9, %xmm4
por %xmm8, %xmm4
pmovmskb %xmm4, %eax
testl %eax, %eax
je 0x310232
orb $0x40, 0xc(%r13)
xorl %eax, %eax
xorl %edx, %edx
xorl %ecx, %ecx
jmp 0x310237
callq 0x1ae595
jmp 0x30f945
callq 0x1ae56f
jmp 0x30f945
pextrw $0x7, %xmm0, %eax
cwtl
movl %eax, (%r13)
movl %ecx, 0x4(%r13)
movl %edx, 0x8(%r13)
callq 0x20a60d
movq %rbx, %rdi
callq 0x20a60d
movq 0x78(%rsp), %rdi
callq 0x20a60d
movq %r14, %rdi
callq 0x20a60d
jmp 0x30f948
callq 0x1ae549
jmp 0x30f945
callq 0x1ae523
jmp 0x30f945
callq 0x1ae4fd
jmp 0x30f945
callq 0x1ae4d7
jmp 0x30f945
callq 0x1ae4b1
jmp 0x30f945
callq 0x1ae48b
jmp 0x30f945