user: Please show me the C implementation that matches the assembly code listed below:

```asm
<rgb2yuy2>:
  endbr64
  lea    (%rdx,%rdx,2),%r8d
  test   %r8d,%r8d
  jle    L7
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  mov    $0x0,%ecx
L15:
  movzbl (%rdi),%eax
  movzbl 0x1(%rdi),%ebx
  movzbl 0x2(%rdi),%r11d
  imul   $0x2646,%eax,%r10d
  imul   $0x4b23,%ebx,%edx
  add    %edx,%r10d
  imul   $0xe98,%r11d,%edx
  add    %edx,%r10d
  sar    $0xf,%r10d
  imul   $0xffffed50,%eax,%r9d
  imul   $0xffffdb23,%ebx,%edx
  add    %edx,%r9d
  imul   $0x378d,%r11d,%edx
  add    %edx,%r9d
  sar    $0xf,%r9d
  sub    $0xffffff80,%r9d
  imul   $0x4efa,%eax,%edx
  imul   $0xffffbdd3,%ebx,%ebx
  add    %ebx,%edx
  imul   $0xfffff333,%r11d,%r11d
  add    %r11d,%edx
  sar    $0xf,%edx
  sub    $0xffffff80,%edx
  test   %r10d,%r10d
  mov    $0x0,%eax
  cmovs  %eax,%r10d
  test   %r9d,%r9d
  cmovs  %eax,%r9d
  test   %edx,%edx
  cmovs  %eax,%edx
  movzbl 0x3(%rdi),%eax
  movzbl 0x4(%rdi),%r12d
  movzbl 0x5(%rdi),%ebp
  imul   $0x2646,%eax,%ebx
  imul   $0x4b23,%r12d,%r11d
  add    %r11d,%ebx
  imul   $0xe98,%ebp,%r11d
  add    %r11d,%ebx
  sar    $0xf,%ebx
  imul   $0xffffed50,%eax,%r11d
  imul   $0xffffdb23,%r12d,%r13d
  add    %r13d,%r11d
  imul   $0x378d,%ebp,%r13d
  add    %r13d,%r11d
  sar    $0xf,%r11d
  sub    $0xffffff80,%r11d
  imul   $0x4efa,%eax,%eax
  imul   $0xffffbdd3,%r12d,%r12d
  add    %r12d,%eax
  imul   $0xfffff333,%ebp,%ebp
  add    %ebp,%eax
  sar    $0xf,%eax
  sub    $0xffffff80,%eax
  test   %ebx,%ebx
  mov    $0x0,%ebp
  cmovs  %ebp,%ebx
  test   %r11d,%r11d
  cmovs  %ebp,%r11d
  test   %eax,%eax
  cmovs  %ebp,%eax
  mov    $0xff,%ebp
  cmp    %ebp,%r10d
  cmovg  %ebp,%r10d
  mov    %r10b,(%rsi)
  mov    $0xff,%r10d
  cmp    %r10d,%r9d
  cmovg  %r10d,%r9d
  cmp    %r10d,%r11d
  cmovg  %r10d,%r11d
  add    %r11d,%r9d
  sar    %r9d
  mov    %r9b,0x1(%rsi)
  mov    $0xff,%r9d
  cmp    %r9d,%ebx
  cmovg  %r9d,%ebx
  mov    %bl,0x2(%rsi)
  cmp    %r9d,%edx
  cmovg  %r9d,%edx
  cmp    %r9d,%eax
  cmovg  %r9d,%eax
  add    %eax,%edx
  sar    %edx
  mov    %dl,0x3(%rsi)
  add    $0x6,%ecx
  add    $0x6,%rdi
  add    $0x4,%rsi
  cmp    %r8d,%ecx
  jl     L15
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
L7:
  ret
```

assistant: ```c
void rgb2yuy2(char *RGB, char *YUV, int NumPixels) {
  int i, j;
  register int y0, y1, u0, u1, v0, v1;
  register int r, g, b;
  for (i = 0, j = 0; i < (NumPixels + (NumPixels << 1)); i += 6, j += 4) {
    r = (unsigned char)RGB[i + 0];
    g = (unsigned char)RGB[i + 1];
    b = (unsigned char)RGB[i + 2];
    y0 = (9798 * r + 19235 * g + 3736 * b) >> 15;
    u0 = ((-4784 * r - 9437 * g + 14221 * b) >> 15) + 128;
    v0 = ((20218 * r - 16941 * g - 3277 * b) >> 15) + 128;
    y0 = y0 < 0 ? 0 : y0;
    u0 = u0 < 0 ? 0 : u0;
    v0 = v0 < 0 ? 0 : v0;
    y0 = y0 > 255 ? 255 : y0;
    u0 = u0 > 255 ? 255 : u0;
    v0 = v0 > 255 ? 255 : v0;
    r = (unsigned char)RGB[i + 3];
    g = (unsigned char)RGB[i + 4];
    b = (unsigned char)RGB[i + 5];
    y1 = (9798 * r + 19235 * g + 3736 * b) >> 15;
    u1 = ((-4784 * r - 9437 * g + 14221 * b) >> 15) + 128;
    v1 = ((20218 * r - 16941 * g - 3277 * b) >> 15) + 128;
    y1 = y1 < 0 ? 0 : y1;
    u1 = u1 < 0 ? 0 : u1;
    v1 = v1 < 0 ? 0 : v1;
    y1 = y1 > 255 ? 255 : y1;
    u1 = u1 > 255 ? 255 : u1;
    v1 = v1 > 255 ? 255 : v1;
    YUV[j + 0] = y0;
    YUV[j + 1] = (u0 + u1) >> 1;
    YUV[j + 2] = y1;
    YUV[j + 3] = (v0 + v1) >> 1;
  }
}
```