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

```asm
<main>:
  endbr64
  push   %r14
  lea    D20(%rip),%rdi
  push   %r13
  push   %r12
  push   %rbp
  lea    D47(%rip),%rbp
  sub    $0x18,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  call   <puts@plt>
  mov    %rsp,%rsi
  mov    %rbp,%rdi
  call   <scanf@plt>
  lea    D131(%rip),%rdi
  call   <puts@plt>
  lea    0x4(%rsp),%rsi
  mov    %rbp,%rdi
  call   <scanf@plt>
  mov    0x4(%rsp),%esi
  mov    (%rsp),%edi
  call   <alloc_2d_double@plt>
  mov    0x4(%rsp),%esi
  mov    (%rsp),%edi
  mov    %rax,%r14
  call   <alloc_2d_double@plt>
  mov    0x4(%rsp),%edx
  pxor   %xmm0,%xmm0
  movsd  D28(%rip),%xmm1
  mov    %rax,%r13
  mov    %edx,%eax
  shr    $0x1f,%eax
  add    %edx,%eax
  mov    (%rsp),%edx
  sar    %eax
  cmp    %edx,%eax
  cmovl  %edx,%eax
  cvtsi2sd %eax,%xmm0
  addsd  %xmm1,%xmm0
  cvttsd2si %xmm0,%edi
  call   <sqrt@plt>
  lea    0x2(%rax),%edi
  call   <alloc_1d_int@plt>
  mov    (%rsp),%ecx
  mov    %rax,%rbp
  mov    0x4(%rsp),%eax
  mov    %ecx,%edx
  test   %eax,%eax
  lea    0x3(%rax),%edi
  cmovns %eax,%edi
  shr    $0x1f,%edx
  add    %ecx,%edx
  sar    %edx
  sar    $0x2,%edi
  cmp    %edx,%edi
  cmovl  %edx,%edi
  cmp    %ecx,%eax
  cmovl  %ecx,%eax
  add    %eax,%edi
  call   <alloc_1d_double@plt>
  movl   $0x0,0x0(%rbp)
  mov    0x4(%rsp),%esi
  mov    %r14,%rdx
  mov    (%rsp),%edi
  mov    %rax,%r12
  call   <putdata2d@plt>
  mov    0x4(%rsp),%esi
  mov    (%rsp),%edi
  mov    %r12,%r9
  mov    %rbp,%r8
  mov    %r14,%rcx
  mov    $0x1,%edx
  call   <cdft2d@plt>
  mov    0x4(%rsp),%esi
  mov    (%rsp),%edi
  mov    %r12,%r9
  mov    %rbp,%r8
  mov    %r14,%rcx
  mov    $0xffffffff,%edx
  call   <cdft2d@plt>
  mov    (%rsp),%edi
  pxor   %xmm2,%xmm2
  mov    0x4(%rsp),%esi
  movsd  D99(%rip),%xmm0
  mov    %r14,%rdx
  cvtsi2sd %edi,%xmm2
  divsd  %xmm2,%xmm0
  pxor   %xmm2,%xmm2
  cvtsi2sd %esi,%xmm2
  divsd  %xmm2,%xmm0
  call   <errorcheck2d@plt>
  lea    D30(%rip),%rdi
  mov    $0x1,%eax
  call   <printf@plt>
  mov    0x4(%rsp),%esi
  mov    (%rsp),%edi
  mov    %r14,%rdx
  call   <putdata2d@plt>
  mov    0x4(%rsp),%esi
  mov    (%rsp),%edi
  mov    %r12,%r9
  mov    %rbp,%r8
  mov    %r14,%rcx
  mov    $0x1,%edx
  call   <rdft2d@plt>
  mov    0x4(%rsp),%esi
  mov    (%rsp),%edi
  mov    %r12,%r9
  mov    %rbp,%r8
  mov    %r14,%rcx
  mov    $0xffffffff,%edx
  call   <rdft2d@plt>
  mov    (%rsp),%edi
  pxor   %xmm2,%xmm2
  mov    0x4(%rsp),%esi
  movsd  D99(%rip),%xmm0
  mov    %r14,%rdx
  cvtsi2sd %edi,%xmm2
  divsd  %xmm2,%xmm0
  pxor   %xmm2,%xmm2
  cvtsi2sd %esi,%xmm2
  divsd  %xmm2,%xmm0
  call   <errorcheck2d@plt>
  lea    D15(%rip),%rdi
  mov    $0x1,%eax
  call   <printf@plt>
  mov    0x4(%rsp),%esi
  mov    (%rsp),%edi
  mov    %r14,%rdx
  call   <putdata2d@plt>
  sub    $0x8,%rsp
  mov    %rbp,%r9
  mov    %r13,%r8
  push   %r12
  mov    0x14(%rsp),%esi
  mov    %r14,%rcx
  mov    $0x1,%edx
  mov    0x10(%rsp),%edi
  call   <ddct2d@plt>
  mov    0x10(%rsp),%edi
  mov    0x14(%rsp),%esi
  mov    %r14,%rcx
  mov    %rbp,%r9
  mov    %r13,%r8
  mov    $0xffffffff,%edx
  mov    %r12,(%rsp)
  call   <ddct2d@plt>
  mov    0x10(%rsp),%edi
  mov    D28(%rip),%rax
  pop    %rcx
  pop    %rsi
  test   %edi,%edi
  movq   %rax,%xmm1
  jle    L57
  mov    %edi,%edx
  mov    %r14,%rax
  lea    (%r14,%rdx,8),%rcx
  nopl   0x0(%rax,%rax,1)
L22:
  mov    (%rax),%rdx
  add    $0x8,%rax
  movsd  (%rdx),%xmm0
  mulsd  %xmm1,%xmm0
  movsd  %xmm0,(%rdx)
  cmp    %rcx,%rax
  jne    L22
L57:
  mov    0x4(%rsp),%esi
  test   %esi,%esi
  jle    L67
  mov    (%r14),%rax
  mov    %esi,%edx
  lea    (%rax,%rdx,8),%rdx
  nopl   0x0(%rax)
L15:
  movsd  (%rax),%xmm0
  add    $0x8,%rax
  mulsd  %xmm1,%xmm0
  movsd  %xmm0,-0x8(%rax)
  cmp    %rdx,%rax
  jne    L15
L67:
  pxor   %xmm2,%xmm2
  movsd  D137(%rip),%xmm0
  mov    %r14,%rdx
  cvtsi2sd %edi,%xmm2
  divsd  %xmm2,%xmm0
  pxor   %xmm2,%xmm2
  cvtsi2sd %esi,%xmm2
  divsd  %xmm2,%xmm0
  call   <errorcheck2d@plt>
  lea    D83(%rip),%rdi
  mov    $0x1,%eax
  call   <printf@plt>
  mov    0x4(%rsp),%esi
  mov    (%rsp),%edi
  mov    %r14,%rdx
  call   <putdata2d@plt>
  sub    $0x8,%rsp
  mov    %rbp,%r9
  mov    %r13,%r8
  push   %r12
  mov    0x14(%rsp),%esi
  mov    %r14,%rcx
  mov    $0x1,%edx
  mov    0x10(%rsp),%edi
  call   <ddst2d@plt>
  mov    0x10(%rsp),%edi
  mov    0x14(%rsp),%esi
  mov    %rbp,%r9
  mov    $0xffffffff,%edx
  mov    %r13,%r8
  mov    %r14,%rcx
  mov    %r12,(%rsp)
  call   <ddst2d@plt>
  mov    0x10(%rsp),%edi
  pop    %rax
  mov    D28(%rip),%rax
  pop    %rdx
  test   %edi,%edi
  movq   %rax,%xmm1
  jle    L26
  mov    %edi,%edx
  mov    %r14,%rax
  lea    (%r14,%rdx,8),%rcx
  nopl   (%rax)
L88:
  mov    (%rax),%rdx
  add    $0x8,%rax
  movsd  (%rdx),%xmm0
  mulsd  %xmm1,%xmm0
  movsd  %xmm0,(%rdx)
  cmp    %rax,%rcx
  jne    L88
L26:
  mov    0x4(%rsp),%esi
  test   %esi,%esi
  jle    L17
  mov    (%r14),%rax
  mov    %esi,%edx
  lea    (%rax,%rdx,8),%rdx
  nopl   0x0(%rax)
L64:
  movsd  (%rax),%xmm0
  add    $0x8,%rax
  mulsd  %xmm1,%xmm0
  movsd  %xmm0,-0x8(%rax)
  cmp    %rax,%rdx
  jne    L64
L17:
  pxor   %xmm1,%xmm1
  movsd  D137(%rip),%xmm0
  mov    %r14,%rdx
  cvtsi2sd %edi,%xmm1
  divsd  %xmm1,%xmm0
  pxor   %xmm1,%xmm1
  cvtsi2sd %esi,%xmm1
  divsd  %xmm1,%xmm0
  call   <errorcheck2d@plt>
  lea    D29(%rip),%rdi
  mov    $0x1,%eax
  call   <printf@plt>
  mov    %r12,%rdi
  call   <free_1d_double@plt>
  mov    %rbp,%rdi
  call   <free_1d_int@plt>
  mov    %r13,%rdi
  call   <free_2d_double@plt>
  mov    %r14,%rdi
  call   <free_2d_double@plt>
  mov    0x8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L63
  add    $0x18,%rsp
  xor    %eax,%eax
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
L63:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: retrieve_data
arguments: tag: D20
type_infered: string
name: retrieve_data
arguments: tag: D47
type_infered: string
name: retrieve_data
arguments: tag: D131
type_infered: string
name: retrieve_data
arguments: tag: D28
type_infered: f64
name: retrieve_data
arguments: tag: D99
type_infered: f64
name: retrieve_data
arguments: tag: D30
type_infered: string
name: retrieve_data
arguments: tag: D15
type_infered: string
name: retrieve_data
arguments: tag: D137
type_infered: f64
name: retrieve_data
arguments: tag: D83
type_infered: string
name: retrieve_data
arguments: tag: D29
type_infered: string

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

tool: D47: %d

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

tool: D28: 0.5

tool: D99: 2

tool: D30: cdft2d err= %g 


tool: D15: rdft2d err= %g 


tool: D137: 4

tool: D83: ddct2d err= %g 


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