// File: /workspace/github_c_makefile_star2_O3/nh13[P]ksw/src/parasail/src/sg_trace_scan_sse2_128_16.c
// Function: parasail_sg_flags_trace_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 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 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;
    __m128i vTIns;
    __m128i vTDel;
    __m128i vTDiag;
    __m128i vTDiagE;
    __m128i vTInsE;
    __m128i vTDiagF;
    __m128i vTDelF;

    /* 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));
    vTIns  = _mm_set1_epi16(PARASAIL_INS);
    vTDel  = _mm_set1_epi16(PARASAIL_DEL);
    vTDiag = _mm_set1_epi16(PARASAIL_DIAG);
    vTDiagE= _mm_set1_epi16(PARASAIL_DIAG_E);
    vTInsE = _mm_set1_epi16(PARASAIL_INS_E);
    vTDiagF= _mm_set1_epi16(PARASAIL_DIAG_F);
    vTDelF = _mm_set1_epi16(PARASAIL_DEL_F);

    /* initialize result */
    result = parasail_result_new_trace(segLen, s2Len, 16, sizeof(__m128i));
    if (!result) return NULL;

    /* set known flags */
    result->flag |= PARASAIL_FLAG_SG | PARASAIL_FLAG_SCAN
        | PARASAIL_FLAG_TRACE
        | 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;

    /* 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 vE_ext;
        __m128i vE_opn;
        __m128i vHt;
        __m128i vF;
        __m128i vF_ext;
        __m128i vF_opn;
        __m128i vH;
        __m128i vHp;
        __m128i *pvW;
        __m128i vW;
        __m128i case1;
        __m128i case2;
        __m128i vGapper;
        __m128i vT;
        __m128i vET;
        __m128i vFT;

        /* 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);
            vGapper = _mm_load_si128(pvGapper+i);
            vE_opn = _mm_subs_epi16(vH, vGapO);
            vE_ext = _mm_subs_epi16(vE, vGapE);
            case1 = _mm_cmpgt_epi16(vE_opn, vE_ext);
            vET = _mm_blendv_epi8_rpl(vTInsE, vTDiagE, case1);
            arr_store(result->trace->trace_table, vET, i, segLen, j);
            vE = _mm_max_epi16(vE_opn, vE_ext);
            vSaturationCheckMin = _mm_min_epi16(vSaturationCheckMin, vE);
            vGapper = _mm_adds_epi16(vHt, vGapper);
            vF = _mm_max_epi16(vF, vGapper);
            vHp = _mm_adds_epi16(vHp, vW);
            vHt = _mm_max_epi16(vE, vHp);
            _mm_store_si128(pvE+i, vE);
            _mm_store_si128(pvHt+i, vHt);
            _mm_store_si128(pvH+i, vHp);
            vHp = vH;
        }

        /* pseudo prefix scan on F and H */
        vHt = _mm_slli_si128(vHt, 2);
        vHt = _mm_insert_epi16(vHt, boundary[j+1], 0);
        vGapper = _mm_load_si128(pvGapper);
        vGapper = _mm_adds_epi16(vHt, vGapper);
        vF = _mm_max_epi16(vF, vGapper);
        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(vF, vHt);
        for (i=0; i<segLen; ++i) {
            vET = arr_load(result->trace->trace_table, i, segLen, j);
            vHp = _mm_load_si128(pvH+i);
            vHt = _mm_load_si128(pvHt+i);
            vF_opn = _mm_subs_epi16(vH, vGapO);
            vF_ext = _mm_subs_epi16(vF, vGapE);
            vF = _mm_max_epi16(vF_opn, vF_ext);
            case1 = _mm_cmpgt_epi16(vF_opn, vF_ext);
            vFT = _mm_blendv_epi8_rpl(vTDelF, vTDiagF, case1);
            vH = _mm_max_epi16(vHt, vF);
            case1 = _mm_cmpeq_epi16(vH, vHp);
            case2 = _mm_cmpeq_epi16(vH, vF);
            vT = _mm_blendv_epi8_rpl(
                    _mm_blendv_epi8_rpl(vTIns, vTDel, case2),
                    vTDiag, case1);
            vT = _mm_or_si128(vT, vET);
            vT = _mm_or_si128(vT, vFT);
            arr_store(result->trace->trace_table, vT, i, segLen, j);
            _mm_store_si128(pvH+i, vH);
            vSaturationCheckMin = _mm_min_epi16(vSaturationCheckMin, vH);
            vSaturationCheckMin = _mm_min_epi16(vSaturationCheckMin, vF);
            vSaturationCheckMax = _mm_max_epi16(vSaturationCheckMax, vH);
        }

        /* 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;
            }
        }
    } 

    /* 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 $0x128, %rsp            # imm = 0x128
movq %rsi, 0x88(%rsp)
testq %rdi, %rdi
je 0x3a74a1
movq 0x30(%rdi), %rax
movq %rax, 0xc8(%rsp)
testq %rax, %rax
je 0x3a74a8
movq 0x10(%rdi), %rax
movq %rax, 0x80(%rsp)
testq %rax, %rax
je 0x3a74af
movl %ecx, %r14d
movl 0x8(%rdi), %ecx
testl %ecx, %ecx
jle 0x3a74b6
cmpq $0x0, 0x88(%rsp)
je 0x3a74bd
movl %edx, %r15d
testl %edx, %edx
jle 0x3a74c4
testl %r14d, %r14d
js 0x3a74cb
testl %r8d, %r8d
js 0x3a74d2
movl %r9d, %r12d
movq %r8, 0x70(%rsp)
leal -0x1(%rcx), %eax
movq %rcx, 0xc0(%rsp)
leaq 0x7(%rcx), %rbx
movq %rbx, %r13
shrq $0x3, %r13
movl %eax, 0x8(%rsp)
xorl %edx, %edx
divl %r13d
movl %eax, 0x10(%rsp)
movl %edx, %ebp
movl %r14d, %esi
negl %esi
movq 0x80(%rsp), %rdx
movl 0x20(%rdx), %eax
movl %eax, %ecx
negl %ecx
movq %rsi, 0x68(%rsp)
cmpl %esi, %eax
cmovgl %r14d, %ecx
movl %ecx, 0x14(%rsp)
movw $0x7ffe, %ax            # imm = 0x7FFE
subw 0x1c(%rdx), %ax
movl %eax, 0x50(%rsp)
movl $0x10, %edx
movl $0x10, %ecx
movl %r13d, %edi
movl %r15d, %esi
callq 0x20adf4
testq %rax, %rax
je 0x3a74d7
movl %r14d, 0x18(%rsp)
movl %ebp, 0x38(%rsp)
movq %rbx, 0xb0(%rsp)
movl 0x170(%rsp), %edi
xorl %r8d, %r8d
testl %r12d, %r12d
setne %r8b
xorl %ecx, %ecx
cmpl $0x0, 0x160(%rsp)
setne %cl
shll $0x4, %ecx
xorl %edx, %edx
cmpl $0x0, 0x168(%rsp)
setne %dl
shll $0xe, %edx
xorl %esi, %esi
movl %edi, 0x3c(%rsp)
testl %edi, %edi
setne %sil
shll $0xf, %esi
leal (%rcx,%r8,8), %ecx
orl %edx, %ecx
orl %esi, %ecx
orl 0xc(%rax), %ecx
orl $0x8280402, %ecx        # imm = 0x8280402
movq %rax, 0xb8(%rsp)
movl %ecx, 0xc(%rax)
movl $0x10, %edi
movq %r13, %rsi
callq 0x2f600c
movq %rax, %r14
movq %r15, 0x40(%rsp)
leal 0x1(%r15), %esi
movl $0x10, %edi
callq 0x20a625
movq %rax, %rbx
movl $0x10, %edi
movq %r13, %rsi
callq 0x2f600c
movq %rax, %r15
movl $0x10, %edi
movq %r13, %rsi
callq 0x2f600c
movq %rax, %rbp
movl $0x10, %edi
movq %r13, 0x28(%rsp)
movq %r13, %rsi
callq 0x2f600c
movq %r14, 0x30(%rsp)
movq %r14, %xmm0
movq %rbx, %xmm1
punpcklqdq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0]
movq %r15, %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 %edx, %edx
testl %ecx, %ecx
jne 0x3a74d9
testq %rax, %rax
je 0x3a74d9
movq %rbx, 0x78(%rsp)
movq 0x40(%rsp), %rcx
decl %ecx
movl %ecx, 0xc(%rsp)
movl $0x7, %edx
subl 0x10(%rsp), %edx
movl 0x18(%rsp), %r8d
movd %r8d, %xmm0
movdqa %xmm0, 0xa0(%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 0x70(%rsp), %rsi
movd %esi, %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, %xmm0      # xmm0 = xmm0[0,0,0,0]
movdqa %xmm0, 0x90(%rsp)
movd 0x50(%rsp), %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]
movdqa %xmm0, 0xd0(%rsp)
movl %edx, 0x24(%rsp)
movd %edx, %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]
movdqa %xmm0, 0x50(%rsp)
movl %ecx, 0x14(%rsp)
movzwl %cx, %ecx
movd %ecx, %xmm4
movq 0x28(%rsp), %rdi
movl %edi, %ecx
imull %esi, %ecx
negl %ecx
movd %ecx, %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]
pslldq $0x2, %xmm0             # xmm0 = zero,zero,xmm0[0,1,2,3,4,5,6,7,8,9,10,11,12,13]
movdqa %xmm4, 0xf0(%rsp)
paddsw %xmm4, %xmm0
movdqa %xmm0, 0xe0(%rsp)
movl %r8d, %ecx
movl %esi, %edx
movslq 0x68(%rsp), %r13
movq %rdx, 0x18(%rsp)
imulq %rdx, %rdi
xorl %r8d, %r8d
movq $-0x7fff, %r9           # imm = 0x8001
movq $-0x8000, %r10          # imm = 0x8000
movq 0xb8(%rsp), %r14
movq %r13, %rdx
xorl %esi, %esi
testl %r12d, %r12d
je 0x3a6bd3
xorl %r11d, %r11d
jmp 0x3a6bd6
movq %rdx, %r11
cmpq %r9, %r11
movq $-0x8000, %rbx          # imm = 0x8000
cmovgeq %r11, %rbx
movw %bx, 0x110(%rsp,%rsi,2)
subq %rcx, %r11
cmpq %r9, %r11
cmovlq %r10, %r11
movw %r11w, 0x100(%rsp,%rsi,2)
incq %rsi
subq %rdi, %rdx
cmpq $0x8, %rsi
jne 0x3a6bc9
movq %r8, %rdx
shlq $0x4, %rdx
movaps 0x110(%rsp), %xmm0
movaps %xmm0, (%rbp,%rdx)
movdqa 0x100(%rsp), %xmm0
movq 0x30(%rsp), %rsi
movdqa %xmm0, (%rsi,%rdx)
incq %r8
subq 0x18(%rsp), %r13
cmpq 0x28(%rsp), %r8
jne 0x3a6bc4
movq %r14, %rbx
movq 0x78(%rsp), %r14
movw $0x0, (%r14)
movq 0x40(%rsp), %r12
movl %r12d, %ecx
addl $0x7, %r12d
andl $-0x8, %r12d
movq %rcx, 0x18(%rsp)
decq %rcx
movq %rcx, %xmm0
pshufd $0x44, %xmm0, %xmm8     # xmm8 = xmm0[0,1,0,1]
movq 0x68(%rsp), %r13
movd %r13d, %xmm0
movdqa %xmm0, %xmm6
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 0x70(%rsp), %rdx
movl %edx, %edi
negl %edi
leal (,%rdx,8), %r8d
leal (%rdx,%rdx,2), %r9d
negl %r9d
addl %edx, %edx
xorl %r10d, %r10d
movdqa 0x2821ea(%rip), %xmm1   # 0x628ea0
pxor %xmm1, %xmm8
pcmpeqd %xmm5, %xmm5
movdqa 0x282e48(%rip), %xmm12  # 0x629b10
xorl %r11d, %r11d
movq 0x28(%rsp), %rsi
movq %r11, %xmm0
pshufd $0x44, %xmm0, %xmm13    # xmm13 = xmm0[0,1,0,1]
movdqa %xmm13, %xmm0
por 0x2821a8(%rip), %xmm0   # 0x628e90
pxor %xmm1, %xmm0
movdqa %xmm0, %xmm7
pcmpgtd %xmm8, %xmm7
pshufd $0xa0, %xmm7, %xmm4     # xmm4 = xmm7[0,0,2,2]
pshuflw $0xe8, %xmm4, %xmm14    # xmm14 = xmm4[0,2,2,3,4,5,6,7]
pcmpeqd %xmm8, %xmm0
pshufd $0xf5, %xmm0, %xmm15    # xmm15 = xmm0[1,1,3,3]
pshuflw $0xe8, %xmm15, %xmm10   # xmm10 = xmm15[0,2,2,3,4,5,6,7]
pand %xmm14, %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 %xmm6, %xmm10   # xmm10 = xmm10[0],xmm6[0],xmm10[1],xmm6[1]
movd %edx, %xmm14
movdqa 0xa0(%rsp), %xmm9
punpckldq %xmm14, %xmm9   # xmm9 = xmm9[0],xmm14[0],xmm9[1],xmm14[1]
psubd %xmm9, %xmm10
leal (%r9,%r13), %ecx
movd %r13d, %xmm9
movd %ecx, %xmm14
shufps $0xd4, %xmm10, %xmm14   # xmm14 = xmm14[0,1],xmm10[1,3]
punpckldq %xmm9, %xmm10   # xmm10 = xmm10[0],xmm9[0],xmm10[1],xmm9[1]
shufps $0x21, %xmm14, %xmm10   # xmm10 = xmm10[1,0],xmm14[2,0]
movaps %xmm10, %xmm14
pcmpgtd %xmm12, %xmm14
andps %xmm14, %xmm10
pandn %xmm12, %xmm14
por %xmm10, %xmm14
movd %xmm0, %ecx
testb $0x1, %cl
je 0x3a6da4
cmpl $0x0, 0x168(%rsp)
movd %xmm14, %ecx
cmovnel %r10d, %ecx
movw %cx, 0x2(%r14,%r11,2)
pand %xmm4, %xmm15
por %xmm7, %xmm15
packssdw %xmm15, %xmm15
pxor %xmm5, %xmm15
packssdw %xmm15, %xmm15
movd %xmm15, %ecx
shrl $0x10, %ecx
testb $0x1, %cl
je 0x3a6de2
pextrw $0x2, %xmm14, %ecx
cmpl $0x0, 0x168(%rsp)
cmovnel %r10d, %ecx
movw %cx, 0x4(%r14,%r11,2)
movdqa %xmm13, %xmm4
por 0x282091(%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 0x3a6e51
pextrw $0x4, %xmm14, %ecx
cmpl $0x0, 0x168(%rsp)
cmovnel %r10d, %ecx
movw %cx, 0x6(%r14,%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 0x3a6e92
pextrw $0x6, %xmm14, %ecx
cmpl $0x0, 0x168(%rsp)
cmovnel %r10d, %ecx
movw %cx, 0x8(%r14,%r11,2)
movdqa %xmm13, %xmm0
por 0x282031(%rip), %xmm0   # 0x628ed0
movd %r11d, %xmm4
pshufd $0x0, %xmm4, %xmm4      # xmm4 = xmm4[0,0,0,0]
por 0x282c4f(%rip), %xmm4   # 0x629b00
pshufd $0xf5, %xmm4, %xmm7     # xmm7 = xmm4[1,1,3,3]
pmuludq %xmm11, %xmm4
pshufd $0xe8, %xmm4, %xmm4     # xmm4 = xmm4[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, %xmm4    # xmm4 = xmm4[0],xmm7[0],xmm4[1],xmm7[1]
movdqa 0x40(%rsp), %xmm7
psubd %xmm4, %xmm7
movdqa %xmm7, %xmm14
pcmpgtd %xmm12, %xmm14
pand %xmm14, %xmm7
pandn %xmm12, %xmm14
por %xmm7, %xmm14
pxor %xmm1, %xmm0
movdqa %xmm0, %xmm7
pcmpgtd %xmm8, %xmm7
pshufd $0xa0, %xmm7, %xmm4     # xmm4 = xmm7[0,0,2,2]
pshuflw $0xe8, %xmm4, %xmm9     # xmm9 = xmm4[0,2,2,3,4,5,6,7]
pcmpeqd %xmm8, %xmm0
pshufd $0xf5, %xmm0, %xmm0     # xmm0 = xmm0[1,1,3,3]
pshuflw $0xe8, %xmm0, %xmm10    # xmm10 = xmm0[0,2,2,3,4,5,6,7]
pand %xmm9, %xmm10
pshufd $0xf5, %xmm7, %xmm7     # xmm7 = xmm7[1,1,3,3]
pshuflw $0xe8, %xmm7, %xmm9     # xmm9 = xmm7[0,2,2,3,4,5,6,7]
por %xmm10, %xmm9
pxor %xmm5, %xmm9
packssdw %xmm9, %xmm9
pextrw $0x4, %xmm9, %ecx
testb $0x1, %cl
je 0x3a6f61
cmpl $0x0, 0x168(%rsp)
movd %xmm14, %ecx
cmovnel %r10d, %ecx
movw %cx, 0xa(%r14,%r11,2)
pand %xmm4, %xmm0
por %xmm7, %xmm0
packssdw %xmm0, %xmm0
pxor %xmm5, %xmm0
packssdw %xmm0, %xmm0
pextrw $0x5, %xmm0, %ecx
testb $0x1, %cl
je 0x3a6f97
pextrw $0x2, %xmm14, %ecx
cmpl $0x0, 0x168(%rsp)
cmovnel %r10d, %ecx
movw %cx, 0xc(%r14,%r11,2)
por 0x281f20(%rip), %xmm13  # 0x628ec0
pxor %xmm1, %xmm13
movdqa %xmm13, %xmm7
pcmpgtd %xmm8, %xmm7
pshufd $0xa0, %xmm7, %xmm0     # xmm0 = xmm7[0,0,2,2]
pcmpeqd %xmm8, %xmm13
pshufd $0xf5, %xmm13, %xmm4    # xmm4 = xmm13[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 0x3a7005
pextrw $0x4, %xmm14, %ecx
cmpl $0x0, 0x168(%rsp)
cmovnel %r10d, %ecx
movw %cx, 0xe(%r14,%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 0x3a7046
pextrw $0x6, %xmm14, %ecx
cmpl $0x0, 0x168(%rsp)
cmovnel %r10d, %ecx
movw %cx, 0x10(%r14,%r11,2)
addq $0x8, %r11
subl %r8d, %edi
subl %r8d, %r13d
addl %r8d, %edx
cmpq %r11, %r12
jne 0x3a6cd0
pxor %xmm0, %xmm0
psubsw %xmm2, %xmm0
leal -0x1(%rsi), %r9d
shlq $0x4, %r9
movq %rax, %rcx
addq %r9, %rcx
movl %esi, %edx
movdqa 0xd0(%rsp), %xmm7
movdqa %xmm0, (%rcx)
psubsw %xmm3, %xmm0
pminsw %xmm0, %xmm7
addq $-0x10, %rcx
decl %edx
jg 0x3a707d
addq %rbp, %r9
movl 0x38(%rsp), %r10d
movq %r10, 0x40(%rsp)
shlq $0x4, %r10
addq %rbp, %r10
movq %rsi, %r11
shlq $0x4, %r11
xorl %r12d, %r12d
movl %esi, %r13d
movdqa 0x282e86(%rip), %xmm5   # 0x629f40
movdqa 0x28475d(%rip), %xmm10  # 0x62b820
movdqa 0x284764(%rip), %xmm11  # 0x62b830
movdqa 0x28476b(%rip), %xmm12  # 0x62b840
movdqa 0x50(%rsp), %xmm0
pcmpeqw 0x282a5d(%rip), %xmm0   # 0x629b40
movdqa %xmm0, 0x50(%rsp)
xorl %edi, %edi
movl 0xc(%rsp), %r8d
movdqa 0x90(%rsp), %xmm0
movdqa %xmm0, %xmm8
movdqa %xmm0, %xmm4
movdqa %xmm4, 0xa0(%rsp)
movdqa (%r9), %xmm15
pslldq $0x2, %xmm15            # xmm15 = zero,zero,xmm15[0,1,2,3,4,5,6,7,8,9,10,11,12,13]
pinsrw $0x0, (%r14,%rdi,2), %xmm15
movq 0x80(%rsp), %rcx
movq 0x10(%rcx), %rcx
movq 0x88(%rsp), %rdx
movzbl (%rdx,%rdi), %edx
movslq (%rcx,%rdx,4), %rcx
imulq %r13, %rcx
shlq $0x4, %rcx
addq 0xc8(%rsp), %rcx
movdqa 0x90(%rsp), %xmm14
movdqa %xmm14, %xmm13
psubsw (%rax), %xmm13
xorl %edx, %edx
movq 0x30(%rsp), %r14
movdqa %xmm5, %xmm9
movdqa 0x28468f(%rip), %xmm5   # 0x62b800
movdqa (%rbp,%rdx), %xmm4
movdqa (%r14,%rdx), %xmm1
movdqa %xmm4, %xmm6
psubsw %xmm2, %xmm6
psubsw %xmm3, %xmm1
movdqa %xmm6, %xmm0
pcmpgtw %xmm1, %xmm0
pand %xmm5, %xmm0
pxor %xmm9, %xmm0
movq 0x10(%rbx), %rsi
movq (%rsi), %rsi
addq %r12, %rsi
paddsw (%rax,%rdx), %xmm13
paddsw (%rcx,%rdx), %xmm15
pmaxsw %xmm13, %xmm14
movdqa %xmm0, (%rdx,%rsi)
pmaxsw %xmm6, %xmm1
pminsw %xmm1, %xmm7
movdqa %xmm1, (%r14,%rdx)
movdqa %xmm1, %xmm13
pmaxsw %xmm15, %xmm13
movdqa %xmm13, (%r15,%rdx)
movdqa %xmm15, (%rbp,%rdx)
addq $0x10, %rdx
movdqa %xmm4, %xmm15
cmpq %rdx, %r11
jne 0x3a7171
pslldq $0x2, %xmm13            # xmm13 = zero,zero,xmm13[0,1,2,3,4,5,6,7,8,9,10,11,12,13]
leaq 0x1(%rdi), %rcx
movq 0x78(%rsp), %r14
pinsrw $0x0, 0x2(%r14,%rdi,2), %xmm13
movdqa (%rax), %xmm0
paddsw %xmm13, %xmm0
pmaxsw %xmm0, %xmm14
movl $0x6, %edx
movdqa 0xe0(%rsp), %xmm1
movdqa %xmm14, %xmm0
pslldq $0x2, %xmm14            # xmm14 = zero,zero,xmm14[0,1,2,3,4,5,6,7,8,9,10,11,12,13]
paddsw %xmm1, %xmm14
pmaxsw %xmm0, %xmm14
decl %edx
jne 0x3a7220
pslldq $0x2, %xmm14            # xmm14 = zero,zero,xmm14[0,1,2,3,4,5,6,7,8,9,10,11,12,13]
paddsw 0xf0(%rsp), %xmm14
pmaxsw %xmm14, %xmm13
xorl %edx, %edx
movdqa %xmm9, %xmm5
movdqa 0x2845b2(%rip), %xmm9   # 0x62b810
movq 0x10(%rbx), %rsi
movq (%rsi), %rsi
addq %r12, %rsi
movdqa (%r15,%rdx), %xmm0
psubsw %xmm2, %xmm13
psubsw %xmm3, %xmm14
movdqa %xmm13, %xmm15
pmaxsw %xmm14, %xmm15
pcmpgtw %xmm14, %xmm13
pand %xmm9, %xmm13
pxor %xmm10, %xmm13
movdqa %xmm0, %xmm1
pmaxsw %xmm15, %xmm1
movdqa (%rbp,%rdx), %xmm4
pcmpeqw %xmm1, %xmm4
pcmpgtw %xmm15, %xmm0
paddw %xmm11, %xmm0
movdqa %xmm4, %xmm6
pandn %xmm0, %xmm6
pand %xmm12, %xmm4
por %xmm6, %xmm4
por (%rdx,%rsi), %xmm13
por %xmm4, %xmm13
movdqa %xmm13, (%rdx,%rsi)
movdqa %xmm1, (%rbp,%rdx)
pminsw %xmm15, %xmm7
pminsw %xmm1, %xmm7
pmaxsw %xmm1, %xmm8
addq $0x10, %rdx
movdqa %xmm1, %xmm13
movdqa %xmm15, %xmm14
cmpq %rdx, %r11
jne 0x3a725e
movdqa (%r10), %xmm0
movdqa %xmm0, %xmm1
movdqa 0xa0(%rsp), %xmm4
pcmpgtw %xmm4, %xmm1
pand 0x50(%rsp), %xmm1
pmovmskb %xmm1, %edx
testl %edx, %edx
cmovnel %edi, %r8d
pmaxsw %xmm0, %xmm4
addq %r11, %r12
movq %rcx, %rdi
cmpq 0x18(%rsp), %rcx
jne 0x3a7102
cmpl $0x0, 0x170(%rsp)
movq 0xc0(%rsp), %r10
movq 0x30(%rsp), %r12
movl 0x14(%rsp), %r11d
movq 0x28(%rsp), %r13
movdqa 0xd0(%rsp), %xmm1
je 0x3a737e
cmpl $0x6, 0x10(%rsp)
jg 0x3a7378
xorl %ecx, %ecx
movl 0x24(%rsp), %edx
pslldq $0x2, %xmm4             # xmm4 = zero,zero,xmm4[0,1,2,3,4,5,6,7,8,9,10,11,12,13]
incl %ecx
cmpl %edx, %ecx
jl 0x3a736d
pextrw $0x7, %xmm4, %r11d
cmpl $0x0, 0x160(%rsp)
je 0x3a73f4
testl $0x7ffffff8, 0xb0(%rsp) # imm = 0x7FFFFFF8
je 0x3a73f4
movl %r13d, %esi
andl $0xfffffff, %esi        # imm = 0xFFFFFFF
shll $0x3, %esi
xorl %edi, %edi
movl 0x8(%rsp), %ecx
movl %edi, %r9d
shrl $0x3, %r9d
movl %edi, %edx
andl $0x7, %edx
imull %r13d, %edx
addl %r9d, %edx
cmpl %r10d, %edx
jge 0x3a73eb
movzwl (%rbp,%rdi,2), %r9d
cmpw %r11w, %r9w
jle 0x3a73d7
movl %r9d, %r11d
movl 0xc(%rsp), %r8d
movl %edx, %ecx
jmp 0x3a73eb
cmpl %ecx, %edx
cmovgel %ecx, %edx
cmpl 0xc(%rsp), %r8d
cmovnel %ecx, %edx
cmpw %r11w, %r9w
cmovel %edx, %ecx
incq %rdi
cmpl %edi, %esi
jne 0x3a73a7
jmp 0x3a73f8
movl 0x8(%rsp), %ecx
movl 0x160(%rsp), %edx
orl %edx, 0x3c(%rsp)
jne 0x3a743b
movq 0x40(%rsp), %rcx
shlq $0x4, %rcx
movdqa (%rbp,%rcx), %xmm0
cmpl $0x6, 0x10(%rsp)
jg 0x3a742c
xorl %ecx, %ecx
movl 0x24(%rsp), %edx
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 0x3a7421
pextrw $0x7, %xmm0, %r11d
movl 0xc(%rsp), %r8d
movl 0x8(%rsp), %ecx
movdqa 0x90(%rsp), %xmm0
pcmpgtw %xmm7, %xmm0
pcmpgtw %xmm1, %xmm8
por %xmm0, %xmm8
pmovmskb %xmm8, %edx
testl %edx, %edx
je 0x3a7467
orb $0x40, 0xc(%rbx)
xorl %r11d, %r11d
xorl %r8d, %r8d
xorl %ecx, %ecx
movswl %r11w, %edx
movl %edx, (%rbx)
movl %ecx, 0x4(%rbx)
movl %r8d, 0x8(%rbx)
movq %rax, %rdi
callq 0x20a60d
movq %rbp, %rdi
callq 0x20a60d
movq %r15, %rdi
callq 0x20a60d
movq %r14, %rdi
callq 0x20a60d
movq %r12, %rdi
callq 0x20a60d
movq %rbx, %rdx
jmp 0x3a74d9
callq 0x1bd0f7
jmp 0x3a74d7
callq 0x1bd0d1
jmp 0x3a74d7
callq 0x1bd0ab
jmp 0x3a74d7
callq 0x1bd085
jmp 0x3a74d7
callq 0x1bd05f
jmp 0x3a74d7
callq 0x1bd039
jmp 0x3a74d7
callq 0x1bd013
jmp 0x3a74d7
callq 0x1bcfed
xorl %edx, %edx
movq %rdx, %rax
addq $0x128, %rsp            # imm = 0x128
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq