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

```asm
<four1>:
  endbr64
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x20,%rsp
  mov    %rdi,%r13
  mov    %edx,%r8d
  lea    (%rsi,%rsi,1),%rbx
  mov    $0x1,%ecx
  mov    $0x1,%edx
  cmp    $0x1,%rbx
  ja     L167
L109:
  cmp    $0x2,%rbx
  jbe    L53
  mov    $0x2,%ebp
  pxor   %xmm5,%xmm5
  cvtsi2sd %r8d,%xmm5
  movsd  %xmm5,0x18(%rsp)
  mov    D17(%rip),%r14
  jmp    L39
L150:
  mov    %rsi,%rax
L130:
  add    %rax,%rdx
  add    $0x2,%rcx
  cmp    %rcx,%rbx
  jbe    L109
  cmp    %rcx,%rdx
  jbe    L167
  lea    0x0(,%rdx,8),%rax
  lea    0x0(%r13,%rax,1),%rdi
  movsd  (%rdi),%xmm0
  movsd  0x0(%r13,%rcx,8),%xmm1
  movsd  %xmm1,(%rdi)
  movsd  %xmm0,0x0(%r13,%rcx,8)
  lea    0x8(%r13,%rax,1),%rax
  movsd  (%rax),%xmm0
  movsd  0x8(%r13,%rcx,8),%xmm1
  movsd  %xmm1,(%rax)
  movsd  %xmm0,0x8(%r13,%rcx,8)
L167:
  cmp    $0x1,%rsi
  jbe    L150
  cmp    %rdx,%rsi
  jae    L150
  mov    %rsi,%rax
L17:
  sub    %rax,%rdx
  shr    %rax
  cmp    $0x1,%rax
  jbe    L130
  cmp    %rax,%rdx
  ja     L17
  jmp    L130
L74:
  mov    %r12,%rax
  shr    %rax
  pxor   %xmm0,%xmm0
  cvtsi2sd %rax,%xmm0
  addsd  %xmm0,%xmm0
  jmp    L173
L171:
  movsd  (%rdx),%xmm2
  movsd  0x8(%rdx),%xmm0
  movapd %xmm2,%xmm1
  mulsd  %xmm3,%xmm1
  movapd %xmm0,%xmm6
  mulsd  %xmm4,%xmm6
  subsd  %xmm6,%xmm1
  mulsd  %xmm3,%xmm0
  mulsd  %xmm4,%xmm2
  addsd  %xmm2,%xmm0
  movsd  -0x8(%rax),%xmm2
  subsd  %xmm1,%xmm2
  movsd  %xmm2,(%rdx)
  movsd  (%rax),%xmm2
  subsd  %xmm0,%xmm2
  movsd  %xmm2,0x8(%rdx)
  addsd  -0x8(%rax),%xmm1
  movsd  %xmm1,-0x8(%rax)
  addsd  (%rax),%xmm0
  movsd  %xmm0,(%rax)
  add    %rbp,%rcx
  add    %rsi,%rdx
  add    %rsi,%rax
  cmp    %rcx,%rbx
  jae    L171
L163:
  movsd  0x8(%rsp),%xmm7
  movapd %xmm7,%xmm0
  mulsd  %xmm3,%xmm0
  movapd %xmm5,%xmm1
  mulsd  %xmm4,%xmm1
  subsd  %xmm1,%xmm0
  addsd  %xmm3,%xmm0
  mulsd  %xmm4,%xmm7
  mulsd  %xmm5,%xmm3
  addsd  %xmm7,%xmm3
  addsd  %xmm3,%xmm4
  add    $0x2,%rdi
  add    $0x10,%r8
  cmp    %r12,%rdi
  jae    L84
  movapd %xmm0,%xmm3
L180:
  lea    (%r9,%r8,1),%rdx
  mov    %r8,%rax
  mov    %rdi,%rcx
  cmp    %rdi,%rbx
  jae    L171
  jmp    L163
L84:
  cmp    %rbp,%rbx
  jbe    L53
L39:
  mov    %rbp,%r12
  add    %rbp,%rbp
  test   %r12,%r12
  js     L74
  pxor   %xmm0,%xmm0
  cvtsi2sd %r12,%xmm0
L173:
  movsd  D9(%rip),%xmm1
  divsd  %xmm0,%xmm1
  mulsd  0x18(%rsp),%xmm1
  movsd  D3(%rip),%xmm5
  movsd  %xmm1,0x10(%rsp)
  mulsd  %xmm1,%xmm5
  movapd %xmm5,%xmm0
  call   <sin@plt>
  movsd  D32(%rip),%xmm5
  mulsd  %xmm0,%xmm5
  mulsd  %xmm0,%xmm5
  movsd  %xmm5,0x8(%rsp)
  movsd  0x10(%rsp),%xmm0
  call   <sin@plt>
  movapd %xmm0,%xmm5
  cmp    $0x1,%r12
  jbe    L84
  lea    0x10(%r13),%r8
  lea    0x0(,%rbp,8),%rsi
  pxor   %xmm4,%xmm4
  movq   %r14,%xmm3
  mov    $0x1,%edi
  lea    -0x8(,%r12,8),%r9
  jmp    L180
L53:
  add    $0x20,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
```

tool_calls: name: parse_data
arguments: data_tag: D17
type_guessed: f64
name: parse_data
arguments: data_tag: D9
type_guessed: f64
name: parse_data
arguments: data_tag: D3
type_guessed: f64
name: parse_data
arguments: data_tag: D32
type_guessed: f32[2]

tool: D17: 1

tool: D9: 6.28318530717959

tool: D3: 0.5

tool: {"D32": [0.0,-2.0]}

assistant: ```c
void four1(double data[], unsigned long nn, int isign) {
  unsigned long n, mmax, m, j, istep, i;
  double wtemp, wr, wpr, wpi, wi, theta;
  double tempr, tempi;
  n = nn << 1;
  j = 1;
  for (i = 1; i < n; i += 2) {
    if (j > i) {
      tempr = (data[j]);
      (data[j]) = (data[i]);
      (data[i]) = tempr;
      tempr = (data[j + 1]);
      (data[j + 1]) = (data[i + 1]);
      (data[i + 1]) = tempr;
    }
    m = nn;
    while (m >= 2 && j > m) {
      j -= m;
      m >>= 1;
    }
    j += m;
  }
  mmax = 2;
  while (n > mmax) {
    istep = mmax << 1;
    theta = isign * (6.28318530717959 / mmax);
    wtemp = sin(0.5 * theta);
    wpr = -2.0 * wtemp * wtemp;
    wpi = sin(theta);
    wr = 1.0;
    wi = 0.0;
    for (m = 1; m < mmax; m += 2) {
      for (i = m; i <= n; i += istep) {
        j = i + mmax;
        tempr = wr * data[j] - wi * data[j + 1];
        tempi = wr * data[j + 1] + wi * data[j];
        data[j] = data[i] - tempr;
        data[j + 1] = data[i + 1] - tempi;
        data[i] += tempr;
        data[i + 1] += tempi;
      }
      wr = (wtemp = wr) * wpr - wi * wpi + wr;
      wi = wi * wpr + wtemp * wpi + wi;
    }
    mmax = istep;
  }
}
```