// File: /workspace/github_c_makefile_star2_O0/enzo1982[P]smooth/libraries/libwebp/src/dsp/yuv_sse2.c
// Function: ConvertRGB24ToY_SSE2
static void ConvertRGB24ToY_SSE2(const uint8_t* rgb, uint8_t* y, int width) {
  const int max_width = width & ~31;
  int i;
  for (i = 0; i < max_width; rgb += 3 * 16 * 2) {
    __m128i rgb_plane[6];
    int j;

    RGB24PackedToPlanar_SSE2(rgb, rgb_plane);

    for (j = 0; j < 2; ++j, i += 16) {
      const __m128i zero = _mm_setzero_si128();
      __m128i r, g, b, Y0, Y1;

      // Convert to 16-bit Y.
      r = _mm_unpacklo_epi8(rgb_plane[0 + j], zero);
      g = _mm_unpacklo_epi8(rgb_plane[2 + j], zero);
      b = _mm_unpacklo_epi8(rgb_plane[4 + j], zero);
      ConvertRGBToY_SSE2(&r, &g, &b, &Y0);

      // Convert to 16-bit Y.
      r = _mm_unpackhi_epi8(rgb_plane[0 + j], zero);
      g = _mm_unpackhi_epi8(rgb_plane[2 + j], zero);
      b = _mm_unpackhi_epi8(rgb_plane[4 + j], zero);
      ConvertRGBToY_SSE2(&r, &g, &b, &Y1);

      // Cast to 8-bit and store.
      STORE_16(_mm_packus_epi16(Y0, Y1), y + i);
    }
  }
  for (; i < width; ++i, rgb += 3) {   // left-over
    y[i] = VP8RGBToY(rgb[0], rgb[1], rgb[2], YUV_HALF);
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x210, %rsp            # imm = 0x210
movq %rdi, -0x118(%rbp)
movq %rsi, -0x120(%rbp)
movl %edx, -0x124(%rbp)
movl -0x124(%rbp), %eax
andl $-0x20, %eax
movl %eax, -0x128(%rbp)
movl $0x0, -0x12c(%rbp)
movl -0x12c(%rbp), %eax
cmpl -0x128(%rbp), %eax
jge 0x17d651
movq -0x118(%rbp), %rdi
leaq -0x190(%rbp), %rsi
callq 0x181690
movl $0x0, -0x194(%rbp)
cmpl $0x2, -0x194(%rbp)
jge 0x17d638
xorps %xmm0, %xmm0
movaps %xmm0, -0xf0(%rbp)
movaps -0xf0(%rbp), %xmm0
movaps %xmm0, -0x1b0(%rbp)
movslq -0x194(%rbp), %rax
shlq $0x4, %rax
movaps -0x190(%rbp,%rax), %xmm1
movaps -0x1b0(%rbp), %xmm0
movaps %xmm1, -0x90(%rbp)
movaps %xmm0, -0xa0(%rbp)
movaps -0x90(%rbp), %xmm0
movaps -0xa0(%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, -0x1c0(%rbp)
movslq -0x194(%rbp), %rax
shlq $0x4, %rax
leaq -0x190(%rbp), %rcx
movq %rcx, -0x208(%rbp)
movaps 0x20(%rax,%rcx), %xmm1
movaps -0x1b0(%rbp), %xmm0
movaps %xmm1, -0xb0(%rbp)
movaps %xmm0, -0xc0(%rbp)
movaps -0xb0(%rbp), %xmm0
movaps -0xc0(%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, -0x1d0(%rbp)
movslq -0x194(%rbp), %rax
shlq $0x4, %rax
movaps 0x40(%rax,%rcx), %xmm1
movaps -0x1b0(%rbp), %xmm0
movaps %xmm1, -0xd0(%rbp)
movaps %xmm0, -0xe0(%rbp)
movaps -0xd0(%rbp), %xmm0
movaps -0xe0(%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, -0x1e0(%rbp)
leaq -0x1c0(%rbp), %rdi
leaq -0x1d0(%rbp), %rsi
leaq -0x1e0(%rbp), %rdx
leaq -0x1f0(%rbp), %rcx
callq 0x180240
movq -0x208(%rbp), %rcx
movslq -0x194(%rbp), %rax
shlq $0x4, %rax
movaps -0x190(%rbp,%rax), %xmm1
movaps -0x1b0(%rbp), %xmm0
movaps %xmm1, -0x30(%rbp)
movaps %xmm0, -0x40(%rbp)
movaps -0x30(%rbp), %xmm0
movaps -0x40(%rbp), %xmm1
punpckhbw %xmm1, %xmm0    # xmm0 = xmm0[8],xmm1[8],xmm0[9],xmm1[9],xmm0[10],xmm1[10],xmm0[11],xmm1[11],xmm0[12],xmm1[12],xmm0[13],xmm1[13],xmm0[14],xmm1[14],xmm0[15],xmm1[15]
movaps %xmm0, -0x1c0(%rbp)
movslq -0x194(%rbp), %rax
shlq $0x4, %rax
movaps 0x20(%rax,%rcx), %xmm1
movaps -0x1b0(%rbp), %xmm0
movaps %xmm1, -0x50(%rbp)
movaps %xmm0, -0x60(%rbp)
movaps -0x50(%rbp), %xmm0
movaps -0x60(%rbp), %xmm1
punpckhbw %xmm1, %xmm0    # xmm0 = xmm0[8],xmm1[8],xmm0[9],xmm1[9],xmm0[10],xmm1[10],xmm0[11],xmm1[11],xmm0[12],xmm1[12],xmm0[13],xmm1[13],xmm0[14],xmm1[14],xmm0[15],xmm1[15]
movaps %xmm0, -0x1d0(%rbp)
movslq -0x194(%rbp), %rax
shlq $0x4, %rax
movaps 0x40(%rax,%rcx), %xmm1
movaps -0x1b0(%rbp), %xmm0
movaps %xmm1, -0x70(%rbp)
movaps %xmm0, -0x80(%rbp)
movaps -0x70(%rbp), %xmm0
movaps -0x80(%rbp), %xmm1
punpckhbw %xmm1, %xmm0    # xmm0 = xmm0[8],xmm1[8],xmm0[9],xmm1[9],xmm0[10],xmm1[10],xmm0[11],xmm1[11],xmm0[12],xmm1[12],xmm0[13],xmm1[13],xmm0[14],xmm1[14],xmm0[15],xmm1[15]
movdqa %xmm0, -0x1e0(%rbp)
leaq -0x1c0(%rbp), %rdi
leaq -0x1d0(%rbp), %rsi
leaq -0x1e0(%rbp), %rdx
leaq -0x200(%rbp), %rcx
callq 0x180240
movq -0x120(%rbp), %rax
movslq -0x12c(%rbp), %rcx
addq %rcx, %rax
movdqa -0x1f0(%rbp), %xmm1
movdqa -0x200(%rbp), %xmm0
movdqa %xmm1, -0x100(%rbp)
movdqa %xmm0, -0x110(%rbp)
movdqa -0x100(%rbp), %xmm0
movdqa -0x110(%rbp), %xmm1
packuswb %xmm1, %xmm0
movq %rax, -0x8(%rbp)
movdqa %xmm0, -0x20(%rbp)
movdqa -0x20(%rbp), %xmm0
movq -0x8(%rbp), %rax
movdqu %xmm0, (%rax)
movl -0x194(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x194(%rbp)
movl -0x12c(%rbp), %eax
addl $0x10, %eax
movl %eax, -0x12c(%rbp)
jmp 0x17d3e7
jmp 0x17d63a
movq -0x118(%rbp), %rax
addq $0x60, %rax
movq %rax, -0x118(%rbp)
jmp 0x17d3b8
jmp 0x17d653
movl -0x12c(%rbp), %eax
cmpl -0x124(%rbp), %eax
jge 0x17d6c1
movq -0x118(%rbp), %rax
movzbl (%rax), %edi
movq -0x118(%rbp), %rax
movzbl 0x1(%rax), %esi
movq -0x118(%rbp), %rax
movzbl 0x2(%rax), %edx
movl $0x8000, %ecx           # imm = 0x8000
callq 0x1807c0
movb %al, %dl
movq -0x120(%rbp), %rax
movslq -0x12c(%rbp), %rcx
movb %dl, (%rax,%rcx)
movl -0x12c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x12c(%rbp)
movq -0x118(%rbp), %rax
addq $0x3, %rax
movq %rax, -0x118(%rbp)
jmp 0x17d653
addq $0x210, %rsp            # imm = 0x210
popq %rbp
retq
nopw (%rax,%rax)