// File: /workspace/github_c_makefile_star2_O2/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 $0xa8, %rsp
movq %rsi, 0x48(%rsp)
testq %rdi, %rdi
je 0x2f30ec
movq 0x30(%rdi), %rax
movq %rax, 0x78(%rsp)
testq %rax, %rax
je 0x2f3110
movq 0x10(%rdi), %rax
movq %rax, 0x70(%rsp)
testq %rax, %rax
je 0x2f3134
movl 0x8(%rdi), %eax
movq %rax, 0x68(%rsp)
testl %eax, %eax
jle 0x2f3158
cmpq $0x0, 0x48(%rsp)
je 0x2f317c
movl %edx, %r15d
testl %edx, %edx
jle 0x2f319d
movl %ecx, %r14d
testl %ecx, %ecx
js 0x2f31be
testl %r8d, %r8d
js 0x2f31df
movl %r9d, %ebx
movl %r8d, 0x34(%rsp)
movq 0x68(%rsp), %rcx
leal -0x1(%rcx), %eax
leaq 0x7(%rcx), %rdi
movq %rdi, %r12
shrq $0x3, %r12
movl %eax, 0x2c(%rsp)
xorl %edx, %edx
divl %r12d
movl %eax, 0x8(%rsp)
movl %edx, %ebp
movl %r14d, %esi
negl %esi
movq 0x70(%rsp), %rdx
movl 0x20(%rdx), %eax
movl %eax, %ecx
negl %ecx
movl %esi, 0x30(%rsp)
cmpl %esi, %eax
cmovgl %r14d, %ecx
movl %ecx, 0x4(%rsp)
movw $0x7ffe, %r13w          # imm = 0x7FFE
subw 0x1c(%rdx), %r13w
andl $0x7ffffff8, %edi       # imm = 0x7FFFFFF8
movl %r15d, %esi
callq 0x1ab93b
testq %rax, %rax
je 0x2f2c64
movl %r13d, 0x50(%rsp)
movl %r14d, 0x38(%rsp)
movl %ebp, 0x5c(%rsp)
xorl %edi, %edi
testl %ebx, %ebx
setne %dil
xorl %ecx, %ecx
cmpl $0x0, 0xe0(%rsp)
setne %cl
shll $0x4, %ecx
xorl %edx, %edx
cmpl $0x0, 0xe8(%rsp)
setne %dl
shll $0xe, %edx
movq %rax, %r8
xorl %esi, %esi
cmpl $0x0, 0xf0(%rsp)
setne %sil
shll $0xf, %esi
leal (%rcx,%rdi,8), %eax
orl %edx, %eax
orl %esi, %eax
orl 0xc(%r8), %eax
orl $0x8240402, %eax        # imm = 0x8240402
movq %r8, 0x18(%rsp)
movl %eax, 0xc(%r8)
pushq $0x10
popq %rbp
movq %rbp, %rdi
movq %r12, %rsi
callq 0x297cd8
movq %rax, %r14
movq %r15, 0x60(%rsp)
leal 0x1(%r15), %esi
movq %rbp, %rdi
movq %rsi, 0x40(%rsp)
callq 0x1ab77b
movq %rax, %r15
movq %rbp, %rdi
movq %r12, %rsi
callq 0x297cd8
movq %rax, %r13
movq %rbp, %rdi
movq %r12, %rsi
callq 0x297cd8
movq %rax, %rbp
pushq $0x10
popq %rdi
movq %r12, %rsi
callq 0x297cd8
movq %r14, %xmm0
movq %r15, 0x20(%rsp)
movq %r15, %xmm1
punpcklqdq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0]
movq %r13, %xmm1
movq %rbp, %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 %r15d, %r15d
testl %ecx, %ecx
jne 0x2f3208
testq %rax, %rax
je 0x2f3208
movq 0x60(%rsp), %rcx
decl %ecx
movl %ecx, 0x14(%rsp)
pushq $0x7
popq %rdx
subl 0x8(%rsp), %edx
movl 0x38(%rsp), %esi
movd %esi, %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]
movl 0x34(%rsp), %edi
movd %edi, %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 0x4(%rsp), %r15d
addl $0xffff8001, %r15d      # imm = 0xFFFF8001
movd %r15d, %xmm0
pshuflw $0x0, %xmm0, %xmm0      # xmm0 = xmm0[0,0,0,0,4,5,6,7]
pshufd $0x0, %xmm0, %xmm0      # xmm0 = xmm0[0,0,0,0]
movd 0x50(%rsp), %xmm1
pshuflw $0x0, %xmm1, %xmm1      # xmm1 = xmm1[0,0,0,0,4,5,6,7]
pshufd $0x0, %xmm1, %xmm1      # xmm1 = xmm1[0,0,0,0]
movd %edx, %xmm2
pshuflw $0x0, %xmm2, %xmm2      # xmm2 = xmm2[0,0,0,0,4,5,6,7]
pshufd $0x0, %xmm2, %xmm6      # xmm6 = xmm2[0,0,0,0]
movl %r15d, 0x4(%rsp)
movzwl %r15w, %ecx
movd %ecx, %xmm7
movl %r12d, %ecx
imull %edi, %ecx
negl %ecx
movd %ecx, %xmm2
pshuflw $0x0, %xmm2, %xmm2      # xmm2 = xmm2[0,0,0,0,4,5,6,7]
pshufd $0x0, %xmm2, %xmm8      # xmm8 = xmm2[0,0,0,0]
pslldq $0x2, %xmm8             # xmm8 = zero,zero,xmm8[0,1,2,3,4,5,6,7,8,9,10,11,12,13]
paddsw %xmm7, %xmm8
movl %esi, %esi
movl %edi, %ecx
movslq 0x30(%rsp), %rdi
movq %r12, %r9
movq %rcx, 0x50(%rsp)
imulq %rcx, %r9
xorl %r10d, %r10d
movq $-0x7fff, %r11          # imm = 0x8001
movq $-0x8000, %rcx          # imm = 0x8000
movq %r12, 0x38(%rsp)
cmpq %r12, %r10
je 0x2f2c6c
movq %rdi, 0x8(%rsp)
movq %rdi, %r12
xorl %edi, %edi
cmpq $0x8, %rdi
je 0x2f2c2a
testl %ebx, %ebx
je 0x2f2bf5
xorl %r8d, %r8d
jmp 0x2f2bf8
movq %r12, %r8
cmpq %r11, %r8
movq $-0x8000, %r15          # imm = 0x8000
cmovgeq %r8, %r15
subq %rsi, %r8
cmpq %r11, %r8
cmovlq %rcx, %r8
movw %r15w, 0x90(%rsp,%rdi,2)
movw %r8w, 0x80(%rsp,%rdi,2)
incq %rdi
subq %r9, %r12
jmp 0x2f2be6
movq %r10, %rdi
shlq $0x4, %rdi
movaps 0x90(%rsp), %xmm2
movaps %xmm2, (%rbp,%rdi)
movdqa 0x80(%rsp), %xmm2
movdqa %xmm2, (%r14,%rdi)
incq %r10
movq 0x8(%rsp), %rdi
subq 0x50(%rsp), %rdi
movq 0x38(%rsp), %r12
jmp 0x2f2bd3
xorl %r15d, %r15d
jmp 0x2f3208
movq 0x20(%rsp), %rcx
andw $0x0, (%rcx)
pushq $0x1
popq %rcx
xorl %esi, %esi
movq 0x60(%rsp), %r10
movl 0x34(%rsp), %r9d
movl 0x30(%rsp), %r11d
movl 0xe8(%rsp), %ebx
movq 0x20(%rsp), %r8
cmpq %rcx, 0x40(%rsp)
je 0x2f2cbe
cmpl $0xffff8001, %r11d      # imm = 0xFFFF8001
movl $0xffff8000, %edi       # imm = 0xFFFF8000
cmovgel %r11d, %edi
testl %ebx, %ebx
cmovnel %esi, %edi
movw %di, (%r8,%rcx,2)
incq %rcx
subl %r9d, %r11d
jmp 0x2f2c95
pxor %xmm3, %xmm3
psubsw %xmm4, %xmm3
leal -0x1(%r12), %ecx
movdqa %xmm1, %xmm2
movl %ecx, %esi
testl %esi, %esi
js 0x2f2cec
movl %esi, %edi
shlq $0x4, %rdi
movdqa %xmm3, (%rax,%rdi)
psubsw %xmm5, %xmm3
pminsw %xmm3, %xmm2
decl %esi
jmp 0x2f2cd1
movl %ecx, %r9d
shlq $0x4, %r9
addq %rbp, %r9
movl 0x5c(%rsp), %ecx
shlq $0x4, %rcx
addq %rbp, %rcx
movq %rcx, 0x40(%rsp)
movl %r10d, %r10d
movq %r12, %r8
shlq $0x4, %r8
xorl %r11d, %r11d
pcmpeqw 0x2d4d25(%rip), %xmm6   # 0x5c7a40
pushq $0x6
popq %rbx
movdqa %xmm0, %xmm3
movdqa %xmm0, %xmm9
movl 0x14(%rsp), %ecx
movl %ecx, 0x8(%rsp)
movq 0x18(%rsp), %rsi
cmpq %r10, %r11
je 0x2f2ed3
movdqa (%r9), %xmm12
pslldq $0x2, %xmm12            # xmm12 = zero,zero,xmm12[0,1,2,3,4,5,6,7,8,9,10,11,12,13]
movq 0x20(%rsp), %rcx
pinsrw $0x0, (%rcx,%r11,2), %xmm12
movq 0x70(%rsp), %rcx
movq 0x10(%rcx), %rcx
movq 0x48(%rsp), %rdi
movzbl (%rdi,%r11), %edi
movl (%rcx,%rdi,4), %ecx
imull %r12d, %ecx
movslq %ecx, %rcx
shlq $0x4, %rcx
addq 0x78(%rsp), %rcx
movdqa %xmm0, %xmm10
psubsw (%rax), %xmm10
xorl %edi, %edi
movdqa %xmm0, %xmm11
cmpq %rdi, %r8
je 0x2f2de4
movdqa (%rbp,%rdi), %xmm13
movdqa (%r14,%rdi), %xmm14
psubsw %xmm5, %xmm14
movdqa %xmm13, %xmm15
psubsw %xmm4, %xmm15
paddsw (%rcx,%rdi), %xmm12
paddsw (%rax,%rdi), %xmm10
pmaxsw %xmm14, %xmm15
pmaxsw %xmm10, %xmm11
pmaxsw %xmm15, %xmm12
movdqa %xmm15, (%r14,%rdi)
movdqa %xmm12, (%r13,%rdi)
addq $0x10, %rdi
movdqa %xmm12, %xmm10
movdqa %xmm13, %xmm12
jmp 0x2f2d8b
pslldq $0x2, %xmm10            # xmm10 = zero,zero,xmm10[0,1,2,3,4,5,6,7,8,9,10,11,12,13]
leaq 0x1(%r11), %r15
movq 0x20(%rsp), %rcx
pinsrw $0x0, 0x2(%rcx,%r11,2), %xmm10
movdqa (%rax), %xmm12
paddsw %xmm10, %xmm12
pmaxsw %xmm12, %xmm11
movl %ebx, %ecx
movdqa %xmm11, %xmm12
pslldq $0x2, %xmm12            # xmm12 = zero,zero,xmm12[0,1,2,3,4,5,6,7,8,9,10,11,12,13]
subl $0x1, %ecx
jb 0x2f2e28
paddsw %xmm8, %xmm12
pmaxsw %xmm12, %xmm11
jmp 0x2f2e0c
paddsw %xmm7, %xmm12
pmaxsw %xmm12, %xmm10
xorl %ecx, %ecx
cmpq %rcx, %r8
je 0x2f2e70
psubsw %xmm5, %xmm12
psubsw %xmm4, %xmm10
pmaxsw %xmm10, %xmm12
movdqa (%r13,%rcx), %xmm10
pmaxsw %xmm12, %xmm10
movdqa %xmm10, (%rbp,%rcx)
pminsw %xmm12, %xmm2
pminsw %xmm10, %xmm2
pmaxsw %xmm10, %xmm3
addq $0x10, %rcx
jmp 0x2f2e34
movq 0x40(%rsp), %rcx
movdqa (%rcx), %xmm10
movdqa %xmm10, %xmm11
pcmpgtw %xmm9, %xmm11
pand %xmm6, %xmm11
pmovmskb %xmm11, %ecx
xorl %edi, %edi
movdqa %xmm10, %xmm11
cmpl %edx, %edi
jge 0x2f2ea3
pslldq $0x2, %xmm11            # xmm11 = zero,zero,xmm11[0,1,2,3,4,5,6,7,8,9,10,11,12,13]
incl %edi
jmp 0x2f2e95
testw %cx, %cx
movl 0x8(%rsp), %ecx
cmovnel %r11d, %ecx
movl %ecx, 0x8(%rsp)
pmaxsw %xmm10, %xmm9
pextrw $0x7, %xmm11, %ecx
movswl %cx, %ecx
movq 0x10(%rsi), %rdi
movq (%rdi), %rdi
movl %ecx, (%rdi,%r11,4)
movq %r15, %r11
jmp 0x2f2d34
leal (,%r12,4), %r9d
imulq $0x1c, %r12, %rcx
movq %rcx, 0x48(%rsp)
imulq $0x18, %r12, %rcx
imulq $0x14, %r12, %r11
imulq $0xc, %r12, %rbx
movq %r12, %r15
shlq $0x3, %r15
xorl %r12d, %r12d
cmpq %r12, %r9
je 0x2f2f91
movdqa (%rbp,%r12,4), %xmm4
movq 0x10(%rsi), %rdi
movq 0x8(%rdi), %rdi
movd %xmm4, %esi
movswl %si, %esi
movl %esi, (%rdi,%r12)
pextrw $0x1, %xmm4, %esi
addq %r12, %rdi
movswl %si, %esi
pextrw $0x2, %xmm4, %r10d
movl %esi, (%r9,%rdi)
movswl %r10w, %esi
pextrw $0x3, %xmm4, %r10d
movl %esi, (%r15,%rdi)
movswl %r10w, %esi
pextrw $0x4, %xmm4, %r10d
movl %esi, (%rbx,%rdi)
movswl %r10w, %esi
pextrw $0x5, %xmm4, %r10d
movl %esi, (%r8,%rdi)
movswl %r10w, %esi
pextrw $0x6, %xmm4, %r10d
movl %esi, (%r11,%rdi)
movswl %r10w, %esi
pextrw $0x7, %xmm4, %r10d
movl %esi, (%rcx,%rdi)
movswl %r10w, %esi
movq 0x48(%rsp), %r10
movl %esi, (%r10,%rdi)
movq 0x18(%rsp), %rsi
addq $0x4, %r12
jmp 0x2f2efa
movl 0xf0(%rsp), %r12d
testl %r12d, %r12d
movl 0x2c(%rsp), %r8d
movq 0x68(%rsp), %rbx
movq 0x38(%rsp), %r15
je 0x2f2fc7
xorl %ecx, %ecx
cmpl %edx, %ecx
jge 0x2f2fbd
pslldq $0x2, %xmm9             # xmm9 = zero,zero,xmm9[0,1,2,3,4,5,6,7,8,9,10,11,12,13]
incl %ecx
jmp 0x2f2faf
pextrw $0x7, %xmm9, %ecx
movl %ecx, 0x4(%rsp)
cmpl $0x0, 0xe0(%rsp)
je 0x2f3045
movl %r15d, %r9d
andl $0xfffffff, %r9d        # imm = 0xFFFFFFF
shll $0x3, %r9d
xorl %r10d, %r10d
cmpl %r10d, %r9d
je 0x2f3045
movl %r10d, %esi
shrl $0x3, %esi
movl %r10d, %ecx
andl $0x7, %ecx
imull %r15d, %ecx
addl %esi, %ecx
cmpl %ebx, %ecx
jge 0x2f303b
movzwl (%rbp,%r10,2), %edi
movl 0x4(%rsp), %esi
cmpw %si, %di
jle 0x2f301f
movl %edi, %esi
movl %esi, 0x4(%rsp)
movl 0x14(%rsp), %esi
movl %esi, 0x8(%rsp)
movl %ecx, %r8d
jmp 0x2f303b
cmpl %r8d, %ecx
cmovgel %r8d, %ecx
movl 0x8(%rsp), %r11d
cmpl 0x14(%rsp), %r11d
cmovnel %r8d, %ecx
cmpw %si, %di
cmovel %ecx, %r8d
movq 0x18(%rsp), %rsi
incq %r10
jmp 0x2f2fe2
orl 0xe0(%rsp), %r12d
jne 0x2f307d
movq 0x40(%rsp), %rcx
movdqa (%rcx), %xmm4
xorl %ecx, %ecx
movl 0x2c(%rsp), %r8d
cmpl %edx, %ecx
jge 0x2f306c
pslldq $0x2, %xmm4             # xmm4 = zero,zero,xmm4[0,1,2,3,4,5,6,7,8,9,10,11,12,13]
incl %ecx
jmp 0x2f305f
pextrw $0x7, %xmm4, %ecx
movl %ecx, 0x4(%rsp)
movl 0x14(%rsp), %ecx
movl %ecx, 0x8(%rsp)
pcmpgtw %xmm2, %xmm0
pcmpgtw %xmm1, %xmm3
por %xmm0, %xmm3
pmovmskb %xmm3, %ecx
testl %ecx, %ecx
je 0x2f30a8
orb $0x40, 0xc(%rsi)
movl $0x0, 0x4(%rsp)
movl $0x0, 0x8(%rsp)
xorl %r8d, %r8d
movswl 0x4(%rsp), %ecx
movl %ecx, (%rsi)
movl %r8d, 0x4(%rsi)
movl 0x8(%rsp), %ecx
movl %ecx, 0x8(%rsi)
movq %rax, %rdi
movq %rsi, %r15
callq 0x1ab763
movq %rbp, %rdi
callq 0x1ab763
movq %r13, %rdi
callq 0x1ab763
movq 0x20(%rsp), %rdi
callq 0x1ab763
movq %r14, %rdi
callq 0x1ab763
jmp 0x2f3208
movq 0x447ee5(%rip), %rax    # 0x73afd8
movq (%rax), %rdi
leaq 0x2d3eee(%rip), %rsi    # 0x5c6feb
leaq 0x2d5d98(%rip), %rdx    # 0x5c8e9c
leaq 0x2aa3d2(%rip), %rcx    # 0x59d4dd
jmp 0x2f31fe
movq 0x447ec1(%rip), %rax    # 0x73afd8
movq (%rax), %rdi
leaq 0x2d3eca(%rip), %rsi    # 0x5c6feb
leaq 0x2d5d74(%rip), %rdx    # 0x5c8e9c
leaq 0x2d48ef(%rip), %rcx    # 0x5c7a1e
jmp 0x2f31fe
movq 0x447e9d(%rip), %rax    # 0x73afd8
movq (%rax), %rdi
leaq 0x2d3ea6(%rip), %rsi    # 0x5c6feb
leaq 0x2d5d50(%rip), %rdx    # 0x5c8e9c
leaq 0x2d47e6(%rip), %rcx    # 0x5c7939
jmp 0x2f31fe
movq 0x447e79(%rip), %rax    # 0x73afd8
movq (%rax), %rdi
leaq 0x2d4598(%rip), %rsi    # 0x5c7701
leaq 0x2d5d2c(%rip), %rdx    # 0x5c8e9c
leaq 0x2d47d2(%rip), %rcx    # 0x5c7949
jmp 0x2f31fe
movq 0x447e55(%rip), %rax    # 0x73afd8
movq (%rax), %rdi
leaq 0x2d3e5e(%rip), %rsi    # 0x5c6feb
leaq 0x2d5d08(%rip), %rdx    # 0x5c8e9c
leaq 0x2d4563(%rip), %rcx    # 0x5c76fe
jmp 0x2f31fe
movq 0x447e34(%rip), %rax    # 0x73afd8
movq (%rax), %rdi
leaq 0x2d4553(%rip), %rsi    # 0x5c7701
leaq 0x2d5ce7(%rip), %rdx    # 0x5c8e9c
leaq 0x2d4559(%rip), %rcx    # 0x5c7715
jmp 0x2f31fe
movq 0x447e13(%rip), %rax    # 0x73afd8
movq (%rax), %rdi
leaq 0x2d454c(%rip), %rsi    # 0x5c771b
leaq 0x2d5cc6(%rip), %rdx    # 0x5c8e9c
leaq 0x2d4553(%rip), %rcx    # 0x5c7730
jmp 0x2f31fe
movq 0x447df2(%rip), %rax    # 0x73afd8
movq (%rax), %rdi
leaq 0x2d452b(%rip), %rsi    # 0x5c771b
leaq 0x2d5ca5(%rip), %rdx    # 0x5c8e9c
leaq 0x2d4537(%rip), %rcx    # 0x5c7735
xorl %r15d, %r15d
xorl %eax, %eax
callq 0x19e180
movq %r15, %rax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq