// File: /workspace/github_c_makefile_star2_O1/enzo1982[P]smooth/libraries/libwebp/src/dsp/alpha_processing_sse2.c
// Function: DispatchAlphaToGreen_SSE2
static void DispatchAlphaToGreen_SSE2(const uint8_t* WEBP_RESTRICT alpha,
                                      int alpha_stride, int width, int height,
                                      uint32_t* WEBP_RESTRICT dst,
                                      int dst_stride) {
  int i, j;
  const __m128i zero = _mm_setzero_si128();
  const int limit = width & ~15;
  for (j = 0; j < height; ++j) {
    for (i = 0; i < limit; i += 16) {   // process 16 alpha bytes
      const __m128i a0 = _mm_loadu_si128((const __m128i*)&alpha[i]);
      const __m128i a1 = _mm_unpacklo_epi8(zero, a0);  // note the 'zero' first!
      const __m128i b1 = _mm_unpackhi_epi8(zero, a0);
      const __m128i a2_lo = _mm_unpacklo_epi16(a1, zero);
      const __m128i b2_lo = _mm_unpacklo_epi16(b1, zero);
      const __m128i a2_hi = _mm_unpackhi_epi16(a1, zero);
      const __m128i b2_hi = _mm_unpackhi_epi16(b1, zero);
      _mm_storeu_si128((__m128i*)&dst[i +  0], a2_lo);
      _mm_storeu_si128((__m128i*)&dst[i +  4], a2_hi);
      _mm_storeu_si128((__m128i*)&dst[i +  8], b2_lo);
      _mm_storeu_si128((__m128i*)&dst[i + 12], b2_hi);
    }
    for (; i < width; ++i) dst[i] = alpha[i] << 8;
    alpha += alpha_stride;
    dst += dst_stride;
  }
}

// Assembly:
testl %ecx, %ecx
jle 0xe3296
pushq %rbp
pushq %r14
pushq %rbx
movl %edx, %eax
andl $-0x10, %eax
movslq %esi, %rsi
movslq %r9d, %r9
movslq %eax, %r10
movl %edx, %r11d
shlq $0x2, %r9
xorl %ebx, %ebx
pxor %xmm0, %xmm0
movdqa 0x4a86c(%rip), %xmm1    # 0x12da20
movdqa 0x4a874(%rip), %xmm2    # 0x12da30
movl $0x0, %r14d
testl %eax, %eax
jle 0xe3266
xorl %r14d, %r14d
movdqu (%rdi,%r14), %xmm4
pxor %xmm3, %xmm3
punpcklbw %xmm4, %xmm3    # xmm3 = xmm3[0],xmm4[0],xmm3[1],xmm4[1],xmm3[2],xmm4[2],xmm3[3],xmm4[3],xmm3[4],xmm4[4],xmm3[5],xmm4[5],xmm3[6],xmm4[6],xmm3[7],xmm4[7]
movdqa %xmm3, %xmm5
punpckhbw %xmm0, %xmm5    # xmm5 = xmm5[8],xmm0[8],xmm5[9],xmm0[9],xmm5[10],xmm0[10],xmm5[11],xmm0[11],xmm5[12],xmm0[12],xmm5[13],xmm0[13],xmm5[14],xmm0[14],xmm5[15],xmm0[15]
movdqa %xmm3, %xmm6
punpcklbw %xmm0, %xmm6    # xmm6 = xmm6[0],xmm0[0],xmm6[1],xmm0[1],xmm6[2],xmm0[2],xmm6[3],xmm0[3],xmm6[4],xmm0[4],xmm6[5],xmm0[5],xmm6[6],xmm0[6],xmm6[7],xmm0[7]
pshufd $0x6c, %xmm6, %xmm6     # xmm6 = xmm6[0,3,2,1]
pshufhw $0xc4, %xmm6, %xmm6     # xmm6 = xmm6[0,1,2,3,4,5,4,7]
pshufd $0x6c, %xmm6, %xmm6     # xmm6 = xmm6[0,3,2,1]
pand %xmm1, %xmm6
packuswb %xmm5, %xmm6
pxor %xmm5, %xmm5
punpckhbw %xmm4, %xmm5    # xmm5 = xmm5[8],xmm4[8],xmm5[9],xmm4[9],xmm5[10],xmm4[10],xmm5[11],xmm4[11],xmm5[12],xmm4[12],xmm5[13],xmm4[13],xmm5[14],xmm4[14],xmm5[15],xmm4[15]
movdqa %xmm5, %xmm4
punpckhbw %xmm0, %xmm4    # xmm4 = xmm4[8],xmm0[8],xmm4[9],xmm0[9],xmm4[10],xmm0[10],xmm4[11],xmm0[11],xmm4[12],xmm0[12],xmm4[13],xmm0[13],xmm4[14],xmm0[14],xmm4[15],xmm0[15]
pshufd $0x6c, %xmm4, %xmm4     # xmm4 = xmm4[0,3,2,1]
pshuflw $0xc4, %xmm4, %xmm4     # xmm4 = xmm4[0,1,0,3,4,5,6,7]
pshufd $0x6c, %xmm4, %xmm4     # xmm4 = xmm4[0,3,2,1]
pshufhw $0xc6, %xmm4, %xmm4     # xmm4 = xmm4[0,1,2,3,6,5,4,7]
pand %xmm2, %xmm4
packuswb %xmm4, %xmm4
punpcklwd %xmm0, %xmm6    # xmm6 = xmm6[0],xmm0[0],xmm6[1],xmm0[1],xmm6[2],xmm0[2],xmm6[3],xmm0[3]
punpcklwd %xmm0, %xmm5    # xmm5 = xmm5[0],xmm0[0],xmm5[1],xmm0[1],xmm5[2],xmm0[2],xmm5[3],xmm0[3]
punpckhwd %xmm0, %xmm3    # xmm3 = xmm3[4],xmm0[4],xmm3[5],xmm0[5],xmm3[6],xmm0[6],xmm3[7],xmm0[7]
punpckhwd %xmm0, %xmm4    # xmm4 = xmm4[4],xmm0[4],xmm4[5],xmm0[5],xmm4[6],xmm0[6],xmm4[7],xmm0[7]
movdqu %xmm6, (%r8,%r14,4)
movdqu %xmm3, 0x10(%r8,%r14,4)
movdqu %xmm5, 0x20(%r8,%r14,4)
movdqu %xmm4, 0x30(%r8,%r14,4)
addq $0x10, %r14
cmpq %r10, %r14
jl 0xe31cd
cmpl %edx, %r14d
jge 0xe3282
movl %r14d, %r14d
movzbl (%rdi,%r14), %ebp
shll $0x8, %ebp
movl %ebp, (%r8,%r14,4)
incq %r14
cmpq %r14, %r11
jne 0xe326e
addq %rsi, %rdi
incl %ebx
addq %r9, %r8
cmpl %ecx, %ebx
jne 0xe31bc
popq %rbx
popq %r14
popq %rbp
retq