// File: /workspace/github_c_makefile_star2_O2/enzo1982[P]smooth/libraries/libwebp/src/dsp/dec_sse2.c
// Function: DoFilter6_SSE2
static WEBP_INLINE void DoFilter6_SSE2(__m128i* const p2, __m128i* const p1,
                                       __m128i* const p0, __m128i* const q0,
                                       __m128i* const q1, __m128i* const q2,
                                       const __m128i* const mask,
                                       int hev_thresh) {
  const __m128i zero = _mm_setzero_si128();
  const __m128i sign_bit = _mm_set1_epi8((char)0x80);
  __m128i a, not_hev;

  // compute hev mask
  GetNotHEV_SSE2(p1, p0, q0, q1, hev_thresh, &not_hev);

  FLIP_SIGN_BIT4(*p1, *p0, *q0, *q1);
  FLIP_SIGN_BIT2(*p2, *q2);
  GetBaseDelta_SSE2(p1, p0, q0, q1, &a);

  { // do simple filter on pixels with hev
    const __m128i m = _mm_andnot_si128(not_hev, *mask);
    const __m128i f = _mm_and_si128(a, m);
    DoSimpleFilter_SSE2(p0, q0, &f);
  }

  { // do strong filter on pixels with not hev
    const __m128i k9 = _mm_set1_epi16(0x0900);
    const __m128i k63 = _mm_set1_epi16(63);

    const __m128i m = _mm_and_si128(not_hev, *mask);
    const __m128i f = _mm_and_si128(a, m);

    const __m128i f_lo = _mm_unpacklo_epi8(zero, f);
    const __m128i f_hi = _mm_unpackhi_epi8(zero, f);

    const __m128i f9_lo = _mm_mulhi_epi16(f_lo, k9);    // Filter (lo) * 9
    const __m128i f9_hi = _mm_mulhi_epi16(f_hi, k9);    // Filter (hi) * 9

    const __m128i a2_lo = _mm_add_epi16(f9_lo, k63);    // Filter * 9 + 63
    const __m128i a2_hi = _mm_add_epi16(f9_hi, k63);    // Filter * 9 + 63

    const __m128i a1_lo = _mm_add_epi16(a2_lo, f9_lo);  // Filter * 18 + 63
    const __m128i a1_hi = _mm_add_epi16(a2_hi, f9_hi);  // Filter * 18 + 63

    const __m128i a0_lo = _mm_add_epi16(a1_lo, f9_lo);  // Filter * 27 + 63
    const __m128i a0_hi = _mm_add_epi16(a1_hi, f9_hi);  // Filter * 27 + 63

    Update2Pixels_SSE2(p2, q2, &a2_lo, &a2_hi);
    Update2Pixels_SSE2(p1, q1, &a1_lo, &a1_hi);
    Update2Pixels_SSE2(p0, q0, &a0_lo, &a0_hi);
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq %r9, %rbp
movq %r8, %r15
movq %rcx, %rbx
movq %rdx, %r14
movq %rsi, %r12
movq %rdi, %r13
movl 0xe8(%rsp), %r8d
leaq 0x60(%rsp), %r9
movq %rsi, %rdi
movq %rdx, %rsi
movq %rcx, %rdx
movq %r15, %rcx
callq 0xd8833
movaps 0x443e3(%rip), %xmm0    # 0x11c9d0
movaps (%r12), %xmm1
xorps %xmm0, %xmm1
movaps %xmm1, (%r12)
movaps (%r14), %xmm1
xorps %xmm0, %xmm1
movaps %xmm1, (%r14)
movaps (%rbx), %xmm1
xorps %xmm0, %xmm1
movaps %xmm1, (%rbx)
movaps (%r15), %xmm1
xorps %xmm0, %xmm1
movaps %xmm1, (%r15)
movq %r13, 0x8(%rsp)
movaps (%r13), %xmm1
xorps %xmm0, %xmm1
movaps %xmm1, (%r13)
movq %rbp, (%rsp)
xorps (%rbp), %xmm0
movaps %xmm0, (%rbp)
movdqa (%r12), %xmm2
psubsb (%r15), %xmm2
movdqa (%rbx), %xmm0
psubsb (%r14), %xmm0
paddsb %xmm0, %xmm2
paddsb %xmm0, %xmm2
leaq 0x60(%rsp), %rax
movdqa (%rax), %xmm1
movdqa %xmm1, 0x20(%rsp)
movq 0xe0(%rsp), %rbp
pandn (%rbp), %xmm1
paddsb %xmm0, %xmm2
movdqa %xmm2, 0x10(%rsp)
pand %xmm2, %xmm1
leaq 0x50(%rsp), %r13
movdqa %xmm1, (%r13)
movq %r14, %rdi
movq %rbx, %rsi
movq %r13, %rdx
callq 0xd8888
movdqa 0x10(%rsp), %xmm1
pand (%rbp), %xmm1
pand 0x20(%rsp), %xmm1
pxor %xmm2, %xmm2
pxor %xmm0, %xmm0
punpcklbw %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1],xmm0[2],xmm1[2],xmm0[3],xmm1[3],xmm0[4],xmm1[4],xmm0[5],xmm1[5],xmm0[6],xmm1[6],xmm0[7],xmm1[7]
movdqa %xmm1, %xmm4
movdqa %xmm0, %xmm1
punpcklbw %xmm2, %xmm0    # xmm0 = xmm0[0],xmm2[0],xmm0[1],xmm2[1],xmm0[2],xmm2[2],xmm0[3],xmm2[3],xmm0[4],xmm2[4],xmm0[5],xmm2[5],xmm0[6],xmm2[6],xmm0[7],xmm2[7]
pshufd $0x6c, %xmm0, %xmm0     # xmm0 = xmm0[0,3,2,1]
pshufhw $0xc4, %xmm0, %xmm0     # xmm0 = xmm0[0,1,2,3,4,5,4,7]
pshufd $0x6c, %xmm0, %xmm0     # xmm0 = xmm0[0,3,2,1]
pand 0x4426a(%rip), %xmm0    # 0x11c940
punpckhbw %xmm2, %xmm1    # xmm1 = xmm1[8],xmm2[8],xmm1[9],xmm2[9],xmm1[10],xmm2[10],xmm1[11],xmm2[11],xmm1[12],xmm2[12],xmm1[13],xmm2[13],xmm1[14],xmm2[14],xmm1[15],xmm2[15]
packuswb %xmm1, %xmm0
pxor %xmm3, %xmm3
punpckhbw %xmm4, %xmm3    # xmm3 = xmm3[8],xmm4[8],xmm3[9],xmm4[9],xmm3[10],xmm4[10],xmm3[11],xmm4[11],xmm3[12],xmm4[12],xmm3[13],xmm4[13],xmm3[14],xmm4[14],xmm3[15],xmm4[15]
movdqa %xmm3, %xmm1
punpckhbw %xmm2, %xmm3    # xmm3 = xmm3[8],xmm2[8],xmm3[9],xmm2[9],xmm3[10],xmm2[10],xmm3[11],xmm2[11],xmm3[12],xmm2[12],xmm3[13],xmm2[13],xmm3[14],xmm2[14],xmm3[15],xmm2[15]
pshufd $0x6c, %xmm3, %xmm3     # xmm3 = xmm3[0,3,2,1]
pshuflw $0xc4, %xmm3, %xmm3     # xmm3 = xmm3[0,1,0,3,4,5,6,7]
pshufd $0x6c, %xmm3, %xmm3     # xmm3 = xmm3[0,3,2,1]
pshufhw $0xc6, %xmm3, %xmm3     # xmm3 = xmm3[0,1,2,3,6,5,4,7]
pand 0x44246(%rip), %xmm3    # 0x11c950
punpcklbw %xmm2, %xmm1    # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1],xmm1[2],xmm2[2],xmm1[3],xmm2[3],xmm1[4],xmm2[4],xmm1[5],xmm2[5],xmm1[6],xmm2[6],xmm1[7],xmm2[7]
packuswb %xmm3, %xmm1
movdqa 0x442c6(%rip), %xmm2    # 0x11c9e0
pmulhw %xmm2, %xmm0
pmulhw %xmm2, %xmm1
movdqa 0x442c6(%rip), %xmm2    # 0x11c9f0
movdqa %xmm0, %xmm3
paddw %xmm2, %xmm3
movdqa %xmm3, (%r13)
paddw %xmm1, %xmm2
leaq 0x90(%rsp), %rcx
movdqa %xmm2, (%rcx)
paddw %xmm0, %xmm3
leaq 0x40(%rsp), %rax
movdqa %xmm3, (%rax)
paddw %xmm1, %xmm2
leaq 0x80(%rsp), %rbp
movdqa %xmm2, (%rbp)
paddw %xmm0, %xmm3
leaq 0x30(%rsp), %rax
movdqa %xmm3, (%rax)
paddw %xmm1, %xmm2
leaq 0x70(%rsp), %r13
movdqa %xmm2, (%r13)
leaq 0x50(%rsp), %rdx
movq 0x8(%rsp), %rdi
movq (%rsp), %rsi
callq 0xd88e1
movq %r12, %rdi
movq %r15, %rsi
leaq 0x40(%rsp), %rdx
movq %rbp, %rcx
callq 0xd88e1
movq %r14, %rdi
movq %rbx, %rsi
leaq 0x30(%rsp), %rdx
movq %r13, %rcx
callq 0xd88e1
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq