// File: /workspace/github_c_makefile_star2_O1/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 0x38a4bb
movq 0x30(%rdi), %rax
movq %rax, 0xd8(%rsp)
testq %rax, %rax
je 0x38a4c2
movq 0x10(%rdi), %rax
movq %rax, 0x80(%rsp)
testq %rax, %rax
je 0x38a4c9
movl %edx, %r13d
movl 0x8(%rdi), %edx
testl %edx, %edx
jle 0x38a4d0
cmpq $0x0, 0x88(%rsp)
je 0x38a4d7
testl %r13d, %r13d
jle 0x38a4de
testl %ecx, %ecx
js 0x38a4e5
testl %r8d, %r8d
js 0x38a4ec
movl %r9d, %r15d
movl %r8d, 0x38(%rsp)
leal -0x1(%rdx), %eax
movq %rdx, 0xd0(%rsp)
leaq 0x7(%rdx), %r14
movq %r14, %r12
shrq $0x3, %r12
movl %eax, 0x5c(%rsp)
cltd
idivl %r12d
movl %eax, 0x10(%rsp)
movl %edx, %ebp
movl %ecx, %esi
negl %esi
movq 0x80(%rsp), %rdx
movl 0x20(%rdx), %eax
movl %eax, %edi
negl %edi
movl %esi, 0x30(%rsp)
cmpl %esi, %eax
movl %ecx, 0x18(%rsp)
cmovgl %ecx, %edi
movl %edi, 0x14(%rsp)
movw $0x7ffe, %ax            # imm = 0x7FFE
subw 0x1c(%rdx), %ax
movl %eax, 0x60(%rsp)
movl $0x10, %edx
movl $0x10, %ecx
movl %r12d, %edi
movl %r13d, %esi
callq 0x2097d1
testq %rax, %rax
je 0x38a4f1
movq %rax, %rbx
movl %ebp, 0x48(%rsp)
movq %r14, 0xc8(%rsp)
xorl %eax, %eax
testl %r15d, %r15d
setne %al
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
cmpl $0x0, 0x170(%rsp)
setne %sil
shll $0xf, %esi
leal (%rcx,%rax,8), %eax
orl %edx, %eax
orl %esi, %eax
orl 0xc(%rbx), %eax
orl $0x8280402, %eax        # imm = 0x8280402
movl %eax, 0xc(%rbx)
movl $0x10, %edi
movq %r12, %rsi
callq 0x2ea474
movq %rax, %r14
leal 0x1(%r13), %esi
movl $0x10, %edi
movq %rsi, 0x90(%rsp)
callq 0x2094cd
movq %rax, 0x40(%rsp)
movl $0x10, %edi
movq %r12, %rsi
callq 0x2ea474
movq %r13, 0x78(%rsp)
movq %rax, %r13
movl $0x10, %edi
movq %r12, %rsi
callq 0x2ea474
movq %rax, %rbp
movl $0x10, %edi
movq %r12, %rsi
callq 0x2ea474
movq 0x40(%rsp), %rdx
testq %r14, %r14
sete %cl
testq %rdx, %rdx
sete %dl
orb %cl, %dl
testq %r13, %r13
sete %cl
testq %rbp, %rbp
sete %sil
orb %cl, %sil
orb %dl, %sil
testq %rax, %rax
sete %cl
orb %sil, %cl
jne 0x38a4f1
movq %rax, 0x50(%rsp)
movq 0x78(%rsp), %rax
decl %eax
movl %eax, 0xc(%rsp)
movl $0x7, %ecx
subl 0x10(%rsp), %ecx
movl 0x18(%rsp), %esi
movd %esi, %xmm0
pshuflw $0x0, %xmm0, %xmm0      # xmm0 = xmm0[0,0,0,0,4,5,6,7]
pshufd $0x0, %xmm0, %xmm3      # xmm3 = xmm0[0,0,0,0]
movl 0x38(%rsp), %edx
movd %edx, %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 0x14(%rsp), %eax
addl $0xffff8001, %eax       # imm = 0xFFFF8001
movd %eax, %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, 0xa0(%rsp)
movd 0x60(%rsp), %xmm0
pshuflw $0x0, %xmm0, %xmm0      # xmm0 = xmm0[0,0,0,0,4,5,6,7]
pshufd $0x0, %xmm0, %xmm2      # xmm2 = xmm0[0,0,0,0]
movl %ecx, 0x24(%rsp)
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, 0xb0(%rsp)
movl %eax, 0x14(%rsp)
movzwl %ax, %ecx
movd %ecx, %xmm1
movl %r12d, %ecx
imull %edx, %ecx
negl %ecx
movd %ecx, %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]
pslldq $0x2, %xmm5             # xmm5 = zero,zero,xmm5[0,1,2,3,4,5,6,7,8,9,10,11,12,13]
movdqa %xmm1, 0xf0(%rsp)
paddsw %xmm1, %xmm5
movl %esi, %ecx
movl %edx, %edx
movslq 0x30(%rsp), %rax
movq %r12, 0x28(%rsp)
movl %r12d, %r8d
movq %r8, 0x18(%rsp)
movq %rdx, 0x60(%rsp)
imulq %rdx, %r8
xorl %r9d, %r9d
movq $-0x7fff, %r10          # imm = 0x8001
movq $-0x8000, %r11          # imm = 0x8000
movq %rax, %rdi
xorl %edx, %edx
testl %r15d, %r15d
je 0x389f40
xorl %esi, %esi
jmp 0x389f43
movq %rdi, %rsi
cmpq %r10, %rsi
movq $-0x8000, %r12          # imm = 0x8000
cmovgeq %rsi, %r12
movw %r12w, 0x110(%rsp,%rdx,2)
subq %rcx, %rsi
cmpq %r10, %rsi
cmovlq %r11, %rsi
movw %si, 0x100(%rsp,%rdx,2)
incq %rdx
subq %r8, %rdi
cmpq $0x8, %rdx
jne 0x389f37
movq %r9, %rdx
shlq $0x4, %rdx
movaps 0x110(%rsp), %xmm0
movaps %xmm0, (%rbp,%rdx)
movdqa 0x100(%rsp), %xmm0
movdqa %xmm0, (%r14,%rdx)
incq %r9
subq 0x60(%rsp), %rax
cmpq 0x18(%rsp), %r9
jne 0x389f32
movq 0x40(%rsp), %rdi
movw $0x0, (%rdi)
movl $0x1, %ecx
xorl %edx, %edx
movl 0x38(%rsp), %esi
movl 0x30(%rsp), %r8d
movl 0x168(%rsp), %r9d
movq 0x90(%rsp), %r10
cmpl $0xffff8001, %r8d       # imm = 0xFFFF8001
movl $0xffff8000, %eax       # imm = 0xFFFF8000
cmovgel %r8d, %eax
testl %r9d, %r9d
cmovnel %edx, %eax
movw %ax, (%rdi,%rcx,2)
incq %rcx
subl %esi, %r8d
cmpq %rcx, %r10
jne 0x389fd4
movdqa %xmm5, 0x90(%rsp)
pxor %xmm0, %xmm0
psubsw %xmm3, %xmm0
movq 0x28(%rsp), %r11
leal -0x1(%r11), %ecx
movq %rcx, %rax
shlq $0x4, %rax
movq 0x50(%rsp), %rdx
addq %rax, %rdx
movl %r11d, %esi
movdqa %xmm2, 0xe0(%rsp)
movdqa %xmm0, (%rdx)
psubsw %xmm4, %xmm0
pminsw %xmm0, %xmm2
addq $-0x10, %rdx
decl %esi
jg 0x38a02e
movl %ecx, %eax
shlq $0x4, %rax
addq %rbp, %rax
movq %rax, 0x38(%rsp)
movl 0x48(%rsp), %r10d
movq %r10, 0x48(%rsp)
shlq $0x4, %r10
addq %rbp, %r10
cmpl $0x1, %r11d
adcl $0x0, %r11d
movq 0x78(%rsp), %rax
cmpl $0x2, %eax
movl $0x1, %ecx
cmovgel %eax, %ecx
movq %rcx, 0x30(%rsp)
movq 0x18(%rsp), %r12
shlq $0x4, %r12
shlq $0x4, %r11
xorl %esi, %esi
movdqa 0x26d52a(%rip), %xmm11  # 0x5f75c0
movdqa 0x26bc31(%rip), %xmm12  # 0x5f5cd0
movdqa 0x26d538(%rip), %xmm9   # 0x5f75e0
movdqa 0x26d53f(%rip), %xmm10  # 0x5f75f0
movdqa 0x26d547(%rip), %xmm6   # 0x5f7600
movdqa 0xb0(%rsp), %xmm0
pcmpeqw 0x26b956(%rip), %xmm0   # 0x5f5a20
movdqa %xmm0, 0xb0(%rsp)
xorl %edx, %edx
movl 0xc(%rsp), %r8d
movdqa 0xa0(%rsp), %xmm0
movdqa %xmm0, %xmm7
movdqa %xmm0, %xmm5
movq 0x50(%rsp), %r15
movdqa %xmm6, %xmm8
movdqa %xmm10, %xmm15
movdqa %xmm9, %xmm14
movdqa %xmm5, 0x60(%rsp)
movq 0x38(%rsp), %rax
movdqa (%rax), %xmm5
pslldq $0x2, %xmm5             # xmm5 = zero,zero,xmm5[0,1,2,3,4,5,6,7,8,9,10,11,12,13]
pinsrw $0x0, (%rdi,%rdx,2), %xmm5
movq 0x80(%rsp), %rax
movq 0x10(%rax), %rax
movq 0x88(%rsp), %rcx
movzbl (%rcx,%rdx), %ecx
movslq (%rax,%rcx,4), %rcx
imulq 0x18(%rsp), %rcx
shlq $0x4, %rcx
addq 0xd8(%rsp), %rcx
movdqa 0xa0(%rsp), %xmm1
movdqa %xmm1, %xmm0
psubsw (%r15), %xmm0
xorl %r9d, %r9d
movdqa %xmm12, %xmm13
movdqa %xmm11, %xmm12
movdqa (%rbp,%r9), %xmm11
movdqa (%r14,%r9), %xmm9
movdqa %xmm11, %xmm10
psubsw %xmm3, %xmm10
psubsw %xmm4, %xmm9
movdqa %xmm10, %xmm6
pcmpgtw %xmm9, %xmm6
pand %xmm12, %xmm6
pxor %xmm13, %xmm6
movq 0x10(%rbx), %rax
movq (%rax), %rax
addq %rsi, %rax
paddsw (%r15,%r9), %xmm0
paddsw (%rcx,%r9), %xmm5
pmaxsw %xmm0, %xmm1
movdqa %xmm6, (%r9,%rax)
pmaxsw %xmm10, %xmm9
pminsw %xmm9, %xmm2
movdqa %xmm9, (%r14,%r9)
movdqa %xmm9, %xmm0
pmaxsw %xmm5, %xmm0
movdqa %xmm0, (%r13,%r9)
movdqa %xmm5, (%rbp,%r9)
addq $0x10, %r9
movdqa %xmm11, %xmm5
cmpq %r9, %r11
jne 0x38a166
pslldq $0x2, %xmm0             # xmm0 = zero,zero,xmm0[0,1,2,3,4,5,6,7,8,9,10,11,12,13]
leaq 0x1(%rdx), %rcx
pinsrw $0x0, 0x2(%rdi,%rdx,2), %xmm0
movdqa (%r15), %xmm5
paddsw %xmm0, %xmm5
pmaxsw %xmm5, %xmm1
movl $0x6, %edi
movdqa 0x90(%rsp), %xmm6
movdqa %xmm1, %xmm5
pslldq $0x2, %xmm1             # xmm1 = zero,zero,xmm1[0,1,2,3,4,5,6,7,8,9,10,11,12,13]
paddsw %xmm6, %xmm1
pmaxsw %xmm5, %xmm1
decl %edi
jne 0x38a21a
pslldq $0x2, %xmm1             # xmm1 = zero,zero,xmm1[0,1,2,3,4,5,6,7,8,9,10,11,12,13]
paddsw 0xf0(%rsp), %xmm1
pmaxsw %xmm1, %xmm0
xorl %r9d, %r9d
movdqa %xmm12, %xmm11
movdqa %xmm13, %xmm12
movdqa 0x26d379(%rip), %xmm13  # 0x5f75d0
movdqa %xmm14, %xmm9
movdqa %xmm15, %xmm10
movq 0x10(%rbx), %rax
movq (%rax), %rdi
addq %rsi, %rdi
movdqa (%r13,%r9), %xmm6
psubsw %xmm3, %xmm0
psubsw %xmm4, %xmm1
movdqa %xmm0, %xmm5
pmaxsw %xmm1, %xmm5
pcmpgtw %xmm1, %xmm0
pand %xmm13, %xmm0
pxor %xmm9, %xmm0
movdqa %xmm6, %xmm1
pmaxsw %xmm5, %xmm1
movdqa (%rbp,%r9), %xmm9
pcmpeqw %xmm1, %xmm9
pcmpgtw %xmm5, %xmm6
paddw %xmm10, %xmm6
movdqa %xmm9, %xmm10
pandn %xmm6, %xmm10
pand %xmm8, %xmm9
por %xmm10, %xmm9
movdqa %xmm15, %xmm10
por (%r9,%rdi), %xmm0
por %xmm9, %xmm0
movdqa %xmm14, %xmm9
movdqa %xmm0, (%r9,%rdi)
movdqa %xmm1, (%rbp,%r9)
pminsw %xmm5, %xmm2
pminsw %xmm1, %xmm2
pmaxsw %xmm1, %xmm7
addq $0x10, %r9
movdqa %xmm1, %xmm0
movdqa %xmm5, %xmm1
cmpq %r9, %r11
jne 0x38a261
movdqa %xmm8, %xmm6
movdqa (%r10), %xmm0
movdqa %xmm0, %xmm1
movdqa 0x60(%rsp), %xmm5
pcmpgtw %xmm5, %xmm1
pand 0xb0(%rsp), %xmm1
pmovmskb %xmm1, %eax
testl %eax, %eax
cmovnel %edx, %r8d
pmaxsw %xmm0, %xmm5
addq %r12, %rsi
movq %rcx, %rdx
cmpq 0x30(%rsp), %rcx
movq 0x40(%rsp), %rdi
jne 0x38a0f0
movl 0x170(%rsp), %r12d
testl %r12d, %r12d
movl 0x5c(%rsp), %r10d
movq 0xd0(%rsp), %r11
movl 0x14(%rsp), %r15d
movq 0x28(%rsp), %r9
je 0x38a392
cmpl $0x6, 0x10(%rsp)
jg 0x38a38c
movl 0x24(%rsp), %eax
cmpl $0x2, %eax
movl $0x1, %ecx
cmovgel %eax, %ecx
pslldq $0x2, %xmm5             # xmm5 = zero,zero,xmm5[0,1,2,3,4,5,6,7,8,9,10,11,12,13]
decl %ecx
jne 0x38a383
pextrw $0x7, %xmm5, %r15d
cmpl $0x0, 0x160(%rsp)
je 0x38a409
testl $0x7ffffff8, 0xc8(%rsp) # imm = 0x7FFFFFF8
je 0x38a409
movl %r9d, %edx
andl $0xfffffff, %edx        # imm = 0xFFFFFFF
shll $0x3, %edx
xorl %esi, %esi
movl %r10d, %ecx
movl %esi, %eax
shrl $0x3, %eax
movl %esi, %edi
andl $0x7, %edi
imull %r9d, %edi
addl %eax, %edi
cmpl %r11d, %edi
jge 0x38a400
movzwl (%rbp,%rsi,2), %r9d
cmpw %r15w, %r9w
jle 0x38a3e7
movl %r9d, %r15d
movl 0xc(%rsp), %r8d
movl %edi, %ecx
jmp 0x38a3fb
cmpl %ecx, %edi
cmovgel %ecx, %edi
cmpl 0xc(%rsp), %r8d
cmovnel %ecx, %edi
cmpw %r15w, %r9w
cmovel %edi, %ecx
movq 0x28(%rsp), %r9
incq %rsi
cmpl %esi, %edx
jne 0x38a3ba
jmp 0x38a40c
movl %r10d, %ecx
orl 0x160(%rsp), %r12d
jne 0x38a452
movq 0x48(%rsp), %rax
shlq $0x4, %rax
movdqa (%rbp,%rax), %xmm0
cmpl $0x6, 0x10(%rsp)
jg 0x38a444
movl 0x24(%rsp), %eax
cmpl $0x2, %eax
movl $0x1, %ecx
cmovgel %eax, %ecx
pslldq $0x2, %xmm0             # xmm0 = zero,zero,xmm0[0,1,2,3,4,5,6,7,8,9,10,11,12,13]
decl %ecx
jne 0x38a43b
pextrw $0x7, %xmm0, %r15d
movl 0xc(%rsp), %r8d
movl %r10d, %ecx
movdqa 0xa0(%rsp), %xmm0
pcmpgtw %xmm2, %xmm0
pcmpgtw 0xe0(%rsp), %xmm7
por %xmm0, %xmm7
pmovmskb %xmm7, %eax
testl %eax, %eax
je 0x38a480
orb $0x40, 0xc(%rbx)
xorl %r15d, %r15d
xorl %r8d, %r8d
xorl %ecx, %ecx
movswl %r15w, %eax
movl %eax, (%rbx)
movl %ecx, 0x4(%rbx)
movl %r8d, 0x8(%rbx)
movq 0x50(%rsp), %rdi
callq 0x2094b5
movq %rbp, %rdi
callq 0x2094b5
movq %r13, %rdi
callq 0x2094b5
movq 0x40(%rsp), %rdi
callq 0x2094b5
movq %r14, %rdi
callq 0x2094b5
jmp 0x38a4f3
callq 0x1bd103
jmp 0x38a4f1
callq 0x1bd0dd
jmp 0x38a4f1
callq 0x1bd0b7
jmp 0x38a4f1
callq 0x1bd091
jmp 0x38a4f1
callq 0x1bd06b
jmp 0x38a4f1
callq 0x1bd045
jmp 0x38a4f1
callq 0x1bd01f
jmp 0x38a4f1
callq 0x1bcff9
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x128, %rsp            # imm = 0x128
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq