// File: /workspace/github_c_makefile_star2_O2/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %r8, 0x8(%rsp)
movl %ecx, %r9d
movl %edx, %r8d
movq %rdi, %rbx
leal (,%rsi,4), %eax
cltq
movq %rdi, %rcx
subq %rax, %rcx
negq %rax
movdqu (%rdi,%rax), %xmm0
movslq %esi, %r13
movdqu (%rcx,%r13), %xmm1
leaq 0x10(%rsp), %rax
movdqa %xmm1, (%rax)
leaq (%r13,%r13), %rax
movq %rax, (%rsp)
movdqu (%rcx,%r13,2), %xmm2
leaq 0x70(%rsp), %r12
movdqa %xmm2, (%r12)
leaq (%r13,%r13,2), %rax
movdqu (%rcx,%rax), %xmm3
leaq 0x60(%rsp), %r14
movdqa %xmm3, (%r14)
movdqa %xmm2, %xmm4
psubusb %xmm3, %xmm4
psubusb %xmm2, %xmm3
por %xmm4, %xmm3
movdqa %xmm1, %xmm4
psubusb %xmm0, %xmm4
psubusb %xmm1, %xmm0
por %xmm4, %xmm0
pmaxub %xmm3, %xmm0
movdqa %xmm2, %xmm3
psubusb %xmm1, %xmm3
psubusb %xmm2, %xmm1
por %xmm3, %xmm1
movdqu (%rdi), %xmm2
leaq 0x50(%rsp), %rbp
movdqa %xmm2, (%rbp)
movdqu (%rdi,%r13), %xmm3
leaq 0x30(%rsp), %r15
movdqa %xmm3, (%r15)
movdqu (%rdi,%r13,2), %xmm4
leaq 0x20(%rsp), %rsi
movdqa %xmm4, (%rsi)
movdqu (%rdi,%rax), %xmm5
movdqa %xmm3, %xmm6
psubusb %xmm2, %xmm6
psubusb %xmm3, %xmm2
por %xmm6, %xmm2
pmaxub %xmm1, %xmm2
pmaxub %xmm0, %xmm2
movdqa %xmm4, %xmm0
psubusb %xmm5, %xmm0
psubusb %xmm4, %xmm5
por %xmm0, %xmm5
movdqa %xmm3, %xmm0
psubusb %xmm4, %xmm0
psubusb %xmm3, %xmm4
por %xmm0, %xmm4
pmaxub %xmm5, %xmm4
pmaxub %xmm2, %xmm4
leaq 0x40(%rsp), %rax
movdqa %xmm4, (%rax)
subq $0x8, %rsp
movq %r12, %rdi
movq %r14, %rsi
movq %rbp, %rdx
movq %r15, %rcx
pushq %rax
callq 0xd8554
popq %rax
popq %rcx
leaq 0x10(%rsp), %rdi
movq %r12, %rsi
movq %r14, %rdx
movq %rbp, %rcx
movq %r15, %r8
leaq 0x20(%rsp), %r15
movq %r15, %r9
pushq 0x8(%rsp)
leaq 0x48(%rsp), %rax
pushq %rax
callq 0xd85a5
popq %rax
popq %rcx
imulq $-0x3, %r13, %rax
leaq 0x10(%rsp), %rcx
movaps (%rcx), %xmm0
movups %xmm0, (%rbx,%rax)
movq %rbx, %rax
subq (%rsp), %rax
movaps (%r12), %xmm0
movups %xmm0, (%rax)
movq %rbx, %rax
subq %r13, %rax
movaps (%r14), %xmm0
movups %xmm0, (%rax)
movaps (%rbp), %xmm0
movups %xmm0, (%rbx)
leaq 0x30(%rsp), %rax
movaps (%rax), %xmm0
movups %xmm0, (%rbx,%r13)
movaps (%r15), %xmm0
movups %xmm0, (%rbx,%r13,2)
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq