// File: /workspace/github_c_makefile_star2_O1/enzo1982[P]smooth/libraries/libwebp/src/dsp/dec_sse2.c
// Function: VFilter16_SSE2
static void VFilter16_SSE2(uint8_t* p, int stride,
                           int thresh, int ithresh, int hev_thresh) {
  __m128i t1;
  __m128i mask;
  __m128i p2, p1, p0, q0, q1, q2;

  // Load p3, p2, p1, p0
  LOAD_H_EDGES4(p - 4 * stride, stride, t1, p2, p1, p0);
  MAX_DIFF1(t1, p2, p1, p0, mask);

  // Load q0, q1, q2, q3
  LOAD_H_EDGES4(p, stride, q0, q1, q2, t1);
  MAX_DIFF2(t1, q2, q1, q0, mask);

  ComplexMask_SSE2(&p1, &p0, &q0, &q1, thresh, ithresh, &mask);
  DoFilter6_SSE2(&p2, &p1, &p0, &q0, &q1, &q2, &mask, hev_thresh);

  // Store
  _mm_storeu_si128((__m128i*)&p[-3 * stride], p2);
  _mm_storeu_si128((__m128i*)&p[-2 * stride], p1);
  _mm_storeu_si128((__m128i*)&p[-1 * stride], p0);
  _mm_storeu_si128((__m128i*)&p[+0 * stride], q0);
  _mm_storeu_si128((__m128i*)&p[+1 * stride], q1);
  _mm_storeu_si128((__m128i*)&p[+2 * stride], q2);
}

// Assembly:
leal (,%rsi,4), %eax
cltq
movq %rdi, %r10
subq %rax, %r10
negq %rax
movdqu (%rdi,%rax), %xmm4
movslq %esi, %rax
leaq (%rax,%rax), %rsi
leaq (%rax,%rax,2), %r9
movdqu (%r10,%r9), %xmm5
movdqu (%r10,%rax,2), %xmm0
movdqa %xmm5, %xmm1
psubusb %xmm0, %xmm1
movdqa %xmm0, %xmm6
psubusb %xmm5, %xmm6
por %xmm1, %xmm6
movdqu (%rax,%r10), %xmm1
movdqa %xmm1, %xmm2
psubusb %xmm4, %xmm2
psubusb %xmm1, %xmm4
por %xmm2, %xmm4
pmaxub %xmm6, %xmm4
movdqa %xmm0, %xmm2
psubusb %xmm1, %xmm2
movdqa %xmm1, %xmm8
psubusb %xmm0, %xmm8
por %xmm2, %xmm8
movdqu (%rdi,%r9), %xmm9
movdqu (%rdi), %xmm2
movdqu (%rdi,%rax), %xmm3
movdqa %xmm2, %xmm10
psubusb %xmm3, %xmm10
movdqa %xmm3, %xmm7
psubusb %xmm2, %xmm7
por %xmm10, %xmm7
pmaxub %xmm7, %xmm8
pmaxub %xmm4, %xmm8
movdqu (%rdi,%rax,2), %xmm4
movdqa %xmm4, %xmm10
psubusb %xmm9, %xmm10
psubusb %xmm4, %xmm9
por %xmm10, %xmm9
movdqa %xmm3, %xmm10
psubusb %xmm4, %xmm10
movdqa %xmm4, %xmm11
psubusb %xmm3, %xmm11
por %xmm10, %xmm11
pmaxub %xmm9, %xmm11
pmaxub %xmm8, %xmm11
movd %ecx, %xmm8
punpcklbw %xmm8, %xmm8    # xmm8 = xmm8[0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7]
pshuflw $0x0, %xmm8, %xmm8      # xmm8 = xmm8[0,0,0,0,4,5,6,7]
pshufd $0x0, %xmm8, %xmm9      # xmm9 = xmm8[0,0,0,0]
pminub %xmm11, %xmm9
pcmpeqb %xmm11, %xmm9
movd %edx, %xmm8
punpcklbw %xmm8, %xmm8    # xmm8 = xmm8[0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7]
pshuflw $0x0, %xmm8, %xmm8      # xmm8 = xmm8[0,0,0,0,4,5,6,7]
pshufd $0x0, %xmm8, %xmm8      # xmm8 = xmm8[0,0,0,0]
movdqa %xmm3, %xmm10
psubusb %xmm0, %xmm10
movdqa %xmm0, %xmm11
psubusb %xmm3, %xmm11
por %xmm10, %xmm11
psrlw $0x1, %xmm11
movdqa %xmm2, %xmm10
psubusb %xmm5, %xmm10
movdqa %xmm5, %xmm12
psubusb %xmm2, %xmm12
por %xmm10, %xmm12
paddusb %xmm12, %xmm12
pand 0x46157(%rip), %xmm11   # 0x129c80
paddusb %xmm12, %xmm11
pminub %xmm11, %xmm8
pcmpeqb %xmm11, %xmm8
pand %xmm9, %xmm8
movd %r8d, %xmm9
punpcklbw %xmm9, %xmm9    # xmm9 = xmm9[0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7]
pshuflw $0x0, %xmm9, %xmm9      # xmm9 = xmm9[0,0,0,0,4,5,6,7]
pshufd $0x0, %xmm9, %xmm10     # xmm10 = xmm9[0,0,0,0]
pmaxub %xmm6, %xmm7
pminub %xmm7, %xmm10
pcmpeqb %xmm7, %xmm10
movdqa 0x47947(%rip), %xmm6    # 0x12b4b0
pxor %xmm6, %xmm0
pxor %xmm6, %xmm3
movdqa %xmm0, %xmm9
psubsb %xmm3, %xmm9
pxor %xmm6, %xmm2
pxor %xmm6, %xmm5
movdqa %xmm2, %xmm7
psubsb %xmm5, %xmm7
paddsb %xmm7, %xmm9
paddsb %xmm7, %xmm9
paddsb %xmm7, %xmm9
movdqa %xmm10, %xmm7
pandn %xmm9, %xmm7
pand %xmm8, %xmm7
movdqa 0x49efe(%rip), %xmm12   # 0x12dab0
paddsb %xmm7, %xmm12
paddsb 0x49f01(%rip), %xmm7    # 0x12dac0
punpcklbw %xmm7, %xmm13   # xmm13 = xmm13[0],xmm7[0],xmm13[1],xmm7[1],xmm13[2],xmm7[2],xmm13[3],xmm7[3],xmm13[4],xmm7[4],xmm13[5],xmm7[5],xmm13[6],xmm7[6],xmm13[7],xmm7[7]
pxor %xmm11, %xmm11
punpckhbw %xmm7, %xmm7    # xmm7 = xmm7[8,8,9,9,10,10,11,11,12,12,13,13,14,14,15,15]
psraw $0xb, %xmm13
psraw $0xb, %xmm7
packsswb %xmm7, %xmm13
punpcklbw %xmm12, %xmm7   # xmm7 = xmm7[0],xmm12[0],xmm7[1],xmm12[1],xmm7[2],xmm12[2],xmm7[3],xmm12[3],xmm7[4],xmm12[4],xmm7[5],xmm12[5],xmm7[6],xmm12[6],xmm7[7],xmm12[7]
punpckhbw %xmm12, %xmm12  # xmm12 = xmm12[8,8,9,9,10,10,11,11,12,12,13,13,14,14,15,15]
psraw $0xb, %xmm7
psraw $0xb, %xmm12
packsswb %xmm12, %xmm7
psubsb %xmm13, %xmm2
paddsb %xmm5, %xmm7
pand %xmm10, %xmm9
pand %xmm8, %xmm9
pxor %xmm5, %xmm5
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]
movdqa %xmm5, %xmm8
punpckhbw %xmm11, %xmm8   # xmm8 = xmm8[8],xmm11[8],xmm8[9],xmm11[9],xmm8[10],xmm11[10],xmm8[11],xmm11[11],xmm8[12],xmm11[12],xmm8[13],xmm11[13],xmm8[14],xmm11[14],xmm8[15],xmm11[15]
punpcklbw %xmm11, %xmm5   # xmm5 = xmm5[0],xmm11[0],xmm5[1],xmm11[1],xmm5[2],xmm11[2],xmm5[3],xmm11[3],xmm5[4],xmm11[4],xmm5[5],xmm11[5],xmm5[6],xmm11[6],xmm5[7],xmm11[7]
pshufd $0x6c, %xmm5, %xmm5     # xmm5 = xmm5[0,3,2,1]
pshufhw $0xc4, %xmm5, %xmm5     # xmm5 = xmm5[0,1,2,3,4,5,4,7]
pshufd $0x6c, %xmm5, %xmm5     # xmm5 = xmm5[0,3,2,1]
pand 0x49de7(%rip), %xmm5    # 0x12da20
packuswb %xmm8, %xmm5
pxor %xmm10, %xmm10
punpckhbw %xmm9, %xmm10   # xmm10 = xmm10[8],xmm9[8],xmm10[9],xmm9[9],xmm10[10],xmm9[10],xmm10[11],xmm9[11],xmm10[12],xmm9[12],xmm10[13],xmm9[13],xmm10[14],xmm9[14],xmm10[15],xmm9[15]
movdqa %xmm10, %xmm8
punpcklbw %xmm11, %xmm8   # xmm8 = xmm8[0],xmm11[0],xmm8[1],xmm11[1],xmm8[2],xmm11[2],xmm8[3],xmm11[3],xmm8[4],xmm11[4],xmm8[5],xmm11[5],xmm8[6],xmm11[6],xmm8[7],xmm11[7]
punpckhbw %xmm11, %xmm10  # xmm10 = xmm10[8],xmm11[8],xmm10[9],xmm11[9],xmm10[10],xmm11[10],xmm10[11],xmm11[11],xmm10[12],xmm11[12],xmm10[13],xmm11[13],xmm10[14],xmm11[14],xmm10[15],xmm11[15]
pshufd $0x6c, %xmm10, %xmm9    # xmm9 = xmm10[0,3,2,1]
pshuflw $0xc4, %xmm9, %xmm9     # xmm9 = xmm9[0,1,0,3,4,5,6,7]
pshufd $0x6c, %xmm9, %xmm9     # xmm9 = xmm9[0,3,2,1]
pshufhw $0xc6, %xmm9, %xmm9     # xmm9 = xmm9[0,1,2,3,6,5,4,7]
pand 0x49db8(%rip), %xmm9    # 0x12da30
packuswb %xmm9, %xmm8
movdqa 0x49e4a(%rip), %xmm9    # 0x12dad0
pmulhw %xmm9, %xmm5
pmulhw %xmm9, %xmm8
movdqa 0x49e47(%rip), %xmm10   # 0x12dae0
movdqa %xmm5, %xmm11
paddw %xmm10, %xmm11
paddw %xmm8, %xmm10
movdqa %xmm11, %xmm9
paddw %xmm5, %xmm9
movdqa %xmm10, %xmm12
paddw %xmm8, %xmm12
paddw %xmm9, %xmm5
paddw %xmm12, %xmm8
psraw $0x7, %xmm11
psraw $0x7, %xmm10
packsswb %xmm10, %xmm11
pxor %xmm6, %xmm1
paddsb %xmm11, %xmm1
pxor %xmm6, %xmm4
psubsb %xmm11, %xmm4
pxor %xmm6, %xmm1
pxor %xmm6, %xmm4
psraw $0x7, %xmm9
psraw $0x7, %xmm12
packsswb %xmm12, %xmm9
paddsb %xmm9, %xmm0
psubsb %xmm9, %xmm3
pxor %xmm6, %xmm0
pxor %xmm6, %xmm3
psraw $0x7, %xmm5
psraw $0x7, %xmm8
packsswb %xmm8, %xmm5
paddsb %xmm5, %xmm7
psubsb %xmm5, %xmm2
pxor %xmm6, %xmm7
pxor %xmm6, %xmm2
movq %rdi, %rcx
subq %r9, %rcx
movdqu %xmm1, (%rcx)
movq %rdi, %rcx
subq %rsi, %rcx
movdqu %xmm0, (%rcx)
movq %rdi, %rcx
subq %rax, %rcx
movdqu %xmm7, (%rcx)
movdqu %xmm2, (%rdi)
movdqu %xmm3, (%rdi,%rax)
movdqu %xmm4, (%rdi,%rax,2)
retq