// File: /workspace/github_c_makefile_star2_O2/samtools[P]htslib/htscodecs/htscodecs/rANS_static32x16pr_sse4.c
// Function: rans_uncompress_O0_32x16_sse4
unsigned char *rans_uncompress_O0_32x16_sse4(unsigned char *in,
                                             unsigned int in_size,
                                             unsigned char *out,
                                             unsigned int out_sz) {
    if (in_size < 16) // 4-states at least
        return NULL;

    if (out_sz >= INT_MAX)
        return NULL; // protect against some overflow cases

#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
    if (out_sz > 100000)
        return NULL;
#endif

    /* Load in the static tables */
    unsigned char *cp = in, *out_free = NULL;
    unsigned char *cp_end = in + in_size;
    int i;
    uint32_t s3[TOTFREQ] __attribute__((aligned(32))); // For TF_SHIFT <= 12

    if (!out)
        out_free = out = malloc(out_sz);
    if (!out)
        return NULL;

    // Precompute reverse lookup of frequency.
    uint32_t F[256] = {0}, fsum;
    int fsz = decode_freq(cp, cp_end, F, &fsum);
    if (!fsz)
        goto err;
    cp += fsz;

    normalise_freq_shift(F, fsum, TOTFREQ);

    // Build symbols; fixme, do as part of decode, see the _d variant
    if (rans_F_to_s3(F, TF_SHIFT, s3))
        goto err;

    if (cp_end - cp < NX * 4)
        goto err;

    int z;
    RansState R[NX] __attribute__((aligned(32)));
    for (z = 0; z < NX; z++) {
        RansDecInit(&R[z], &cp);
        if (R[z] < RANS_BYTE_L)
            goto err;
    }

    uint16_t *sp = (uint16_t *)cp;

    int out_end = (out_sz&~(NX-1));
    const uint32_t mask = (1u << TF_SHIFT)-1;

    __m128i maskv  = _mm_set1_epi32(mask); // set mask in all lanes
    LOAD128(Rv, R);

    uint8_t overflow[72+64] = {0};
    for (i=0; i < out_end; i+=NX) {
        //for (z = 0; z < NX; z++)
        //  m[z] = R[z] & mask;
        __m128i masked1 = _mm_and_si128(Rv1, maskv);
        __m128i masked2 = _mm_and_si128(Rv2, maskv);
        __m128i masked3 = _mm_and_si128(Rv3, maskv);
        __m128i masked4 = _mm_and_si128(Rv4, maskv);

        //  S[z] = s3[m[z]];
        __m128i Sv1 = _mm_i32gather_epi32x((int *)s3, masked1, sizeof(*s3));
        __m128i Sv2 = _mm_i32gather_epi32x((int *)s3, masked2, sizeof(*s3));
        __m128i Sv3 = _mm_i32gather_epi32x((int *)s3, masked3, sizeof(*s3));
        __m128i Sv4 = _mm_i32gather_epi32x((int *)s3, masked4, sizeof(*s3));

        //  f[z] = S[z]>>(TF_SHIFT+8);
        __m128i fv1 = _mm_srli_epi32(Sv1, TF_SHIFT+8);
        __m128i fv2 = _mm_srli_epi32(Sv2, TF_SHIFT+8);
        __m128i fv3 = _mm_srli_epi32(Sv3, TF_SHIFT+8);
        __m128i fv4 = _mm_srli_epi32(Sv4, TF_SHIFT+8);

        //  b[z] = (S[z]>>8) & mask;
        __m128i bv1 = _mm_and_si128(_mm_srli_epi32(Sv1, 8), maskv);
        __m128i bv2 = _mm_and_si128(_mm_srli_epi32(Sv2, 8), maskv);
        __m128i bv3 = _mm_and_si128(_mm_srli_epi32(Sv3, 8), maskv);
        __m128i bv4 = _mm_and_si128(_mm_srli_epi32(Sv4, 8), maskv);

        //  s[z] = S[z] & 0xff;
        __m128i sv1 = _mm_and_si128(Sv1, _mm_set1_epi32(0xff));
        __m128i sv2 = _mm_and_si128(Sv2, _mm_set1_epi32(0xff));
        __m128i sv3 = _mm_and_si128(Sv3, _mm_set1_epi32(0xff));
        __m128i sv4 = _mm_and_si128(Sv4, _mm_set1_epi32(0xff));

        //  R[z] = f[z] * (R[z] >> TF_SHIFT) + b[z];
        Rv1 = _mm_add_epi32(
                  _mm_mullo_epi32(
                      _mm_srli_epi32(Rv1,TF_SHIFT), fv1), bv1);
        Rv2 = _mm_add_epi32(
                  _mm_mullo_epi32(
                      _mm_srli_epi32(Rv2,TF_SHIFT), fv2), bv2);
        Rv3 = _mm_add_epi32(
                  _mm_mullo_epi32(
                      _mm_srli_epi32(Rv3,TF_SHIFT), fv3), bv3);
        Rv4 = _mm_add_epi32(
                  _mm_mullo_epi32(
                      _mm_srli_epi32(Rv4,TF_SHIFT), fv4), bv4);

        // Tricky one:  out[i+z] = s[z];
        //             ---d---c ---b---a  sv1
        //             ---h---g ---f---e  sv2
        // packs_epi32 -h-g-f-e -d-c-b-a  sv1(2)
        // packs_epi16 ponmlkji hgfedcba  sv1(2) / sv3(4)
        sv1 = _mm_packus_epi32(sv1, sv2);
        sv3 = _mm_packus_epi32(sv3, sv4);
        sv1 = _mm_packus_epi16(sv1, sv3);

        // c =  R[z] < RANS_BYTE_L;
        // A little tricky as we only have signed comparisons.
        // See https://stackoverflow.com/questions/32945410/sse2-intrinsics-comparing-unsigned-integers

#define _mm_cmplt_epu32_imm(a,b) _mm_andnot_si128(_mm_cmpeq_epi32(_mm_max_epu32((a),_mm_set1_epi32(b)), (a)), _mm_set1_epi32(-1));

//#define _mm_cmplt_epu32_imm(a,b) _mm_cmpgt_epi32(_mm_set1_epi32((b)-0x80000000), _mm_xor_si128((a), _mm_set1_epi32(0x80000000)))

        __m128i renorm_mask1, renorm_mask2, renorm_mask3, renorm_mask4;
        renorm_mask1 = _mm_cmplt_epu32_imm(Rv1, RANS_BYTE_L);
        renorm_mask2 = _mm_cmplt_epu32_imm(Rv2, RANS_BYTE_L);
        renorm_mask3 = _mm_cmplt_epu32_imm(Rv3, RANS_BYTE_L);
        renorm_mask4 = _mm_cmplt_epu32_imm(Rv4, RANS_BYTE_L);

//#define P(A,B,C,D) ((A)+((B)<<2) + ((C)<<4) + ((D)<<6))
#define P(A,B,C,D)                              \
        { A+0,A+1,A+2,A+3,                      \
          B+0,B+1,B+2,B+3,                      \
          C+0,C+1,C+2,C+3,                      \
          D+0,D+1,D+2,D+3}
#ifdef _
#undef _
#endif
#define _ 0x80
        uint8_t pidx[16][16] = {
            P(_,_,_,_),
            P(0,_,_,_),
            P(_,0,_,_),
            P(0,4,_,_),

            P(_,_,0,_),
            P(0,_,4,_),
            P(_,0,4,_),
            P(0,4,8,_),

            P(_,_,_,0),
            P(0,_,_,4),
            P(_,0,_,4),
            P(0,4,_,8),

            P(_,_,0,4),
            P(0,_,4,8),
            P(_,0,4,8),
            P(0,4,8,12),
        };
#undef _

        // Protect against running off the end of in buffer.
        // We copy it to a worst-case local buffer when near the end.
        // 72 = 7*8(imask1..7) + 16;  worse case for 8th _mm_loadu_si128 call.
        // An extra 64 bytes is to avoid triggering this multiple times
        // after we swap sp/cp_end over.
        if ((uint8_t *)sp+72 > cp_end) {
            memmove(overflow, sp, cp_end - (uint8_t *)sp);
            sp = (uint16_t *)overflow;
            cp_end = (uint8_t *)overflow + sizeof(overflow);
        }

        // Shuffle the renorm values to correct lanes and incr sp pointer
        __m128i Vv1 = _mm_cvtepu16_epi32(_mm_loadu_si128((__m128i *)sp));
        unsigned int imask1 = _mm_movemask_ps((__m128)renorm_mask1);
        Vv1 = _mm_shuffle_epi8(Vv1, _mm_load_si128((__m128i*)pidx[imask1]));
        sp += _mm_popcnt_u32(imask1);

        __m128i Vv2 = _mm_cvtepu16_epi32(_mm_loadu_si128((__m128i *)sp));
        unsigned int imask2 = _mm_movemask_ps((__m128)renorm_mask2);
        sp += _mm_popcnt_u32(imask2);
        Vv2 = _mm_shuffle_epi8(Vv2, _mm_load_si128((__m128i*)pidx[imask2]));

        __m128i Vv3 = _mm_cvtepu16_epi32(_mm_loadu_si128((__m128i *)sp));
        unsigned int imask3 = _mm_movemask_ps((__m128)renorm_mask3);
        Vv3 = _mm_shuffle_epi8(Vv3, _mm_load_si128((__m128i*)pidx[imask3]));
        sp += _mm_popcnt_u32(imask3);

        __m128i Vv4 = _mm_cvtepu16_epi32(_mm_loadu_si128((__m128i *)sp));
        unsigned int imask4 = _mm_movemask_ps((__m128)renorm_mask4);
        sp += _mm_popcnt_u32(imask4);
        Vv4 = _mm_shuffle_epi8(Vv4, _mm_load_si128((__m128i*)pidx[imask4]));

        __m128i Yv1 = _mm_slli_epi32(Rv1, 16);
        __m128i Yv2 = _mm_slli_epi32(Rv2, 16);
        __m128i Yv3 = _mm_slli_epi32(Rv3, 16);
        __m128i Yv4 = _mm_slli_epi32(Rv4, 16);

        // y = (R[z] << 16) | V[z];
        Yv1 = _mm_or_si128(Yv1, Vv1);
        Yv2 = _mm_or_si128(Yv2, Vv2);
        Yv3 = _mm_or_si128(Yv3, Vv3);
        Yv4 = _mm_or_si128(Yv4, Vv4);

        // R[z] = c ? Y[z] : R[z];
        Rv1 = _mm_blendv_epi8(Rv1, Yv1, renorm_mask1);
        Rv2 = _mm_blendv_epi8(Rv2, Yv2, renorm_mask2);
        Rv3 = _mm_blendv_epi8(Rv3, Yv3, renorm_mask3);
        Rv4 = _mm_blendv_epi8(Rv4, Yv4, renorm_mask4);

        // ------------------------------------------------------------

        //  m[z] = R[z] & mask;
        __m128i masked5 = _mm_and_si128(Rv5, maskv);
        __m128i masked6 = _mm_and_si128(Rv6, maskv);
        __m128i masked7 = _mm_and_si128(Rv7, maskv);
        __m128i masked8 = _mm_and_si128(Rv8, maskv);

        //  S[z] = s3[m[z]];
        __m128i Sv5 = _mm_i32gather_epi32x((int *)s3, masked5, sizeof(*s3));
        __m128i Sv6 = _mm_i32gather_epi32x((int *)s3, masked6, sizeof(*s3));
        __m128i Sv7 = _mm_i32gather_epi32x((int *)s3, masked7, sizeof(*s3));
        __m128i Sv8 = _mm_i32gather_epi32x((int *)s3, masked8, sizeof(*s3));

        //  f[z] = S[z]>>(TF_SHIFT+8);
        __m128i fv5 = _mm_srli_epi32(Sv5, TF_SHIFT+8);
        __m128i fv6 = _mm_srli_epi32(Sv6, TF_SHIFT+8);
        __m128i fv7 = _mm_srli_epi32(Sv7, TF_SHIFT+8);
        __m128i fv8 = _mm_srli_epi32(Sv8, TF_SHIFT+8);

        //  b[z] = (S[z]>>8) & mask;
        __m128i bv5 = _mm_and_si128(_mm_srli_epi32(Sv5, 8), maskv);
        __m128i bv6 = _mm_and_si128(_mm_srli_epi32(Sv6, 8), maskv);
        __m128i bv7 = _mm_and_si128(_mm_srli_epi32(Sv7, 8), maskv);
        __m128i bv8 = _mm_and_si128(_mm_srli_epi32(Sv8, 8), maskv);

        //  s[z] = S[z] & 0xff;
        __m128i sv5 = _mm_and_si128(Sv5, _mm_set1_epi32(0xff));
        __m128i sv6 = _mm_and_si128(Sv6, _mm_set1_epi32(0xff));
        __m128i sv7 = _mm_and_si128(Sv7, _mm_set1_epi32(0xff));
        __m128i sv8 = _mm_and_si128(Sv8, _mm_set1_epi32(0xff));

        //  R[z] = f[z] * (R[z] >> TF_SHIFT) + b[z];
        Rv5 = _mm_add_epi32(
                  _mm_mullo_epi32(
                      _mm_srli_epi32(Rv5,TF_SHIFT), fv5), bv5);
        Rv6 = _mm_add_epi32(
                  _mm_mullo_epi32(
                      _mm_srli_epi32(Rv6,TF_SHIFT), fv6), bv6);
        Rv7 = _mm_add_epi32(
                  _mm_mullo_epi32(
                      _mm_srli_epi32(Rv7,TF_SHIFT), fv7), bv7);
        Rv8 = _mm_add_epi32(
                  _mm_mullo_epi32(
                      _mm_srli_epi32(Rv8,TF_SHIFT), fv8), bv8);

        // Tricky one:  out[i+z] = s[z];
        //             ---d---c ---b---a  sv1
        //             ---h---g ---f---e  sv2
        // packs_epi32 -h-g-f-e -d-c-b-a  sv1(2)
        // packs_epi16 ponmlkji hgfedcba  sv1(2) / sv3(4)
        sv5 = _mm_packus_epi32(sv5, sv6);
        sv7 = _mm_packus_epi32(sv7, sv8);
        sv5 = _mm_packus_epi16(sv5, sv7);

        // c =  R[z] < RANS_BYTE_L;
        __m128i renorm_mask5, renorm_mask6, renorm_mask7, renorm_mask8;
        renorm_mask5 = _mm_cmplt_epu32_imm(Rv5, RANS_BYTE_L);
        renorm_mask6 = _mm_cmplt_epu32_imm(Rv6, RANS_BYTE_L);
        renorm_mask7 = _mm_cmplt_epu32_imm(Rv7, RANS_BYTE_L);
        renorm_mask8 = _mm_cmplt_epu32_imm(Rv8, RANS_BYTE_L);
        
        // Shuffle the renorm values to correct lanes and incr sp pointer
        __m128i Vv5 = _mm_cvtepu16_epi32(_mm_loadu_si128((__m128i *)sp));
        unsigned int imask5 = _mm_movemask_ps((__m128)renorm_mask5);
        Vv5 = _mm_shuffle_epi8(Vv5, _mm_load_si128((__m128i*)pidx[imask5]));
        sp += _mm_popcnt_u32(imask5);

        __m128i Vv6 = _mm_cvtepu16_epi32(_mm_loadu_si128((__m128i *)sp));
        unsigned int imask6 = _mm_movemask_ps((__m128)renorm_mask6);
        sp += _mm_popcnt_u32(imask6);
        Vv6 = _mm_shuffle_epi8(Vv6, _mm_load_si128((__m128i*)pidx[imask6]));

        __m128i Vv7 = _mm_cvtepu16_epi32(_mm_loadu_si128((__m128i *)sp));
        unsigned int imask7 = _mm_movemask_ps((__m128)renorm_mask7);
        Vv7 = _mm_shuffle_epi8(Vv7, _mm_load_si128((__m128i*)pidx[imask7]));
        sp += _mm_popcnt_u32(imask7);

        __m128i Vv8 = _mm_cvtepu16_epi32(_mm_loadu_si128((__m128i *)sp));
        unsigned int imask8 = _mm_movemask_ps((__m128)renorm_mask8);
        sp += _mm_popcnt_u32(imask8);
        Vv8 = _mm_shuffle_epi8(Vv8, _mm_load_si128((__m128i*)pidx[imask8]));

        __m128i Yv5 = _mm_slli_epi32(Rv5, 16);
        __m128i Yv6 = _mm_slli_epi32(Rv6, 16);
        __m128i Yv7 = _mm_slli_epi32(Rv7, 16);
        __m128i Yv8 = _mm_slli_epi32(Rv8, 16);

        // y = (R[z] << 16) | V[z];
        Yv5 = _mm_or_si128(Yv5, Vv5);
        Yv6 = _mm_or_si128(Yv6, Vv6);
        Yv7 = _mm_or_si128(Yv7, Vv7);
        Yv8 = _mm_or_si128(Yv8, Vv8);

        // R[z] = c ? Y[z] : R[z];
        Rv5 = _mm_blendv_epi8(Rv5, Yv5, renorm_mask5);
        Rv6 = _mm_blendv_epi8(Rv6, Yv6, renorm_mask6);
        Rv7 = _mm_blendv_epi8(Rv7, Yv7, renorm_mask7);
        Rv8 = _mm_blendv_epi8(Rv8, Yv8, renorm_mask8);

        // Maybe just a store128 instead?
        _mm_storeu_si128((__m128i *)&out[i+ 0], sv1);
        _mm_storeu_si128((__m128i *)&out[i+16], sv5);
//      *(uint64_t *)&out[i+ 0] = _mm_extract_epi64(sv1, 0);
//      *(uint64_t *)&out[i+ 8] = _mm_extract_epi64(sv1, 1);
//      *(uint64_t *)&out[i+16] = _mm_extract_epi64(sv5, 0);
//      *(uint64_t *)&out[i+24] = _mm_extract_epi64(sv5, 1);
    }

    STORE128(Rv, R);

    for (z = out_sz & (NX-1); z-- > 0; )
      out[out_end + z] = s3[R[z] & mask];

    //fprintf(stderr, "    0 Decoded %d bytes\n", (int)(cp-in)); //c-size

    return out;

 err:
    free(out_free);
    return NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
andq $-0x20, %rsp
subq $0x4640, %rsp           # imm = 0x4640
movl %esi, %ebx
cmpl $0x10, %esi
setb %al
cmpl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
setae %sil
orb %al, %sil
jne 0x599e3
movq %rdi, %r12
movq %rcx, 0x40(%rsp)
xorl %r13d, %r13d
testq %rdx, %rdx
je 0x59887
xorl %eax, %eax
jmp 0x5989c
movl 0x40(%rsp), %edi
callq 0x4680
movq %rax, %rdx
testq %rax, %rax
je 0x599e3
movq %rax, 0x90(%rsp)
movq %rdx, 0xf8(%rsp)
movl %ebx, %eax
movq %rax, 0x50(%rsp)
leaq (%r12,%rax), %r14
leaq 0x220(%rsp), %rbx
movl $0x400, %edx            # imm = 0x400
movq %rbx, %rdi
xorl %esi, %esi
callq 0x4260
movq %r12, %rdi
movq %r14, 0x48(%rsp)
movq %r14, %rsi
movq %rbx, %rdx
callq 0x5c509
movslq %eax, %rbx
addq %r12, %rbx
xorl %r15d, %r15d
cmpq $0x400, %r15            # imm = 0x400
je 0x59927
cmpl $0x0, 0x220(%rsp,%r15)
je 0x59921
leaq (%rsp,%r15), %r14
addq $0x220, %r14            # imm = 0x220
movq %rbx, %rdi
movq 0x48(%rsp), %rsi
movq %r14, %rdx
callq 0x5bcab
cltq
addq %rax, %rbx
addl (%r14), %r13d
addq $0x4, %r15
jmp 0x598ea
subq %r12, %rbx
testl %ebx, %ebx
movq 0xf8(%rsp), %r15
je 0x599d6
movslq %ebx, %rbx
leaq 0x220(%rsp), %rdi
movl %r13d, %esi
movl $0x1000, %edx           # imm = 0x1000
callq 0x5a165
xorl %eax, %eax
xorl %ecx, %ecx
cmpq $0x100, %rax            # imm = 0x100
je 0x59998
movl 0x220(%rsp,%rax,4), %edx
movl $0x1000, %esi           # imm = 0x1000
subl %ecx, %esi
leal -0x1(%rdx), %edi
cmpl %esi, %edi
jae 0x59993
movl %edx, %esi
shll $0x14, %esi
addl %eax, %esi
subl $0x1, %edx
jb 0x59993
movslq %ecx, %rcx
movl %esi, 0x620(%rsp,%rcx,4)
incl %ecx
addl $0x100, %esi            # imm = 0x100
jmp 0x5997a
incq %rax
jmp 0x59956
cmpl $0x1000, %ecx           # imm = 0x1000
jne 0x599d6
movq 0x50(%rsp), %rax
subq %rbx, %rax
cmpq $0x80, %rax
jl 0x599d6
addq %rbx, %r12
xorl %ebx, %ebx
cmpq $0x80, %rbx
je 0x599f8
movl (%r12,%rbx), %eax
movl %eax, 0x100(%rsp,%rbx)
cmpl $0x8000, %eax           # imm = 0x8000
jb 0x599d6
addq $0x4, %rbx
jmp 0x599b5
movq 0x90(%rsp), %rdi
callq 0x45c0
xorl %r15d, %r15d
movq %r15, %rax
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x40(%rsp), %rax
andl $0x7fffffe0, %eax       # imm = 0x7FFFFFE0
movq %rax, 0xa8(%rsp)
movaps 0x100(%rsp), %xmm0
movaps %xmm0, (%rsp)
movaps 0x110(%rsp), %xmm0
movaps %xmm0, 0x10(%rsp)
movaps 0x120(%rsp), %xmm0
movaps %xmm0, 0x20(%rsp)
movaps 0x130(%rsp), %xmm0
movaps %xmm0, 0x30(%rsp)
movaps 0x140(%rsp), %xmm0
movaps %xmm0, 0xb0(%rsp)
movaps 0x150(%rsp), %xmm0
movaps %xmm0, 0xc0(%rsp)
movaps 0x160(%rsp), %xmm0
movaps %xmm0, 0xd0(%rsp)
movaps 0x170(%rsp), %xmm0
movaps %xmm0, 0x50(%rsp)
leaq 0x190(%rsp), %rdi
xorl %r14d, %r14d
movl $0x88, %edx
xorl %esi, %esi
callq 0x4260
movaps (%rsp), %xmm0
movaps 0x10(%rsp), %xmm4
movaps 0x20(%rsp), %xmm3
movaps 0x30(%rsp), %xmm2
addq %rbx, %r12
leaq 0x620(%rsp), %r13
leaq 0x2834a(%rip), %rbx     # 0x81e00
cmpq 0xa8(%rsp), %r14
jae 0x5a0cc
movaps %xmm0, (%rsp)
movaps 0x282a1(%rip), %xmm1    # 0x81d70
andps %xmm1, %xmm0
movaps %xmm4, %xmm5
andps %xmm1, %xmm5
movaps %xmm5, 0x70(%rsp)
movaps %xmm3, %xmm5
andps %xmm1, %xmm5
movaps %xmm5, 0x80(%rsp)
movaps %xmm2, %xmm5
andps %xmm1, %xmm5
movaps %xmm5, 0x60(%rsp)
movq %r13, %rdi
movaps %xmm2, 0x30(%rsp)
movaps %xmm3, 0x20(%rsp)
movaps %xmm4, 0x10(%rsp)
callq 0x5a192
movaps %xmm0, 0x90(%rsp)
movq %r13, %rdi
movaps 0x70(%rsp), %xmm0
callq 0x5a192
movaps %xmm0, 0x70(%rsp)
movq %r13, %rdi
movaps 0x80(%rsp), %xmm0
callq 0x5a192
movaps %xmm0, 0x80(%rsp)
movq %r13, %rdi
movdqa 0x60(%rsp), %xmm0
callq 0x5a192
movdqa 0x90(%rsp), %xmm2
movdqa %xmm2, %xmm1
psrld $0x14, %xmm1
movdqa (%rsp), %xmm3
psrld $0xc, %xmm3
pmulld %xmm1, %xmm3
movdqa %xmm3, %xmm1
movdqa %xmm2, %xmm4
psrld $0x8, %xmm4
pmovsxwd 0x2825c(%rip), %xmm3    # 0x81de0
pand %xmm3, %xmm4
paddd %xmm1, %xmm4
movdqa 0x70(%rsp), %xmm6
movdqa %xmm6, %xmm1
psrld $0x14, %xmm1
movdqa 0x10(%rsp), %xmm5
psrld $0xc, %xmm5
pmulld %xmm1, %xmm5
movdqa %xmm5, %xmm1
movdqa %xmm6, %xmm5
movdqa %xmm6, %xmm9
psrld $0x8, %xmm5
pand %xmm3, %xmm5
paddd %xmm1, %xmm5
movdqa 0x80(%rsp), %xmm7
movdqa %xmm7, %xmm1
psrld $0x14, %xmm1
movdqa 0x20(%rsp), %xmm6
psrld $0xc, %xmm6
pmulld %xmm1, %xmm6
movdqa %xmm6, %xmm1
movdqa %xmm7, %xmm6
movdqa %xmm7, %xmm8
psrld $0x8, %xmm6
pand %xmm3, %xmm6
paddd %xmm1, %xmm6
movdqa %xmm0, %xmm1
psrld $0x14, %xmm1
movdqa 0x30(%rsp), %xmm7
psrld $0xc, %xmm7
pmulld %xmm1, %xmm7
movdqa %xmm7, %xmm1
movdqa %xmm0, %xmm7
psrld $0x8, %xmm7
pand %xmm3, %xmm7
paddd %xmm1, %xmm7
pmovzxbd 0x281c0(%rip), %xmm1    # 0x81df8
pand %xmm1, %xmm2
pand %xmm1, %xmm9
packusdw %xmm9, %xmm2
pand %xmm1, %xmm8
pand %xmm1, %xmm0
packusdw %xmm0, %xmm8
packuswb %xmm8, %xmm2
movdqa %xmm2, 0x90(%rsp)
leaq 0x48(%r12), %rax
movq 0x48(%rsp), %rdx
cmpq %rdx, %rax
jbe 0x59cc4
subq %r12, %rdx
movq %r12, %rsi
leaq 0x190(%rsp), %r12
movq %r12, %rdi
movdqa %xmm4, 0x30(%rsp)
movdqa %xmm5, 0x20(%rsp)
movdqa %xmm6, 0x10(%rsp)
movdqa %xmm7, (%rsp)
callq 0x4830
movdqa (%rsp), %xmm7
movdqa 0x10(%rsp), %xmm6
movdqa 0x20(%rsp), %xmm5
movdqa 0x30(%rsp), %xmm4
leaq 0x218(%rsp), %rax
movq %rax, 0x48(%rsp)
pmovzxwd (%r12), %xmm2
movdqa %xmm4, %xmm0
pmovsxwd 0x28110(%rip), %xmm1    # 0x81de8
pminud %xmm1, %xmm0
movdqa %xmm1, %xmm8
pcmpeqd %xmm4, %xmm0
movmskps %xmm0, %eax
popcntl %eax, %ecx
shll $0x4, %eax
pshufb (%rax,%rbx), %xmm2
leaq (%r12,%rcx,2), %rax
pmovzxwd (%rax), %xmm3
movdqa %xmm5, %xmm1
pminud %xmm8, %xmm1
movdqa %xmm8, %xmm10
pcmpeqd %xmm5, %xmm1
movmskps %xmm1, %ecx
popcntl %ecx, %edx
leaq (%rax,%rdx,2), %rax
shll $0x4, %ecx
pshufb (%rcx,%rbx), %xmm3
movdqa %xmm5, %xmm9
movdqa %xmm4, %xmm5
movdqa %xmm4, %xmm8
pslld $0x10, %xmm5
por %xmm2, %xmm5
pmovzxwd (%rax), %xmm4
blendvps %xmm0, %xmm5, %xmm8
movaps %xmm8, 0x30(%rsp)
movdqa %xmm6, %xmm2
pminud %xmm10, %xmm2
pcmpeqd %xmm6, %xmm2
movmskps %xmm2, %ecx
popcntl %ecx, %edx
shll $0x4, %ecx
pshufb (%rcx,%rbx), %xmm4
movdqa %xmm9, %xmm5
pslld $0x10, %xmm5
por %xmm3, %xmm5
movaps %xmm1, %xmm0
blendvps %xmm0, %xmm5, %xmm9
movaps %xmm9, 0x20(%rsp)
leaq (%rax,%rdx,2), %rax
pmovzxwd (%rax), %xmm3
movdqa %xmm6, %xmm5
pslld $0x10, %xmm5
por %xmm4, %xmm5
movdqa %xmm7, %xmm1
pminud %xmm10, %xmm1
pcmpeqd %xmm7, %xmm1
movmskps %xmm1, %ecx
popcntl %ecx, %edx
leaq (%rax,%rdx,2), %r12
shll $0x4, %ecx
pshufb (%rcx,%rbx), %xmm3
movaps %xmm2, %xmm0
blendvps %xmm0, %xmm5, %xmm6
movaps %xmm6, 0x10(%rsp)
movdqa %xmm7, %xmm2
pslld $0x10, %xmm2
por %xmm3, %xmm2
movaps %xmm1, %xmm0
blendvps %xmm0, %xmm2, %xmm7
movaps %xmm7, (%rsp)
movaps 0xb0(%rsp), %xmm0
movaps 0x27f7a(%rip), %xmm1    # 0x81d70
andps %xmm1, %xmm0
movaps 0xc0(%rsp), %xmm2
andps %xmm1, %xmm2
movaps %xmm2, 0xe0(%rsp)
movaps 0xd0(%rsp), %xmm2
andps %xmm1, %xmm2
movaps %xmm2, 0x60(%rsp)
movaps 0x50(%rsp), %xmm2
andps %xmm1, %xmm2
movaps %xmm2, 0x80(%rsp)
movq %r13, %rdi
callq 0x5a192
movaps %xmm0, 0x70(%rsp)
movq %r13, %rdi
movaps 0xe0(%rsp), %xmm0
callq 0x5a192
movaps %xmm0, 0xe0(%rsp)
movq %r13, %rdi
movaps 0x60(%rsp), %xmm0
callq 0x5a192
movaps %xmm0, 0x60(%rsp)
movq %r13, %rdi
movdqa 0x80(%rsp), %xmm0
callq 0x5a192
movdqa %xmm0, %xmm1
movdqa 0x70(%rsp), %xmm9
movdqa %xmm9, %xmm2
psrld $0x14, %xmm2
movdqa 0xe0(%rsp), %xmm10
movdqa %xmm10, %xmm3
psrld $0x14, %xmm3
movdqa 0x60(%rsp), %xmm11
movdqa %xmm11, %xmm0
psrld $0x14, %xmm0
movdqa 0xb0(%rsp), %xmm4
psrld $0xc, %xmm4
pmulld %xmm2, %xmm4
movdqa %xmm9, %xmm2
psrld $0x8, %xmm2
pmovsxwd 0x27f0b(%rip), %xmm13   # 0x81de0
pand %xmm13, %xmm2
paddd %xmm4, %xmm2
movdqa %xmm1, %xmm5
psrld $0x14, %xmm5
movdqa 0xc0(%rsp), %xmm4
psrld $0xc, %xmm4
pmulld %xmm3, %xmm4
movdqa %xmm10, %xmm3
psrld $0x8, %xmm3
pand %xmm13, %xmm3
paddd %xmm4, %xmm3
movdqa %xmm11, %xmm4
psrld $0x8, %xmm4
movdqa 0xd0(%rsp), %xmm6
psrld $0xc, %xmm6
pmulld %xmm0, %xmm6
pand %xmm13, %xmm4
paddd %xmm6, %xmm4
movdqa 0x50(%rsp), %xmm12
psrld $0xc, %xmm12
pmulld %xmm5, %xmm12
pmovzxwd (%r12), %xmm5
movdqa %xmm2, %xmm0
pmovsxwd 0x27e8d(%rip), %xmm8    # 0x81de8
pminud %xmm8, %xmm0
pcmpeqd %xmm2, %xmm0
movmskps %xmm0, %eax
popcntl %eax, %ecx
shll $0x4, %eax
pshufb (%rax,%rbx), %xmm5
leaq (%r12,%rcx,2), %rax
movdqa %xmm2, %xmm6
pslld $0x10, %xmm6
pmovzxwd (%rax), %xmm7
por %xmm5, %xmm6
blendvps %xmm0, %xmm6, %xmm2
movdqa %xmm3, %xmm0
pminud %xmm8, %xmm0
pcmpeqd %xmm3, %xmm0
movmskps %xmm0, %ecx
popcntl %ecx, %edx
shll $0x4, %ecx
pshufb (%rcx,%rbx), %xmm7
movdqa %xmm3, %xmm6
pslld $0x10, %xmm6
por %xmm7, %xmm6
movdqa %xmm1, %xmm5
psrld $0x8, %xmm5
pand %xmm13, %xmm5
leaq (%rax,%rdx,2), %rax
blendvps %xmm0, %xmm6, %xmm3
pmovzxwd (%rax), %xmm6
movdqa %xmm4, %xmm0
pminud %xmm8, %xmm0
pcmpeqd %xmm4, %xmm0
movmskps %xmm0, %ecx
popcntl %ecx, %edx
shll $0x4, %ecx
pshufb (%rcx,%rbx), %xmm6
paddd %xmm12, %xmm5
leaq (%rax,%rdx,2), %rax
movdqa %xmm4, %xmm7
pslld $0x10, %xmm7
por %xmm6, %xmm7
pmovzxwd (%rax), %xmm6
blendvps %xmm0, %xmm7, %xmm4
movdqa %xmm5, %xmm0
pminud %xmm8, %xmm0
pcmpeqd %xmm5, %xmm0
movmskps %xmm0, %ecx
popcntl %ecx, %edx
shll $0x4, %ecx
pshufb (%rcx,%rbx), %xmm6
movdqa %xmm5, %xmm7
pslld $0x10, %xmm7
por %xmm6, %xmm7
blendvps %xmm0, %xmm7, %xmm5
pmovzxbd 0x27daa(%rip), %xmm0    # 0x81df8
movdqa %xmm9, %xmm6
pand %xmm0, %xmm6
movdqa %xmm10, %xmm7
pand %xmm0, %xmm7
packusdw %xmm7, %xmm6
movdqa %xmm11, %xmm7
pand %xmm0, %xmm7
pand %xmm0, %xmm1
packusdw %xmm1, %xmm7
packuswb %xmm7, %xmm6
movaps 0x90(%rsp), %xmm0
movups %xmm0, (%r15,%r14)
movdqu %xmm6, 0x10(%r15,%r14)
leaq (%rax,%rdx,2), %r12
addq $0x20, %r14
movaps %xmm5, 0x50(%rsp)
movaps %xmm4, 0xd0(%rsp)
movaps %xmm3, 0xc0(%rsp)
movaps %xmm2, 0xb0(%rsp)
movaps (%rsp), %xmm2
movaps 0x10(%rsp), %xmm3
movaps 0x20(%rsp), %xmm4
movaps 0x30(%rsp), %xmm0
jmp 0x59ab6
movaps %xmm0, 0x100(%rsp)
movaps %xmm4, 0x110(%rsp)
movaps %xmm3, 0x120(%rsp)
movaps %xmm2, 0x130(%rsp)
movaps 0xb0(%rsp), %xmm0
movaps %xmm0, 0x140(%rsp)
movaps 0xc0(%rsp), %xmm0
movaps %xmm0, 0x150(%rsp)
movaps 0xd0(%rsp), %xmm0
movaps %xmm0, 0x160(%rsp)
movaps 0x50(%rsp), %xmm0
movaps %xmm0, 0x170(%rsp)
movq 0x40(%rsp), %rsi
andl $0x1f, %esi
movq 0xa8(%rsp), %rax
addq %r15, %rax
decq %rax
movl $0xfff, %ecx            # imm = 0xFFF
testq %rsi, %rsi
jle 0x599e6
movl 0xfc(%rsp,%rsi,4), %edx
andl %ecx, %edx
movb 0x620(%rsp,%rdx,4), %dl
movb %dl, (%rax,%rsi)
decq %rsi
jmp 0x5a144