// File: /workspace/github_c_makefile_star2_O2/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:
pushq %rbp
pushq %r14
pushq %rbx
movslq %edx, %rax
andl $-0x10, %edx
movslq %esi, %rsi
movslq %r9d, %r9
movslq %edx, %rdx
xorl %r10d, %r10d
testl %ecx, %ecx
cmovlel %r10d, %ecx
shlq $0x2, %r9
pxor %xmm0, %xmm0
movdqa 0x46267(%rip), %xmm1    # 0x11c940
movdqa 0x4626f(%rip), %xmm2    # 0x11c950
cmpl %ecx, %r10d
je 0xd67bf
movq %rdi, %r11
movq %r8, %rbx
xorl %r14d, %r14d
cmpq %rdx, %r14
jge 0xd67ac
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
addq $0x40, %rbx
addq $0x10, %r11
jmp 0xd66f3
movzbl (%r11), %ebp
shll $0x8, %ebp
movl %ebp, (%rbx)
incq %r14
addq $0x4, %rbx
incq %r11
cmpq %rax, %r14
jl 0xd6799
addq %rsi, %rdi
incl %r10d
addq %r9, %r8
jmp 0xd66e1
popq %rbx
popq %r14
popq %rbp
retq