// File: /workspace/github_c_makefile_star2_O0/enzo1982[P]smooth/libraries/libwebp/src/dsp/alpha_processing_sse2.c
// Function: DispatchAlpha_SSE2
static int DispatchAlpha_SSE2(const uint8_t* WEBP_RESTRICT alpha,
                              int alpha_stride, int width, int height,
                              uint8_t* WEBP_RESTRICT dst, int dst_stride) {
  // alpha_and stores an 'and' operation of all the alpha[] values. The final
  // value is not 0xff if any of the alpha[] is not equal to 0xff.
  uint32_t alpha_and = 0xff;
  int i, j;
  const __m128i zero = _mm_setzero_si128();
  const __m128i rgb_mask = _mm_set1_epi32((int)0xffffff00);  // to preserve RGB
  const __m128i all_0xff = _mm_set_epi32(0, 0, ~0, ~0);
  __m128i all_alphas = all_0xff;

  // We must be able to access 3 extra bytes after the last written byte
  // 'dst[4 * width - 4]', because we don't know if alpha is the first or the
  // last byte of the quadruplet.
  const int limit = (width - 1) & ~7;

  for (j = 0; j < height; ++j) {
    __m128i* out = (__m128i*)dst;
    for (i = 0; i < limit; i += 8) {
      // load 8 alpha bytes
      const __m128i a0 = _mm_loadl_epi64((const __m128i*)&alpha[i]);
      const __m128i a1 = _mm_unpacklo_epi8(a0, zero);
      const __m128i a2_lo = _mm_unpacklo_epi16(a1, zero);
      const __m128i a2_hi = _mm_unpackhi_epi16(a1, zero);
      // load 8 dst pixels (32 bytes)
      const __m128i b0_lo = _mm_loadu_si128(out + 0);
      const __m128i b0_hi = _mm_loadu_si128(out + 1);
      // mask dst alpha values
      const __m128i b1_lo = _mm_and_si128(b0_lo, rgb_mask);
      const __m128i b1_hi = _mm_and_si128(b0_hi, rgb_mask);
      // combine
      const __m128i b2_lo = _mm_or_si128(b1_lo, a2_lo);
      const __m128i b2_hi = _mm_or_si128(b1_hi, a2_hi);
      // store
      _mm_storeu_si128(out + 0, b2_lo);
      _mm_storeu_si128(out + 1, b2_hi);
      // accumulate eight alpha 'and' in parallel
      all_alphas = _mm_and_si128(all_alphas, a0);
      out += 2;
    }
    for (; i < width; ++i) {
      const uint32_t alpha_value = alpha[i];
      dst[4 * i] = alpha_value;
      alpha_and &= alpha_value;
    }
    alpha += alpha_stride;
    dst += dst_stride;
  }
  // Combine the eight alpha 'and' into a 8-bit mask.
  alpha_and &= _mm_movemask_epi8(_mm_cmpeq_epi8(all_alphas, all_0xff));
  return (alpha_and != 0xff);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2a0, %rsp            # imm = 0x2A0
movq %rdi, -0x1f8(%rbp)
movl %esi, -0x1fc(%rbp)
movl %edx, -0x200(%rbp)
movl %ecx, -0x204(%rbp)
movq %r8, -0x210(%rbp)
movl %r9d, -0x214(%rbp)
movl $0xff, -0x218(%rbp)
xorps %xmm0, %xmm0
movaps %xmm0, -0x1f0(%rbp)
movaps -0x1f0(%rbp), %xmm0
movaps %xmm0, -0x230(%rbp)
movl $0xffffff00, -0x114(%rbp) # imm = 0xFFFFFF00
movl -0x114(%rbp), %eax
movl %eax, -0xf4(%rbp)
movl %eax, -0xf8(%rbp)
movl %eax, -0xfc(%rbp)
movl %eax, -0x100(%rbp)
movd -0xf4(%rbp), %xmm0
movd -0xf8(%rbp), %xmm1
punpckldq %xmm0, %xmm1    # xmm1 = xmm1[0],xmm0[0],xmm1[1],xmm0[1]
movd -0xfc(%rbp), %xmm2
movd -0x100(%rbp), %xmm0
punpckldq %xmm2, %xmm0    # xmm0 = xmm0[0],xmm2[0],xmm0[1],xmm2[1]
punpcklqdq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0]
movaps %xmm0, -0x110(%rbp)
movaps -0x110(%rbp), %xmm0
movaps %xmm0, -0x240(%rbp)
movl $0x0, -0xd4(%rbp)
movl $0x0, -0xd8(%rbp)
movl $0xffffffff, -0xdc(%rbp) # imm = 0xFFFFFFFF
movl $0xffffffff, -0xe0(%rbp) # imm = 0xFFFFFFFF
movd -0xd4(%rbp), %xmm0
movd -0xd8(%rbp), %xmm1
punpckldq %xmm0, %xmm1    # xmm1 = xmm1[0],xmm0[0],xmm1[1],xmm0[1]
movd -0xdc(%rbp), %xmm2
movd -0xe0(%rbp), %xmm0
punpckldq %xmm2, %xmm0    # xmm0 = xmm0[0],xmm2[0],xmm0[1],xmm2[1]
punpcklqdq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0]
movdqa %xmm0, -0xf0(%rbp)
movdqa -0xf0(%rbp), %xmm0
movdqa %xmm0, -0x250(%rbp)
movdqa -0x250(%rbp), %xmm0
movdqa %xmm0, -0x260(%rbp)
movl -0x200(%rbp), %eax
subl $0x1, %eax
andl $-0x8, %eax
movl %eax, -0x264(%rbp)
movl $0x0, -0x220(%rbp)
movl -0x220(%rbp), %eax
cmpl -0x204(%rbp), %eax
jge 0x1566c6
movq -0x210(%rbp), %rax
movq %rax, -0x270(%rbp)
movl $0x0, -0x21c(%rbp)
movl -0x21c(%rbp), %eax
cmpl -0x264(%rbp), %eax
jge 0x156615
movq -0x1f8(%rbp), %rax
movslq -0x21c(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x1c8(%rbp)
movq -0x1c8(%rbp), %rax
movq (%rax), %xmm0
movaps %xmm0, -0x1e0(%rbp)
movaps -0x1e0(%rbp), %xmm0
movaps %xmm0, -0x280(%rbp)
movaps -0x280(%rbp), %xmm1
movaps -0x230(%rbp), %xmm0
movaps %xmm1, -0x1b0(%rbp)
movaps %xmm0, -0x1c0(%rbp)
movaps -0x1b0(%rbp), %xmm0
movaps -0x1c0(%rbp), %xmm1
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]
movaps %xmm0, -0x290(%rbp)
movaps -0x290(%rbp), %xmm1
movaps -0x230(%rbp), %xmm0
movaps %xmm1, -0xc0(%rbp)
movaps %xmm0, -0xd0(%rbp)
movaps -0xc0(%rbp), %xmm0
movaps -0xd0(%rbp), %xmm1
punpcklwd %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1],xmm0[2],xmm1[2],xmm0[3],xmm1[3]
movaps %xmm0, -0x2a0(%rbp)
movaps -0x290(%rbp), %xmm1
movaps -0x230(%rbp), %xmm0
movaps %xmm1, -0xa0(%rbp)
movaps %xmm0, -0xb0(%rbp)
movaps -0xa0(%rbp), %xmm0
movaps -0xb0(%rbp), %xmm1
punpckhwd %xmm1, %xmm0    # xmm0 = xmm0[4],xmm1[4],xmm0[5],xmm1[5],xmm0[6],xmm1[6],xmm0[7],xmm1[7]
movdqa %xmm0, -0x2b0(%rbp)
movq -0x270(%rbp), %rax
movq %rax, -0x158(%rbp)
movq -0x158(%rbp), %rax
movdqu (%rax), %xmm0
movdqa %xmm0, -0x2c0(%rbp)
movq -0x270(%rbp), %rax
addq $0x10, %rax
movq %rax, -0x160(%rbp)
movq -0x160(%rbp), %rax
movdqu (%rax), %xmm0
movdqa %xmm0, -0x2d0(%rbp)
movdqa -0x2c0(%rbp), %xmm1
movdqa -0x240(%rbp), %xmm0
movdqa %xmm1, -0x40(%rbp)
movdqa %xmm0, -0x50(%rbp)
movdqa -0x40(%rbp), %xmm0
pand -0x50(%rbp), %xmm0
movdqa %xmm0, -0x2e0(%rbp)
movdqa -0x2d0(%rbp), %xmm1
movdqa -0x240(%rbp), %xmm0
movdqa %xmm1, -0x60(%rbp)
movdqa %xmm0, -0x70(%rbp)
movdqa -0x60(%rbp), %xmm0
pand -0x70(%rbp), %xmm0
movdqa %xmm0, -0x2f0(%rbp)
movdqa -0x2e0(%rbp), %xmm1
movdqa -0x2a0(%rbp), %xmm0
movdqa %xmm1, -0x170(%rbp)
movdqa %xmm0, -0x180(%rbp)
movdqa -0x170(%rbp), %xmm0
por -0x180(%rbp), %xmm0
movdqa %xmm0, -0x300(%rbp)
movdqa -0x2f0(%rbp), %xmm1
movdqa -0x2b0(%rbp), %xmm0
movdqa %xmm1, -0x190(%rbp)
movdqa %xmm0, -0x1a0(%rbp)
movdqa -0x190(%rbp), %xmm0
por -0x1a0(%rbp), %xmm0
movdqa %xmm0, -0x310(%rbp)
movq -0x270(%rbp), %rax
movdqa -0x300(%rbp), %xmm0
movq %rax, -0x120(%rbp)
movdqa %xmm0, -0x130(%rbp)
movdqa -0x130(%rbp), %xmm0
movq -0x120(%rbp), %rax
movdqu %xmm0, (%rax)
movq -0x270(%rbp), %rax
addq $0x10, %rax
movdqa -0x310(%rbp), %xmm0
movq %rax, -0x138(%rbp)
movdqa %xmm0, -0x150(%rbp)
movdqa -0x150(%rbp), %xmm0
movq -0x138(%rbp), %rax
movdqu %xmm0, (%rax)
movdqa -0x260(%rbp), %xmm1
movdqa -0x280(%rbp), %xmm0
movdqa %xmm1, -0x80(%rbp)
movdqa %xmm0, -0x90(%rbp)
movdqa -0x80(%rbp), %xmm0
pand -0x90(%rbp), %xmm0
movdqa %xmm0, -0x260(%rbp)
movq -0x270(%rbp), %rax
addq $0x20, %rax
movq %rax, -0x270(%rbp)
movl -0x21c(%rbp), %eax
addl $0x8, %eax
movl %eax, -0x21c(%rbp)
jmp 0x15635f
jmp 0x156617
movl -0x21c(%rbp), %eax
cmpl -0x200(%rbp), %eax
jge 0x15667e
movq -0x1f8(%rbp), %rax
movslq -0x21c(%rbp), %rcx
movzbl (%rax,%rcx), %eax
movl %eax, -0x314(%rbp)
movl -0x314(%rbp), %eax
movb %al, %dl
movq -0x210(%rbp), %rax
movl -0x21c(%rbp), %ecx
shll $0x2, %ecx
movslq %ecx, %rcx
movb %dl, (%rax,%rcx)
movl -0x314(%rbp), %eax
andl -0x218(%rbp), %eax
movl %eax, -0x218(%rbp)
movl -0x21c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x21c(%rbp)
jmp 0x156617
movl -0x1fc(%rbp), %ecx
movq -0x1f8(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x1f8(%rbp)
movl -0x214(%rbp), %ecx
movq -0x210(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x210(%rbp)
movl -0x220(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x220(%rbp)
jmp 0x156335
movaps -0x260(%rbp), %xmm1
movaps -0x250(%rbp), %xmm0
movaps %xmm1, -0x10(%rbp)
movaps %xmm0, -0x20(%rbp)
movaps -0x10(%rbp), %xmm0
movaps -0x20(%rbp), %xmm1
pcmpeqb %xmm1, %xmm0
movdqa %xmm0, -0x30(%rbp)
movdqa -0x30(%rbp), %xmm0
pmovmskb %xmm0, %eax
andl -0x218(%rbp), %eax
movl %eax, -0x218(%rbp)
cmpl $0xff, -0x218(%rbp)
setne %al
andb $0x1, %al
movzbl %al, %eax
addq $0x2a0, %rsp            # imm = 0x2A0
popq %rbp
retq
nopl (%rax)