user: Converte this assembly snippet into its equivalent C code:

```asm
<rgb2hsv>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %rdi,-0x28(%rbp)
  mov    %rsi,-0x30(%rbp)
  mov    -0x28(%rbp),%rax
  movsd  (%rax),%xmm1
  mov    -0x28(%rbp),%rax
  add    $0x8,%rax
  movsd  (%rax),%xmm0
  comisd %xmm1,%xmm0
  jbe    L6
  mov    -0x28(%rbp),%rax
  movsd  (%rax),%xmm0
  jmp    L121
L6:
  mov    -0x28(%rbp),%rax
  movsd  0x8(%rax),%xmm0
L121:
  movsd  %xmm0,-0x18(%rbp)
  mov    -0x28(%rbp),%rax
  add    $0x10,%rax
  movsd  (%rax),%xmm0
  comisd -0x18(%rbp),%xmm0
  jbe    L80
  movsd  -0x18(%rbp),%xmm0
  jmp    L150
L80:
  mov    -0x28(%rbp),%rax
  movsd  0x10(%rax),%xmm0
L150:
  movsd  %xmm0,-0x18(%rbp)
  mov    -0x28(%rbp),%rax
  movsd  (%rax),%xmm0
  mov    -0x28(%rbp),%rax
  add    $0x8,%rax
  movsd  (%rax),%xmm1
  comisd %xmm1,%xmm0
  jbe    L122
  mov    -0x28(%rbp),%rax
  movsd  (%rax),%xmm0
  jmp    L28
L122:
  mov    -0x28(%rbp),%rax
  movsd  0x8(%rax),%xmm0
L28:
  movsd  %xmm0,-0x10(%rbp)
  mov    -0x28(%rbp),%rax
  add    $0x10,%rax
  movsd  (%rax),%xmm1
  movsd  -0x10(%rbp),%xmm0
  comisd %xmm1,%xmm0
  jbe    L107
  movsd  -0x10(%rbp),%xmm0
  jmp    L176
L107:
  mov    -0x28(%rbp),%rax
  movsd  0x10(%rax),%xmm0
L176:
  movsd  %xmm0,-0x10(%rbp)
  mov    -0x30(%rbp),%rax
  add    $0x10,%rax
  movsd  -0x10(%rbp),%xmm0
  movsd  %xmm0,(%rax)
  movsd  -0x10(%rbp),%xmm0
  subsd  -0x18(%rbp),%xmm0
  movsd  %xmm0,-0x8(%rbp)
  movsd  D37(%rip),%xmm0
  comisd -0x8(%rbp),%xmm0
  jbe    L15
  mov    -0x30(%rbp),%rax
  add    $0x8,%rax
  pxor   %xmm0,%xmm0
  movsd  %xmm0,(%rax)
  mov    -0x30(%rbp),%rax
  pxor   %xmm0,%xmm0
  movsd  %xmm0,(%rax)
  jmp    L87
L15:
  movsd  -0x10(%rbp),%xmm0
  pxor   %xmm1,%xmm1
  comisd %xmm1,%xmm0
  jbe    L59
  mov    -0x30(%rbp),%rax
  add    $0x8,%rax
  movsd  -0x8(%rbp),%xmm0
  divsd  -0x10(%rbp),%xmm0
  movsd  %xmm0,(%rax)
  mov    -0x28(%rbp),%rax
  movsd  (%rax),%xmm0
  comisd -0x10(%rbp),%xmm0
  jae    L183
  jmp    L69
L59:
  mov    -0x30(%rbp),%rax
  add    $0x8,%rax
  pxor   %xmm0,%xmm0
  movsd  %xmm0,(%rax)
  mov    -0x30(%rbp),%rax
  movsd  D5(%rip),%xmm0
  movsd  %xmm0,(%rax)
  jmp    L87
L183:
  mov    -0x28(%rbp),%rax
  add    $0x8,%rax
  movsd  (%rax),%xmm0
  mov    -0x28(%rbp),%rax
  add    $0x10,%rax
  movsd  (%rax),%xmm1
  subsd  %xmm1,%xmm0
  divsd  -0x8(%rbp),%xmm0
  mov    -0x30(%rbp),%rax
  movsd  %xmm0,(%rax)
  jmp    L34
L69:
  mov    -0x28(%rbp),%rax
  add    $0x8,%rax
  movsd  (%rax),%xmm0
  comisd -0x10(%rbp),%xmm0
  jb     L33
  mov    -0x28(%rbp),%rax
  add    $0x10,%rax
  movsd  (%rax),%xmm0
  mov    -0x28(%rbp),%rax
  movsd  (%rax),%xmm1
  subsd  %xmm1,%xmm0
  movapd %xmm0,%xmm1
  divsd  -0x8(%rbp),%xmm1
  movsd  D21(%rip),%xmm0
  addsd  %xmm1,%xmm0
  mov    -0x30(%rbp),%rax
  movsd  %xmm0,(%rax)
  jmp    L34
L33:
  mov    -0x28(%rbp),%rax
  movsd  (%rax),%xmm0
  mov    -0x28(%rbp),%rax
  add    $0x8,%rax
  movsd  (%rax),%xmm1
  subsd  %xmm1,%xmm0
  movapd %xmm0,%xmm1
  divsd  -0x8(%rbp),%xmm1
  movsd  D43(%rip),%xmm0
  addsd  %xmm1,%xmm0
  mov    -0x30(%rbp),%rax
  movsd  %xmm0,(%rax)
L34:
  mov    -0x30(%rbp),%rax
  movsd  (%rax),%xmm1
  movsd  D22(%rip),%xmm0
  mulsd  %xmm1,%xmm0
  mov    -0x30(%rbp),%rax
  movsd  %xmm0,(%rax)
  mov    -0x30(%rbp),%rax
  movsd  (%rax),%xmm1
  pxor   %xmm0,%xmm0
  comisd %xmm1,%xmm0
  ja     L24
  jmp    L169
L24:
  mov    -0x30(%rbp),%rax
  movsd  (%rax),%xmm1
  movsd  D58(%rip),%xmm0
  addsd  %xmm1,%xmm0
  mov    -0x30(%rbp),%rax
  movsd  %xmm0,(%rax)
L169:
  nop
L87:
  pop    %rbp
  ret
```

