// File: /workspace/github_c_makefile_star2_O1/enzo1982[P]smooth/libraries/libwebp/src/dsp/dec_sse2.c
// Function: VFilter16i_SSE2
static void VFilter16i_SSE2(uint8_t* p, int stride,
                            int thresh, int ithresh, int hev_thresh) {
  int k;
  __m128i p3, p2, p1, p0;   // loop invariants

  LOAD_H_EDGES4(p, stride, p3, p2, p1, p0);  // prologue

  for (k = 3; k > 0; --k) {
    __m128i mask, tmp1, tmp2;
    uint8_t* const b = p + 2 * stride;   // beginning of p1
    p += 4 * stride;

    MAX_DIFF1(p3, p2, p1, p0, mask);   // compute partial mask
    LOAD_H_EDGES4(p, stride, p3, p2, tmp1, tmp2);
    MAX_DIFF2(p3, p2, tmp1, tmp2, mask);

    // p3 and p2 are not just temporary variables here: they will be
    // re-used for next span. And q2/q3 will become p1/p0 accordingly.
    ComplexMask_SSE2(&p1, &p0, &p3, &p2, thresh, ithresh, &mask);
    DoFilter4_SSE2(&p1, &p0, &p3, &p2, &mask, hev_thresh);

    // Store
    _mm_storeu_si128((__m128i*)&b[0 * stride], p1);
    _mm_storeu_si128((__m128i*)&b[1 * stride], p0);
    _mm_storeu_si128((__m128i*)&b[2 * stride], p3);
    _mm_storeu_si128((__m128i*)&b[3 * stride], p2);

    // rotate samples
    p1 = tmp1;
    p0 = tmp2;
  }
}

// Assembly:
movdqu (%rdi), %xmm2
movslq %esi, %r10
movdqu (%rdi,%r10), %xmm0
leaq (%r10,%r10), %rax
movdqu (%rdi,%r10,2), %xmm13
leaq (%r10,%r10,2), %rsi
movdqu (%rdi,%rsi), %xmm12
leaq (,%r10,4), %r9
movd %ecx, %xmm1
punpcklbw %xmm1, %xmm1    # xmm1 = xmm1[0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7]
pshuflw $0x0, %xmm1, %xmm1      # xmm1 = xmm1[0,0,0,0,4,5,6,7]
pshufd $0x0, %xmm1, %xmm1      # xmm1 = xmm1[0,0,0,0]
movd %edx, %xmm3
punpcklbw %xmm3, %xmm3    # xmm3 = xmm3[0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7]
pshuflw $0x0, %xmm3, %xmm3      # xmm3 = xmm3[0,0,0,0,4,5,6,7]
pshufd $0x0, %xmm3, %xmm3      # xmm3 = xmm3[0,0,0,0]
movd %r8d, %xmm4
punpcklbw %xmm4, %xmm4    # xmm4 = xmm4[0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7]
pshuflw $0x0, %xmm4, %xmm4      # xmm4 = xmm4[0,0,0,0,4,5,6,7]
pshufd $0x0, %xmm4, %xmm4      # xmm4 = xmm4[0,0,0,0]
leaq (%rsi,%r10,2), %rcx
leaq (%rsi,%r10,4), %rdx
leaq (%rax,%r10,4), %r8
leaq (%r10,%r10,4), %r10
movl $0x4, %r11d
movdqa 0x46613(%rip), %xmm7    # 0x12b4b0
movdqa %xmm12, %xmm6
psubusb %xmm13, %xmm6
movdqa %xmm13, %xmm8
psubusb %xmm12, %xmm8
por %xmm6, %xmm8
movdqa %xmm0, %xmm6
psubusb %xmm2, %xmm6
psubusb %xmm0, %xmm2
por %xmm6, %xmm2
pmaxub %xmm8, %xmm2
movdqa %xmm13, %xmm6
psubusb %xmm0, %xmm6
psubusb %xmm13, %xmm0
por %xmm6, %xmm0
pmaxub %xmm2, %xmm0
movdqu (%rdi,%r8), %xmm11
movdqu (%rdi,%rdx), %xmm14
movdqa %xmm14, %xmm2
psubusb %xmm11, %xmm2
movdqa %xmm11, %xmm10
psubusb %xmm14, %xmm10
por %xmm2, %xmm10
pmaxub %xmm0, %xmm10
movdqu (%rdi,%r10), %xmm0
movdqu (%rdi,%r9), %xmm2
movdqa %xmm0, %xmm9
psubusb %xmm2, %xmm9
movdqa %xmm2, %xmm15
psubusb %xmm0, %xmm15
por %xmm9, %xmm15
movdqa %xmm11, %xmm9
psubusb %xmm0, %xmm9
movdqa %xmm0, %xmm6
psubusb %xmm11, %xmm6
por %xmm9, %xmm6
pmaxub %xmm15, %xmm6
pmaxub %xmm10, %xmm6
movdqa %xmm6, %xmm10
pminub %xmm1, %xmm10
pcmpeqb %xmm6, %xmm10
movdqa %xmm0, %xmm6
psubusb %xmm13, %xmm6
movdqa %xmm13, %xmm5
psubusb %xmm0, %xmm5
por %xmm6, %xmm5
movdqa %xmm2, %xmm6
psubusb %xmm12, %xmm6
movdqa %xmm12, %xmm9
psubusb %xmm2, %xmm9
por %xmm6, %xmm9
psrlw $0x1, %xmm5
pand 0x44ce4(%rip), %xmm5    # 0x129c80
paddusb %xmm9, %xmm9
paddusb %xmm5, %xmm9
movdqa %xmm9, %xmm6
pminub %xmm3, %xmm6
pcmpeqb %xmm9, %xmm6
pmaxub %xmm8, %xmm15
movdqa %xmm15, %xmm8
pminub %xmm4, %xmm8
pcmpeqb %xmm15, %xmm8
pxor %xmm7, %xmm13
pxor %xmm7, %xmm0
movdqa %xmm13, %xmm5
psubsb %xmm0, %xmm5
pxor %xmm7, %xmm2
pxor %xmm7, %xmm12
movdqa %xmm8, %xmm9
pandn %xmm5, %xmm9
movdqa %xmm2, %xmm5
psubsb %xmm12, %xmm5
paddsb %xmm5, %xmm9
paddsb %xmm5, %xmm9
paddsb %xmm5, %xmm9
pand %xmm10, %xmm9
pand %xmm6, %xmm9
movdqa %xmm9, %xmm5
paddsb 0x48a94(%rip), %xmm5    # 0x12dab0
paddsb 0x48a9b(%rip), %xmm9    # 0x12dac0
punpcklbw %xmm5, %xmm6    # xmm6 = xmm6[0],xmm5[0],xmm6[1],xmm5[1],xmm6[2],xmm5[2],xmm6[3],xmm5[3],xmm6[4],xmm5[4],xmm6[5],xmm5[5],xmm6[6],xmm5[6],xmm6[7],xmm5[7]
punpckhbw %xmm5, %xmm5    # xmm5 = xmm5[8,8,9,9,10,10,11,11,12,12,13,13,14,14,15,15]
psraw $0xb, %xmm6
psraw $0xb, %xmm5
packsswb %xmm5, %xmm6
punpcklbw %xmm9, %xmm5    # xmm5 = xmm5[0],xmm9[0],xmm5[1],xmm9[1],xmm5[2],xmm9[2],xmm5[3],xmm9[3],xmm5[4],xmm9[4],xmm5[5],xmm9[5],xmm5[6],xmm9[6],xmm5[7],xmm9[7]
punpckhbw %xmm9, %xmm9    # xmm9 = xmm9[8,8,9,9,10,10,11,11,12,12,13,13,14,14,15,15]
psraw $0xb, %xmm5
psraw $0xb, %xmm9
packsswb %xmm9, %xmm5
paddsb %xmm12, %xmm6
psubsb %xmm5, %xmm2
pxor %xmm7, %xmm5
pavgb 0xf066(%rip), %xmm5     # 0xf40d0
paddb 0x48a7e(%rip), %xmm5    # 0x12daf0
pand %xmm8, %xmm5
psubsb %xmm5, %xmm0
paddsb %xmm13, %xmm5
pxor %xmm7, %xmm5
movdqu %xmm5, (%rdi,%rax)
pxor %xmm7, %xmm6
movdqu %xmm6, (%rdi,%rsi)
pxor %xmm7, %xmm2
pxor %xmm7, %xmm0
movdqu %xmm2, (%rdi,%rax,2)
movdqu %xmm0, (%rdi,%rcx)
addq %r9, %rdi
decl %r11d
movdqa %xmm14, %xmm12
movdqa %xmm11, %xmm13
cmpl $0x1, %r11d
ja 0xe4e9d
retq