// File: /workspace/github_c_makefile_star2_O2/enzo1982[P]smooth/libraries/libwebp/src/dsp/yuv_sse2.c
// Function: PlanarTo24b_SSE2
static WEBP_INLINE void PlanarTo24b_SSE2(__m128i* const in0, __m128i* const in1,
                                         __m128i* const in2, __m128i* const in3,
                                         __m128i* const in4, __m128i* const in5,
                                         uint8_t* const rgb) {
  // The input is 6 registers of sixteen 8b but for the sake of explanation,
  // let's take 6 registers of four 8b values.
  // To pack, we will keep taking one every two 8b integer and move it
  // around as follows:
  // Input:
  //   r0r1r2r3 | r4r5r6r7 | g0g1g2g3 | g4g5g6g7 | b0b1b2b3 | b4b5b6b7
  // Split the 6 registers in two sets of 3 registers: the first set as the even
  // 8b bytes, the second the odd ones:
  //   r0r2r4r6 | g0g2g4g6 | b0b2b4b6 | r1r3r5r7 | g1g3g5g7 | b1b3b5b7
  // Repeat the same permutations twice more:
  //   r0r4g0g4 | b0b4r1r5 | g1g5b1b5 | r2r6g2g6 | b2b6r3r7 | g3g7b3b7
  //   r0g0b0r1 | g1b1r2g2 | b2r3g3b3 | r4g4b4r5 | g5b5r6g6 | b6r7g7b7
  VP8PlanarTo24b_SSE2(in0, in1, in2, in3, in4, in5);

  _mm_storeu_si128((__m128i*)(rgb +  0), *in0);
  _mm_storeu_si128((__m128i*)(rgb + 16), *in1);
  _mm_storeu_si128((__m128i*)(rgb + 32), *in2);
  _mm_storeu_si128((__m128i*)(rgb + 48), *in3);
  _mm_storeu_si128((__m128i*)(rgb + 64), *in4);
  _mm_storeu_si128((__m128i*)(rgb + 80), *in5);
}