tool_calls: name: read_data
arguments: label: D37
type_infered: f64
name: read_data
arguments: label: D5
type_infered: f32[2]
name: read_data
arguments: label: D21
type_infered: f64
name: read_data
arguments: label: D43
type_infered: f64
name: read_data
arguments: label: D22
type_infered: f64
name: read_data
arguments: label: D58
type_infered: f64

tool: D37: 1e-05

tool: {"D5": [0.0,1.875]}

tool: D21: 2

tool: D43: 4

tool: D22: 60

tool: D58: 360

assistant: ```c
void rgb2hsv(double *rgb_in, double *hsv_out) {
  double min, max, delta;
  min = rgb_in[0] < rgb_in[1] ? rgb_in[0] : rgb_in[1];
  min = min < rgb_in[2] ? min : rgb_in[2];
  max = rgb_in[0] > rgb_in[1] ? rgb_in[0] : rgb_in[1];
  max = max > rgb_in[2] ? max : rgb_in[2];
  hsv_out[2] = max;
  delta = max - min;
  if (delta < 0.00001) {
    hsv_out[1] = 0;
    hsv_out[0] = 0;
    return;
  }
  if (max > 0.0) {
    hsv_out[1] = (delta / max);
  } else {
    hsv_out[1] = 0.0;
    hsv_out[0] = 1;
    return;
  }
  if (rgb_in[0] >= max)
    hsv_out[0] = (rgb_in[1] - rgb_in[2]) / delta;
  else if (rgb_in[1] >= max)
    hsv_out[0] = 2.0 + (rgb_in[2] - rgb_in[0]) / delta;
  else
    hsv_out[0] = 4.0 + (rgb_in[0] - rgb_in[1]) / delta;
  hsv_out[0] *= 60.0;
  if (hsv_out[0] < 0.0)
    hsv_out[0] += 360.0;
  return;
}
```