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

```asm
<TorusNoise>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x68,%rsp
  movsd  %xmm1,0x30(%rsp)
  movss  %xmm3,0x38(%rsp)
  movss  %xmm4,0x3c(%rsp)
  comisd D8(%rip),%xmm0
  jbe    L61
  cvttsd2si %xmm0,%ecx
L44:
  comisd D8(%rip),%xmm2
  jbe    L9
  cvttsd2si %xmm2,%edx
L24:
  lea    -0x1(%rcx),%eax
  imul   $0xd5fff,%eax,%eax
  lea    -0x1(%rdx,%rax,1),%r15d
  mov    $0xffffffff,%r14d
  movss  D56(%rip),%xmm4
  movss  %xmm4,0xc(%rsp)
  pxor   %xmm1,%xmm1
  cvtsi2sd %ecx,%xmm1
  subsd  %xmm1,%xmm0
  movsd  %xmm0,0x48(%rsp)
  pxor   %xmm0,%xmm0
  cvtsi2sd %edx,%xmm0
  subsd  %xmm0,%xmm2
  movsd  %xmm2,0x40(%rsp)
  jmp    L20
L61:
  cvttsd2si %xmm0,%ecx
  sub    $0x1,%ecx
  jmp    L44
L9:
  cvttsd2si %xmm2,%edx
  sub    $0x1,%edx
  jmp    L24
L47:
  add    $0x1,%r14d
  add    $0xd5fff,%r15d
  cmp    $0x2,%r14d
  je     L4
L20:
  mov    %r15d,%ebp
  mov    $0xffffffff,%ebx
  pxor   %xmm1,%xmm1
  cvtsi2sd %r14d,%xmm1
  movsd  0x48(%rsp),%xmm0
  subsd  %xmm1,%xmm0
  subsd  D24(%rip),%xmm0
  movsd  %xmm0,0x28(%rsp)
L75:
  pxor   %xmm1,%xmm1
  cvtsi2sd %ebx,%xmm1
  movsd  0x40(%rsp),%xmm0
  subsd  %xmm1,%xmm0
  subsd  D24(%rip),%xmm0
  movsd  %xmm0,0x10(%rsp)
  mov    %ebp,%edi
  call   <noise1u@plt>
  lea    0x58(%rsp),%r12
  lea    0x50(%rsp),%r13
  addsd  %xmm0,%xmm0
  mulsd  D69(%rip),%xmm0
  mov    %r13,%rsi
  mov    %r12,%rdi
  call   <sincos@plt>
  movsd  0x50(%rsp),%xmm4
  movsd  %xmm4,0x18(%rsp)
  movsd  0x58(%rsp),%xmm2
  movsd  %xmm2,0x20(%rsp)
  lea    0x181cd(%rbp),%edi
  call   <noise1u@plt>
  mulsd  D24(%rip),%xmm0
  mulsd  D69(%rip),%xmm0
  mov    %r13,%rsi
  mov    %r12,%rdi
  call   <sincos@plt>
  movsd  0x50(%rsp),%xmm1
  movsd  0x18(%rsp),%xmm4
  mulsd  %xmm1,%xmm4
  movapd %xmm4,%xmm0
  movsd  0x28(%rsp),%xmm6
  mulsd  %xmm6,%xmm0
  mulsd  0x20(%rsp),%xmm1
  movsd  0x30(%rsp),%xmm7
  mulsd  %xmm7,%xmm1
  addsd  %xmm1,%xmm0
  movsd  0x10(%rsp),%xmm5
  movapd %xmm5,%xmm1
  mulsd  0x58(%rsp),%xmm1
  addsd  %xmm1,%xmm0
  movapd %xmm0,%xmm3
  mulsd  %xmm0,%xmm3
  movapd %xmm7,%xmm1
  mulsd  %xmm7,%xmm1
  movapd %xmm6,%xmm0
  mulsd  %xmm6,%xmm0
  addsd  %xmm1,%xmm0
  movapd %xmm5,%xmm1
  mulsd  %xmm5,%xmm1
  addsd  %xmm1,%xmm0
  movsd  %xmm3,0x10(%rsp)
  subsd  %xmm3,%xmm0
  call   <sqrt@plt>
  cvtss2sd %xmm0,%xmm0
  pxor   %xmm1,%xmm1
  cvtss2sd 0x3c(%rsp),%xmm1
  subsd  %xmm1,%xmm0
  mulsd  %xmm0,%xmm0
  addsd  0x10(%rsp),%xmm0
  call   <sqrt@plt>
  subss  0x38(%rsp),%xmm0
  minss  0xc(%rsp),%xmm0
  movss  %xmm0,0xc(%rsp)
  add    $0x1,%ebx
  add    $0x1,%ebp
  cmp    $0x2,%ebx
  jne    L75
  jmp    L47
L4:
  movss  0xc(%rsp),%xmm0
  add    $0x68,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
```

tool_calls: name: read_data
arguments: data_label: D8
type: byte[16]
name: read_data
arguments: data_label: D56
type: f32
name: read_data
arguments: data_label: D24
type: f64
name: read_data
arguments: data_label: D69
type: byte[8]

tool: {"D8": [0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0x3f]}

tool: D56: 999

tool: D24: 0.5

tool: {"D69": [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;
}
```