user: 请将这段汇编代码片段转换成等效的C代码:

```asm
<TorusNoise>:
  endbr64
  push   %r15
  movapd %xmm1,%xmm5
  cvttsd2si %xmm0,%eax
  xor    %edx,%edx
  push   %r14
  movapd %xmm5,%xmm6
  cvtss2sd %xmm4,%xmm4
  push   %r13
  mulsd  %xmm5,%xmm6
  push   %r12
  mov    $0xffffffff,%r12d
  push   %rbp
  push   %rbx
  sub    $0x78,%rsp
  movsd  %xmm1,0x38(%rsp)
  pxor   %xmm1,%xmm1
  lea    0x68(%rsp),%rbp
  lea    0x60(%rsp),%rbx
  ucomisd %xmm1,%xmm0
  movss  %xmm3,0x44(%rsp)
  movsd  %xmm6,0x50(%rsp)
  movsd  %xmm4,0x48(%rsp)
  setbe  %dl
  xor    %ecx,%ecx
  sub    %edx,%eax
  ucomisd %xmm1,%xmm2
  pxor   %xmm1,%xmm1
  cvtsi2sd %eax,%xmm1
  cvttsd2si %xmm2,%edx
  setbe  %cl
  sub    $0x1,%eax
  imul   $0xd5fff,%eax,%eax
  subsd  %xmm1,%xmm0
  sub    %ecx,%edx
  lea    -0x1(%rdx,%rax,1),%r13d
  movsd  %xmm0,0x58(%rsp)
  pxor   %xmm0,%xmm0
  cvtsi2sd %edx,%xmm0
  subsd  %xmm0,%xmm2
  movsd  %xmm2,0x30(%rsp)
  movss  D2(%rip),%xmm2
L2:
  pxor   %xmm1,%xmm1
  movsd  0x58(%rsp),%xmm0
  mov    %r13d,%r15d
  mov    $0xffffffff,%r14d
  cvtsi2sd %r12d,%xmm1
  subsd  %xmm1,%xmm0
  subsd  D58(%rip),%xmm0
  movapd %xmm0,%xmm4
  movsd  %xmm0,0x20(%rsp)
  mulsd  %xmm0,%xmm4
  movsd  %xmm4,0x28(%rsp)
L7:
  pxor   %xmm0,%xmm0
  movsd  0x30(%rsp),%xmm3
  mov    %r15d,%edi
  movss  %xmm2,0x40(%rsp)
  cvtsi2sd %r14d,%xmm0
  add    $0x1,%r14d
  subsd  %xmm0,%xmm3
  subsd  D58(%rip),%xmm3
  movsd  %xmm3,0x18(%rsp)
  call   <noise1u@plt>
  mov    %rbx,%rsi
  mov    %rbp,%rdi
  addsd  %xmm0,%xmm0
  mulsd  D24(%rip),%xmm0
  call   <sincos@plt>
  movsd  0x68(%rsp),%xmm5
  movsd  0x60(%rsp),%xmm1
  lea    0x181cd(%r15),%edi
  add    $0x1,%r15d
  movsd  %xmm5,0x8(%rsp)
  movsd  %xmm1,0x10(%rsp)
  call   <noise1u@plt>
  mulsd  D58(%rip),%xmm0
  mov    %rbx,%rsi
  mov    %rbp,%rdi
  mulsd  D24(%rip),%xmm0
  call   <sincos@plt>
  movsd  0x60(%rsp),%xmm0
  movsd  0x10(%rsp),%xmm1
  movsd  0x18(%rsp),%xmm3
  mulsd  %xmm0,%xmm1
  mulsd  0x8(%rsp),%xmm0
  mulsd  0x38(%rsp),%xmm0
  mulsd  0x20(%rsp),%xmm1
  addsd  %xmm0,%xmm1
  movsd  0x68(%rsp),%xmm0
  mulsd  %xmm3,%xmm0
  mulsd  %xmm3,%xmm3
  addsd  %xmm0,%xmm1
  movsd  0x28(%rsp),%xmm0
  addsd  0x50(%rsp),%xmm0
  mulsd  %xmm1,%xmm1
  addsd  %xmm3,%xmm0
  subsd  %xmm1,%xmm0
  movsd  %xmm1,0x8(%rsp)
  call   <sqrt@plt>
  movsd  0x8(%rsp),%xmm1
  cvtss2sd %xmm0,%xmm0
  subsd  0x48(%rsp),%xmm0
  mulsd  %xmm0,%xmm0
  addsd  %xmm1,%xmm0
  call   <sqrt@plt>
  subss  0x44(%rsp),%xmm0
  movss  0x40(%rsp),%xmm2
  minss  %xmm2,%xmm0
  movaps %xmm0,%xmm2
  cmp    $0x2,%r14d
  jne    L7
  add    $0x1,%r12d
  add    $0xd5fff,%r13d
  cmp    $0x2,%r12d
  jne    L2
  add    $0x78,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
```

tool_calls: name: parse_data
arguments: label: D2
data_type: f32
name: parse_data
arguments: label: D58
data_type: f64
name: parse_data
arguments: label: D24
data_type: byte[8]

tool: D2: 999

tool: D58: 0.5

tool: {"D24": [0x00,0x00,0x00,0x60,0xfb,0x21,0x09,0x40]}

assistant: ```c
float TorusNoise(double x, double y, double z, float thick, float radius) {
  int i = (((x) > 0) ? ((int)x) : (((int)x) - 1));
  int k = (((z) > 0) ? ((int)z) : (((int)z) - 1));
  double dy = y;
  float minval = 999;
  int ox, oz;
  for (ox = -1; ox <= 1; ox++) {
    for (oz = -1; oz <= 1; oz++) {
      double fx = x - i - ox;
      double fz = z - k - oz;
      double dx = fx - 0.5f;
      double dz = fz - 0.5f;
      int id = (i + ox) * 876543 + (k + oz);
      double ang = noise1u(id) * 2 * 3.14159265f;
      double tilt = noise1u(id + 98765) * 0.5 * 3.14159265f;
      double ti = cos(tilt);
      double rx = cos(ang) * ti;
      double ry = sin(ang) * ti;
      double rz = sin(tilt);
      double h = dx * rx + dy * ry + dz * rz;
      double l2 = dx * dx + dy * dy + dz * dz;
      double d = sqrt(l2 - h * h);
      double a = d - radius;
      float val = sqrt(a * a + h * h) - thick;
      if (val < minval)
        minval = val;
    }
  }
  return minval;
}
```