// File: /workspace/github_c_makefile_star2_O2/enzo1982[P]smooth/libraries/libwebp/src/dsp/lossless_sse2.c
// Function: ConvertBGRAToRGB_SSE2
static void ConvertBGRAToRGB_SSE2(const uint32_t* src, int num_pixels,
                                  uint8_t* dst) {
  const __m128i* in = (const __m128i*)src;
  __m128i* out = (__m128i*)dst;

  while (num_pixels >= 32) {
    // Load the BGRA buffers.
    __m128i in0 = _mm_loadu_si128(in + 0);
    __m128i in1 = _mm_loadu_si128(in + 1);
    __m128i in2 = _mm_loadu_si128(in + 2);
    __m128i in3 = _mm_loadu_si128(in + 3);
    __m128i in4 = _mm_loadu_si128(in + 4);
    __m128i in5 = _mm_loadu_si128(in + 5);
    __m128i in6 = _mm_loadu_si128(in + 6);
    __m128i in7 = _mm_loadu_si128(in + 7);
    VP8L32bToPlanar_SSE2(&in0, &in1, &in2, &in3);
    VP8L32bToPlanar_SSE2(&in4, &in5, &in6, &in7);
    // At this points, in1/in5 contains red only, in2/in6 green only ...
    // Pack the colors in 24b RGB.
    VP8PlanarTo24b_SSE2(&in1, &in5, &in2, &in6, &in3, &in7);
    _mm_storeu_si128(out + 0, in1);
    _mm_storeu_si128(out + 1, in5);
    _mm_storeu_si128(out + 2, in2);
    _mm_storeu_si128(out + 3, in6);
    _mm_storeu_si128(out + 4, in3);
    _mm_storeu_si128(out + 5, in7);
    in += 8;
    out += 6;
    num_pixels -= 32;
  }
  // left-overs
  if (num_pixels > 0) {
    VP8LConvertBGRAToRGB_C((const uint32_t*)in, num_pixels, (uint8_t*)out);
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %rdx, %rbx
movl %esi, %ebp
movq %rdi, %r14
leaq 0x20(%rsp), %r13
leaq 0x10(%rsp), %r15
movq %rsp, %r12
cmpl $0x20, %ebp
jl 0xda596
movups (%r14), %xmm0
movaps %xmm0, 0x70(%rsp)
movups 0x10(%r14), %xmm0
movaps %xmm0, 0x50(%rsp)
movups 0x20(%r14), %xmm0
movaps %xmm0, 0x40(%rsp)
movups 0x30(%r14), %xmm0
movaps %xmm0, 0x30(%rsp)
movups 0x40(%r14), %xmm0
movaps %xmm0, 0x60(%rsp)
movups 0x50(%r14), %xmm0
movaps %xmm0, 0x20(%rsp)
movups 0x60(%r14), %xmm0
movaps %xmm0, 0x10(%rsp)
movups 0x70(%r14), %xmm0
movaps %xmm0, (%rsp)
leaq 0x70(%rsp), %rdi
leaq 0x50(%rsp), %rsi
leaq 0x40(%rsp), %rdx
leaq 0x30(%rsp), %rcx
callq 0xda82a
leaq 0x60(%rsp), %rdi
movq %r13, %rsi
movq %r15, %rdx
movq %r12, %rcx
callq 0xda82a
movdqa 0x50(%rsp), %xmm5
movdqa 0x20(%rsp), %xmm1
movdqa %xmm5, %xmm2
movdqa 0x4288d(%rip), %xmm10   # 0x11cbb0
pand %xmm10, %xmm2
movdqa %xmm1, %xmm0
pand %xmm10, %xmm0
packuswb %xmm0, %xmm2
movdqa 0x40(%rsp), %xmm3
movdqa 0x10(%rsp), %xmm4
movdqa %xmm3, %xmm7
pand %xmm10, %xmm7
movdqa %xmm4, %xmm0
pand %xmm10, %xmm0
packuswb %xmm0, %xmm7
movdqa 0x30(%rsp), %xmm6
movdqa (%rsp), %xmm8
movdqa %xmm6, %xmm0
pand %xmm10, %xmm0
movdqa %xmm8, %xmm9
pand %xmm10, %xmm9
packuswb %xmm9, %xmm0
psrlw $0x8, %xmm5
psrlw $0x8, %xmm1
packuswb %xmm1, %xmm5
psrlw $0x8, %xmm3
psrlw $0x8, %xmm4
packuswb %xmm4, %xmm3
psrlw $0x8, %xmm6
psrlw $0x8, %xmm8
packuswb %xmm8, %xmm6
movdqa %xmm2, %xmm4
pand %xmm10, %xmm4
movdqa %xmm7, %xmm1
pand %xmm10, %xmm1
packuswb %xmm1, %xmm4
movdqa %xmm0, %xmm8
pand %xmm10, %xmm8
movdqa %xmm5, %xmm1
pand %xmm10, %xmm1
packuswb %xmm1, %xmm8
movdqa %xmm3, %xmm1
pand %xmm10, %xmm1
movdqa %xmm6, %xmm9
pand %xmm10, %xmm9
packuswb %xmm9, %xmm1
psrlw $0x8, %xmm2
psrlw $0x8, %xmm7
packuswb %xmm7, %xmm2
psrlw $0x8, %xmm0
psrlw $0x8, %xmm5
packuswb %xmm5, %xmm0
psrlw $0x8, %xmm3
psrlw $0x8, %xmm6
packuswb %xmm6, %xmm3
movdqa %xmm4, %xmm5
pand %xmm10, %xmm5
movdqa %xmm8, %xmm6
pand %xmm10, %xmm6
packuswb %xmm6, %xmm5
movdqa %xmm1, %xmm7
pand %xmm10, %xmm7
movdqa %xmm2, %xmm6
pand %xmm10, %xmm6
packuswb %xmm6, %xmm7
movdqa %xmm0, %xmm6
pand %xmm10, %xmm6
movdqa %xmm3, %xmm9
pand %xmm10, %xmm9
packuswb %xmm9, %xmm6
psrlw $0x8, %xmm4
psrlw $0x8, %xmm8
packuswb %xmm8, %xmm4
psrlw $0x8, %xmm1
psrlw $0x8, %xmm2
packuswb %xmm2, %xmm1
psrlw $0x8, %xmm0
psrlw $0x8, %xmm3
packuswb %xmm3, %xmm0
movdqa %xmm5, %xmm2
pand %xmm10, %xmm2
movdqa %xmm7, %xmm3
pand %xmm10, %xmm3
packuswb %xmm3, %xmm2
movdqa %xmm6, %xmm8
pand %xmm10, %xmm8
movdqa %xmm4, %xmm3
pand %xmm10, %xmm3
packuswb %xmm3, %xmm8
movdqa %xmm1, %xmm3
pand %xmm10, %xmm3
movdqa %xmm0, %xmm9
pand %xmm10, %xmm9
packuswb %xmm9, %xmm3
psrlw $0x8, %xmm5
psrlw $0x8, %xmm7
packuswb %xmm7, %xmm5
psrlw $0x8, %xmm6
psrlw $0x8, %xmm4
packuswb %xmm4, %xmm6
psrlw $0x8, %xmm1
psrlw $0x8, %xmm0
packuswb %xmm0, %xmm1
movdqa %xmm2, %xmm0
pand %xmm10, %xmm0
movdqa %xmm8, %xmm4
pand %xmm10, %xmm4
packuswb %xmm4, %xmm0
movdqa %xmm3, %xmm4
pand %xmm10, %xmm4
movdqa %xmm5, %xmm7
pand %xmm10, %xmm7
packuswb %xmm7, %xmm4
movdqa %xmm6, %xmm7
pand %xmm10, %xmm7
movdqa %xmm1, %xmm9
pand %xmm10, %xmm9
packuswb %xmm9, %xmm7
psrlw $0x8, %xmm2
psrlw $0x8, %xmm8
packuswb %xmm8, %xmm2
psrlw $0x8, %xmm3
psrlw $0x8, %xmm5
packuswb %xmm5, %xmm3
psrlw $0x8, %xmm6
psrlw $0x8, %xmm1
packuswb %xmm1, %xmm6
movdqu %xmm0, (%rbx)
movdqu %xmm4, 0x10(%rbx)
movdqu %xmm7, 0x20(%rbx)
movdqu %xmm2, 0x30(%rbx)
movdqu %xmm3, 0x40(%rbx)
movdqu %xmm6, 0x50(%rbx)
subq $-0x80, %r14
addq $0x60, %rbx
addl $-0x20, %ebp
jmp 0xda287
testl %ebp, %ebp
jle 0xda5b8
movq %r14, %rdi
movl %ebp, %esi
movq %rbx, %rdx
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xd2194
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq