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

```asm
<four1>:
  endbr64
  push   %r13
  push   %r12
  push   %rbp
  lea    (%rsi,%rsi,1),%rbp
  push   %rbx
  sub    $0x28,%rsp
  cmp    $0x1,%rbp
  jbe    L77
  cmp    $0x1,%rsi
  mov    %edx,%r9d
  mov    %rdi,%r12
  mov    $0x1,%ecx
  seta   %r8b
  mov    $0x1,%edx
  nopl   0x0(%rax)
L97:
  mov    %rsi,%rax
  cmp    %rsi,%rdx
  jbe    L117
  test   %r8b,%r8b
  jne    L93
  jmp    L117
  nopw   0x0(%rax,%rax,1)
L46:
  cmp    %rax,%rdx
  jbe    L117
L93:
  sub    %rax,%rdx
  shr    %rax
  cmp    $0x1,%rax
  ja     L46
L117:
  add    $0x2,%rcx
  add    %rax,%rdx
  cmp    %rcx,%rbp
  jbe    L124
  cmp    %rcx,%rdx
  jbe    L97
  lea    0x0(,%rdx,8),%rax
  movsd  (%r12,%rcx,8),%xmm1
  lea    (%r12,%rax,1),%rdi
  lea    0x8(%r12,%rax,1),%rax
  movsd  (%rdi),%xmm0
  movsd  %xmm1,(%rdi)
  movsd  0x8(%r12,%rcx,8),%xmm1
  movsd  %xmm0,(%r12,%rcx,8)
  movsd  (%rax),%xmm0
  movsd  %xmm1,(%rax)
  movsd  %xmm0,0x8(%r12,%rcx,8)
  jmp    L97
  nop
L127:
  cmp    %rbx,%rbp
  ja     L105
L77:
  add    $0x28,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
L124:
  cmp    $0x2,%rbp
  jbe    L77
  pxor   %xmm6,%xmm6
  mov    $0x2,%ebx
  cvtsi2sd %r9d,%xmm6
  movsd  %xmm6,0x18(%rsp)
  nopw   0x0(%rax,%rax,1)
L105:
  mov    %rbx,%r13
  add    %rbx,%rbx
  test   %r13,%r13
  js     L148
  pxor   %xmm0,%xmm0
  cvtsi2sd %r13,%xmm0
L150:
  movsd  D13(%rip),%xmm1
  divsd  %xmm0,%xmm1
  movsd  D12(%rip),%xmm0
  mulsd  0x18(%rsp),%xmm1
  mulsd  %xmm1,%xmm0
  movsd  %xmm1,0x10(%rsp)
  call   <sin@plt>
  movsd  D18(%rip),%xmm5
  movsd  0x10(%rsp),%xmm1
  mulsd  %xmm0,%xmm5
  mulsd  %xmm0,%xmm5
  movapd %xmm1,%xmm0
  movsd  %xmm5,0x8(%rsp)
  call   <sin@plt>
  cmp    $0x1,%r13
  movsd  0x8(%rsp),%xmm5
  movapd %xmm0,%xmm6
  jbe    L127
  lea    -0x1(%r13),%r9
  mov    D38(%rip),%rax
  pxor   %xmm4,%xmm4
  lea    0x10(%r12),%r8
  cmp    %rbp,%r9
  lea    0x0(,%rbx,8),%rsi
  mov    $0x1,%edi
  cmova  %rbp,%r9
  movq   %rax,%xmm3
  lea    -0x8(,%r13,8),%r10
  nop
L75:
  lea    (%r10,%r8,1),%rdx
  mov    %r8,%rax
  mov    %rdi,%rcx
  nopw   0x0(%rax,%rax,1)
L39:
  movsd  (%rdx),%xmm2
  movsd  0x8(%rdx),%xmm0
  add    %rbx,%rcx
  movapd %xmm2,%xmm1
  movapd %xmm0,%xmm7
  mulsd  %xmm3,%xmm1
  mulsd  %xmm4,%xmm7
  mulsd  %xmm4,%xmm2
  mulsd  %xmm3,%xmm0
  subsd  %xmm7,%xmm1
  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
  addsd  (%rax),%xmm0
  add    %rsi,%rdx
  movsd  %xmm1,-0x8(%rax)
  movsd  %xmm0,(%rax)
  add    %rsi,%rax
  cmp    %rcx,%rbp
  jae    L39
  movapd %xmm5,%xmm0
  movapd %xmm6,%xmm1
  add    $0x2,%rdi
  add    $0x10,%r8
  mulsd  %xmm4,%xmm1
  mulsd  %xmm3,%xmm0
  subsd  %xmm1,%xmm0
  movapd %xmm5,%xmm1
  mulsd  %xmm4,%xmm1
  addsd  %xmm3,%xmm0
  mulsd  %xmm6,%xmm3
  addsd  %xmm1,%xmm3
  addsd  %xmm3,%xmm4
  cmp    %r9,%rdi
  ja     L127
  movapd %xmm0,%xmm3
  jmp    L75
L148:
  mov    %r13,%rax
  pxor   %xmm0,%xmm0
  shr    %rax
  cvtsi2sd %rax,%xmm0
  addsd  %xmm0,%xmm0
  jmp    L150
```

tool_calls: name: disassemble_data
arguments: tag: D13
data_type: f64
name: disassemble_data
arguments: tag: D12
data_type: f64
name: disassemble_data
arguments: tag: D18
data_type: f32[2]
name: disassemble_data
arguments: tag: D38
data_type: f64

tool: D13: 6.28318530717959

tool: D12: 0.5

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

tool: D38: 1

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;
  }
}
```