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

```asm
<build_grid>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x28,%rsp
  mov    %edi,0x10(%rsp)
  mov    %rdx,%rbx
  mov    %r8d,0xc(%rsp)
  mov    %r9d,0x1c(%rsp)
  mov    0x60(%rsp),%r14
  mov    0x68(%rsp),%r15
  mov    0x70(%rsp),%rbp
  mov    0x80(%rsp),%r12
  mov    0x88(%rsp),%r13
  movsd  0x8(%rdx),%xmm1
  mov    %esi,0x14(%rsp)
  pxor   %xmm0,%xmm0
  cvtsi2sd %esi,%xmm0
  mulsd  %xmm1,%xmm0
  subsd  0x10(%rdx),%xmm1
  movsd  D21(%rip),%xmm2
  addsd  %xmm2,%xmm1
  divsd  %xmm1,%xmm0
  addsd  %xmm2,%xmm0
  call   <floor@plt>
  mov    %eax,%edx
  test   %eax,%eax
  mov    $0x1,%eax
  mov    %eax,%ecx
  cmovne %edx,%ecx
  mov    %ecx,0x18(%rsp)
  mov    0x14(%rsp),%eax
  add    $0x1,%eax
  sub    %ecx,%eax
  mov    %eax,%esi
  mov    $0x2,%eax
  cmp    %eax,%esi
  cmovge %esi,%eax
  mov    %eax,0x14(%rsp)
  lea    -0x1(%rax,%rcx,1),%edx
  mov    0xc(%rsp),%eax
  imul   %edx,%eax
  mov    %eax,%edi
  lea    0x1(%rax),%eax
  cmp    %eax,0x10(%rsp)
  jle    L18
L37:
  shll   0xc(%rsp)
  mov    0xc(%rsp),%eax
  mov    %eax,%edi
  imul   %edx,%edi
  lea    0x1(%rdi),%eax
  cmp    0x10(%rsp),%eax
  jl     L37
L18:
  add    $0x2,%edi
  mov    0x78(%rsp),%rax
  mov    %edi,(%rax)
  shl    $0x3,%edi
  call   <malloc@plt>
  mov    %rax,0x0(%rbp)
  mov    0x78(%rsp),%rax
  mov    (%rax),%eax
  mov    %eax,0x10(%rsp)
  lea    0x0(,%rax,8),%edi
  call   <malloc@plt>
  mov    %rax,(%r12)
  mov    0x78(%rsp),%rax
  mov    (%rax),%eax
  mov    %eax,0x10(%rsp)
  lea    0x0(,%rax,8),%edi
  call   <malloc@plt>
  mov    %rax,0x0(%r13)
  mov    0x18(%rsp),%esi
  imul   0xc(%rsp),%esi
  pxor   %xmm0,%xmm0
  cvtsi2sd %esi,%xmm0
  movsd  D38(%rip),%xmm1
  divsd  %xmm0,%xmm1
  test   %esi,%esi
  js     L7
  lea    0x1(%rsi),%ecx
  mov    $0x0,%eax
L48:
  mov    0x0(%rbp),%rdx
  pxor   %xmm0,%xmm0
  cvtsi2sd %eax,%xmm0
  mulsd  0x8(%rbx),%xmm0
  mulsd  %xmm1,%xmm0
  movsd  %xmm0,(%rdx,%rax,8)
  movsd  (%r14),%xmm0
  mov    (%r12),%rdx
  movsd  %xmm0,(%rdx,%rax,8)
  movsd  (%r15),%xmm0
  mov    0x0(%r13),%rdx
  movsd  %xmm0,(%rdx,%rax,8)
  add    $0x1,%rax
  cmp    %rcx,%rax
  jne    L48
L7:
  mov    0x14(%rsp),%ecx
  sub    $0x1,%ecx
  imul   0xc(%rsp),%ecx
  pxor   %xmm0,%xmm0
  cvtsi2sd %ecx,%xmm0
  movsd  D38(%rip),%xmm3
  divsd  %xmm0,%xmm3
  test   %ecx,%ecx
  js     L9
  movslq %esi,%rsi
  lea    0x8(,%rsi,8),%rax
  add    $0x1,%ecx
  mov    $0x0,%edx
L67:
  movsd  0x10(%rbx),%xmm2
  mov    0x0(%rbp),%rsi
  movsd  0x18(%rbx),%xmm1
  subsd  %xmm2,%xmm1
  pxor   %xmm0,%xmm0
  cvtsi2sd %edx,%xmm0
  mulsd  %xmm1,%xmm0
  mulsd  %xmm3,%xmm0
  addsd  %xmm2,%xmm0
  movsd  %xmm0,(%rsi,%rax,1)
  movsd  0x8(%r14),%xmm0
  mov    (%r12),%rsi
  movsd  %xmm0,(%rsi,%rax,1)
  movsd  0x8(%r15),%xmm0
  mov    0x0(%r13),%rsi
  movsd  %xmm0,(%rsi,%rax,1)
  add    $0x1,%edx
  add    $0x8,%rax
  cmp    %edx,%ecx
  jne    L67
L9:
  cmpl   $0x0,0x1c(%rsp)
  jne    L46
  mov    0x78(%rsp),%rax
  mov    (%rax),%eax
  movslq %eax,%rcx
  mov    0x0(%rbp),%rdx
  movsd  D21(%rip),%xmm0
  subsd  %xmm3,%xmm0
  movsd  -0x8(%rdx,%rcx,8),%xmm1
  comisd %xmm0,%xmm1
  jbe    L46
  sub    $0x1,%eax
  mov    0x78(%rsp),%rbx
  mov    %eax,(%rbx)
L46:
  add    $0x28,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
```

tool_calls: name: retrieve_data
arguments: tag: D21
type: f64
name: retrieve_data
arguments: tag: D38
type: f64

tool: D21: 0.5

tool: D38: 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)--;
}
```