user: 请从给定的汇编指令推导出C源代码：

```asm
<hsv_to_rgb>:
  endbr64
  movapd %xmm0,%xmm3
  pxor   %xmm0,%xmm0
  comisd %xmm3,%xmm0
  ja     L66
  comisd %xmm1,%xmm0
  movsd  D40(%rip),%xmm2
  ja     L117
  comisd %xmm2,%xmm3
  jbe    L38
  movapd %xmm2,%xmm3
L16:
  comisd %xmm2,%xmm1
  movsd  D10(%rip),%xmm6
  jbe    L123
  mulsd  %xmm6,%xmm0
  mov    $0xffffffff,%r8d
  movapd %xmm2,%xmm1
  cvttsd2si %xmm0,%r9d
L82:
  movslq %edi,%rax
  pxor   %xmm0,%xmm0
  pxor   %xmm4,%xmm4
  mov    %edi,%r10d
  imul   $0xffffffffb60b60b7,%rax,%rax
  sar    $0x1f,%r10d
  movapd %xmm2,%xmm5
  shr    $0x20,%rax
  add    %edi,%eax
  sar    $0x8,%eax
  sub    %r10d,%eax
  imul   $0x168,%eax,%eax
  sub    %eax,%edi
  cvtsi2sd %edi,%xmm0
  divsd  D49(%rip),%xmm0
  cvttsd2si %xmm0,%eax
  cvtsi2sd %eax,%xmm4
  subsd  %xmm4,%xmm0
  movapd %xmm2,%xmm4
  subsd  %xmm0,%xmm5
  mulsd  %xmm3,%xmm5
  subsd  %xmm5,%xmm4
  mulsd  %xmm1,%xmm4
  test   %eax,%eax
  jne    L151
  mulsd  %xmm6,%xmm4
  mov    %r8w,(%rsi)
  cvttsd2si %xmm4,%eax
  mov    %ax,(%rdx)
  mov    %r9w,(%rcx)
  ret
L117:
  comisd %xmm2,%xmm3
  jbe    L0
  xor    %r9d,%r9d
  movapd %xmm2,%xmm3
  movapd %xmm0,%xmm1
  xor    %r8d,%r8d
  movsd  D10(%rip),%xmm6
  jmp    L82
  nopl   (%rax)
L151:
  mulsd  %xmm3,%xmm0
  subsd  %xmm0,%xmm2
  mulsd  %xmm1,%xmm2
  cmp    $0x3,%eax
  je     L60
  jg     L1
  cmp    $0x1,%eax
  je     L43
  cmp    $0x2,%eax
  jne    L97
  mulsd  %xmm6,%xmm4
  mov    %r8d,%eax
  mov    %r9d,%r8d
  mov    %r8w,(%rsi)
  mov    %ax,(%rdx)
  cvttsd2si %xmm4,%r9d
  mov    %r9w,(%rcx)
  ret
  nopl   0x0(%rax)
L1:
  cmp    $0x4,%eax
  jne    L97
  mulsd  %xmm6,%xmm4
  mov    %r9d,%eax
  mov    %r8d,%r9d
  cvttsd2si %xmm4,%r8d
  mov    %r8w,(%rsi)
  mov    %ax,(%rdx)
  mov    %r9w,(%rcx)
  ret
L66:
  comisd %xmm1,%xmm0
  ja     L120
  movsd  D40(%rip),%xmm2
  movapd %xmm0,%xmm3
L38:
  movapd %xmm2,%xmm0
  subsd  %xmm3,%xmm0
  jmp    L16
  nop
L120:
  xor    %r9d,%r9d
  movapd %xmm0,%xmm3
  movapd %xmm0,%xmm1
  xor    %r8d,%r8d
  movsd  D40(%rip),%xmm2
  movsd  D10(%rip),%xmm6
  jmp    L82
  nopl   0x0(%rax,%rax,1)
L97:
  mulsd  %xmm6,%xmm2
  mov    %r9d,%eax
  mov    %r8w,(%rsi)
  mov    %ax,(%rdx)
  cvttsd2si %xmm2,%r9d
  mov    %r9w,(%rcx)
  ret
L43:
  mulsd  %xmm6,%xmm2
  mov    %r8d,%eax
  cvttsd2si %xmm2,%r8d
  mov    %r8w,(%rsi)
  mov    %ax,(%rdx)
  mov    %r9w,(%rcx)
  ret
  nopl   0x0(%rax,%rax,1)
L60:
  mulsd  %xmm6,%xmm2
  mov    %r8d,%edi
  mov    %r9d,%r8d
  mov    %edi,%r9d
  mov    %r8w,(%rsi)
  cvttsd2si %xmm2,%eax
  mov    %ax,(%rdx)
  mov    %r9w,(%rcx)
  ret
L0:
  movapd %xmm2,%xmm1
  movsd  D10(%rip),%xmm6
  xor    %r8d,%r8d
  subsd  %xmm3,%xmm1
  mulsd  %xmm0,%xmm1
  mulsd  %xmm6,%xmm1
  cvttsd2si %xmm1,%r9d
  movapd %xmm0,%xmm1
  jmp    L82
L123:
  mulsd  %xmm1,%xmm0
  movapd %xmm1,%xmm4
  mulsd  %xmm6,%xmm4
  mulsd  %xmm6,%xmm0
  cvttsd2si %xmm4,%r8d
  cvttsd2si %xmm0,%r9d
  jmp    L82
```

tool_calls: name: parse_data
arguments: data_tag: D40
type_infered: byte[8]
name: parse_data
arguments: data_tag: D10
type_infered: byte[8]
name: parse_data
arguments: data_tag: D49
type_infered: f64

tool: {"D40": [0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0x3f]}

tool: {"D10": [0x00,0x00,0x00,0x00,0xe0,0xff,0xef,0x40]}

tool: D49: 60

assistant: ```c
void hsv_to_rgb(int h, double s, double v, unsigned short *r, unsigned short *g, unsigned short *b) {
  double H, S, V, R, G, B;
  double p1, p2, p3;
  double f;
  int i;
  if (s < 0)
    s = 0;
  if (v < 0)
    v = 0;
  if (s > 1)
    s = 1;
  if (v > 1)
    v = 1;
  S = s;
  V = v;
  H = (h % 360) / 60.0;
  i = H;
  f = H - i;
  p1 = V * (1 - S);
  p2 = V * (1 - (S * f));
  p3 = V * (1 - (S * (1 - f)));
  if (i == 0) {
    R = V;
    G = p3;
    B = p1;
  } else if (i == 1) {
    R = p2;
    G = V;
    B = p1;
  } else if (i == 2) {
    R = p1;
    G = V;
    B = p3;
  } else if (i == 3) {
    R = p1;
    G = p2;
    B = V;
  } else if (i == 4) {
    R = p3;
    G = p1;
    B = V;
  } else {
    R = V;
    G = p1;
    B = p2;
  }
  *r = R * 65535;
  *g = G * 65535;
  *b = B * 65535;
}
```