// File: /workspace/github_c_makefile_star2_O3/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), %xmm0
movslq %esi, %r10
movdqu (%rdi,%r10), %xmm14
leaq (%r10,%r10), %rax
movdqu (%rdi,%r10,2), %xmm12
leaq (%r10,%r10,2), %rsi
movdqu (%rdi,%rsi), %xmm11
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, %xmm2
punpcklbw %xmm2, %xmm2    # xmm2 = xmm2[0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7]
pshuflw $0x0, %xmm2, %xmm2      # xmm2 = xmm2[0,0,0,0,4,5,6,7]
pshufd $0x0, %xmm2, %xmm2      # xmm2 = xmm2[0,0,0,0]
movd %r8d, %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]
leaq (%rsi,%r10,2), %rcx
leaq (%rsi,%r10,4), %rdx
leaq (%rax,%r10,4), %r8
leaq (%r10,%r10,4), %r10
movl $0x4, %r11d
movdqa 0x4666c(%rip), %xmm6    # 0x12a6d0
movdqa %xmm11, %xmm5
psubusb %xmm12, %xmm5
movdqa %xmm12, %xmm7
psubusb %xmm11, %xmm7
por %xmm5, %xmm7
movdqa %xmm14, %xmm5
psubusb %xmm0, %xmm5
psubusb %xmm14, %xmm0
por %xmm5, %xmm0
pmaxub %xmm7, %xmm0
movdqa %xmm12, %xmm5
psubusb %xmm14, %xmm5
psubusb %xmm12, %xmm14
por %xmm5, %xmm14
pmaxub %xmm0, %xmm14
movdqu (%rdi,%r9), %xmm0
movdqu (%rdi,%r8), %xmm10
movdqu (%rdi,%rdx), %xmm13
movdqa %xmm13, %xmm5
psubusb %xmm10, %xmm5
movdqa %xmm10, %xmm8
psubusb %xmm13, %xmm8
por %xmm5, %xmm8
pmaxub %xmm14, %xmm8
movdqu (%rdi,%r10), %xmm14
movdqa %xmm14, %xmm5
psubusb %xmm0, %xmm5
movdqa %xmm0, %xmm15
psubusb %xmm14, %xmm15
por %xmm5, %xmm15
movdqa %xmm10, %xmm9
psubusb %xmm14, %xmm9
movdqa %xmm14, %xmm5
psubusb %xmm10, %xmm5
por %xmm9, %xmm5
pmaxub %xmm15, %xmm5
pmaxub %xmm8, %xmm5
movdqa %xmm5, %xmm9
pminub %xmm1, %xmm9
pcmpeqb %xmm5, %xmm9
movdqa %xmm14, %xmm5
psubusb %xmm12, %xmm5
movdqa %xmm12, %xmm4
psubusb %xmm14, %xmm4
por %xmm5, %xmm4
movdqa %xmm0, %xmm5
psubusb %xmm11, %xmm5
movdqa %xmm11, %xmm8
psubusb %xmm0, %xmm8
por %xmm5, %xmm8
psrlw $0x1, %xmm4
pand 0x44d38(%rip), %xmm4    # 0x128ea0
paddusb %xmm8, %xmm8
paddusb %xmm4, %xmm8
movdqa %xmm8, %xmm5
pminub %xmm2, %xmm5
pcmpeqb %xmm8, %xmm5
pmaxub %xmm7, %xmm15
movdqa %xmm15, %xmm7
pminub %xmm3, %xmm7
pcmpeqb %xmm15, %xmm7
pxor %xmm6, %xmm12
pxor %xmm6, %xmm14
movdqa %xmm12, %xmm4
psubsb %xmm14, %xmm4
pxor %xmm6, %xmm0
pxor %xmm6, %xmm11
movdqa %xmm7, %xmm8
pandn %xmm4, %xmm8
movdqa %xmm0, %xmm4
psubsb %xmm11, %xmm4
paddsb %xmm4, %xmm8
paddsb %xmm4, %xmm8
paddsb %xmm4, %xmm8
pand %xmm9, %xmm8
pand %xmm5, %xmm8
movdqa %xmm8, %xmm4
paddsb 0x48ae7(%rip), %xmm4    # 0x12ccd0
paddsb 0x48aee(%rip), %xmm8    # 0x12cce0
punpcklbw %xmm4, %xmm5    # xmm5 = xmm5[0],xmm4[0],xmm5[1],xmm4[1],xmm5[2],xmm4[2],xmm5[3],xmm4[3],xmm5[4],xmm4[4],xmm5[5],xmm4[5],xmm5[6],xmm4[6],xmm5[7],xmm4[7]
punpckhbw %xmm4, %xmm4    # xmm4 = xmm4[8,8,9,9,10,10,11,11,12,12,13,13,14,14,15,15]
psraw $0xb, %xmm5
psraw $0xb, %xmm4
packsswb %xmm4, %xmm5
punpcklbw %xmm8, %xmm4    # xmm4 = xmm4[0],xmm8[0],xmm4[1],xmm8[1],xmm4[2],xmm8[2],xmm4[3],xmm8[3],xmm4[4],xmm8[4],xmm4[5],xmm8[5],xmm4[6],xmm8[6],xmm4[7],xmm8[7]
punpckhbw %xmm8, %xmm8    # xmm8 = xmm8[8,8,9,9,10,10,11,11,12,12,13,13,14,14,15,15]
psraw $0xb, %xmm4
psraw $0xb, %xmm8
packsswb %xmm8, %xmm4
paddsb %xmm11, %xmm5
psubsb %xmm4, %xmm0
pxor %xmm6, %xmm4
pavgb 0xee99(%rip), %xmm4     # 0xf30d0
paddb 0x48ad1(%rip), %xmm4    # 0x12cd10
pand %xmm7, %xmm4
psubsb %xmm4, %xmm14
paddsb %xmm12, %xmm4
pxor %xmm6, %xmm4
movdqu %xmm4, (%rdi,%rax)
pxor %xmm6, %xmm5
movdqu %xmm5, (%rdi,%rsi)
pxor %xmm6, %xmm0
pxor %xmm6, %xmm14
movdqu %xmm0, (%rdi,%rax,2)
movdqu %xmm14, (%rdi,%rcx)
addq %r9, %rdi
decl %r11d
movdqa %xmm13, %xmm11
movdqa %xmm10, %xmm12
cmpl $0x1, %r11d
ja 0xe4064
retq