// File: /workspace/github_c_makefile_star2_O3/nh13[P]ksw/src/parasail/src/sg_scan_sse2_128_16.c
// Function: parasail_sg_flags_rowcol_scan_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,
        int s1_beg, int s1_end, int s2_beg, int s2_end)
{
    /* declare local variables */
    int32_t i = 0;
    int32_t j = 0;
    int32_t k = 0;
    int32_t end_query = 0;
    int32_t end_ref = 0;
    int32_t s1Len = 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 pvP = NULL;
    __m128i* restrict pvE = NULL;
    int16_t* restrict boundary = NULL;
    __m128i* restrict pvHt = NULL;
    __m128i* restrict pvH = NULL;
    __m128i* restrict pvGapper = NULL;
    __m128i vGapO;
    __m128i vGapE;
    int16_t NEG_LIMIT = 0;
    int16_t POS_LIMIT = 0;
    __m128i vZero;
    int16_t score = 0;
    __m128i vNegLimit;
    __m128i vPosLimit;
    __m128i vSaturationCheckMin;
    __m128i vSaturationCheckMax;
    __m128i vMaxH;
    __m128i vPosMask;
    __m128i vNegInfFront;
    __m128i 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 = 8; /* number of values in vector unit */
    segLen = (s1Len + segWidth - 1) / segWidth;
    offset = (s1Len - 1) % segLen;
    position = (segWidth - 1) - (s1Len - 1) / segLen;
    pvP = (__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;
    vZero = _mm_setzero_si128();
    score = NEG_LIMIT;
    vNegLimit = _mm_set1_epi16(NEG_LIMIT);
    vPosLimit = _mm_set1_epi16(POS_LIMIT);
    vSaturationCheckMin = vPosLimit;
    vSaturationCheckMax = vNegLimit;
    vMaxH = vNegLimit;
    vPosMask = _mm_cmpeq_epi16(_mm_set1_epi16(position),
            _mm_set_epi16(0,1,2,3,4,5,6,7));
    vNegInfFront = vZero;
    vNegInfFront = _mm_insert_epi16(vNegInfFront, NEG_LIMIT, 0);
    vSegLenXgap = _mm_adds_epi16(vNegInfFront,
            _mm_slli_si128(_mm_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_SG | PARASAIL_FLAG_SCAN
        | PARASAIL_FLAG_BITS_16 | PARASAIL_FLAG_LANES_8;
    result->flag |= s1_beg ? PARASAIL_FLAG_SG_S1_BEG : 0;
    result->flag |= s1_end ? PARASAIL_FLAG_SG_S1_END : 0;
    result->flag |= s2_beg ? PARASAIL_FLAG_SG_S2_BEG : 0;
    result->flag |= s2_end ? PARASAIL_FLAG_SG_S2_END : 0;
#ifdef PARASAIL_TABLE
    result->flag |= PARASAIL_FLAG_TABLE;
#endif
#ifdef PARASAIL_ROWCOL
    result->flag |= PARASAIL_FLAG_ROWCOL;
#endif

    /* initialize heap variables */
    pvE = parasail_memalign___m128i(16, segLen);
    boundary = parasail_memalign_int16_t(16, s2Len+1);
    pvHt= parasail_memalign___m128i(16, segLen);
    pvH = parasail_memalign___m128i(16, segLen);
    pvGapper = parasail_memalign___m128i(16, 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;
            __m128i_16_t h;
            __m128i_16_t e;
            for (segNum=0; segNum<segWidth; ++segNum) {
                int64_t tmp = s1_beg ? 0 : (-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(&pvH[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 = s2_beg ? 0 : (-open-gap*(i-1));
            boundary[i] = tmp < INT16_MIN ? INT16_MIN : tmp;
        }
    }

    {
        __m128i vGapper = _mm_subs_epi16(vZero,vGapO);
        for (i=segLen-1; i>=0; --i) {
            _mm_store_si128(pvGapper+i, vGapper);
            vGapper = _mm_subs_epi16(vGapper, vGapE);
            /* long queries and/or large penalties will break the pseudo prefix scan */
            vSaturationCheckMin = _mm_min_epi16(vSaturationCheckMin, vGapper);
        }
    }

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

        /* calculate E */
        /* calculate Ht */
        /* calculate F and H first pass */
        vHp = _mm_load_si128(pvH+(segLen-1));
        vHp = _mm_slli_si128(vHp, 2);
        vHp = _mm_insert_epi16(vHp, boundary[j], 0);
        pvW = pvP + matrix->mapper[(unsigned char)s2[j]]*segLen;
        vHt = _mm_subs_epi16(vNegLimit, pvGapper[0]);
        vF = vNegLimit;
        for (i=0; i<segLen; ++i) {
            vH = _mm_load_si128(pvH+i);
            vE = _mm_load_si128(pvE+i);
            vW = _mm_load_si128(pvW+i);
            vE = _mm_max_epi16(
                    _mm_subs_epi16(vE, vGapE),
                    _mm_subs_epi16(vH, vGapO));
            vHp = _mm_adds_epi16(vHp, vW);
            vF = _mm_max_epi16(vF, _mm_adds_epi16(vHt, pvGapper[i]));
            vHt = _mm_max_epi16(vE, vHp);
            _mm_store_si128(pvE+i, vE);
            _mm_store_si128(pvHt+i, vHt);
            vHp = vH;
        }

        /* pseudo prefix scan on F and H */
        vHt = _mm_slli_si128(vHt, 2);
        vHt = _mm_insert_epi16(vHt, boundary[j+1], 0);
        vF = _mm_max_epi16(vF, _mm_adds_epi16(vHt, pvGapper[0]));
        for (i=0; i<segWidth-2; ++i) {
            __m128i vFt = _mm_slli_si128(vF, 2);
            vFt = _mm_adds_epi16(vFt, vSegLenXgap);
            vF = _mm_max_epi16(vF, vFt);
        }

        /* calculate final H */
        vF = _mm_slli_si128(vF, 2);
        vF = _mm_adds_epi16(vF, vNegInfFront);
        vH = _mm_max_epi16(vHt, vF);
        for (i=0; i<segLen; ++i) {
            vHt = _mm_load_si128(pvHt+i);
            vF = _mm_max_epi16(
                    _mm_subs_epi16(vF, vGapE),
                    _mm_subs_epi16(vH, vGapO));
            vH = _mm_max_epi16(vHt, vF);
            _mm_store_si128(pvH+i, vH);
            vSaturationCheckMin = _mm_min_epi16(vSaturationCheckMin, vH);
            vSaturationCheckMin = _mm_min_epi16(vSaturationCheckMin, vF);
            vSaturationCheckMax = _mm_max_epi16(vSaturationCheckMax, vH);
#ifdef PARASAIL_TABLE
            arr_store_si128(result->tables->score_table, vH, i, segLen, j, s2Len);
#endif
        } 

        /* extract vector containing last value from column */
        {
            __m128i vCompare;
            vH = _mm_load_si128(pvH + offset);
            vCompare = _mm_and_si128(vPosMask, _mm_cmpgt_epi16(vH, vMaxH));
            vMaxH = _mm_max_epi16(vH, vMaxH);
            if (_mm_movemask_epi8(vCompare)) {
                end_ref = j;
            }
#ifdef PARASAIL_ROWCOL
            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(pvH + i);
        arr_store_col(result->rowcols->score_col, vH, i, segLen);
    }
#endif

    /* max last value from all columns */
    if (s2_end)
    {
        for (k=0; k<position; ++k) {
            vMaxH = _mm_slli_si128(vMaxH, 2);
        }
        score = (int16_t) _mm_extract_epi16(vMaxH, 7);
        end_query = s1Len-1;
    }

    /* max of last column */
    if (s1_end)
    {
        /* Trace the alignment ending position on read. */
        int16_t *t = (int16_t*)pvH;
        int32_t column_len = segLen * segWidth;
        for (i = 0; i<column_len; ++i, ++t) {
            int32_t temp = i / segWidth + i % segWidth * segLen;
            if (temp >= s1Len) continue;
            if (*t > score) {
                score = *t;
                end_query = temp;
                end_ref = s2Len-1;
            }
            else if (*t == score && end_ref == s2Len-1 && temp < end_query) {
                end_query = temp;
            }
        }
    }

    if (!s1_end && !s2_end) {
        /* extract last value from the last column */
        {
            __m128i vH = _mm_load_si128(pvH + offset);
            for (k=0; k<position; ++k) {
                vH = _mm_slli_si128(vH, 2);
            }
            score = (int16_t) _mm_extract_epi16 (vH, 7);
            end_ref = s2Len - 1;
            end_query = s1Len - 1;
        }
    }

    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(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 $0x118, %rsp            # imm = 0x118
movq %rdx, 0x40(%rsp)
movq %rsi, 0x78(%rsp)
testq %rdi, %rdi
je 0x352dca
movq 0x30(%rdi), %rax
movq %rax, 0xa8(%rsp)
testq %rax, %rax
je 0x352dd1
movq 0x10(%rdi), %rax
movq %rax, 0x70(%rsp)
testq %rax, %rax
je 0x352dd8
movl %ecx, %r13d
movl 0x8(%rdi), %ecx
testl %ecx, %ecx
jle 0x352ddf
cmpq $0x0, 0x78(%rsp)
je 0x352de6
cmpl $0x0, 0x40(%rsp)
jle 0x352ded
testl %r13d, %r13d
js 0x352df4
testl %r8d, %r8d
js 0x352dfb
movl %r9d, %ebp
movq %r8, 0x68(%rsp)
leal -0x1(%rcx), %eax
movq %rcx, 0xa0(%rsp)
leaq 0x7(%rcx), %rbx
movq %rbx, %r12
shrq $0x3, %r12
movl %eax, 0x3c(%rsp)
xorl %edx, %edx
divl %r12d
movl %eax, 0x10(%rsp)
movl %edx, %r14d
movl %r13d, %esi
negl %esi
movq 0x70(%rsp), %rdx
movl 0x20(%rdx), %eax
movl %eax, %ecx
negl %ecx
movq %rsi, 0x60(%rsp)
cmpl %esi, %eax
cmovgl %r13d, %ecx
movl %ecx, 0x14(%rsp)
movw $0x7ffe, %ax            # imm = 0x7FFE
subw 0x1c(%rdx), %ax
movl %eax, 0x8(%rsp)
andl $0x7ffffff8, %ebx       # imm = 0x7FFFFFF8
movl %ebx, %edi
movq 0x40(%rsp), %r15
movl %r15d, %esi
callq 0x20ac53
testq %rax, %rax
je 0x352e00
movl %r13d, 0x50(%rsp)
movl %r14d, 0x34(%rsp)
movq %rbx, 0x98(%rsp)
movl 0x160(%rsp), %r8d
xorl %edi, %edi
testl %ebp, %ebp
setne %dil
xorl %ecx, %ecx
cmpl $0x0, 0x150(%rsp)
setne %cl
shll $0x4, %ecx
xorl %edx, %edx
cmpl $0x0, 0x158(%rsp)
setne %dl
shll $0xe, %edx
xorl %esi, %esi
movl %r8d, 0x38(%rsp)
testl %r8d, %r8d
setne %sil
shll $0xf, %esi
leal (%rcx,%rdi,8), %ecx
orl %edx, %ecx
orl %esi, %ecx
orl 0xc(%rax), %ecx
orl $0x8240402, %ecx        # imm = 0x8240402
movq %rax, 0x20(%rsp)
movl %ecx, 0xc(%rax)
movl $0x10, %edi
movq %r12, %rsi
callq 0x2f600c
movq %rax, %r14
leal 0x1(%r15), %esi
movl $0x10, %edi
callq 0x20a625
movq %rax, %rbx
movl $0x10, %edi
movq %r12, %rsi
callq 0x2f600c
movq %rax, %r13
movl $0x10, %edi
movq %r12, %rsi
callq 0x2f600c
movq %rax, %r15
movl $0x10, %edi
movq %r12, 0x18(%rsp)
movq %r12, %rsi
callq 0x2f600c
movq %r14, %xmm0
movq %rbx, 0x28(%rsp)
movq %rbx, %xmm1
punpcklqdq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0]
movq %r13, %xmm1
movq %r15, %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, %ecx
xorl %ebx, %ebx
testl %ecx, %ecx
jne 0x352e02
testq %rax, %rax
je 0x352e02
movq 0x40(%rsp), %rcx
decl %ecx
movl %ecx, 0xc(%rsp)
movl $0x7, %edx
subl 0x10(%rsp), %edx
movl 0x50(%rsp), %esi
movd %esi, %xmm0
movdqa %xmm0, 0x80(%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]
movq 0x68(%rsp), %rdi
movd %edi, %xmm1
pshuflw $0x0, %xmm1, %xmm0      # xmm0 = xmm1[0,0,0,0,4,5,6,7]
pshufd $0x0, %xmm0, %xmm3      # xmm3 = xmm0[0,0,0,0]
movl 0x14(%rsp), %ecx
addl $0xffff8001, %ecx       # imm = 0xFFFF8001
movd %ecx, %xmm0
pshuflw $0x0, %xmm0, %xmm0      # xmm0 = xmm0[0,0,0,0,4,5,6,7]
pshufd $0x0, %xmm0, %xmm4      # xmm4 = xmm0[0,0,0,0]
movd 0x8(%rsp), %xmm0
pshuflw $0x0, %xmm0, %xmm0      # xmm0 = xmm0[0,0,0,0,4,5,6,7]
pshufd $0x0, %xmm0, %xmm5      # xmm5 = xmm0[0,0,0,0]
movl %edx, 0x8(%rsp)
movd %edx, %xmm0
pshuflw $0x0, %xmm0, %xmm0      # xmm0 = xmm0[0,0,0,0,4,5,6,7]
pshufd $0x0, %xmm0, %xmm7      # xmm7 = xmm0[0,0,0,0]
movl %ecx, 0x14(%rsp)
movzwl %cx, %ecx
movd %ecx, %xmm8
movq 0x18(%rsp), %r9
movl %r9d, %ecx
imull %edi, %ecx
negl %ecx
movd %ecx, %xmm0
pshuflw $0x0, %xmm0, %xmm0      # xmm0 = xmm0[0,0,0,0,4,5,6,7]
pshufd $0x0, %xmm0, %xmm6      # xmm6 = xmm0[0,0,0,0]
pslldq $0x2, %xmm6             # xmm6 = zero,zero,xmm6[0,1,2,3,4,5,6,7,8,9,10,11,12,13]
paddsw %xmm8, %xmm6
movl %esi, %esi
movl %edi, %ecx
movslq 0x60(%rsp), %r12
movq %rcx, 0x50(%rsp)
imulq %rcx, %r9
xorl %r10d, %r10d
movq $-0x7fff, %r11          # imm = 0x8001
movq $-0x8000, %rcx          # imm = 0x8000
movq %r12, %rbx
xorl %edi, %edi
testl %ebp, %ebp
je 0x35251a
xorl %r8d, %r8d
jmp 0x35251d
movq %rbx, %r8
cmpq %r11, %r8
movq $-0x8000, %rdx          # imm = 0x8000
cmovgeq %r8, %rdx
movw %dx, 0x100(%rsp,%rdi,2)
subq %rsi, %r8
cmpq %r11, %r8
cmovlq %rcx, %r8
movw %r8w, 0xf0(%rsp,%rdi,2)
incq %rdi
subq %r9, %rbx
cmpq $0x8, %rdi
jne 0x352511
movq %r10, %rdx
shlq $0x4, %rdx
movaps 0x100(%rsp), %xmm0
movaps %xmm0, (%r15,%rdx)
movdqa 0xf0(%rsp), %xmm0
movdqa %xmm0, (%r14,%rdx)
incq %r10
subq 0x50(%rsp), %r12
cmpq 0x18(%rsp), %r10
jne 0x35250c
movdqa %xmm8, 0xb0(%rsp)
movdqa %xmm7, 0xc0(%rsp)
movdqa %xmm5, 0xd0(%rsp)
movdqa %xmm4, 0xe0(%rsp)
movq 0x28(%rsp), %rdx
movw $0x0, (%rdx)
movq 0x40(%rsp), %rbp
movl %ebp, %ecx
addl $0x7, %ebp
andl $-0x8, %ebp
movq %rcx, 0x90(%rsp)
decq %rcx
movq %rcx, %xmm0
pshufd $0x44, %xmm0, %xmm8     # xmm8 = xmm0[0,1,0,1]
movq 0x60(%rsp), %rbx
movd %ebx, %xmm0
movdqa %xmm0, 0x50(%rsp)
pshufd $0x0, %xmm0, %xmm0      # xmm0 = xmm0[0,0,0,0]
movdqa %xmm0, 0x40(%rsp)
pshufd $0x0, %xmm1, %xmm11     # xmm11 = xmm1[0,0,0,0]
movq 0x68(%rsp), %r12
movl %r12d, %edi
negl %edi
leal (,%r12,8), %r8d
leal (%r12,%r12,2), %r9d
negl %r9d
addl %r12d, %r12d
xorl %r10d, %r10d
movdqa 0x2d6883(%rip), %xmm1   # 0x628ea0
pxor %xmm1, %xmm8
pcmpeqd %xmm5, %xmm5
movdqa 0x2d74e1(%rip), %xmm13  # 0x629b10
xorl %r11d, %r11d
movq %r11, %xmm0
pshufd $0x44, %xmm0, %xmm14    # xmm14 = xmm0[0,1,0,1]
movdqa %xmm14, %xmm0
por 0x2d6846(%rip), %xmm0   # 0x628e90
pxor %xmm1, %xmm0
movdqa %xmm0, %xmm7
pcmpgtd %xmm8, %xmm7
pshufd $0xa0, %xmm7, %xmm12    # xmm12 = xmm7[0,0,2,2]
pshuflw $0xe8, %xmm12, %xmm15   # xmm15 = xmm12[0,2,2,3,4,5,6,7]
pcmpeqd %xmm8, %xmm0
pshufd $0xf5, %xmm0, %xmm4     # xmm4 = xmm0[1,1,3,3]
pshuflw $0xe8, %xmm4, %xmm10    # xmm10 = xmm4[0,2,2,3,4,5,6,7]
pand %xmm15, %xmm10
pshufd $0xf5, %xmm7, %xmm7     # xmm7 = xmm7[1,1,3,3]
pshuflw $0xe8, %xmm7, %xmm0     # xmm0 = xmm7[0,2,2,3,4,5,6,7]
por %xmm10, %xmm0
pxor %xmm5, %xmm0
packssdw %xmm0, %xmm0
movd %edi, %xmm10
punpckldq 0x50(%rsp), %xmm10 # xmm10 = xmm10[0],mem[0],xmm10[1],mem[1]
movd %r12d, %xmm15
movdqa 0x80(%rsp), %xmm9
punpckldq %xmm15, %xmm9   # xmm9 = xmm9[0],xmm15[0],xmm9[1],xmm15[1]
psubd %xmm9, %xmm10
leal (%r9,%rbx), %ecx
movq %rbx, %rsi
movd %ebx, %xmm9
movd %ecx, %xmm15
shufps $0xd4, %xmm10, %xmm15   # xmm15 = xmm15[0,1],xmm10[1,3]
punpckldq %xmm9, %xmm10   # xmm10 = xmm10[0],xmm9[0],xmm10[1],xmm9[1]
shufps $0x21, %xmm15, %xmm10   # xmm10 = xmm10[1,0],xmm15[2,0]
movaps %xmm10, %xmm15
pcmpgtd %xmm13, %xmm15
andps %xmm15, %xmm10
pandn %xmm13, %xmm15
por %xmm10, %xmm15
movd %xmm0, %ecx
testb $0x1, %cl
movl 0x158(%rsp), %ebx
je 0x35270c
testl %ebx, %ebx
movd %xmm15, %ecx
cmovnel %r10d, %ecx
movw %cx, 0x2(%rdx,%r11,2)
pand %xmm12, %xmm4
por %xmm7, %xmm4
packssdw %xmm4, %xmm4
pxor %xmm5, %xmm4
packssdw %xmm4, %xmm4
movd %xmm4, %ecx
shrl $0x10, %ecx
testb $0x1, %cl
je 0x35273f
pextrw $0x2, %xmm15, %ecx
testl %ebx, %ebx
cmovnel %r10d, %ecx
movw %cx, 0x4(%rdx,%r11,2)
movdqa %xmm14, %xmm4
por 0x2d6734(%rip), %xmm4   # 0x628e80
pxor %xmm1, %xmm4
movdqa %xmm4, %xmm7
pcmpgtd %xmm8, %xmm7
pshufd $0xa0, %xmm7, %xmm0     # xmm0 = xmm7[0,0,2,2]
pcmpeqd %xmm8, %xmm4
pshufd $0xf5, %xmm4, %xmm4     # xmm4 = xmm4[1,1,3,3]
movdqa %xmm4, %xmm9
pand %xmm0, %xmm9
pshufd $0xf5, %xmm7, %xmm7     # xmm7 = xmm7[1,1,3,3]
por %xmm7, %xmm9
packssdw %xmm9, %xmm9
pxor %xmm5, %xmm9
packssdw %xmm9, %xmm9
pextrw $0x2, %xmm9, %ecx
testb $0x1, %cl
je 0x3527a8
pextrw $0x4, %xmm15, %ecx
testl %ebx, %ebx
cmovnel %r10d, %ecx
movw %cx, 0x6(%rdx,%r11,2)
pshufhw $0x84, %xmm0, %xmm0     # xmm0 = xmm0[0,1,2,3,4,5,4,6]
pshufhw $0x84, %xmm4, %xmm4     # xmm4 = xmm4[0,1,2,3,4,5,4,6]
pand %xmm0, %xmm4
pshufhw $0x84, %xmm7, %xmm0     # xmm0 = xmm7[0,1,2,3,4,5,4,6]
por %xmm4, %xmm0
pxor %xmm5, %xmm0
packssdw %xmm0, %xmm0
pextrw $0x3, %xmm0, %ecx
testb $0x1, %cl
je 0x3527e3
pextrw $0x6, %xmm15, %ecx
testl %ebx, %ebx
cmovnel %r10d, %ecx
movw %cx, 0x8(%rdx,%r11,2)
movdqa %xmm14, %xmm4
por 0x2d66e0(%rip), %xmm4   # 0x628ed0
movd %r11d, %xmm0
pshufd $0x0, %xmm0, %xmm0      # xmm0 = xmm0[0,0,0,0]
por 0x2d72fe(%rip), %xmm0   # 0x629b00
pshufd $0xf5, %xmm0, %xmm7     # xmm7 = xmm0[1,1,3,3]
pmuludq %xmm11, %xmm0
pshufd $0xe8, %xmm0, %xmm0     # xmm0 = xmm0[0,2,2,3]
pshufd $0xf5, %xmm11, %xmm9    # xmm9 = xmm11[1,1,3,3]
pmuludq %xmm7, %xmm9
pshufd $0xe8, %xmm9, %xmm7     # xmm7 = xmm9[0,2,2,3]
punpckldq %xmm7, %xmm0    # xmm0 = xmm0[0],xmm7[0],xmm0[1],xmm7[1]
movdqa 0x40(%rsp), %xmm7
psubd %xmm0, %xmm7
movdqa %xmm7, %xmm15
pcmpgtd %xmm13, %xmm15
pand %xmm15, %xmm7
pandn %xmm13, %xmm15
por %xmm7, %xmm15
pxor %xmm1, %xmm4
movdqa %xmm4, %xmm9
pcmpgtd %xmm8, %xmm9
pshufd $0xa0, %xmm9, %xmm7     # xmm7 = xmm9[0,0,2,2]
pshuflw $0xe8, %xmm7, %xmm10    # xmm10 = xmm7[0,2,2,3,4,5,6,7]
pcmpeqd %xmm8, %xmm4
pshufd $0xf5, %xmm4, %xmm0     # xmm0 = xmm4[1,1,3,3]
pshuflw $0xe8, %xmm0, %xmm12    # xmm12 = xmm0[0,2,2,3,4,5,6,7]
pand %xmm10, %xmm12
pshufd $0xf5, %xmm9, %xmm4     # xmm4 = xmm9[1,1,3,3]
pshuflw $0xe8, %xmm4, %xmm9     # xmm9 = xmm4[0,2,2,3,4,5,6,7]
por %xmm12, %xmm9
pxor %xmm5, %xmm9
packssdw %xmm9, %xmm9
pextrw $0x4, %xmm9, %ecx
testb $0x1, %cl
je 0x3528af
testl %ebx, %ebx
movd %xmm15, %ecx
cmovnel %r10d, %ecx
movw %cx, 0xa(%rdx,%r11,2)
pand %xmm7, %xmm0
por %xmm4, %xmm0
packssdw %xmm0, %xmm0
pxor %xmm5, %xmm0
packssdw %xmm0, %xmm0
pextrw $0x5, %xmm0, %ecx
testb $0x1, %cl
je 0x3528df
pextrw $0x2, %xmm15, %ecx
testl %ebx, %ebx
cmovnel %r10d, %ecx
movw %cx, 0xc(%rdx,%r11,2)
por 0x2d65d8(%rip), %xmm14  # 0x628ec0
pxor %xmm1, %xmm14
movdqa %xmm14, %xmm7
pcmpgtd %xmm8, %xmm7
pshufd $0xa0, %xmm7, %xmm0     # xmm0 = xmm7[0,0,2,2]
pcmpeqd %xmm8, %xmm14
pshufd $0xf5, %xmm14, %xmm4    # xmm4 = xmm14[1,1,3,3]
movdqa %xmm4, %xmm9
pand %xmm0, %xmm9
pshufd $0xf5, %xmm7, %xmm7     # xmm7 = xmm7[1,1,3,3]
por %xmm7, %xmm9
packssdw %xmm9, %xmm9
pxor %xmm5, %xmm9
packssdw %xmm9, %xmm9
pextrw $0x6, %xmm9, %ecx
testb $0x1, %cl
je 0x352947
pextrw $0x4, %xmm15, %ecx
testl %ebx, %ebx
cmovnel %r10d, %ecx
movw %cx, 0xe(%rdx,%r11,2)
pshufhw $0x84, %xmm0, %xmm0     # xmm0 = xmm0[0,1,2,3,4,5,4,6]
pshufhw $0x84, %xmm4, %xmm4     # xmm4 = xmm4[0,1,2,3,4,5,4,6]
pand %xmm0, %xmm4
pshufhw $0x84, %xmm7, %xmm0     # xmm0 = xmm7[0,1,2,3,4,5,4,6]
por %xmm4, %xmm0
pxor %xmm5, %xmm0
packssdw %xmm0, %xmm0
pextrw $0x7, %xmm0, %ecx
testb $0x1, %cl
je 0x352982
pextrw $0x6, %xmm15, %ecx
testl %ebx, %ebx
cmovnel %r10d, %ecx
movw %cx, 0x10(%rdx,%r11,2)
addq $0x8, %r11
subl %r8d, %edi
movq %rsi, %rbx
subl %r8d, %ebx
addl %r8d, %r12d
cmpq %r11, %rbp
jne 0x352632
pxor %xmm1, %xmm1
psubsw %xmm2, %xmm1
movq 0x18(%rsp), %rdx
leal -0x1(%rdx), %r10d
shlq $0x4, %r10
movq %rax, %rcx
addq %r10, %rcx
movl %edx, %edi
movdqa 0xd0(%rsp), %xmm12
movdqa %xmm12, %xmm7
movdqa %xmm1, (%rcx)
psubsw %xmm3, %xmm1
pminsw %xmm1, %xmm7
addq $-0x10, %rcx
decl %edi
jg 0x3529c7
addq %r15, %r10
movl 0x34(%rsp), %r11d
movq %r11, 0x80(%rsp)
shlq $0x4, %r11
addq %r15, %r11
movq %rdx, %r9
shlq $0x4, %r9
xorl %ebp, %ebp
movdqa 0xc0(%rsp), %xmm13
pcmpeqw 0x2d7132(%rip), %xmm13  # 0x629b40
movl %edx, %ebx
movl 0xc(%rsp), %edi
movdqa 0xe0(%rsp), %xmm11
movdqa %xmm11, %xmm5
movdqa %xmm11, %xmm8
movq 0x20(%rsp), %r8
movdqa 0xb0(%rsp), %xmm14
movq 0x90(%rsp), %rsi
movq %rbp, %r12
movdqa (%r10), %xmm4
pslldq $0x2, %xmm4             # xmm4 = zero,zero,xmm4[0,1,2,3,4,5,6,7,8,9,10,11,12,13]
movq 0x28(%rsp), %rcx
pinsrw $0x0, (%rcx,%rbp,2), %xmm4
movdqa %xmm5, %xmm1
movq 0x70(%rsp), %rcx
movq 0x10(%rcx), %rcx
movq 0x78(%rsp), %rdx
movzbl (%rdx,%rbp), %edx
movslq (%rcx,%rdx,4), %rcx
imulq %rbx, %rcx
shlq $0x4, %rcx
addq 0xa8(%rsp), %rcx
movdqa %xmm11, %xmm5
psubsw (%rax), %xmm5
xorl %ebp, %ebp
movdqa %xmm11, %xmm9
movdqa (%r15,%rbp), %xmm0
movdqa (%r14,%rbp), %xmm10
paddsw (%rcx,%rbp), %xmm4
paddsw (%rax,%rbp), %xmm5
psubsw %xmm3, %xmm10
pmaxsw %xmm5, %xmm9
movdqa %xmm4, %xmm5
movdqa %xmm0, %xmm4
psubsw %xmm2, %xmm0
pmaxsw %xmm10, %xmm0
pmaxsw %xmm0, %xmm5
movdqa %xmm0, (%r14,%rbp)
movdqa %xmm5, (%r13,%rbp)
addq $0x10, %rbp
cmpq %rbp, %r9
jne 0x352a91
pslldq $0x2, %xmm5             # xmm5 = zero,zero,xmm5[0,1,2,3,4,5,6,7,8,9,10,11,12,13]
leaq 0x1(%r12), %rbp
movq 0x28(%rsp), %rcx
pinsrw $0x0, 0x2(%rcx,%r12,2), %xmm5
movdqa (%rax), %xmm0
paddsw %xmm5, %xmm0
pmaxsw %xmm0, %xmm9
movl $0x6, %ecx
movl 0x8(%rsp), %edx
movdqa %xmm9, %xmm0
pslldq $0x2, %xmm9             # xmm9 = zero,zero,xmm9[0,1,2,3,4,5,6,7,8,9,10,11,12,13]
paddsw %xmm6, %xmm9
pmaxsw %xmm0, %xmm9
decl %ecx
jne 0x352b09
pslldq $0x2, %xmm9             # xmm9 = zero,zero,xmm9[0,1,2,3,4,5,6,7,8,9,10,11,12,13]
paddsw %xmm14, %xmm9
pmaxsw %xmm9, %xmm5
xorl %ecx, %ecx
psubsw %xmm3, %xmm9
psubsw %xmm2, %xmm5
pmaxsw %xmm5, %xmm9
movdqa (%r13,%rcx), %xmm5
pmaxsw %xmm9, %xmm5
movdqa %xmm5, (%r15,%rcx)
pminsw %xmm9, %xmm7
pminsw %xmm5, %xmm7
pmaxsw %xmm5, %xmm8
addq $0x10, %rcx
cmpq %rcx, %r9
jne 0x352b34
movdqa (%r11), %xmm5
movdqa %xmm5, %xmm0
pcmpgtw %xmm1, %xmm0
pand %xmm13, %xmm0
pmovmskb %xmm0, %ecx
testl %ecx, %ecx
cmovnel %r12d, %edi
movdqa %xmm5, %xmm0
cmpl $0x6, 0x10(%rsp)
jg 0x352ba3
xorl %ecx, %ecx
movdqa %xmm5, %xmm0
pslldq $0x2, %xmm0             # xmm0 = zero,zero,xmm0[0,1,2,3,4,5,6,7,8,9,10,11,12,13]
incl %ecx
cmpl %edx, %ecx
jl 0x352b98
pmaxsw %xmm1, %xmm5
pextrw $0x7, %xmm0, %ecx
movswl %cx, %ecx
movq 0x10(%r8), %rdx
movq (%rdx), %rdx
movl %ecx, (%rdx,%r12,4)
cmpq %rsi, %rbp
jne 0x352a3f
movq 0x18(%rsp), %rdx
leal (,%rdx,4), %esi
leaq (%rdx,%rdx,8), %rcx
leaq (%rcx,%rcx,2), %r10
addq %rdx, %r10
leaq (,%rdx,8), %rcx
leaq (%rcx,%rcx,2), %r11
shll $0x2, %edx
leaq (%rdx,%rdx,4), %rbx
leaq (%rdx,%rdx,2), %r12
xorl %ebp, %ebp
movdqa (%r15,%rbp,4), %xmm0
movq 0x10(%r8), %rdx
movq 0x8(%rdx), %r8
movd %xmm0, %edx
movswl %dx, %edx
movl %edx, (%r8,%rbp)
addq %rbp, %r8
pextrw $0x1, %xmm0, %edx
movswl %dx, %edx
movl %edx, (%rsi,%r8)
pextrw $0x2, %xmm0, %edx
movswl %dx, %edx
movl %edx, (%rcx,%r8)
pextrw $0x3, %xmm0, %edx
movswl %dx, %edx
movl %edx, (%r12,%r8)
pextrw $0x4, %xmm0, %edx
movswl %dx, %edx
movl %edx, (%r9,%r8)
pextrw $0x5, %xmm0, %edx
movswl %dx, %edx
movl %edx, (%rbx,%r8)
pextrw $0x6, %xmm0, %edx
movswl %dx, %edx
movl %edx, (%r11,%r8)
pextrw $0x7, %xmm0, %edx
movswl %dx, %edx
movl %edx, (%r10,%r8)
movq 0x20(%rsp), %r8
addq $0x4, %rbp
cmpq %rbp, %rsi
jne 0x352bf3
cmpl $0x0, 0x160(%rsp)
movl 0x3c(%rsp), %r11d
movq 0xa0(%rsp), %rbx
movl 0x14(%rsp), %ebp
movq 0x18(%rsp), %r12
movl 0x8(%rsp), %edx
je 0x352cae
cmpl $0x6, 0x10(%rsp)
jg 0x352ca9
xorl %ecx, %ecx
pslldq $0x2, %xmm5             # xmm5 = zero,zero,xmm5[0,1,2,3,4,5,6,7,8,9,10,11,12,13]
incl %ecx
cmpl %edx, %ecx
jl 0x352c9e
pextrw $0x7, %xmm5, %ebp
cmpl $0x0, 0x150(%rsp)
je 0x352d28
cmpl $0x0, 0x98(%rsp)
je 0x352d28
movl %r12d, %r9d
andl $0xfffffff, %r9d        # imm = 0xFFFFFFF
shll $0x3, %r9d
xorl %r10d, %r10d
movl %r11d, %esi
movl %r10d, %edx
shrl $0x3, %edx
movl %r10d, %ecx
andl $0x7, %ecx
imull %r12d, %ecx
addl %edx, %ecx
cmpl %ebx, %ecx
jge 0x352d1a
movzwl (%r15,%r10,2), %r8d
cmpw %bp, %r8w
jle 0x352d02
movl %r8d, %ebp
movl 0xc(%rsp), %edi
movl %ecx, %esi
jmp 0x352d15
cmpl %esi, %ecx
cmovgel %esi, %ecx
cmpl 0xc(%rsp), %edi
cmovnel %esi, %ecx
cmpw %bp, %r8w
cmovel %ecx, %esi
movq 0x20(%rsp), %r8
movl 0x8(%rsp), %edx
incq %r10
cmpl %r10d, %r9d
jne 0x352cd6
jmp 0x352d2b
movl %r11d, %esi
movl 0x150(%rsp), %ecx
orl %ecx, 0x38(%rsp)
jne 0x352d6a
movq 0x80(%rsp), %rcx
shlq $0x4, %rcx
movdqa (%r15,%rcx), %xmm0
cmpl $0x6, 0x10(%rsp)
jg 0x352d5e
xorl %ecx, %ecx
pslldq $0x2, %xmm0             # xmm0 = zero,zero,xmm0[0,1,2,3,4,5,6,7,8,9,10,11,12,13]
incl %ecx
cmpl %edx, %ecx
jl 0x352d53
pextrw $0x7, %xmm0, %ebp
movl 0xc(%rsp), %edi
movl %r11d, %esi
pcmpgtw %xmm7, %xmm11
pcmpgtw %xmm12, %xmm8
por %xmm11, %xmm8
pmovmskb %xmm8, %ecx
testl %ecx, %ecx
je 0x352d8d
orb $0x40, 0xc(%r8)
xorl %ebp, %ebp
xorl %edi, %edi
xorl %esi, %esi
movswl %bp, %ecx
movl %ecx, (%r8)
movl %esi, 0x4(%r8)
movl %edi, 0x8(%r8)
movq %rax, %rdi
movq %r8, %rbx
callq 0x20a60d
movq %r15, %rdi
callq 0x20a60d
movq %r13, %rdi
callq 0x20a60d
movq 0x28(%rsp), %rdi
callq 0x20a60d
movq %r14, %rdi
callq 0x20a60d
jmp 0x352e02
callq 0x1b48cb
jmp 0x352e00
callq 0x1b48a5
jmp 0x352e00
callq 0x1b487f
jmp 0x352e00
callq 0x1b4859
jmp 0x352e00
callq 0x1b4833
jmp 0x352e00
callq 0x1b480d
jmp 0x352e00
callq 0x1b47e7
jmp 0x352e00
callq 0x1b47c1
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq