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

```asm
<rgb24_to_yuv420p>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  mov    %r8d,-0x18(%rsp)
  mov    %r9d,-0x14(%rsp)
  lea    (%r8,%r8,2),%eax
  test   %r9d,%r9d
  jle    L33
  mov    %rdi,%r11
  mov    %rsi,%rbx
  mov    %rdx,%rbp
  mov    %rcx,%r12
  movslq %eax,%rdx
  lea    0x0(,%rdx,4),%rdi
  mov    %rdi,-0x20(%rsp)
  movslq %r8d,%r13
  shl    $0x2,%r13
  lea    -0x1(%r8),%edx
  shr    %edx
  lea    0x1(%rdx),%edx
  lea    0x0(,%rdx,4),%r14
  neg    %eax
  cltq
  lea    0x18(%rdi,%rax,4),%rax
  mov    %rax,-0x38(%rsp)
  imul   %rdx,%rax
  mov    %rax,-0x10(%rsp)
  mov    $0x2,%eax
  sub    %r8d,%eax
  cltq
  lea    0x0(%r13,%rax,4),%rax
  mov    %rax,-0x30(%rsp)
  imul   %rax,%rdx
  mov    %rdx,-0x8(%rsp)
  movl   $0x0,-0x24(%rsp)
  jmp    L31
L14:
  mov    -0x20(%rsp),%rax
  lea    (%r12,%rax,1),%rdi
  mov    %r12,%rsi
  mov    %r11,%r9
  mov    $0x0,%r10d
L19:
  mov    (%rsi),%eax
  mov    0x4(%rsi),%ecx
  mov    0x8(%rsi),%edx
  imul   $0x4d,%eax,%r15d
  imul   $0x96,%ecx,%r8d
  add    %r15d,%r8d
  imul   $0x1d,%edx,%r15d
  lea    0x80(%r8,%r15,1),%r8d
  sar    $0x8,%r8d
  mov    %r8d,(%r9)
  mov    0xc(%rsi),%r15d
  mov    0x10(%rsi),%r8d
  add    %r15d,%eax
  add    %r8d,%ecx
  add    0x14(%rsi),%edx
  imul   $0x4d,%r15d,%r15d
  imul   $0x96,%r8d,%r8d
  add    %r15d,%r8d
  imul   $0x1d,0x14(%rsi),%r15d
  lea    0x80(%r8,%r15,1),%r8d
  sar    $0x8,%r8d
  mov    %r8d,0x4(%r9)
  mov    (%rdi),%r15d
  mov    0x4(%rdi),%r8d
  add    %r15d,%eax
  add    %r8d,%ecx
  add    0x8(%rdi),%edx
  imul   $0x4d,%r15d,%r15d
  imul   $0x96,%r8d,%r8d
  add    %r15d,%r8d
  imul   $0x1d,0x8(%rdi),%r15d
  lea    0x80(%r8,%r15,1),%r8d
  sar    $0x8,%r8d
  mov    %r8d,(%r9,%r13,1)
  mov    0xc(%rdi),%r15d
  mov    0x10(%rdi),%r8d
  add    %r15d,%eax
  add    %r8d,%ecx
  add    0x14(%rdi),%edx
  imul   $0x4d,%r15d,%r15d
  imul   $0x96,%r8d,%r8d
  add    %r15d,%r8d
  imul   $0x1d,0x14(%rdi),%r15d
  lea    0x80(%r8,%r15,1),%r8d
  sar    $0x8,%r8d
  mov    %r8d,0x4(%r9,%r13,1)
  imul   $0xffffffd5,%eax,%r15d
  imul   $0xffffffab,%ecx,%r8d
  add    %r15d,%r8d
  mov    %edx,%r15d
  shl    $0x7,%r15d
  lea    0x1ff(%r8,%r15,1),%r8d
  sar    $0xa,%r8d
  sub    $0xffffff80,%r8d
  mov    %r8d,(%rbx,%r10,1)
  shl    $0x7,%eax
  imul   $0xffffff95,%ecx,%ecx
  add    %ecx,%eax
  imul   $0xffffffeb,%edx,%edx
  lea    0x1ff(%rax,%rdx,1),%eax
  sar    $0xa,%eax
  sub    $0xffffff80,%eax
  mov    %eax,0x0(%rbp,%r10,1)
  mov    -0x38(%rsp),%rax
  add    %rax,%rsi
  add    -0x30(%rsp),%r9
  add    $0x4,%r10
  add    %rax,%rdi
  cmp    %r14,%r10
  jne    L19
  add    %r14,%rbx
  add    %r14,%rbp
  add    -0x10(%rsp),%r12
  add    -0x8(%rsp),%r11
L26:
  add    -0x20(%rsp),%r12
  add    %r13,%r11
  addl   $0x2,-0x24(%rsp)
  mov    -0x24(%rsp),%eax
  cmp    %eax,-0x14(%rsp)
  jle    L33
L31:
  cmpl   $0x0,-0x18(%rsp)
  jg     L14
  jmp    L26
L33:
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
```

