// File: /workspace/github_c_makefile_star2_O2/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd8, %rsp
movl %r8d, 0x18(%rsp)
movl %ecx, 0x14(%rsp)
movl %edx, 0x10(%rsp)
movq %rdi, %r13
movdqu (%rdi), %xmm1
movslq %esi, %rcx
movdqu (%rdi,%rcx), %xmm0
leaq (%rcx,%rcx), %rax
movq %rax, 0x60(%rsp)
movdqu (%rdi,%rcx,2), %xmm3
leaq 0x30(%rsp), %rax
movdqa %xmm3, (%rax)
leaq (%rcx,%rcx,2), %rdx
movdqu (%rdi,%rdx), %xmm4
leaq 0x20(%rsp), %rax
movdqa %xmm4, (%rax)
leal (,%rcx,4), %eax
movslq %eax, %rsi
leaq (%rsi,%rdx), %rax
movq %rax, 0x58(%rsp)
leaq (%rsi,%rcx,2), %rax
movq %rax, 0x50(%rsp)
movq %rdx, 0x68(%rsp)
leaq (%rdx,%rcx,2), %rax
movq %rax, 0x48(%rsp)
movq %rsi, 0x40(%rsp)
addq %rsi, %rcx
movq %rcx, 0x70(%rsp)
pushq $-0x3
popq %rax
testl %eax, %eax
je 0xd7994
movl %eax, 0x1c(%rsp)
movq 0x40(%rsp), %rax
leaq (%rax,%r13), %rcx
movq %rcx, 0x78(%rsp)
movdqa %xmm3, %xmm2
psubusb %xmm4, %xmm2
psubusb %xmm3, %xmm4
por %xmm2, %xmm4
movdqa %xmm0, %xmm2
psubusb %xmm1, %xmm2
psubusb %xmm0, %xmm1
por %xmm2, %xmm1
pmaxub %xmm4, %xmm1
movdqa %xmm3, %xmm2
psubusb %xmm0, %xmm2
psubusb %xmm3, %xmm0
por %xmm2, %xmm0
pmaxub %xmm1, %xmm0
movdqu (%r13,%rax), %xmm1
movdqa %xmm1, 0x90(%rsp)
movq 0x70(%rsp), %rax
movdqu (%r13,%rax), %xmm2
movdqa %xmm2, 0x80(%rsp)
movq 0x50(%rsp), %rax
movdqu (%r13,%rax), %xmm5
movdqa %xmm5, 0xa0(%rsp)
movq 0x58(%rsp), %rax
movdqu (%r13,%rax), %xmm6
movdqa %xmm6, 0xb0(%rsp)
movdqa %xmm6, %xmm3
psubusb %xmm5, %xmm3
movdqa %xmm5, %xmm4
psubusb %xmm6, %xmm4
por %xmm3, %xmm4
pmaxub %xmm0, %xmm4
movdqa %xmm2, %xmm0
psubusb %xmm1, %xmm0
psubusb %xmm2, %xmm1
por %xmm0, %xmm1
movdqa %xmm5, %xmm0
psubusb %xmm2, %xmm0
psubusb %xmm5, %xmm2
por %xmm0, %xmm2
pmaxub %xmm1, %xmm2
pmaxub %xmm4, %xmm2
movdqa %xmm2, 0xc0(%rsp)
leaq 0xc0(%rsp), %rbx
movq %rbx, (%rsp)
leaq 0x30(%rsp), %r15
movq %r15, %rdi
leaq 0x20(%rsp), %r12
movq %r12, %rsi
leaq 0x90(%rsp), %r14
movq %r14, %rdx
leaq 0x80(%rsp), %rbp
movq %rbp, %rcx
movl 0x10(%rsp), %r8d
movl 0x14(%rsp), %r9d
callq 0xd8554
movq %r15, %rdi
movq %r12, %rsi
movq %r14, %rdx
movq %rbp, %rcx
movq %rbx, %r8
movl 0x18(%rsp), %r9d
callq 0xd8b11
movdqa 0xb0(%rsp), %xmm4
movdqa 0xa0(%rsp), %xmm3
movaps 0x30(%rsp), %xmm0
movq 0x60(%rsp), %rcx
movups %xmm0, (%r13,%rcx)
movaps 0x20(%rsp), %xmm0
movq 0x68(%rsp), %rax
movups %xmm0, (%r13,%rax)
movdqa 0x90(%rsp), %xmm1
movdqu %xmm1, (%r13,%rcx,2)
movdqa 0x80(%rsp), %xmm0
movq 0x48(%rsp), %rax
movdqu %xmm0, (%r13,%rax)
movl 0x1c(%rsp), %eax
movdqa %xmm3, 0x30(%rsp)
movdqa %xmm4, 0x20(%rsp)
incl %eax
movq 0x78(%rsp), %r13
jmp 0xd77dd
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq