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

```asm
<HC_to_polar>:
  endbr64
  push   %r15
  pxor   %xmm2,%xmm2
  mov    %rcx,%r15
  push   %r14
  mov    %rdi,%r14
  push   %r13
  push   %r12
  push   %rbp
  mov    %rsi,%rbp
  push   %rbx
  sub    $0x28,%rsp
  movq   $0x0,(%r8)
  movsd  (%rsi),%xmm0
  mulsd  %xmm0,%xmm0
  ucomisd %xmm0,%xmm2
  ja     L137
  sqrtsd %xmm0,%xmm0
L106:
  lea    0x1(%r14),%rax
  movsd  %xmm0,(%r15)
  mov    %rax,%r12
  shr    $0x3f,%r12
  add    %rax,%r12
  sar    %r12
  cmp    $0x2,%r14
  jle    L68
  lea    -0x8(%rbp,%r14,8),%r13
  mov    $0x1,%ebx
  test   %edx,%edx
  je     L140
  xchg   %ax,%ax
L174:
  movsd  0x0(%rbp,%rbx,8),%xmm1
  movsd  0x0(%r13),%xmm3
  movapd %xmm1,%xmm4
  movapd %xmm3,%xmm0
  mulsd  %xmm3,%xmm0
  mulsd  %xmm1,%xmm4
  addsd  %xmm4,%xmm0
  ucomisd %xmm0,%xmm2
  ja     L0
  sqrtsd %xmm0,%xmm0
L17:
  comisd %xmm2,%xmm0
  movsd  %xmm0,(%r15,%rbx,8)
  jbe    L143
  xorpd  D7(%rip),%xmm3
  mov    %r8,0x8(%rsp)
  sub    $0x8,%r13
  movapd %xmm3,%xmm0
  call   <atan2@plt>
  mov    0x8(%rsp),%r8
  pxor   %xmm2,%xmm2
  movsd  %xmm0,(%r8,%rbx,8)
  add    $0x1,%rbx
  cmp    %rbx,%r12
  jg     L174
L68:
  test   $0x1,%r14b
  je     L121
L173:
  add    $0x28,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax)
L125:
  movq   $0x0,(%r8,%rbx,8)
  add    $0x1,%rbx
  sub    $0x8,%r13
  cmp    %rbx,%r12
  jle    L68
L140:
  movsd  0x0(%rbp,%rbx,8),%xmm1
  movsd  0x0(%r13),%xmm3
  movapd %xmm1,%xmm0
  movapd %xmm3,%xmm4
  mulsd  %xmm1,%xmm0
  mulsd  %xmm3,%xmm4
  addsd  %xmm4,%xmm0
  ucomisd %xmm0,%xmm2
  ja     L155
  sqrtsd %xmm0,%xmm0
L145:
  comisd %xmm2,%xmm0
  movsd  %xmm0,(%r15,%rbx,8)
  jbe    L125
  movapd %xmm3,%xmm0
  mov    %r8,0x8(%rsp)
  sub    $0x8,%r13
  call   <atan2@plt>
  mov    0x8(%rsp),%r8
  pxor   %xmm2,%xmm2
  movsd  %xmm0,(%r8,%rbx,8)
  add    $0x1,%rbx
  cmp    %r12,%rbx
  jl     L140
  test   $0x1,%r14b
  jne    L173
  nopl   0x0(%rax,%rax,1)
L121:
  mov    %r14,%rax
  shr    $0x3f,%rax
  add    %r14,%rax
  sar    %rax
  movq   $0x0,(%r8,%rax,8)
  movsd  0x0(%rbp,%rax,8),%xmm0
  lea    (%r15,%rax,8),%rbx
  mulsd  %xmm0,%xmm0
  ucomisd %xmm0,%xmm2
  ja     L161
  sqrtsd %xmm0,%xmm0
L79:
  movsd  %xmm0,(%rbx)
  add    $0x28,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax)
L143:
  movq   $0x0,(%r8,%rbx,8)
  add    $0x1,%rbx
  sub    $0x8,%r13
  cmp    %rbx,%r12
  jg     L174
  jmp    L68
L155:
  mov    %r8,0x18(%rsp)
  movsd  %xmm3,0x10(%rsp)
  movsd  %xmm1,0x8(%rsp)
  call   <sqrt@plt>
  mov    0x18(%rsp),%r8
  movsd  0x10(%rsp),%xmm3
  pxor   %xmm2,%xmm2
  movsd  0x8(%rsp),%xmm1
  jmp    L145
L0:
  mov    %r8,0x18(%rsp)
  movsd  %xmm1,0x10(%rsp)
  movsd  %xmm3,0x8(%rsp)
  call   <sqrt@plt>
  movsd  0x8(%rsp),%xmm3
  movsd  0x10(%rsp),%xmm1
  pxor   %xmm2,%xmm2
  mov    0x18(%rsp),%r8
  jmp    L17
L137:
  mov    %r8,0x10(%rsp)
  mov    %edx,0x8(%rsp)
  call   <sqrt@plt>
  mov    0x10(%rsp),%r8
  mov    0x8(%rsp),%edx
  pxor   %xmm2,%xmm2
  jmp    L106
L161:
  call   <sqrt@plt>
  jmp    L79
```

tool_calls: name: retrieve_data
arguments: data_tag: D7
type: f32[4]

tool: {"D7": [0.0,-0.0,0.0,0.0]}

assistant: ```c
void HC_to_polar(long len, const double *freq, int conj, double *amp, double *phs) {
  int i;
  double rl, im;
  phs[0] = 0.0;
  amp[0] = sqrt(freq[0] * freq[0]);
  for (i = 1; i < (len + 1) / 2; i++) {
    rl = freq[i];
    im = freq[len - i];
    amp[i] = sqrt(rl * rl + im * im);
    if (amp[i] > 0.0) {
      if (conj == 0)
        phs[i] = atan2(+im, rl);
      else
        phs[i] = atan2(-im, rl);
    } else {
      phs[i] = 0.0;
    }
  }
  if (len % 2 == 0) {
    phs[len / 2] = 0.0;
    amp[len / 2] = sqrt(freq[len / 2] * freq[len / 2]);
  }
}
```