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

```asm
<main>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x40,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  lea    D128(%rip),%rax
  mov    %rax,%rdi
  call   <puts@plt>
  lea    -0x40(%rbp),%rax
  mov    %rax,%rsi
  lea    D79(%rip),%rax
  mov    %rax,%rdi
  call   <scanf@plt>
  lea    D46(%rip),%rax
  mov    %rax,%rdi
  call   <puts@plt>
  lea    -0x3c(%rbp),%rax
  mov    %rax,%rsi
  lea    D79(%rip),%rax
  mov    %rax,%rdi
  call   <scanf@plt>
  mov    -0x3c(%rbp),%edx
  mov    -0x40(%rbp),%eax
  mov    %edx,%esi
  mov    %eax,%edi
  call   <alloc_2d_double@plt>
  mov    %rax,-0x30(%rbp)
  mov    -0x3c(%rbp),%edx
  mov    -0x40(%rbp),%eax
  mov    %edx,%esi
  mov    %eax,%edi
  call   <alloc_2d_double@plt>
  mov    %rax,-0x28(%rbp)
  mov    -0x3c(%rbp),%eax
  mov    %eax,%edx
  shr    $0x1f,%edx
  add    %edx,%eax
  sar    %eax
  mov    %eax,%edx
  mov    -0x40(%rbp),%eax
  cmp    %eax,%edx
  cmovge %edx,%eax
  mov    %eax,-0x34(%rbp)
  pxor   %xmm1,%xmm1
  cvtsi2sdl -0x34(%rbp),%xmm1
  movsd  D10(%rip),%xmm0
  addsd  %xmm1,%xmm0
  cvttsd2si %xmm0,%eax
  mov    %eax,%edi
  call   <sqrt@plt>
  add    $0x2,%eax
  mov    %eax,%edi
  call   <alloc_1d_int@plt>
  mov    %rax,-0x20(%rbp)
  mov    -0x3c(%rbp),%eax
  lea    0x3(%rax),%edx
  test   %eax,%eax
  cmovs  %edx,%eax
  sar    $0x2,%eax
  mov    %eax,%edx
  mov    -0x40(%rbp),%eax
  mov    %eax,%ecx
  shr    $0x1f,%ecx
  add    %ecx,%eax
  sar    %eax
  cmp    %eax,%edx
  cmovge %edx,%eax
  mov    %eax,%ecx
  mov    -0x3c(%rbp),%edx
  mov    -0x40(%rbp),%eax
  cmp    %eax,%edx
  cmovge %edx,%eax
  add    %ecx,%eax
  mov    %eax,-0x34(%rbp)
  mov    -0x34(%rbp),%eax
  mov    %eax,%edi
  call   <alloc_1d_double@plt>
  mov    %rax,-0x18(%rbp)
  mov    -0x20(%rbp),%rax
  movl   $0x0,(%rax)
  mov    -0x3c(%rbp),%ecx
  mov    -0x40(%rbp),%eax
  mov    -0x30(%rbp),%rdx
  mov    %ecx,%esi
  mov    %eax,%edi
  call   <putdata2d@plt>
  mov    -0x3c(%rbp),%esi
  mov    -0x40(%rbp),%eax
  mov    -0x18(%rbp),%rdi
  mov    -0x20(%rbp),%rcx
  mov    -0x30(%rbp),%rdx
  mov    %rdi,%r9
  mov    %rcx,%r8
  mov    %rdx,%rcx
  mov    $0x1,%edx
  mov    %eax,%edi
  call   <cdft2d@plt>
  mov    -0x3c(%rbp),%esi
  mov    -0x40(%rbp),%eax
  mov    -0x18(%rbp),%rdi
  mov    -0x20(%rbp),%rcx
  mov    -0x30(%rbp),%rdx
  mov    %rdi,%r9
  mov    %rcx,%r8
  mov    %rdx,%rcx
  mov    $0xffffffff,%edx
  mov    %eax,%edi
  call   <cdft2d@plt>
  mov    -0x40(%rbp),%eax
  pxor   %xmm1,%xmm1
  cvtsi2sd %eax,%xmm1
  movsd  D87(%rip),%xmm0
  divsd  %xmm1,%xmm0
  mov    -0x3c(%rbp),%eax
  pxor   %xmm1,%xmm1
  cvtsi2sd %eax,%xmm1
  divsd  %xmm1,%xmm0
  movq   %xmm0,%rsi
  mov    -0x3c(%rbp),%ecx
  mov    -0x40(%rbp),%eax
  mov    -0x30(%rbp),%rdx
  movq   %rsi,%xmm0
  mov    %ecx,%esi
  mov    %eax,%edi
  call   <errorcheck2d@plt>
  movq   %xmm0,%rax
  mov    %rax,-0x10(%rbp)
  mov    -0x10(%rbp),%rax
  movq   %rax,%xmm0
  lea    D165(%rip),%rax
  mov    %rax,%rdi
  mov    $0x1,%eax
  call   <printf@plt>
  mov    -0x3c(%rbp),%ecx
  mov    -0x40(%rbp),%eax
  mov    -0x30(%rbp),%rdx
  mov    %ecx,%esi
  mov    %eax,%edi
  call   <putdata2d@plt>
  mov    -0x3c(%rbp),%esi
  mov    -0x40(%rbp),%eax
  mov    -0x18(%rbp),%rdi
  mov    -0x20(%rbp),%rcx
  mov    -0x30(%rbp),%rdx
  mov    %rdi,%r9
  mov    %rcx,%r8
  mov    %rdx,%rcx
  mov    $0x1,%edx
  mov    %eax,%edi
  call   <rdft2d@plt>
  mov    -0x3c(%rbp),%esi
  mov    -0x40(%rbp),%eax
  mov    -0x18(%rbp),%rdi
  mov    -0x20(%rbp),%rcx
  mov    -0x30(%rbp),%rdx
  mov    %rdi,%r9
  mov    %rcx,%r8
  mov    %rdx,%rcx
  mov    $0xffffffff,%edx
  mov    %eax,%edi
  call   <rdft2d@plt>
  mov    -0x40(%rbp),%eax
  pxor   %xmm1,%xmm1
  cvtsi2sd %eax,%xmm1
  movsd  D87(%rip),%xmm0
  divsd  %xmm1,%xmm0
  mov    -0x3c(%rbp),%eax
  pxor   %xmm1,%xmm1
  cvtsi2sd %eax,%xmm1
  divsd  %xmm1,%xmm0
  movq   %xmm0,%rsi
  mov    -0x3c(%rbp),%ecx
  mov    -0x40(%rbp),%eax
  mov    -0x30(%rbp),%rdx
  movq   %rsi,%xmm0
  mov    %ecx,%esi
  mov    %eax,%edi
  call   <errorcheck2d@plt>
  movq   %xmm0,%rax
  mov    %rax,-0x10(%rbp)
  mov    -0x10(%rbp),%rax
  movq   %rax,%xmm0
  lea    D22(%rip),%rax
  mov    %rax,%rdi
  mov    $0x1,%eax
  call   <printf@plt>
  mov    -0x3c(%rbp),%ecx
  mov    -0x40(%rbp),%eax
  mov    -0x30(%rbp),%rdx
  mov    %ecx,%esi
  mov    %eax,%edi
  call   <putdata2d@plt>
  mov    -0x3c(%rbp),%esi
  mov    -0x40(%rbp),%eax
  mov    -0x20(%rbp),%rdi
  mov    -0x28(%rbp),%rcx
  mov    -0x30(%rbp),%rdx
  sub    $0x8,%rsp
  push   -0x18(%rbp)
  mov    %rdi,%r9
  mov    %rcx,%r8
  mov    %rdx,%rcx
  mov    $0x1,%edx
  mov    %eax,%edi
  call   <ddct2d@plt>
  add    $0x10,%rsp
  mov    -0x3c(%rbp),%esi
  mov    -0x40(%rbp),%eax
  mov    -0x20(%rbp),%rdi
  mov    -0x28(%rbp),%rcx
  mov    -0x30(%rbp),%rdx
  sub    $0x8,%rsp
  push   -0x18(%rbp)
  mov    %rdi,%r9
  mov    %rcx,%r8
  mov    %rdx,%rcx
  mov    $0xffffffff,%edx
  mov    %eax,%edi
  call   <ddct2d@plt>
  add    $0x10,%rsp
  movl   $0x0,-0x38(%rbp)
  jmp    L75
L67:
  mov    -0x38(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x30(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rax
  movsd  (%rax),%xmm1
  mov    -0x38(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x30(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rax
  movsd  D10(%rip),%xmm0
  mulsd  %xmm1,%xmm0
  movsd  %xmm0,(%rax)
  addl   $0x1,-0x38(%rbp)
L75:
  mov    -0x40(%rbp),%eax
  cmp    %eax,-0x38(%rbp)
  jl     L67
  movl   $0x0,-0x38(%rbp)
  jmp    L65
L11:
  mov    -0x30(%rbp),%rax
  mov    (%rax),%rdx
  mov    -0x38(%rbp),%eax
  cltq
  shl    $0x3,%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm1
  mov    -0x30(%rbp),%rax
  mov    (%rax),%rdx
  mov    -0x38(%rbp),%eax
  cltq
  shl    $0x3,%rax
  add    %rdx,%rax
  movsd  D10(%rip),%xmm0
  mulsd  %xmm1,%xmm0
  movsd  %xmm0,(%rax)
  addl   $0x1,-0x38(%rbp)
L65:
  mov    -0x3c(%rbp),%eax
  cmp    %eax,-0x38(%rbp)
  jl     L11
  mov    -0x40(%rbp),%eax
  pxor   %xmm1,%xmm1
  cvtsi2sd %eax,%xmm1
  movsd  D31(%rip),%xmm0
  divsd  %xmm1,%xmm0
  mov    -0x3c(%rbp),%eax
  pxor   %xmm1,%xmm1
  cvtsi2sd %eax,%xmm1
  divsd  %xmm1,%xmm0
  movq   %xmm0,%rsi
  mov    -0x3c(%rbp),%ecx
  mov    -0x40(%rbp),%eax
  mov    -0x30(%rbp),%rdx
  movq   %rsi,%xmm0
  mov    %ecx,%esi
  mov    %eax,%edi
  call   <errorcheck2d@plt>
  movq   %xmm0,%rax
  mov    %rax,-0x10(%rbp)
  mov    -0x10(%rbp),%rax
  movq   %rax,%xmm0
  lea    D100(%rip),%rax
  mov    %rax,%rdi
  mov    $0x1,%eax
  call   <printf@plt>
  mov    -0x3c(%rbp),%ecx
  mov    -0x40(%rbp),%eax
  mov    -0x30(%rbp),%rdx
  mov    %ecx,%esi
  mov    %eax,%edi
  call   <putdata2d@plt>
  mov    -0x3c(%rbp),%esi
  mov    -0x40(%rbp),%eax
  mov    -0x20(%rbp),%rdi
  mov    -0x28(%rbp),%rcx
  mov    -0x30(%rbp),%rdx
  sub    $0x8,%rsp
  push   -0x18(%rbp)
  mov    %rdi,%r9
  mov    %rcx,%r8
  mov    %rdx,%rcx
  mov    $0x1,%edx
  mov    %eax,%edi
  call   <ddst2d@plt>
  add    $0x10,%rsp
  mov    -0x3c(%rbp),%esi
  mov    -0x40(%rbp),%eax
  mov    -0x20(%rbp),%rdi
  mov    -0x28(%rbp),%rcx
  mov    -0x30(%rbp),%rdx
  sub    $0x8,%rsp
  push   -0x18(%rbp)
  mov    %rdi,%r9
  mov    %rcx,%r8
  mov    %rdx,%rcx
  mov    $0xffffffff,%edx
  mov    %eax,%edi
  call   <ddst2d@plt>
  add    $0x10,%rsp
  movl   $0x0,-0x38(%rbp)
  jmp    L60
L84:
  mov    -0x38(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x30(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rax
  movsd  (%rax),%xmm1
  mov    -0x38(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x30(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rax
  movsd  D10(%rip),%xmm0
  mulsd  %xmm1,%xmm0
  movsd  %xmm0,(%rax)
  addl   $0x1,-0x38(%rbp)
L60:
  mov    -0x40(%rbp),%eax
  cmp    %eax,-0x38(%rbp)
  jl     L84
  movl   $0x0,-0x38(%rbp)
  jmp    L81
L64:
  mov    -0x30(%rbp),%rax
  mov    (%rax),%rdx
  mov    -0x38(%rbp),%eax
  cltq
  shl    $0x3,%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm1
  mov    -0x30(%rbp),%rax
  mov    (%rax),%rdx
  mov    -0x38(%rbp),%eax
  cltq
  shl    $0x3,%rax
  add    %rdx,%rax
  movsd  D10(%rip),%xmm0
  mulsd  %xmm1,%xmm0
  movsd  %xmm0,(%rax)
  addl   $0x1,-0x38(%rbp)
L81:
  mov    -0x3c(%rbp),%eax
  cmp    %eax,-0x38(%rbp)
  jl     L64
  mov    -0x40(%rbp),%eax
  pxor   %xmm1,%xmm1
  cvtsi2sd %eax,%xmm1
  movsd  D31(%rip),%xmm0
  divsd  %xmm1,%xmm0
  mov    -0x3c(%rbp),%eax
  pxor   %xmm1,%xmm1
  cvtsi2sd %eax,%xmm1
  divsd  %xmm1,%xmm0
  movq   %xmm0,%rsi
  mov    -0x3c(%rbp),%ecx
  mov    -0x40(%rbp),%eax
  mov    -0x30(%rbp),%rdx
  movq   %rsi,%xmm0
  mov    %ecx,%esi
  mov    %eax,%edi
  call   <errorcheck2d@plt>
  movq   %xmm0,%rax
  mov    %rax,-0x10(%rbp)
  mov    -0x10(%rbp),%rax
  movq   %rax,%xmm0
  lea    D93(%rip),%rax
  mov    %rax,%rdi
  mov    $0x1,%eax
  call   <printf@plt>
  mov    -0x18(%rbp),%rax
  mov    %rax,%rdi
  call   <free_1d_double@plt>
  mov    -0x20(%rbp),%rax
  mov    %rax,%rdi
  call   <free_1d_int@plt>
  mov    -0x28(%rbp),%rax
  mov    %rax,%rdi
  call   <free_2d_double@plt>
  mov    -0x30(%rbp),%rax
  mov    %rax,%rdi
  call   <free_2d_double@plt>
  mov    $0x0,%eax
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L51
  call   <__stack_chk_fail@plt>
L51:
  leave
  ret
```

tool_calls: name: unpack_data
arguments: data_tag: D128
datatype: string
name: unpack_data
arguments: data_tag: D79
datatype: string
name: unpack_data
arguments: data_tag: D46
datatype: string
name: unpack_data
arguments: data_tag: D10
datatype: f64
name: unpack_data
arguments: data_tag: D87
datatype: f64
name: unpack_data
arguments: data_tag: D165
datatype: string
name: unpack_data
arguments: data_tag: D22
datatype: string
name: unpack_data
arguments: data_tag: D31
datatype: f64
name: unpack_data
arguments: data_tag: D100
datatype: string
name: unpack_data
arguments: data_tag: D93
datatype: string

tool: D128: data length n1=? (n1 = power of 2) 

tool: D79: %d

tool: D46: data length n2=? (n2 = power of 2) 

tool: D10: 0.5

tool: D87: 2

tool: D165: cdft2d err= %g 


tool: D22: rdft2d err= %g 


tool: D31: 4

tool: D100: ddct2d err= %g 


tool: D93: ddst2d err= %g 


assistant: ```c
int main() {
  void cdft2d(int, int, int, double **, int *, double *);
  void rdft2d(int, int, int, double **, int *, double *);
  void ddct2d(int, int, int, double **, double **, int *, double *);
  void ddst2d(int, int, int, double **, double **, int *, double *);
  void putdata2d(int n1, int n2, double **a);
  double errorcheck2d(int n1, int n2, double scale, double **a);
  int *ip, n1, n2, n, i;
  double **a, **t, *w, err;
  printf("data length n1=? (n1 = power of 2) \n");
  scanf("%d", &n1);
  printf("data length n2=? (n2 = power of 2) \n");
  scanf("%d", &n2);
  a = alloc_2d_double(n1, n2);
  t = alloc_2d_double(n1, n2);
  n = ((n1) > (n2 / 2) ? (n1) : (n2 / 2));
  ip = alloc_1d_int(2 + (int)sqrt(n + 0.5));
  n = ((n1 / 2) > (n2 / 4) ? (n1 / 2) : (n2 / 4)) + ((n1) > (n2) ? (n1) : (n2));
  w = alloc_1d_double(n);
  ip[0] = 0;
  putdata2d(n1, n2, a);
  cdft2d(n1, n2, 1, a, ip, w);
  cdft2d(n1, n2, -1, a, ip, w);
  err = errorcheck2d(n1, n2, 2.0 / n1 / n2, a);
  printf("cdft2d err= %g \n", err);
  putdata2d(n1, n2, a);
  rdft2d(n1, n2, 1, a, ip, w);
  rdft2d(n1, n2, -1, a, ip, w);
  err = errorcheck2d(n1, n2, 2.0 / n1 / n2, a);
  printf("rdft2d err= %g \n", err);
  putdata2d(n1, n2, a);
  ddct2d(n1, n2, 1, a, t, ip, w);
  ddct2d(n1, n2, -1, a, t, ip, w);
  for (i = 0; i <= n1 - 1; i++) {
    a[i][0] *= 0.5;
  }
  for (i = 0; i <= n2 - 1; i++) {
    a[0][i] *= 0.5;
  }
  err = errorcheck2d(n1, n2, 4.0 / n1 / n2, a);
  printf("ddct2d err= %g \n", err);
  putdata2d(n1, n2, a);
  ddst2d(n1, n2, 1, a, t, ip, w);
  ddst2d(n1, n2, -1, a, t, ip, w);
  for (i = 0; i <= n1 - 1; i++) {
    a[i][0] *= 0.5;
  }
  for (i = 0; i <= n2 - 1; i++) {
    a[0][i] *= 0.5;
  }
  err = errorcheck2d(n1, n2, 4.0 / n1 / n2, a);
  printf("ddst2d err= %g \n", err);
  free_1d_double(w);
  free_1d_int(ip);
  free_2d_double(t);
  free_2d_double(a);
  return 0;
}
```