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

```asm
<rgb2yuv>:
  endbr64
  test   %esi,%esi
  jle    L31
  push   %r12
  xor    %r12d,%r12d
  push   %rbp
  mov    %rdi,%rbp
  push   %rbx
  mov    %esi,%ebx
  sub    $0x10,%rsp
  movsd  D95(%rip),%xmm4
  movsd  D42(%rip),%xmm3
  jmp    L32
  nopl   0x0(%rax)
L60:
  pxor   %xmm5,%xmm5
  comisd %xmm3,%xmm2
  maxsd  %xmm0,%xmm5
  movapd %xmm5,%xmm0
  ja     L44
L38:
  pxor   %xmm6,%xmm6
  comisd %xmm3,%xmm1
  maxsd  %xmm2,%xmm6
  movapd %xmm6,%xmm2
  ja     L42
L30:
  pxor   %xmm5,%xmm5
  maxsd  %xmm1,%xmm5
  movapd %xmm5,%xmm1
L11:
  movsd  %xmm1,0x8(%rsp)
  add    $0x3,%r12d
  add    $0x3,%rbp
  movsd  %xmm2,(%rsp)
  call   <round@plt>
  movsd  (%rsp),%xmm2
  mov    %al,-0x3(%rbp)
  movapd %xmm2,%xmm0
  call   <round@plt>
  movsd  0x8(%rsp),%xmm1
  mov    %al,-0x2(%rbp)
  movapd %xmm1,%xmm0
  call   <round@plt>
  mov    %al,-0x1(%rbp)
  mov    D42(%rip),%rax
  cmp    %r12d,%ebx
  movq   %rax,%xmm3
  mov    D95(%rip),%rax
  movq   %rax,%xmm4
  jle    L57
L32:
  movzbl 0x0(%rbp),%ecx
  movzbl 0x1(%rbp),%edx
  pxor   %xmm1,%xmm1
  pxor   %xmm6,%xmm6
  movsd  D85(%rip),%xmm0
  movsd  D143(%rip),%xmm2
  pxor   %xmm5,%xmm5
  shl    $0x10,%ecx
  shl    $0x10,%edx
  movzbl 0x2(%rbp),%eax
  movsd  D127(%rip),%xmm7
  sub    $0x8000,%ecx
  sub    $0x8000,%edx
  cvtsi2sd %ecx,%xmm1
  shl    $0x10,%eax
  cvtsi2sd %edx,%xmm6
  sub    $0x8000,%eax
  cvtsi2sd %eax,%xmm5
  mulsd  %xmm1,%xmm0
  mulsd  %xmm6,%xmm2
  mulsd  %xmm6,%xmm7
  mulsd  D130(%rip),%xmm6
  addsd  %xmm2,%xmm0
  movsd  D28(%rip),%xmm2
  mulsd  %xmm5,%xmm2
  addsd  %xmm2,%xmm0
  movsd  D0(%rip),%xmm2
  mulsd  %xmm1,%xmm2
  mulsd  D36(%rip),%xmm1
  divsd  %xmm4,%xmm0
  subsd  %xmm7,%xmm2
  movsd  D36(%rip),%xmm7
  subsd  %xmm6,%xmm1
  mulsd  %xmm5,%xmm7
  mulsd  D109(%rip),%xmm5
  addsd  %xmm7,%xmm2
  subsd  %xmm5,%xmm1
  divsd  %xmm4,%xmm2
  addsd  D149(%rip),%xmm0
  comisd %xmm3,%xmm0
  divsd  %xmm4,%xmm1
  addsd  D140(%rip),%xmm2
  addsd  D140(%rip),%xmm1
  jbe    L60
  comisd %xmm3,%xmm2
  movapd %xmm3,%xmm0
  jbe    L38
L44:
  comisd %xmm3,%xmm1
  movapd %xmm3,%xmm2
  jbe    L30
L42:
  movapd %xmm3,%xmm1
  jmp    L11
  nopl   0x0(%rax,%rax,1)
L57:
  add    $0x10,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
  nopl   0x0(%rax)
L31:
  ret
```

tool_calls: name: disassemble_data
arguments: data_label: D95
type: byte[8]
name: disassemble_data
arguments: data_label: D42
type: byte[8]
name: disassemble_data
arguments: data_label: D85
type: f64
name: disassemble_data
arguments: data_label: D143
type: f64
name: disassemble_data
arguments: data_label: D127
type: f64
name: disassemble_data
arguments: data_label: D130
type: f64
name: disassemble_data
arguments: data_label: D28
type: f64
name: disassemble_data
arguments: data_label: D0
type: byte[8]
name: disassemble_data
arguments: data_label: D36
type: f64
name: disassemble_data
arguments: data_label: D109
type: f64
name: disassemble_data
arguments: data_label: D149
type: byte[8]
name: disassemble_data
arguments: data_label: D140
type: byte[8]

tool: {"D95": [0x00,0x00,0x00,0x00,0x50,0xa1,0xf2,0x40]}

tool: {"D42": [0x00,0x00,0x00,0x00,0x00,0xe0,0x6f,0x40]}

tool: D85: 0.2124997

tool: D143: 0.7153988

tool: D127: 0.3942953

tool: D130: 0.4645915

tool: D28: 0.0721015

tool: {"D0": [0x5f,0x73,0xb3,0xe4,0x96,0xfb,0xbd,0xbf]}

tool: D36: 0.5114155

tool: D109: 0.0468239

tool: {"D149": [0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x40]}

tool: {"D140": [0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x40]}

assistant: ```c
void rgb2yuv(unsigned char *img, int size) {
  int r, g, b, i;
  double y, u, v;
  for (i = 0; i < size; i += 3) {
    r = (int)img[i];
    g = (int)img[i + 1];
    b = (int)img[i + 2];
    r = (r << 16) - 32768;
    g = (g << 16) - 32768;
    b = (b << 16) - 32768;
    y = (0.2124997 * r + 0.7153988 * g + 0.0721015 * b) / 76309 + 16;
    u = (-0.1171202 * r - 0.3942953 * g + 0.5114155 * b) / 76309 + 128;
    v = (0.5114155 * r - 0.4645915 * g - 0.0468239 * b) / 76309 + 128;
    if (y > 255)
      y = 255;
    if (y < 0)
      y = 0;
    if (u > 255)
      u = 255;
    if (u < 0)
      u = 0;
    if (v > 255)
      v = 255;
    if (v < 0)
      v = 0;
    img[i] = (unsigned char)round(y);
    img[i + 1] = (unsigned char)round(u);
    img[i + 2] = (unsigned char)round(v);
  }
}
```