// Assembly:
movq 0x8(%rsp), %rax
movdqa (%rdi), %xmm2
movdqa (%rsi), %xmm7
movdqa 0x3dee7(%rip), %xmm0    # 0x11cbb0
movdqa %xmm2, %xmm3
pand %xmm0, %xmm3
movdqa %xmm7, %xmm1
pand %xmm0, %xmm1
packuswb %xmm1, %xmm3
movdqa (%rdx), %xmm1
movdqa (%rcx), %xmm8
movdqa %xmm1, %xmm5
pand %xmm0, %xmm5
movdqa %xmm8, %xmm4
pand %xmm0, %xmm4
packuswb %xmm4, %xmm5
movdqa (%r8), %xmm4
movdqa (%r9), %xmm9
movdqa %xmm4, %xmm6
pand %xmm0, %xmm6
movdqa %xmm9, %xmm10
pand %xmm0, %xmm10
packuswb %xmm10, %xmm6
psrlw $0x8, %xmm2
psrlw $0x8, %xmm7
packuswb %xmm7, %xmm2
psrlw $0x8, %xmm1
psrlw $0x8, %xmm8
packuswb %xmm8, %xmm1
psrlw $0x8, %xmm4
psrlw $0x8, %xmm9
packuswb %xmm9, %xmm4
movdqa %xmm3, %xmm7
pand %xmm0, %xmm7
movdqa %xmm5, %xmm8
pand %xmm0, %xmm8
packuswb %xmm8, %xmm7
movdqa %xmm7, (%rdi)
movdqa %xmm6, %xmm7
pand %xmm0, %xmm7
movdqa %xmm2, %xmm8
pand %xmm0, %xmm8
packuswb %xmm8, %xmm7
movdqa %xmm7, (%rsi)
movdqa %xmm1, %xmm7
pand %xmm0, %xmm7
movdqa %xmm4, %xmm8
pand %xmm0, %xmm8
packuswb %xmm8, %xmm7
movdqa %xmm7, (%rdx)
psrlw $0x8, %xmm3
psrlw $0x8, %xmm5
packuswb %xmm5, %xmm3
movdqa %xmm3, (%rcx)
psrlw $0x8, %xmm6
psrlw $0x8, %xmm2
packuswb %xmm2, %xmm6
movdqa %xmm6, (%r8)
psrlw $0x8, %xmm1
psrlw $0x8, %xmm4
packuswb %xmm4, %xmm1
movdqa %xmm1, (%r9)
movdqa (%rdi), %xmm5
movdqa (%rsi), %xmm7
movdqa %xmm5, %xmm3
pand %xmm0, %xmm3
movdqa %xmm7, %xmm2
pand %xmm0, %xmm2
packuswb %xmm2, %xmm3
movdqa (%rdx), %xmm2
movdqa (%rcx), %xmm8
movdqa %xmm2, %xmm9
pand %xmm0, %xmm9
movdqa %xmm8, %xmm4
pand %xmm0, %xmm4
packuswb %xmm4, %xmm9
movdqa (%r8), %xmm6
movdqa %xmm6, %xmm4
pand %xmm0, %xmm4
movdqa %xmm1, %xmm10
pand %xmm0, %xmm10
packuswb %xmm10, %xmm4
psrlw $0x8, %xmm5
psrlw $0x8, %xmm7
packuswb %xmm7, %xmm5
psrlw $0x8, %xmm2
psrlw $0x8, %xmm8
packuswb %xmm8, %xmm2
psrlw $0x8, %xmm6
psrlw $0x8, %xmm1
packuswb %xmm1, %xmm6
movdqa %xmm3, %xmm1
pand %xmm0, %xmm1
movdqa %xmm9, %xmm7
pand %xmm0, %xmm7
packuswb %xmm7, %xmm1
movdqa %xmm4, %xmm8
pand %xmm0, %xmm8
movdqa %xmm5, %xmm7
pand %xmm0, %xmm7
packuswb %xmm7, %xmm8
movdqa %xmm2, %xmm7
pand %xmm0, %xmm7
movdqa %xmm6, %xmm10
pand %xmm0, %xmm10
packuswb %xmm10, %xmm7
psrlw $0x8, %xmm3
psrlw $0x8, %xmm9
packuswb %xmm9, %xmm3
psrlw $0x8, %xmm4
psrlw $0x8, %xmm5
packuswb %xmm5, %xmm4
psrlw $0x8, %xmm2
psrlw $0x8, %xmm6
packuswb %xmm6, %xmm2
movdqa %xmm1, %xmm5
pand %xmm0, %xmm5
movdqa %xmm8, %xmm6
pand %xmm0, %xmm6
packuswb %xmm6, %xmm5
movdqa %xmm5, (%rdi)
movdqa %xmm7, %xmm5
pand %xmm0, %xmm5
movdqa %xmm3, %xmm6
pand %xmm0, %xmm6
packuswb %xmm6, %xmm5
movdqa %xmm5, (%rsi)
movdqa %xmm4, %xmm5
pand %xmm0, %xmm5
pand %xmm2, %xmm0
packuswb %xmm0, %xmm5
movdqa %xmm5, (%rdx)
psrlw $0x8, %xmm1
psrlw $0x8, %xmm8
packuswb %xmm8, %xmm1
movdqa %xmm1, (%rcx)
psrlw $0x8, %xmm7
psrlw $0x8, %xmm3
packuswb %xmm3, %xmm7
movdqa %xmm7, (%r8)
psrlw $0x8, %xmm4
psrlw $0x8, %xmm2
packuswb %xmm2, %xmm4
movdqa %xmm4, (%r9)
movaps (%rdi), %xmm0
movups %xmm0, (%rax)
movaps (%rsi), %xmm0
movups %xmm0, 0x10(%rax)
movaps (%rdx), %xmm0
movups %xmm0, 0x20(%rax)
movaps (%rcx), %xmm0
movups %xmm0, 0x30(%rax)
movaps (%r8), %xmm0
movups %xmm0, 0x40(%rax)
movaps (%r9), %xmm0
movups %xmm0, 0x50(%rax)
retq