// File: /workspace/github_c_makefile_star2_O3/nh13[P]ksw/src/parasail/src/sg_diag_sse2_128_64.c
// Function: parasail_sg_flags_rowcol_diag_sse2_128_64
parasail_result_t* FNAME(
        const char * const restrict _s1, const int _s1Len,
        const char * const restrict _s2, const int s2Len,
        const int open, const int gap, const parasail_matrix_t *matrix,
        int s1_beg, int s1_end, int s2_beg, int s2_end)
{
    /* declare local variables */
    int32_t N = 0;
    int32_t PAD = 0;
    int32_t PAD2 = 0;
    int32_t s1Len = 0;
    int32_t s1Len_PAD = 0;
    int32_t s2Len_PAD = 0;
    int64_t * restrict s1 = NULL;
    int64_t * restrict s2B = NULL;
    int64_t * restrict _H_pr = NULL;
    int64_t * restrict _F_pr = NULL;
    int64_t * restrict s2 = NULL;
    int64_t * restrict H_pr = NULL;
    int64_t * restrict F_pr = NULL;
    parasail_result_t *result = NULL;
    int32_t i = 0;
    int32_t j = 0;
    int32_t end_query = 0;
    int32_t end_ref = 0;
    int64_t NEG_LIMIT = 0;
    int64_t POS_LIMIT = 0;
    int64_t score = 0;
    __m128i vNegLimit;
    __m128i vPosLimit;
    __m128i vSaturationCheckMin;
    __m128i vSaturationCheckMax;
    __m128i vNegInf;
    __m128i vOpen;
    __m128i vGap;
    __m128i vOne;
    __m128i vN;
    __m128i vGapN;
    __m128i vNegOne;
    __m128i vI;
    __m128i vJreset;
    __m128i vMaxHRow;
    __m128i vMaxHCol;
    __m128i vLastVal;
    __m128i vEndI;
    __m128i vEndJ;
    __m128i vILimit;
    __m128i vILimit1;
    __m128i vJLimit;
    __m128i vJLimit1;
    __m128i vIBoundary;

    /* validate inputs */
    PARASAIL_CHECK_NULL(_s2);
    PARASAIL_CHECK_GT0(s2Len);
    PARASAIL_CHECK_GE0(open);
    PARASAIL_CHECK_GE0(gap);
    PARASAIL_CHECK_NULL(matrix);
    if (matrix->type == PARASAIL_MATRIX_TYPE_SQUARE) {
        PARASAIL_CHECK_NULL(_s1);
        PARASAIL_CHECK_GT0(_s1Len);
    }

    /* initialize stack variables */
    N = 2; /* number of values in vector */
    PAD = N-1;
    PAD2 = PAD*2;
    s1Len = matrix->type == PARASAIL_MATRIX_TYPE_SQUARE ? _s1Len : matrix->length;
    s1Len_PAD = s1Len+PAD;
    s2Len_PAD = s2Len+PAD;
    i = 0;
    j = 0;
    end_query = 0;
    end_ref = 0;
    NEG_LIMIT = (-open < matrix->min ? INT64_MIN + open : INT64_MIN - matrix->min) + 1;
    POS_LIMIT = INT64_MAX - matrix->max - 1;
    score = NEG_LIMIT;
    vNegLimit = _mm_set1_epi64x_rpl(NEG_LIMIT);
    vPosLimit = _mm_set1_epi64x_rpl(POS_LIMIT);
    vSaturationCheckMin = vPosLimit;
    vSaturationCheckMax = vNegLimit;
    vNegInf = _mm_set1_epi64x_rpl(NEG_LIMIT);
    vOpen = _mm_set1_epi64x_rpl(open);
    vGap  = _mm_set1_epi64x_rpl(gap);
    vOne = _mm_set1_epi64x_rpl(1);
    vN = _mm_set1_epi64x_rpl(N);
    vGapN = s1_beg ? _mm_set1_epi64x_rpl(0) : _mm_set1_epi64x_rpl(gap*N);
    vNegOne = _mm_set1_epi64x_rpl(-1);
    vI = _mm_set_epi64x_rpl(0,1);
    vJreset = _mm_set_epi64x_rpl(0,-1);
    vMaxHRow = vNegInf;
    vMaxHCol = vNegInf;
    vLastVal = vNegInf;
    vEndI = vNegInf;
    vEndJ = vNegInf;
    vILimit = _mm_set1_epi64x_rpl(s1Len);
    vILimit1 = _mm_sub_epi64(vILimit, vOne);
    vJLimit = _mm_set1_epi64x_rpl(s2Len);
    vJLimit1 = _mm_sub_epi64(vJLimit, vOne);
    vIBoundary = s1_beg ? _mm_set1_epi64x_rpl(0) : _mm_set_epi64x_rpl(
            -open-0*gap,
            -open-1*gap);

    /* initialize result */
#ifdef PARASAIL_TABLE
    result = parasail_result_new_table1(s1Len, s2Len);
#else
#ifdef PARASAIL_ROWCOL
    result = parasail_result_new_rowcol1(s1Len, s2Len);
#else
    result = parasail_result_new();
#endif
#endif
    if (!result) return NULL;

    /* set known flags */
    result->flag |= PARASAIL_FLAG_SG | PARASAIL_FLAG_DIAG
        | PARASAIL_FLAG_BITS_64 | PARASAIL_FLAG_LANES_2;
    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 */
    s2B= parasail_memalign_int64_t(16, s2Len+PAD2);
    _H_pr = parasail_memalign_int64_t(16, s2Len+PAD2);
    _F_pr = parasail_memalign_int64_t(16, s2Len+PAD2);
    s2 = s2B+PAD; /* will allow later for negative indices */
    H_pr = _H_pr+PAD;
    F_pr = _F_pr+PAD;

    /* validate heap variables */
    if (!s2B) return NULL;
    if (!_H_pr) return NULL;
    if (!_F_pr) return NULL;

    /* convert _s1 from char to int in range 0-23 */
    if (matrix->type == PARASAIL_MATRIX_TYPE_SQUARE) {
        s1 = parasail_memalign_int64_t(16, s1Len+PAD);
        if (!s1) return NULL;
        for (i=0; i<s1Len; ++i) {
            s1[i] = matrix->mapper[(unsigned char)_s1[i]];
        }
        /* pad back of s1 with dummy values */
        for (i=s1Len; i<s1Len_PAD; ++i) {
            s1[i] = 0; /* point to first matrix row because we don't care */
        }
    }

    /* convert _s2 from char to int in range 0-23 */
    for (j=0; j<s2Len; ++j) {
        s2[j] = matrix->mapper[(unsigned char)_s2[j]];
    }
    /* pad front of s2 with dummy values */
    for (j=-PAD; j<0; ++j) {
        s2[j] = 0; /* point to first matrix row because we don't care */
    }
    /* pad back of s2 with dummy values */
    for (j=s2Len; j<s2Len_PAD; ++j) {
        s2[j] = 0; /* point to first matrix row because we don't care */
    }

    /* set initial values for stored row */
    if (s2_beg) {
        for (j=0; j<s2Len; ++j) {
            H_pr[j] = 0;
            F_pr[j] = NEG_LIMIT;
        }
    }
    else {
        for (j=0; j<s2Len; ++j) {
            H_pr[j] = -open - j*gap;
            F_pr[j] = NEG_LIMIT;
        }
    }
    /* pad front of stored row values */
    for (j=-PAD; j<0; ++j) {
        H_pr[j] = NEG_LIMIT;
        F_pr[j] = NEG_LIMIT;
    }
    /* pad back of stored row values */
    for (j=s2Len; j<s2Len+PAD; ++j) {
        H_pr[j] = NEG_LIMIT;
        F_pr[j] = NEG_LIMIT;
    }
    H_pr[-1] = 0; /* upper left corner */

    /* iterate over query sequence */
    for (i=0; i<s1Len; i+=N) {
        __m128i vNH = vNegInf;
        __m128i vWH = vNegInf;
        __m128i vE = vNegInf;
        __m128i vF = vNegInf;
        __m128i vJ = vJreset;
        const int * const restrict matrow0 = &matrix->matrix[matrix->size * ((matrix->type == PARASAIL_MATRIX_TYPE_SQUARE) ? s1[i+0] : ((i+0 >= s1Len) ? s1Len-1 : i+0))];
        const int * const restrict matrow1 = &matrix->matrix[matrix->size * ((matrix->type == PARASAIL_MATRIX_TYPE_SQUARE) ? s1[i+1] : ((i+1 >= s1Len) ? s1Len-1 : i+1))];
        __m128i vIltLimit = _mm_cmplt_epi64_rpl(vI, vILimit);
        __m128i vIeqLimit1 = _mm_cmpeq_epi64_rpl(vI, vILimit1);
        vNH = _mm_srli_si128(vNH, 8);
        vNH = _mm_insert_epi64_rpl(vNH, H_pr[-1], 1);
        vWH = _mm_srli_si128(vWH, 8);
        vWH = _mm_insert_epi64_rpl(vWH, s1_beg ? 0 : (-open - i*gap), 1);
        H_pr[-1] = -open - (i+N)*gap;
        /* iterate over database sequence */
        for (j=0; j<s2Len+PAD; ++j) {
            __m128i vMat;
            __m128i vNWH = vNH;
            vNH = _mm_srli_si128(vWH, 8);
            vNH = _mm_insert_epi64_rpl(vNH, H_pr[j], 1);
            vF = _mm_srli_si128(vF, 8);
            vF = _mm_insert_epi64_rpl(vF, F_pr[j], 1);
            vF = _mm_max_epi64_rpl(
                    _mm_sub_epi64(vNH, vOpen),
                    _mm_sub_epi64(vF, vGap));
            vE = _mm_max_epi64_rpl(
                    _mm_sub_epi64(vWH, vOpen),
                    _mm_sub_epi64(vE, vGap));
            vMat = _mm_set_epi64x_rpl(
                    matrow0[s2[j-0]],
                    matrow1[s2[j-1]]
                    );
            vNWH = _mm_add_epi64(vNWH, vMat);
            vWH = _mm_max_epi64_rpl(vNWH, vE);
            vWH = _mm_max_epi64_rpl(vWH, vF);
            /* as minor diagonal vector passes across the j=-1 boundary,
             * assign the appropriate boundary conditions */
            {
                __m128i cond = _mm_cmpeq_epi64_rpl(vJ,vNegOne);
                vWH = _mm_blendv_epi8_rpl(vWH, vIBoundary, cond);
                vF = _mm_blendv_epi8_rpl(vF, vNegInf, cond);
                vE = _mm_blendv_epi8_rpl(vE, vNegInf, cond);
            }
            /* cannot start checking sat until after J clears boundary */
            if (j > PAD) {
                vSaturationCheckMin = _mm_min_epi64_rpl(vSaturationCheckMin, vWH);
                vSaturationCheckMax = _mm_max_epi64_rpl(vSaturationCheckMax, vWH);
            }
#ifdef PARASAIL_TABLE
            arr_store_si128(result->tables->score_table, vWH, i, s1Len, j, s2Len);
#endif
#ifdef PARASAIL_ROWCOL
            arr_store_rowcol(result->rowcols->score_row, result->rowcols->score_col, vWH, i, s1Len, j, s2Len);
#endif
            H_pr[j-1] = (int64_t)_mm_extract_epi64_rpl(vWH,0);
            F_pr[j-1] = (int64_t)_mm_extract_epi64_rpl(vF,0);
            /* as minor diagonal vector passes across the i or j limit
             * boundary, extract the last value of the column or row */
            {
                __m128i vJeqLimit1 = _mm_cmpeq_epi64_rpl(vJ, vJLimit1);
                __m128i vJgtNegOne = _mm_cmpgt_epi64_rpl(vJ, vNegOne);
                __m128i vJltLimit = _mm_cmplt_epi64_rpl(vJ, vJLimit);
                __m128i cond_j = _mm_and_si128(vIltLimit, vJeqLimit1);
                __m128i cond_i = _mm_and_si128(vIeqLimit1,
                        _mm_and_si128(vJgtNegOne, vJltLimit));
                __m128i cond_max_row = _mm_cmpgt_epi64_rpl(vWH, vMaxHRow);
                __m128i cond_max_col = _mm_cmpgt_epi64_rpl(vWH, vMaxHCol);
                __m128i cond_last_val = _mm_and_si128(vIeqLimit1, vJeqLimit1);
                __m128i cond_all_row = _mm_and_si128(cond_max_row, cond_i);
                __m128i cond_all_col = _mm_and_si128(cond_max_col, cond_j);
                vMaxHRow = _mm_blendv_epi8_rpl(vMaxHRow, vWH, cond_all_row);
                vMaxHCol = _mm_blendv_epi8_rpl(vMaxHCol, vWH, cond_all_col);
                vLastVal = _mm_blendv_epi8_rpl(vLastVal, vWH, cond_last_val);
                vEndI = _mm_blendv_epi8_rpl(vEndI, vI, cond_all_col);
                vEndJ = _mm_blendv_epi8_rpl(vEndJ, vJ, cond_all_row);
            }
            vJ = _mm_add_epi64(vJ, vOne);
        }
        vI = _mm_add_epi64(vI, vN);
        vIBoundary = _mm_sub_epi64(vIBoundary, vGapN);
    }

    /* alignment ending position */
    {
        int64_t max_row = NEG_LIMIT;
        int64_t max_col = NEG_LIMIT;
        int64_t last_val = NEG_LIMIT;
        int64_t *s = (int64_t*)&vMaxHRow;
        int64_t *t = (int64_t*)&vMaxHCol;
        int64_t *u = (int64_t*)&vLastVal;
        int64_t *i = (int64_t*)&vEndI;
        int64_t *j = (int64_t*)&vEndJ;
        int32_t k;
        for (k=0; k<N; ++k, ++s, ++t, ++u, ++i, ++j) {
            if (*t > max_col || (*t == max_col && *i < end_query)) {
                max_col = *t;
                end_query = *i;
            }
            if (*s > max_row) {
                max_row = *s;
                end_ref = *j;
            }
            if (*u > last_val) {
                last_val = *u;
            }
        }
        if (s1_end && s2_end) {
            if (max_col > max_row || (max_col == max_row && end_ref == s2Len-1)) {
                score = max_col;
                end_ref = s2Len-1;
            }
            else {
                score = max_row;
                end_query = s1Len-1;
            }
        }
        else if (s1_end) {
            score = max_col;
            end_ref = s2Len-1;
        }
        else if (s2_end) {
            score = max_row;
            end_query = s1Len-1;
        }
        else {
            score = last_val;
            end_query = s1Len-1;
            end_ref = s2Len-1;
        }
    }

    if (_mm_movemask_epi8(_mm_or_si128(
            _mm_cmplt_epi64_rpl(vSaturationCheckMin, vNegLimit),
            _mm_cmpgt_epi64_rpl(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(_F_pr);
    parasail_free(_H_pr);
    parasail_free(s2B);
    if (matrix->type == PARASAIL_MATRIX_TYPE_SQUARE) {
        parasail_free(s1);
    }

    return result;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1c8, %rsp            # imm = 0x1C8
movq %r9, 0x18(%rsp)
testq %rdx, %rdx
je 0x357fc7
movl %ecx, %r12d
testl %ecx, %ecx
jle 0x357fd1
testl %r8d, %r8d
js 0x357fdb
cmpl $0x0, 0x18(%rsp)
js 0x357fe5
movq 0x200(%rsp), %rbx
testq %rbx, %rbx
je 0x357fef
cmpl $0x0, 0x30(%rbx)
je 0x35743f
movl 0x34(%rbx), %r13d
jmp 0x357453
testq %rdi, %rdi
je 0x358106
movl %esi, %r13d
testl %esi, %esi
jle 0x35810d
leal 0x1(%r13), %eax
movl %eax, 0xd0(%rsp)
movslq 0x20(%rbx), %rax
movl %r8d, %r9d
negl %r8d
movq %r9, %rcx
btsq $0x3f, %rcx
movabsq $-0x8000000000000000, %rsi # imm = 0x8000000000000000
movq %rsi, %rbp
subq %rax, %rbp
movl %r8d, 0x14(%rsp)
cmpl %r8d, %eax
cmovgq %rcx, %rbp
leaq 0x1(%rbp), %rcx
movslq 0x1c(%rbx), %rax
subq %rax, %rsi
addq $-0x2, %rsi
movq %rsi, 0x40(%rsp)
movq %rcx, %xmm0
pshufd $0x44, %xmm0, %xmm0     # xmm0 = xmm0[0,1,0,1]
movdqa %xmm0, 0x60(%rsp)
movq 0x18(%rsp), %rax
addl %eax, %eax
movslq %r13d, %r8
leaq -0x1(%r8), %rsi
movq %rsi, 0x110(%rsp)
movl %r12d, %r15d
leaq -0x1(%r15), %r14
pxor %xmm0, %xmm0
movdqa %xmm0, 0x90(%rsp)
cmpl $0x0, 0x208(%rsp)
jne 0x3574ed
movd %eax, %xmm0
pshufd $0x44, %xmm0, %xmm0     # xmm0 = xmm0[0,1,0,1]
movdqa %xmm0, 0x130(%rsp)
movq %r9, 0xa0(%rsp)
movq %rdi, 0xc0(%rsp)
movq %rdx, 0x50(%rsp)
movq %r8, 0x30(%rsp)
movq %rcx, 0x38(%rsp)
movdqa 0x60(%rsp), %xmm0
movdqa %xmm0, 0x170(%rsp)
movdqa %xmm0, 0x160(%rsp)
movdqa %xmm0, 0x150(%rsp)
movdqa %xmm0, 0xe0(%rsp)
movdqa %xmm0, 0x140(%rsp)
jne 0x35756f
movl 0x14(%rsp), %ecx
movslq %ecx, %rax
subl 0x18(%rsp), %ecx
movslq %ecx, %rcx
movq %rcx, %xmm1
movq %rax, %xmm0
punpcklqdq %xmm0, %xmm1    # xmm1 = xmm1[0],xmm0[0]
movdqa %xmm1, 0x90(%rsp)
movl %r13d, %edi
movl %r12d, %esi
callq 0x20ac53
testq %rax, %rax
je 0x358112
movq %rbp, 0xf8(%rsp)
movq %r13, 0x28(%rsp)
xorl %edi, %edi
cmpl $0x0, 0x208(%rsp)
setne %dil
xorl %ecx, %ecx
cmpl $0x0, 0x210(%rsp)
setne %cl
shll $0x4, %ecx
xorl %edx, %edx
cmpl $0x0, 0x218(%rsp)
setne %dl
shll $0xe, %edx
xorl %esi, %esi
cmpl $0x0, 0x220(%rsp)
setne %sil
shll $0xf, %esi
leal (%rcx,%rdi,8), %ecx
orl %edx, %ecx
orl %esi, %ecx
orl 0xc(%rax), %ecx
orl $0x2841002, %ecx        # imm = 0x2841002
movq %rax, 0x20(%rsp)
movl %ecx, 0xc(%rax)
movq %r12, 0x8(%rsp)
leal 0x2(%r12), %ebp
movl $0x10, %edi
movq %rbp, %rsi
callq 0x20a636
movq %rax, %r12
movl $0x10, %edi
movq %rbp, %rsi
callq 0x20a636
movq %rax, %r13
movl $0x10, %edi
movq %rbp, %rsi
callq 0x20a636
movq %rax, %rbp
testq %r12, %r12
sete %al
testq %r13, %r13
sete %cl
orb %al, %cl
testq %rbp, %rbp
sete %al
orb %cl, %al
jne 0x358112
cmpl $0x0, 0x30(%rbx)
je 0x35765e
xorl %eax, %eax
movq 0x38(%rsp), %rsi
movq 0x30(%rsp), %r8
movq 0x50(%rsp), %r9
movq 0xa0(%rsp), %r11
jmp 0x3576c2
movslq 0xd0(%rsp), %rsi
movl $0x10, %edi
callq 0x20a636
testq %rax, %rax
je 0x358112
cmpl $0x0, 0x28(%rsp)
movq 0x38(%rsp), %rsi
movq 0x30(%rsp), %r8
movq 0x50(%rsp), %r9
movq 0xc0(%rsp), %r10
movq 0xa0(%rsp), %r11
jle 0x3576ba
movq 0x10(%rbx), %rdi
xorl %ecx, %ecx
movzbl (%r10,%rcx), %edx
movslq (%rdi,%rdx,4), %rdx
movq %rdx, (%rax,%rcx,8)
incq %rcx
cmpq %rcx, %r8
jne 0x3576a5
movq $0x0, (%rax,%r8,8)
movq 0x40(%rsp), %xmm2
movq %r11, %xmm0
movd 0x18(%rsp), %xmm1
movdqa %xmm2, 0x180(%rsp)
pshufd $0x44, %xmm2, %xmm2     # xmm2 = xmm2[0,1,0,1]
movdqa %xmm2, 0xb0(%rsp)
pshufd $0x44, %xmm0, %xmm0     # xmm0 = xmm0[0,1,0,1]
movdqa %xmm0, 0x1b0(%rsp)
pshufd $0x44, %xmm1, %xmm0     # xmm0 = xmm1[0,1,0,1]
movdqa %xmm0, 0x1a0(%rsp)
movq 0x10(%rbx), %rdi
xorl %ecx, %ecx
movzbl (%r9,%rcx), %edx
movslq (%rdi,%rdx,4), %rdx
movq %rdx, 0x8(%r12,%rcx,8)
incq %rcx
cmpq %rcx, %r15
jne 0x35770c
xorl %ecx, %ecx
movq %rcx, (%r12)
movq %rcx, 0x8(%r12,%r15,8)
movl 0x18(%rsp), %ecx
movq %rcx, 0x78(%rsp)
movslq 0x14(%rsp), %rdi
cmpl $0x0, 0x218(%rsp)
je 0x35775f
xorl %ecx, %ecx
movq $0x0, 0x8(%r13,%rcx,8)
movq %rsi, 0x8(%rbp,%rcx,8)
incq %rcx
cmpq %rcx, %r15
jne 0x357747
jmp 0x35777b
xorl %edx, %edx
movq %rdi, %rcx
movq %rcx, 0x8(%r13,%rdx,8)
movq %rsi, 0x8(%rbp,%rdx,8)
incq %rdx
subq 0x78(%rsp), %rcx
cmpq %rdx, %r15
jne 0x357764
movq %rax, 0x70(%rsp)
movq %rsi, (%rbp)
movq %rsi, 0x8(%r13,%r15,8)
movq %rsi, 0x8(%rbp,%r15,8)
movq $0x0, (%r13)
movq 0x28(%rsp), %rax
testl %eax, %eax
jle 0x357e84
movq 0x8(%rbx), %rcx
movq %rcx, 0x100(%rsp)
leal -0x1(%rax), %esi
movdqa 0x60(%rsp), %xmm7
movdqa %xmm7, %xmm0
psrldq $0x8, %xmm0             # xmm0 = xmm0[8,9,10,11,12,13,14,15],zero,zero,zero,zero,zero,zero,zero,zero
movdqa %xmm0, 0x190(%rsp)
movq 0x8(%rsp), %rax
leal -0x1(%rax), %ecx
movq %rcx, 0x128(%rsp)
incl %eax
movq %rax, 0x120(%rsp)
movd 0x2d24f4(%rip), %xmm0   # 0x629ce0
movdqa %xmm0, 0x40(%rsp)
xorl %r11d, %r11d
movdqa %xmm7, 0x80(%rsp)
movdqa %xmm7, %xmm11
movdqa %xmm7, %xmm9
movdqa %xmm7, %xmm14
movdqa %xmm7, %xmm10
movdqa %xmm7, %xmm3
movq %rdi, 0x108(%rsp)
cmpl $0x0, 0x30(%rbx)
je 0x357839
movq %r11, %rax
orq $0x1, %rax
cmpq %r8, %rax
cmovgel %esi, %eax
movslq %eax, %rcx
movq %r11, %rdx
jmp 0x357847
movq 0x70(%rsp), %rax
movq (%rax,%r11,8), %rdx
movq 0x8(%rax,%r11,8), %rcx
movslq 0x18(%rbx), %rax
imulq %rax, %rdx
imulq %rax, %rcx
movq %rcx, 0x50(%rsp)
movdqa 0x40(%rsp), %xmm0
movq %xmm0, %rbx
xorl %r9d, %r9d
cmpq %r8, %rbx
setl %r9b
negq %r9
pshufd $0xee, %xmm0, %xmm0     # xmm0 = xmm0[2,3,2,3]
movq %xmm0, %rcx
xorl %eax, %eax
cmpq %r8, %rcx
setl %al
negq %rax
xorl %r10d, %r10d
movq %rdx, %r8
movq 0x110(%rsp), %rdx
cmpq %rdx, %rbx
sete %r10b
negq %r10
xorl %ebx, %ebx
cmpq %rdx, %rcx
sete %bl
leaq 0x2(%r11), %rcx
movq %rcx, 0x118(%rsp)
imulq 0x78(%rsp), %rcx
movq %rdi, %rdx
subq %rcx, %rdx
movl %r11d, %ecx
imull 0x18(%rsp), %ecx
movl 0x14(%rsp), %edi
subl %ecx, %edi
movq %r9, %xmm2
movq %rax, %xmm0
movq %r10, %xmm4
negq %rbx
movq %rbx, %xmm1
cmpl $0x0, 0x208(%rsp)
movq 0x100(%rsp), %rax
leaq (%rax,%r8,4), %r9
movq 0x50(%rsp), %rcx
leaq (%rax,%rcx,4), %rcx
punpcklqdq %xmm0, %xmm2    # xmm2 = xmm2[0],xmm0[0]
movdqa %xmm2, 0xd0(%rsp)
punpcklqdq %xmm1, %xmm4    # xmm4 = xmm4[0],xmm1[0]
movdqa %xmm4, 0xc0(%rsp)
movq (%r13), %xmm0
movq %rdx, (%r13)
movl $0x0, %eax
cmovnel %eax, %edi
movslq %edi, %rax
movq %rax, %xmm1
movdqa 0x190(%rsp), %xmm5
movdqa %xmm5, %xmm8
punpcklqdq %xmm1, %xmm8    # xmm8 = xmm8[0],xmm1[0]
punpcklqdq %xmm0, %xmm5    # xmm5 = xmm5[0],xmm0[0]
movq %r11, %r10
orq $0x1, %r10
xorl %edx, %edx
movq 0x2d238c(%rip), %xmm12  # 0x629ce8
movdqa 0x60(%rsp), %xmm0
movdqa %xmm0, %xmm2
movdqa 0x2d2022(%rip), %xmm6   # 0x629990
pcmpeqd %xmm7, %xmm7
movdqa %xmm3, 0xa0(%rsp)
movdqa %xmm14, 0x50(%rsp)
movq (%r12,%rdx,8), %rax
movq 0x8(%r12,%rdx,8), %rdi
movslq (%r9,%rdi,4), %rdi
movslq (%rcx,%rax,4), %rax
movq %rdi, %xmm1
movq %rax, %xmm3
punpcklqdq %xmm1, %xmm3    # xmm3 = xmm3[0],xmm1[0]
paddq %xmm5, %xmm3
pshufd $0xee, %xmm8, %xmm5     # xmm5 = xmm8[2,3,2,3]
movq 0x8(%r13,%rdx,8), %xmm1
punpcklqdq %xmm1, %xmm5    # xmm5 = xmm5[0],xmm1[0]
pshufd $0xee, %xmm2, %xmm2     # xmm2 = xmm2[2,3,2,3]
movq 0x8(%rbp,%rdx,8), %xmm1
punpcklqdq %xmm1, %xmm2    # xmm2 = xmm2[0],xmm1[0]
movdqa %xmm5, %xmm4
movdqa 0x1b0(%rsp), %xmm1
psubq %xmm1, %xmm4
movdqa 0x1a0(%rsp), %xmm13
psubq %xmm13, %xmm2
psubq %xmm1, %xmm8
psubq %xmm13, %xmm0
movdqa %xmm2, %xmm1
pxor %xmm6, %xmm1
movdqa %xmm4, %xmm14
pxor %xmm6, %xmm14
movdqa %xmm14, %xmm15
pcmpgtd %xmm1, %xmm15
pshufd $0xa0, %xmm15, %xmm13   # xmm13 = xmm15[0,0,2,2]
pcmpeqd %xmm1, %xmm14
pshufd $0xf5, %xmm14, %xmm14   # xmm14 = xmm14[1,1,3,3]
pand %xmm13, %xmm14
pshufd $0xf5, %xmm15, %xmm1    # xmm1 = xmm15[1,1,3,3]
por %xmm14, %xmm1
pand %xmm1, %xmm4
pandn %xmm2, %xmm1
por %xmm4, %xmm1
movdqa %xmm0, %xmm2
pxor %xmm6, %xmm2
movdqa %xmm8, %xmm4
pxor %xmm6, %xmm4
movdqa %xmm4, %xmm13
pcmpgtd %xmm2, %xmm13
pshufd $0xa0, %xmm13, %xmm14   # xmm14 = xmm13[0,0,2,2]
pcmpeqd %xmm2, %xmm4
pshufd $0xf5, %xmm4, %xmm2     # xmm2 = xmm4[1,1,3,3]
pand %xmm14, %xmm2
pshufd $0xf5, %xmm13, %xmm4    # xmm4 = xmm13[1,1,3,3]
por %xmm2, %xmm4
pand %xmm4, %xmm8
pandn %xmm0, %xmm4
por %xmm8, %xmm4
movdqa %xmm4, %xmm0
pxor %xmm6, %xmm0
movdqa %xmm3, %xmm2
pxor %xmm6, %xmm2
movdqa %xmm2, %xmm8
pcmpgtd %xmm0, %xmm8
pshufd $0xa0, %xmm8, %xmm13    # xmm13 = xmm8[0,0,2,2]
pcmpeqd %xmm0, %xmm2
pshufd $0xf5, %xmm2, %xmm0     # xmm0 = xmm2[1,1,3,3]
pand %xmm13, %xmm0
pshufd $0xf5, %xmm8, %xmm2     # xmm2 = xmm8[1,1,3,3]
por %xmm0, %xmm2
pand %xmm2, %xmm3
pandn %xmm4, %xmm2
por %xmm3, %xmm2
movdqa %xmm2, %xmm0
pxor %xmm6, %xmm0
movdqa %xmm1, %xmm3
pxor %xmm6, %xmm3
movdqa %xmm0, %xmm8
pcmpgtd %xmm3, %xmm8
pshufd $0xa0, %xmm8, %xmm13    # xmm13 = xmm8[0,0,2,2]
pcmpeqd %xmm0, %xmm3
pshufd $0xf5, %xmm3, %xmm0     # xmm0 = xmm3[1,1,3,3]
pand %xmm13, %xmm0
pshufd $0xf5, %xmm8, %xmm3     # xmm3 = xmm8[1,1,3,3]
por %xmm0, %xmm3
pand %xmm3, %xmm2
pandn %xmm1, %xmm3
por %xmm2, %xmm3
movdqa %xmm12, %xmm0
pcmpeqd %xmm7, %xmm0
pshufd $0xb1, %xmm0, %xmm14    # xmm14 = xmm0[1,0,3,2]
pand %xmm0, %xmm14
movdqa %xmm14, %xmm0
pandn %xmm3, %xmm0
movdqa 0x90(%rsp), %xmm8
pand %xmm14, %xmm8
por %xmm0, %xmm8
movdqa %xmm8, %xmm3
pxor %xmm6, %xmm3
cmpq $0x2, %rdx
jb 0x357bed
movdqa 0xb0(%rsp), %xmm15
movdqa %xmm15, %xmm0
pxor %xmm6, %xmm0
movdqa %xmm3, %xmm2
pcmpgtd %xmm0, %xmm2
pshufd $0xa0, %xmm2, %xmm13    # xmm13 = xmm2[0,0,2,2]
pcmpeqd %xmm3, %xmm0
pshufd $0xf5, %xmm0, %xmm0     # xmm0 = xmm0[1,1,3,3]
pand %xmm13, %xmm0
pshufd $0xf5, %xmm2, %xmm2     # xmm2 = xmm2[1,1,3,3]
por %xmm0, %xmm2
pand %xmm2, %xmm15
pandn %xmm8, %xmm2
por %xmm2, %xmm15
movdqa %xmm15, 0xb0(%rsp)
movdqa 0x80(%rsp), %xmm15
movdqa %xmm15, %xmm0
pxor %xmm6, %xmm0
movdqa %xmm0, %xmm2
pcmpgtd %xmm3, %xmm2
pshufd $0xa0, %xmm2, %xmm13    # xmm13 = xmm2[0,0,2,2]
pcmpeqd %xmm3, %xmm0
pshufd $0xf5, %xmm0, %xmm0     # xmm0 = xmm0[1,1,3,3]
pand %xmm13, %xmm0
pshufd $0xf5, %xmm2, %xmm2     # xmm2 = xmm2[1,1,3,3]
por %xmm0, %xmm2
pand %xmm2, %xmm15
pandn %xmm8, %xmm2
por %xmm2, %xmm15
movdqa %xmm15, 0x80(%rsp)
cmpq %rsi, %r11
setne %dil
movq 0x20(%rsp), %rax
movq 0x10(%rax), %rax
movq (%rax), %rbx
movq 0x8(%rax), %rax
cmpq %r15, %rdx
setae %r8b
orb %dil, %r8b
pshufd $0xee, %xmm8, %xmm0     # xmm0 = xmm8[2,3,2,3]
jne 0x357c1b
movd %xmm0, (%rbx,%rdx,4)
cmpq %rdx, 0x128(%rsp)
jne 0x357c2b
movd %xmm0, (%rax,%r11,4)
cmpq %rsi, %r10
setne %dil
testq %rdx, %rdx
sete %r8b
orb %dil, %r8b
jne 0x357c45
movd %xmm8, -0x4(%rbx,%rdx,4)
movdqa %xmm14, %xmm2
pandn %xmm1, %xmm2
movdqa 0x60(%rsp), %xmm0
pand %xmm14, %xmm0
por %xmm0, %xmm2
pandn %xmm4, %xmm14
cmpq 0x30(%rsp), %r10
setge %dil
cmpq %rdx, %r15
setne %r8b
orb %dil, %r8b
jne 0x357c7d
movd %xmm8, (%rax,%r10,4)
por %xmm14, %xmm0
movq %xmm12, %rax
xorl %edi, %edi
cmpq %r14, %rax
sete %dil
negq %rdi
pshufd $0xee, %xmm12, %xmm1    # xmm1 = xmm12[2,3,2,3]
movq %xmm1, %r8
xorl %ebx, %ebx
cmpq %r14, %r8
sete %bl
negq %rbx
movq %rdi, %xmm1
movq %rbx, %xmm4
punpcklqdq %xmm4, %xmm1    # xmm1 = xmm1[0],xmm4[0]
xorl %edi, %edi
cmpq %r15, %rax
setl %dil
negq %rdi
xorl %eax, %eax
cmpq %r15, %r8
setl %al
negq %rax
movq %rdi, %xmm4
movq %rax, %xmm13
punpcklqdq %xmm13, %xmm4   # xmm4 = xmm4[0],xmm13[0]
movdqa %xmm11, %xmm13
movdqa 0x2d1ca6(%rip), %xmm6   # 0x629990
pxor %xmm6, %xmm13
movdqa %xmm3, %xmm14
pcmpgtd %xmm13, %xmm14
pshufd $0xa0, %xmm14, %xmm15   # xmm15 = xmm14[0,0,2,2]
pcmpeqd %xmm3, %xmm13
pshufd $0xf5, %xmm13, %xmm13   # xmm13 = xmm13[1,1,3,3]
pand %xmm15, %xmm13
pshufd $0xf5, %xmm14, %xmm14   # xmm14 = xmm14[1,1,3,3]
por %xmm13, %xmm14
movdqa %xmm9, %xmm13
pxor %xmm6, %xmm13
movdqa %xmm3, %xmm15
pcmpgtd %xmm13, %xmm15
pcmpeqd %xmm3, %xmm13
pshufd $0xa0, %xmm15, %xmm3    # xmm3 = xmm15[0,0,2,2]
pshufd $0xf5, %xmm13, %xmm13   # xmm13 = xmm13[1,1,3,3]
pand %xmm3, %xmm13
pshufd $0xf5, %xmm15, %xmm15   # xmm15 = xmm15[1,1,3,3]
por %xmm13, %xmm15
pshufd $0xf5, %xmm12, %xmm3    # xmm3 = xmm12[1,1,3,3]
pcmpeqd %xmm7, %xmm7
pcmpgtd %xmm7, %xmm3
pand %xmm4, %xmm3
movdqa 0xc0(%rsp), %xmm13
pand %xmm13, %xmm3
pand %xmm14, %xmm3
movdqa 0xd0(%rsp), %xmm4
pand %xmm1, %xmm4
pand %xmm13, %xmm1
pand %xmm15, %xmm4
movdqa %xmm3, %xmm13
pandn %xmm11, %xmm13
movdqa %xmm3, %xmm11
pand %xmm8, %xmm11
por %xmm13, %xmm11
movdqa %xmm4, %xmm13
pandn %xmm9, %xmm13
movdqa %xmm4, %xmm9
pand %xmm8, %xmm9
por %xmm13, %xmm9
movdqa %xmm8, %xmm13
pand %xmm1, %xmm13
pandn 0x50(%rsp), %xmm1
movdqa %xmm1, %xmm14
por %xmm13, %xmm14
movdqa %xmm4, %xmm1
pandn %xmm10, %xmm1
pand 0x40(%rsp), %xmm4
movdqa %xmm4, %xmm10
por %xmm1, %xmm10
movdqa %xmm3, %xmm1
pandn 0xa0(%rsp), %xmm1
pand %xmm12, %xmm3
por %xmm1, %xmm3
movq %xmm8, (%r13,%rdx,8)
movq %xmm2, (%rbp,%rdx,8)
psubq %xmm7, %xmm12
incq %rdx
cmpq %rdx, 0x120(%rsp)
jne 0x357972
movdqa 0x40(%rsp), %xmm0
paddq 0x2d10b8(%rip), %xmm0   # 0x628ef0
movdqa %xmm0, 0x40(%rsp)
movdqa 0x90(%rsp), %xmm0
psubq 0x130(%rsp), %xmm0
movdqa %xmm0, 0x90(%rsp)
movq 0x118(%rsp), %rax
movq %rax, %r11
movq 0x30(%rsp), %r8
cmpq %r8, %rax
movq 0x200(%rsp), %rbx
movq 0x108(%rsp), %rdi
jl 0x35781e
jmp 0x357eab
movdqa 0x60(%rsp), %xmm0
movdqa %xmm0, %xmm3
movdqa %xmm0, %xmm10
movdqa %xmm0, %xmm14
movdqa %xmm0, %xmm9
movdqa %xmm0, %xmm11
movdqa %xmm0, 0x80(%rsp)
movdqa %xmm11, 0x170(%rsp)
movdqa %xmm9, 0x160(%rsp)
movdqa %xmm14, 0x150(%rsp)
movdqa %xmm10, 0xe0(%rsp)
movdqa %xmm3, 0x140(%rsp)
xorl %edi, %edi
movb $0x1, %r8b
movq 0x38(%rsp), %r11
movq %r11, %rax
movq %r11, %rsi
xorl %ecx, %ecx
xorl %edx, %edx
movl 0x210(%rsp), %r15d
movq 0x160(%rsp,%rdi), %r9
cmpq %rax, %r9
jle 0x357f15
movq 0xe0(%rsp,%rdi), %r10
movl %r10d, %ecx
movq %r9, %rax
jmp 0x357f2d
jne 0x357f2d
movq 0xe0(%rsp,%rdi), %r10
movq %r11, %r14
movslq %ecx, %r11
cmpq %r11, %r10
movq %r14, %r11
jl 0x357f0d
movq 0x170(%rsp,%rdi), %r9
cmpq %rsi, %r9
jle 0x357f44
movl 0x140(%rsp,%rdi), %edx
movq %r9, %rsi
movq 0x150(%rsp,%rdi), %r9
cmpq %r11, %r9
cmovgq %r9, %r11
addq $0x8, %rdi
testb $0x1, %r8b
movl $0x0, %r8d
jne 0x357ef8
movl 0x220(%rsp), %r9d
testl %r9d, %r9d
sete %dil
testl %r15d, %r15d
sete %r8b
orb %dil, %r8b
jne 0x357faf
cmpq %rsi, %rax
movq 0x20(%rsp), %r8
jg 0x357fb9
jne 0x357f9a
movq 0x8(%rsp), %rdi
decl %edi
movq %rdi, 0x8(%rsp)
cmpl %edi, %edx
je 0x358019
movq 0x28(%rsp), %rdi
decl %edi
movq %rsi, %rax
movl %edx, %ecx
movq %rcx, 0x8(%rsp)
movl %edi, %ecx
jmp 0x358019
testl %r15d, %r15d
movq 0x20(%rsp), %r8
je 0x357ff9
movq 0x8(%rsp), %rdx
decl %edx
movq %rdx, 0x8(%rsp)
jmp 0x358019
callq 0x1b53c7
jmp 0x358112
callq 0x1b53a1
jmp 0x358112
callq 0x1b537b
jmp 0x358112
callq 0x1b5355
jmp 0x358112
callq 0x1b532f
jmp 0x358112
movq 0x28(%rsp), %rcx
decl %ecx
movq 0x8(%rsp), %rax
decl %eax
testl %r9d, %r9d
cmovneq %rsi, %r11
cmovnel %edx, %eax
movq %rax, 0x8(%rsp)
movq %r11, %rax
movq 0xf8(%rsp), %xmm0
pshufd $0x44, %xmm0, %xmm0     # xmm0 = xmm0[0,1,0,1]
movdqa 0x2d1961(%rip), %xmm1   # 0x629990
movdqa 0xb0(%rsp), %xmm4
pxor %xmm1, %xmm4
pxor %xmm1, %xmm0
movdqa %xmm4, %xmm2
pcmpgtd %xmm0, %xmm2
pshufd $0xa0, %xmm2, %xmm3     # xmm3 = xmm2[0,0,2,2]
pcmpeqd %xmm4, %xmm0
pshufd $0xf5, %xmm0, %xmm0     # xmm0 = xmm0[1,1,3,3]
pand %xmm3, %xmm0
pshufd $0xf5, %xmm2, %xmm2     # xmm2 = xmm2[1,1,3,3]
por %xmm0, %xmm2
pcmpeqd %xmm0, %xmm0
pxor %xmm2, %xmm0
pshufd $0x44, 0x180(%rsp), %xmm2 # xmm2 = mem[0,1,0,1]
movdqa 0x80(%rsp), %xmm4
pxor %xmm1, %xmm4
pxor %xmm1, %xmm2
movdqa %xmm4, %xmm1
pcmpgtd %xmm2, %xmm1
pshufd $0xa0, %xmm1, %xmm3     # xmm3 = xmm1[0,0,2,2]
pcmpeqd %xmm4, %xmm2
pshufd $0xf5, %xmm2, %xmm2     # xmm2 = xmm2[1,1,3,3]
pand %xmm3, %xmm2
pshufd $0xf5, %xmm1, %xmm1     # xmm1 = xmm1[1,1,3,3]
por %xmm2, %xmm1
por %xmm0, %xmm1
pmovmskb %xmm1, %edx
testl %edx, %edx
je 0x3580c7
orb $0x40, 0xc(%r8)
xorl %eax, %eax
movq $0x0, 0x8(%rsp)
xorl %ecx, %ecx
movl %eax, (%r8)
movl %ecx, 0x4(%r8)
movq 0x8(%rsp), %rax
movl %eax, 0x8(%r8)
movq %rbp, %rdi
callq 0x20a60d
movq %r13, %rdi
callq 0x20a60d
movq %r12, %rdi
callq 0x20a60d
cmpl $0x0, 0x30(%rbx)
jne 0x3580ff
movq 0x70(%rsp), %rdi
callq 0x20a60d
movq 0x20(%rsp), %rax
jmp 0x358114
callq 0x1b5309
jmp 0x358112
callq 0x1b52e3
xorl %eax, %eax
addq $0x1c8, %rsp            # imm = 0x1C8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq