user: 请从给定的汇编指令推导出C源代码：

```asm
<build_grid>:
  endbr64
  push   %r15
  pxor   %xmm0,%xmm0
  mov    %esi,%r15d
  push   %r14
  cvtsi2sd %esi,%xmm0
  push   %r13
  push   %r12
  push   %rbp
  mov    %rdx,%rbp
  push   %rbx
  mov    %r8d,%ebx
  sub    $0x18,%rsp
  movsd  0x8(%rdx),%xmm1
  mov    0x50(%rsp),%r14
  mov    0x58(%rsp),%r13
  mov    %edi,0xc(%rsp)
  mulsd  %xmm1,%xmm0
  subsd  0x10(%rdx),%xmm1
  mov    %r9d,0x8(%rsp)
  addsd  D31(%rip),%xmm1
  mov    0x68(%rsp),%r12
  divsd  %xmm1,%xmm0
  addsd  D31(%rip),%xmm0
  call   <floor@plt>
  mov    0xc(%rsp),%r10d
  mov    $0x1,%r8d
  test   %eax,%eax
  je     L4
  add    $0x1,%r15d
  mov    %eax,%r8d
  sub    %eax,%r15d
L4:
  mov    $0x2,%eax
  cmp    %eax,%r15d
  cmovl  %eax,%r15d
  mov    %ebx,%eax
  lea    -0x1(%r8,%r15,1),%edi
  imul   %edi,%eax
  lea    0x1(%rax),%edx
  cmp    %edx,%r10d
  jle    L17
  nopl   0x0(%rax)
L87:
  add    %ebx,%ebx
  mov    %ebx,%eax
  imul   %edi,%eax
  lea    0x1(%rax),%edx
  cmp    %r10d,%edx
  jl     L87
L17:
  add    $0x2,%eax
  mov    %r8d,0xc(%rsp)
  mov    %eax,(%r12)
  lea    0x0(,%rax,8),%edi
  call   <malloc@plt>
  mov    0x60(%rsp),%rsi
  mov    %rax,(%rsi)
  mov    (%r12),%eax
  lea    0x0(,%rax,8),%edi
  call   <malloc@plt>
  mov    0x70(%rsp),%rsi
  mov    %rax,(%rsi)
  mov    (%r12),%eax
  lea    0x0(,%rax,8),%edi
  call   <malloc@plt>
  mov    0xc(%rsp),%edi
  pxor   %xmm0,%xmm0
  movsd  D39(%rip),%xmm3
  mov    %rax,%rdx
  mov    0x78(%rsp),%rax
  imul   %ebx,%edi
  movapd %xmm3,%xmm1
  mov    %rdx,(%rax)
  cvtsi2sd %edi,%xmm0
  divsd  %xmm0,%xmm1
  test   %edi,%edi
  js     L74
  mov    0x60(%rsp),%rax
  movslq %edi,%r9
  mov    (%rax),%r11
  mov    0x70(%rsp),%rax
  mov    (%rax),%r10
  xor    %eax,%eax
  nopw   0x0(%rax,%rax,1)
L19:
  pxor   %xmm0,%xmm0
  mov    %rax,%rcx
  cvtsi2sd %eax,%xmm0
  mulsd  0x8(%rbp),%xmm0
  mulsd  %xmm1,%xmm0
  movsd  %xmm0,(%r11,%rax,8)
  movsd  (%r14),%xmm0
  movsd  %xmm0,(%r10,%rax,8)
  movsd  0x0(%r13),%xmm0
  movsd  %xmm0,(%rdx,%rax,8)
  add    $0x1,%rax
  cmp    %rcx,%r9
  jne    L19
L74:
  sub    $0x1,%r15d
  pxor   %xmm0,%xmm0
  imul   %ebx,%r15d
  cvtsi2sd %r15d,%xmm0
  divsd  %xmm0,%xmm3
  test   %r15d,%r15d
  js     L88
  mov    0x60(%rsp),%rax
  movslq %edi,%rdi
  movslq %r15d,%r15
  shl    $0x3,%rdi
  mov    (%rax),%r8
  mov    0x70(%rsp),%rax
  add    %rdi,%rdx
  mov    (%rax),%r9
  add    %rdi,%r8
  xor    %eax,%eax
  add    %rdi,%r9
  nopl   0x0(%rax,%rax,1)
L26:
  movsd  0x10(%rbp),%xmm2
  movsd  0x18(%rbp),%xmm1
  pxor   %xmm0,%xmm0
  mov    %rax,%rcx
  cvtsi2sd %eax,%xmm0
  subsd  %xmm2,%xmm1
  mulsd  %xmm1,%xmm0
  mulsd  %xmm3,%xmm0
  addsd  %xmm2,%xmm0
  movsd  %xmm0,0x8(%r8,%rax,8)
  movsd  0x8(%r14),%xmm0
  movsd  %xmm0,0x8(%r9,%rax,8)
  movsd  0x8(%r13),%xmm0
  movsd  %xmm0,0x8(%rdx,%rax,8)
  add    $0x1,%rax
  cmp    %rcx,%r15
  jne    L26
L88:
  mov    0x8(%rsp),%eax
  test   %eax,%eax
  jne    L58
  mov    0x60(%rsp),%rsi
  movsd  D31(%rip),%xmm0
  movslq (%r12),%rcx
  mov    (%rsi),%rdx
  subsd  %xmm3,%xmm0
  mov    %rcx,%rax
  movsd  -0x8(%rdx,%rcx,8),%xmm1
  comisd %xmm0,%xmm1
  jbe    L58
  sub    $0x1,%eax
  mov    %eax,(%r12)
L58:
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
```

tool_calls: name: disassemble_data
arguments: tag: D31
type_guessed: f64
name: disassemble_data
arguments: tag: D39
type_guessed: f64

tool: D31: 0.5

tool: D39: 1

assistant: ```c
void build_grid(int lgfiltre, int nfcns, const double *bands, int nbands, int lgrid, int nodd, const double *dev, const double *weight, double **FreqGrille, int *taillegrilledense, double **des, double **wt) {
  int np = floor(0.5 + (nfcns * bands[1]) / (0.5 + (bands[1] - bands[2])));
  if (np == 0)
    np++;
  int ns = nfcns + 1 - np;
  if (ns <= 1)
    ns = 2;
  while ((np + ns - 1) * lgrid + 2 <= lgfiltre)
    lgrid *= 2;
  *taillegrilledense = (np + ns - 1) * lgrid + 2;
  *FreqGrille = malloc(*taillegrilledense * sizeof(double));
  *des = malloc(*taillegrilledense * sizeof(double));
  *wt = malloc(*taillegrilledense * sizeof(double));
  double delf = 1.0 / (lgrid * np);
  for (int k = 0; k < np * lgrid + 1; k++) {
    (*FreqGrille)[k] = k * bands[1] * delf;
    (*des)[k] = dev[0];
    (*wt)[k] = weight[0];
  }
  delf = 1.0 / ((ns - 1) * lgrid);
  for (int k = 0; k < (ns - 1) * lgrid + 1; k++) {
    (*FreqGrille)[(np * lgrid) + 1 + k] = bands[2] + k * (bands[3] - bands[2]) * delf;
    (*des)[(np * lgrid) + 1 + k] = dev[1];
    (*wt)[(np * lgrid) + 1 + k] = weight[1];
  }
  if (nodd == 0 && (*FreqGrille)[*taillegrilledense - 1] > (0.5 - delf))
    (*taillegrilledense)--;
}
```