user: 请将这段汇编代码片段转换成等效的C代码：

```asm
<rgb24_to_yuv420p>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %rdi,-0x38(%rbp)
  mov    %rsi,-0x40(%rbp)
  mov    %rdx,-0x48(%rbp)
  mov    %rcx,-0x50(%rbp)
  mov    %r8d,-0x54(%rbp)
  mov    %r9d,-0x58(%rbp)
  mov    -0x54(%rbp),%eax
  mov    %eax,-0x28(%rbp)
  mov    -0x54(%rbp),%edx
  mov    %edx,%eax
  add    %eax,%eax
  add    %edx,%eax
  mov    %eax,-0x24(%rbp)
  mov    -0x50(%rbp),%rax
  mov    %rax,-0x8(%rbp)
  movl   $0x0,-0x2c(%rbp)
  jmp    L4
L24:
  movl   $0x0,-0x30(%rbp)
  jmp    L9
L39:
  mov    -0x8(%rbp),%rax
  mov    (%rax),%eax
  mov    %eax,-0x20(%rbp)
  mov    -0x8(%rbp),%rax
  mov    0x4(%rax),%eax
  mov    %eax,-0x1c(%rbp)
  mov    -0x8(%rbp),%rax
  mov    0x8(%rax),%eax
  mov    %eax,-0x18(%rbp)
  mov    -0x20(%rbp),%eax
  mov    %eax,-0x14(%rbp)
  mov    -0x1c(%rbp),%eax
  mov    %eax,-0x10(%rbp)
  mov    -0x18(%rbp),%eax
  mov    %eax,-0xc(%rbp)
  mov    -0x20(%rbp),%eax
  imul   $0x4d,%eax,%edx
  mov    -0x1c(%rbp),%eax
  imul   $0x96,%eax,%eax
  add    %eax,%edx
  mov    -0x18(%rbp),%eax
  imul   $0x1d,%eax,%eax
  add    %edx,%eax
  sub    $0xffffff80,%eax
  sar    $0x8,%eax
  mov    %eax,%edx
  mov    -0x38(%rbp),%rax
  mov    %edx,(%rax)
  mov    -0x8(%rbp),%rax
  mov    0xc(%rax),%eax
  mov    %eax,-0x20(%rbp)
  mov    -0x8(%rbp),%rax
  mov    0x10(%rax),%eax
  mov    %eax,-0x1c(%rbp)
  mov    -0x8(%rbp),%rax
  mov    0x14(%rax),%eax
  mov    %eax,-0x18(%rbp)
  mov    -0x20(%rbp),%eax
  add    %eax,-0x14(%rbp)
  mov    -0x1c(%rbp),%eax
  add    %eax,-0x10(%rbp)
  mov    -0x18(%rbp),%eax
  add    %eax,-0xc(%rbp)
  mov    -0x20(%rbp),%eax
  imul   $0x4d,%eax,%edx
  mov    -0x1c(%rbp),%eax
  imul   $0x96,%eax,%eax
  add    %eax,%edx
  mov    -0x18(%rbp),%eax
  imul   $0x1d,%eax,%eax
  add    %edx,%eax
  lea    0x80(%rax),%edx
  mov    -0x38(%rbp),%rax
  add    $0x4,%rax
  sar    $0x8,%edx
  mov    %edx,(%rax)
  mov    -0x24(%rbp),%eax
  cltq
  shl    $0x2,%rax
  add    %rax,-0x8(%rbp)
  mov    -0x28(%rbp),%eax
  cltq
  shl    $0x2,%rax
  add    %rax,-0x38(%rbp)
  mov    -0x8(%rbp),%rax
  mov    (%rax),%eax
  mov    %eax,-0x20(%rbp)
  mov    -0x8(%rbp),%rax
  mov    0x4(%rax),%eax
  mov    %eax,-0x1c(%rbp)
  mov    -0x8(%rbp),%rax
  mov    0x8(%rax),%eax
  mov    %eax,-0x18(%rbp)
  mov    -0x20(%rbp),%eax
  add    %eax,-0x14(%rbp)
  mov    -0x1c(%rbp),%eax
  add    %eax,-0x10(%rbp)
  mov    -0x18(%rbp),%eax
  add    %eax,-0xc(%rbp)
  mov    -0x20(%rbp),%eax
  imul   $0x4d,%eax,%edx
  mov    -0x1c(%rbp),%eax
  imul   $0x96,%eax,%eax
  add    %eax,%edx
  mov    -0x18(%rbp),%eax
  imul   $0x1d,%eax,%eax
  add    %edx,%eax
  sub    $0xffffff80,%eax
  sar    $0x8,%eax
  mov    %eax,%edx
  mov    -0x38(%rbp),%rax
  mov    %edx,(%rax)
  mov    -0x8(%rbp),%rax
  mov    0xc(%rax),%eax
  mov    %eax,-0x20(%rbp)
  mov    -0x8(%rbp),%rax
  mov    0x10(%rax),%eax
  mov    %eax,-0x1c(%rbp)
  mov    -0x8(%rbp),%rax
  mov    0x14(%rax),%eax
  mov    %eax,-0x18(%rbp)
  mov    -0x20(%rbp),%eax
  add    %eax,-0x14(%rbp)
  mov    -0x1c(%rbp),%eax
  add    %eax,-0x10(%rbp)
  mov    -0x18(%rbp),%eax
  add    %eax,-0xc(%rbp)
  mov    -0x20(%rbp),%eax
  imul   $0x4d,%eax,%edx
  mov    -0x1c(%rbp),%eax
  imul   $0x96,%eax,%eax
  add    %eax,%edx
  mov    -0x18(%rbp),%eax
  imul   $0x1d,%eax,%eax
  add    %edx,%eax
  lea    0x80(%rax),%edx
  mov    -0x38(%rbp),%rax
  add    $0x4,%rax
  sar    $0x8,%edx
  mov    %edx,(%rax)
  mov    -0x14(%rbp),%eax
  imul   $0xffffffd5,%eax,%edx
  mov    -0x10(%rbp),%eax
  imul   $0xffffffab,%eax,%eax
  add    %eax,%edx
  mov    -0xc(%rbp),%eax
  shl    $0x7,%eax
  add    %edx,%eax
  add    $0x1ff,%eax
  sar    $0xa,%eax
  lea    0x80(%rax),%edx
  mov    -0x40(%rbp),%rax
  mov    %edx,(%rax)
  mov    -0x14(%rbp),%eax
  shl    $0x7,%eax
  mov    %eax,%edx
  mov    -0x10(%rbp),%eax
  imul   $0xffffff95,%eax,%eax
  add    %eax,%edx
  mov    -0xc(%rbp),%eax
  imul   $0xffffffeb,%eax,%eax
  add    %edx,%eax
  add    $0x1ff,%eax
  sar    $0xa,%eax
  lea    0x80(%rax),%edx
  mov    -0x48(%rbp),%rax
  mov    %edx,(%rax)
  addq   $0x4,-0x40(%rbp)
  addq   $0x4,-0x48(%rbp)
  mov    -0x24(%rbp),%eax
  neg    %eax
  cltq
  add    $0x6,%rax
  shl    $0x2,%rax
  add    %rax,-0x8(%rbp)
  mov    -0x28(%rbp),%eax
  neg    %eax
  cltq
  add    $0x2,%rax
  shl    $0x2,%rax
  add    %rax,-0x38(%rbp)
  addl   $0x2,-0x30(%rbp)
L9:
  mov    -0x30(%rbp),%eax
  cmp    -0x54(%rbp),%eax
  jl     L39
  mov    -0x24(%rbp),%eax
  cltq
  shl    $0x2,%rax
  add    %rax,-0x8(%rbp)
  mov    -0x28(%rbp),%eax
  cltq
  shl    $0x2,%rax
  add    %rax,-0x38(%rbp)
  addl   $0x2,-0x2c(%rbp)
L4:
  mov    -0x2c(%rbp),%eax
  cmp    -0x58(%rbp),%eax
  jl     L24
  nop
  nop
  pop    %rbp
  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;
  }
}
```