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

```asm
<ImageKit_Colorspace_RGB2HSV>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x60,%rsp
  movsd  %xmm0,-0x38(%rbp)
  movsd  %xmm1,-0x40(%rbp)
  movsd  %xmm2,-0x48(%rbp)
  mov    %rdi,-0x50(%rbp)
  mov    %rsi,-0x58(%rbp)
  mov    %rdx,-0x60(%rbp)
  movsd  -0x38(%rbp),%xmm0
  movsd  %xmm0,-0x28(%rbp)
  movsd  -0x40(%rbp),%xmm0
  comisd -0x28(%rbp),%xmm0
  jbe    L1
  movsd  -0x40(%rbp),%xmm0
  movsd  %xmm0,-0x28(%rbp)
L1:
  movsd  -0x48(%rbp),%xmm0
  comisd -0x28(%rbp),%xmm0
  jbe    L7
  movsd  -0x48(%rbp),%xmm0
  movsd  %xmm0,-0x28(%rbp)
L7:
  movsd  -0x38(%rbp),%xmm0
  movsd  %xmm0,-0x20(%rbp)
  movsd  -0x20(%rbp),%xmm0
  comisd -0x40(%rbp),%xmm0
  jbe    L25
  movsd  -0x40(%rbp),%xmm0
  movsd  %xmm0,-0x20(%rbp)
L25:
  movsd  -0x20(%rbp),%xmm0
  comisd -0x48(%rbp),%xmm0
  jbe    L124
  movsd  -0x48(%rbp),%xmm0
  movsd  %xmm0,-0x20(%rbp)
L124:
  movsd  -0x28(%rbp),%xmm0
  subsd  -0x20(%rbp),%xmm0
  movsd  %xmm0,-0x18(%rbp)
  movsd  -0x28(%rbp),%xmm0
  movsd  %xmm0,-0x10(%rbp)
  movsd  -0x28(%rbp),%xmm0
  pxor   %xmm1,%xmm1
  comisd %xmm1,%xmm0
  jbe    L141
  movsd  -0x18(%rbp),%xmm0
  divsd  -0x28(%rbp),%xmm0
  jmp    L42
L141:
  pxor   %xmm0,%xmm0
L42:
  movsd  %xmm0,-0x8(%rbp)
  pxor   %xmm0,%xmm0
  ucomisd -0x18(%rbp),%xmm0
  jp     L37
  pxor   %xmm0,%xmm0
  ucomisd -0x18(%rbp),%xmm0
  jne    L37
  pxor   %xmm0,%xmm0
  movsd  %xmm0,-0x30(%rbp)
  jmp    L23
L37:
  movsd  -0x28(%rbp),%xmm0
  ucomisd -0x38(%rbp),%xmm0
  jp     L146
  movsd  -0x28(%rbp),%xmm0
  ucomisd -0x38(%rbp),%xmm0
  jne    L146
  movsd  -0x40(%rbp),%xmm0
  subsd  -0x48(%rbp),%xmm0
  divsd  -0x18(%rbp),%xmm0
  movq   %xmm0,%rax
  movsd  D2(%rip),%xmm0
  movapd %xmm0,%xmm1
  movq   %rax,%xmm0
  call   <fmod@plt>
  movq   %xmm0,%rax
  mov    %rax,-0x30(%rbp)
  jmp    L23
L146:
  movsd  -0x28(%rbp),%xmm0
  ucomisd -0x40(%rbp),%xmm0
  jp     L69
  movsd  -0x28(%rbp),%xmm0
  ucomisd -0x40(%rbp),%xmm0
  jne    L69
  movsd  -0x48(%rbp),%xmm0
  subsd  -0x38(%rbp),%xmm0
  movapd %xmm0,%xmm1
  divsd  -0x18(%rbp),%xmm1
  movsd  D24(%rip),%xmm0
  addsd  %xmm1,%xmm0
  movsd  %xmm0,-0x30(%rbp)
  jmp    L23
L69:
  movsd  -0x38(%rbp),%xmm0
  subsd  -0x40(%rbp),%xmm0
  movapd %xmm0,%xmm1
  divsd  -0x18(%rbp),%xmm1
  movsd  D11(%rip),%xmm0
  addsd  %xmm1,%xmm0
  movsd  %xmm0,-0x30(%rbp)
L23:
  movsd  -0x30(%rbp),%xmm0
  movsd  D2(%rip),%xmm1
  divsd  %xmm1,%xmm0
  mov    -0x50(%rbp),%rax
  movsd  %xmm0,(%rax)
  mov    -0x58(%rbp),%rax
  movsd  -0x8(%rbp),%xmm0
  movsd  %xmm0,(%rax)
  mov    -0x60(%rbp),%rax
  movsd  -0x10(%rbp),%xmm0
  movsd  %xmm0,(%rax)
  mov    $0x0,%eax
  leave
  ret
```

tool_calls: name: read_data
arguments: label: D2
datatype: f64
name: read_data
arguments: label: D24
datatype: f64
name: read_data
arguments: label: D11
datatype: f64

tool: D2: 6

tool: D24: 2

tool: D11: 4

assistant: ```c
int ImageKit_Colorspace_RGB2HSV(double r, double g, double b, double *oh, double *os, double *ov) {
  double hue;
  double saturation;
  double value;
  double M;
  double m;
  double C;
  M = r;
  if (M < g)
    M = g;
  if (M < b)
    M = b;
  m = r;
  if (m > g)
    m = g;
  if (m > b)
    m = b;
  C = M - m;
  value = M;
  saturation = ((M > 0) ? C / M : 0.0);
  if (C == 0) {
    hue = 0.0;
  } else if (M == r) {
    hue = fmod((g - b) / C, 6.0);
  } else if (M == g) {
    hue = (b - r) / C + 2.0;
  } else {
    hue = (r - g) / C + 4.0;
  }
  *oh = hue / 6.0;
  *os = saturation;
  *ov = value;
  return 0;
}
```