assistant: ```c
void rgb24_to_yuv420p(uint8_t *lum, uint8_t *cb, uint8_t *cr, uint8_t *src, int width, int height) {
  int wrap, wrap3, x, y;
  int r, g, b, r1, g1, b1;
  uint8_t *p;
  wrap = width;
  wrap3 = width * 3;
  p = src;
  for (y = 0; y < height; y += 2) {
    for (x = 0; x < width; x += 2) {
      r = p[0];
      g = p[1];
      b = p[2];
      r1 = r;
      g1 = g;
      b1 = b;
      lum[0] = (((int)((0.29900) * (1L << 8) + 0.5)) * r + ((int)((0.58700) * (1L << 8) + 0.5)) * g + ((int)((0.11400) * (1L << 8) + 0.5)) * b + (1 << (8 - 1))) >> 8;
      r = p[3];
      g = p[4];
      b = p[5];
      r1 += r;
      g1 += g;
      b1 += b;
      lum[1] = (((int)((0.29900) * (1L << 8) + 0.5)) * r + ((int)((0.58700) * (1L << 8) + 0.5)) * g + ((int)((0.11400) * (1L << 8) + 0.5)) * b + (1 << (8 - 1))) >> 8;
      p += wrap3;
      lum += wrap;
      r = p[0];
      g = p[1];
      b = p[2];
      r1 += r;
      g1 += g;
      b1 += b;
      lum[0] = (((int)((0.29900) * (1L << 8) + 0.5)) * r + ((int)((0.58700) * (1L << 8) + 0.5)) * g + ((int)((0.11400) * (1L << 8) + 0.5)) * b + (1 << (8 - 1))) >> 8;
      r = p[3];
      g = p[4];
      b = p[5];
      r1 += r;
      g1 += g;
      b1 += b;
      lum[1] = (((int)((0.29900) * (1L << 8) + 0.5)) * r + ((int)((0.58700) * (1L << 8) + 0.5)) * g + ((int)((0.11400) * (1L << 8) + 0.5)) * b + (1 << (8 - 1))) >> 8;
      cb[0] = 128 + ((-((int)((0.16874) * (1L << 8) + 0.5)) * r1 - ((int)((0.33126) * (1L << 8) + 0.5)) * g1 + ((int)((0.50000) * (1L << 8) + 0.5)) * b1 + 4 * (1 << (8 - 1)) - 1) >> (8 + 2));
      cr[0] = 128 + ((((int)((0.50000) * (1L << 8) + 0.5)) * r1 - ((int)((0.41869) * (1L << 8) + 0.5)) * g1 - ((int)((0.08131) * (1L << 8) + 0.5)) * b1 + 4 * (1 << (8 - 1)) - 1) >> (8 + 2));
      cb++;
      cr++;
      p += -wrap3 + 2 * 3;
      lum += -wrap + 2;
    }
    p += wrap3;
    lum += wrap;
  }
}
```