user: Please show me the C implementation that matches the assembly code listed below:

```asm
<main>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  lea    -0x3b000(%rsp),%r11
L94:
  sub    $0x1000,%rsp
  orq    $0x0,(%rsp)
  cmp    %r11,%rsp
  jne    L94
  sub    $0xff8,%rsp
  mov    %rsi,%rbx
  mov    %fs:0x28,%rax
  mov    %rax,0x3bfe8(%rsp)
  xor    %eax,%eax
  cmp    $0x2,%edi
  jle    L187
  mov    0x8(%rsi),%rdi
  call   <atoi@plt>
  mov    %eax,%r14d
  mov    %eax,0x40(%rsp)
  mov    0x10(%rbx),%rdi
  call   <atoi@plt>
  mov    %eax,0x44(%rsp)
  or     %eax,%r14d
  js     L140
  cmpl   $0x14,0x40(%rsp)
  jg     L135
  cmpl   $0x14,0x44(%rsp)
  jg     L135
L143:
  mov    0x44(%rsp),%r8d
  mov    0x40(%rsp),%ecx
  mov    $0x15,%edx
  mov    $0x15,%esi
  lea    D86(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  lea    D165(%rip),%rdi
  call   <puts@plt>
  mov    $0xa8,%edi
  call   <malloc@plt>
  mov    %rax,%r14
  mov    $0xdc8,%edi
  call   <malloc@plt>
  mov    %rax,%r15
  lea    D72(%rip),%rdi
  call   <puts@plt>
  mov    %r14,%rdx
  mov    $0x0,%eax
  movsd  D204(%rip),%xmm2
  movsd  D209(%rip),%xmm1
L139:
  pxor   %xmm0,%xmm0
  cvtsi2sd %eax,%xmm0
  mulsd  %xmm2,%xmm0
  subsd  %xmm1,%xmm0
  movsd  %xmm0,(%rdx)
  add    $0x1,%eax
  add    $0x8,%rdx
  cmp    $0x15,%eax
  jne    L139
  mov    $0x0,%eax
  movsd  D99(%rip),%xmm2
  movsd  D209(%rip),%xmm1
L60:
  pxor   %xmm0,%xmm0
  cvtsi2sd %eax,%xmm0
  mulsd  %xmm2,%xmm0
  subsd  %xmm1,%xmm0
  movsd  %xmm0,0x50(%rsp,%rax,8)
  add    $0x1,%rax
  cmp    $0x65,%rax
  jne    L60
  movq   $0x0,(%rsp)
  mov    %r14,0x8(%rsp)
L142:
  mov    (%rsp),%rax
  mov    %eax,%r14d
  mov    0x8(%rsp),%rbp
  lea    0x0(%rbp,%rax,8),%r13
  mov    $0x0,%ebx
L168:
  mov    $0x15,%ecx
  mov    %ebx,%edx
  mov    $0x15,%esi
  mov    %r14d,%edi
  call   <index_2D_to_1D@plt>
  cltq
  lea    (%r15,%rax,8),%r12
  movsd  0x0(%rbp),%xmm1
  movsd  0x0(%r13),%xmm0
  call   <xyn@plt>
  movsd  %xmm0,(%r12)
  add    $0x1,%ebx
  add    $0x8,%rbp
  cmp    $0x15,%ebx
  jne    L168
  addq   $0x1,(%rsp)
  mov    (%rsp),%rax
  cmp    $0x15,%rax
  jne    L142
  mov    0x8(%rsp),%r14
  lea    0x50(%rsp),%r13
  mov    %r13,0x48(%rsp)
  mov    $0x0,%r12d
L42:
  mov    $0x0,%ebp
L91:
  mov    $0x65,%ecx
  mov    %ebp,%edx
  mov    $0x65,%esi
  mov    %r12d,%edi
  call   <index_2D_to_1D@plt>
  mov    %eax,%ebx
  movsd  0x50(%rsp,%rbp,8),%xmm1
  movsd  0x0(%r13),%xmm0
  call   <xyn@plt>
  movslq %ebx,%rbx
  movsd  %xmm0,0x380(%rsp,%rbx,8)
  add    $0x1,%rbp
  cmp    $0x65,%rbp
  jne    L91
  add    $0x1,%r12d
  add    $0x8,%r13
  cmp    $0x65,%r12d
  jne    L42
  lea    D148(%rip),%rdi
  call   <puts@plt>
  mov    0x48(%rsp),%r13
  movl   $0x0,0x3c(%rsp)
  pxor   %xmm5,%xmm5
  movsd  %xmm5,0x18(%rsp)
  movsd  %xmm5,0x20(%rsp)
  movsd  %xmm5,(%rsp)
  movsd  %xmm5,0x10(%rsp)
  movsd  %xmm5,0x8(%rsp)
  mov    %r15,%rax
  mov    %r14,%r15
  mov    %r13,%r14
  mov    %rax,%r13
L112:
  mov    $0x0,%r12d
  mov    %r13,%rbp
L109:
  mov    $0x65,%ecx
  mov    %r12d,%edx
  mov    $0x65,%esi
  mov    0x3c(%rsp),%edi
  call   <index_2D_to_1D@plt>
  mov    %eax,%ebx
  movsd  0x50(%rsp,%r12,8),%xmm1
  movsd  %xmm1,0x28(%rsp)
  movsd  (%r14),%xmm5
  movsd  %xmm5,0x30(%rsp)
  sub    $0x8,%rsp
  push   %rbp
  mov    $0x15,%r9d
  mov    %r15,%r8
  mov    $0x15,%ecx
  mov    %r15,%rdx
  mov    0x54(%rsp),%esi
  mov    0x50(%rsp),%edi
  movapd %xmm5,%xmm0
  call   <lagrange_interp_2Dfo@plt>
  movq   %xmm0,%r13
  movslq %ebx,%rbx
  movsd  %xmm0,0x28130(%rsp,%rbx,8)
  mov    %rbp,%r8
  mov    $0x15,%ecx
  mov    %r15,%rdx
  mov    $0x15,%esi
  mov    %r15,%rdi
  movsd  0x38(%rsp),%xmm1
  movsd  0x40(%rsp),%xmm0
  call   <lagrange_interp_2D@plt>
  movapd %xmm0,%xmm1
  movsd  %xmm0,0x14260(%rsp,%rbx,8)
  movsd  0x390(%rsp,%rbx,8),%xmm2
  movq   %r13,%xmm0
  subsd  %xmm2,%xmm0
  movapd %xmm1,%xmm4
  subsd  %xmm2,%xmm4
  movapd %xmm0,%xmm1
  mulsd  %xmm0,%xmm1
  addsd  0x18(%rsp),%xmm1
  movsd  %xmm1,0x18(%rsp)
  movapd %xmm4,%xmm1
  movsd  %xmm4,0x38(%rsp)
  mulsd  %xmm4,%xmm1
  addsd  0x20(%rsp),%xmm1
  movsd  %xmm1,0x20(%rsp)
  movsd  D209(%rip),%xmm6
  addsd  0x10(%rsp),%xmm6
  movsd  %xmm6,0x10(%rsp)
  movsd  0x28(%rsp),%xmm1
  call   <fmax@plt>
  movsd  %xmm0,0x28(%rsp)
  movsd  0x30(%rsp),%xmm1
  movsd  0x38(%rsp),%xmm0
  call   <fmax@plt>
  movsd  %xmm0,0x30(%rsp)
  add    $0x1,%r12
  add    $0x10,%rsp
  cmp    $0x65,%r12
  jne    L109
  mov    %rbp,%r13
  addl   $0x1,0x3c(%rsp)
  mov    0x3c(%rsp),%eax
  add    $0x8,%r14
  cmp    $0x65,%eax
  jne    L112
  mov    %r15,%r14
  mov    %rbp,%r15
  movsd  0x8(%rsp),%xmm0
  divsd  (%rsp),%xmm0
  call   <sqrt@plt>
  movq   %xmm0,%rbx
  movsd  0x10(%rsp),%xmm0
  divsd  (%rsp),%xmm0
  call   <sqrt@plt>
  movapd %xmm0,%xmm1
  movq   %rbx,%xmm3
  movsd  0x18(%rsp),%xmm2
  movsd  0x20(%rsp),%xmm0
  lea    D123(%rip),%rdi
  mov    $0x4,%eax
  call   <printf@plt>
  lea    D116(%rip),%rdi
  call   <puts@plt>
  lea    D54(%rip),%rbx
  mov    %rbx,%rsi
  lea    D25(%rip),%rdi
  call   <fopen@plt>
  mov    %rax,%r13
  mov    %rax,0x10(%rsp)
  mov    %rbx,%rsi
  lea    D207(%rip),%rdi
  call   <fopen@plt>
  mov    %rax,%rbp
  mov    %rax,0x18(%rsp)
  mov    %r13,%rcx
  mov    $0x14,%edx
  mov    $0x1,%esi
  lea    D20(%rip),%rbx
  mov    %rbx,%rdi
  call   <fwrite@plt>
  mov    %rbp,%rcx
  mov    $0x14,%edx
  mov    $0x1,%esi
  mov    %rbx,%rdi
  call   <fwrite@plt>
  mov    $0x65,%edx
  lea    D13(%rip),%rbx
  mov    %rbx,%rsi
  mov    %r13,%rdi
  mov    $0x0,%eax
  call   <fprintf@plt>
  mov    $0x65,%edx
  mov    %rbx,%rsi
  mov    %rbp,%rdi
  mov    $0x0,%eax
  call   <fprintf@plt>
  mov    $0x0,%r13d
  mov    %r14,0x20(%rsp)
  mov    %r15,0x28(%rsp)
  mov    %r13d,%r14d
  mov    0x48(%rsp),%r13
L100:
  mov    $0x0,%ebp
L113:
  mov    $0x65,%ecx
  mov    %ebp,%edx
  mov    $0x65,%esi
  mov    %r14d,%edi
  call   <index_2D_to_1D@plt>
  movslq %eax,%rbx
  mov    0x380(%rsp,%rbx,8),%r15
  movsd  0x50(%rsp,%rbp,8),%xmm1
  movsd  %xmm1,(%rsp)
  movsd  0x0(%r13),%xmm7
  movsd  %xmm7,0x8(%rsp)
  movsd  0x28120(%rsp,%rbx,8),%xmm3
  movq   %r15,%xmm2
  movapd %xmm7,%xmm0
  mov    %ebp,%ecx
  mov    %r14d,%edx
  lea    D136(%rip),%rsi
  mov    0x18(%rsp),%rdi
  mov    $0x4,%eax
  call   <fprintf@plt>
  movsd  0x14250(%rsp,%rbx,8),%xmm3
  movq   %r15,%xmm2
  movsd  (%rsp),%xmm1
  movsd  0x8(%rsp),%xmm0
  mov    %ebp,%ecx
  mov    %r14d,%edx
  lea    D136(%rip),%rsi
  mov    0x10(%rsp),%rdi
  mov    $0x4,%eax
  call   <fprintf@plt>
  add    $0x1,%rbp
  cmp    $0x65,%rbp
  jne    L113
  add    $0x1,%r14d
  add    $0x8,%r13
  cmp    $0x65,%r14d
  jne    L100
  mov    0x20(%rsp),%r14
  mov    0x28(%rsp),%r15
  mov    0x18(%rsp),%rdi
  call   <fclose@plt>
  mov    0x10(%rsp),%rdi
  call   <fclose@plt>
  mov    %r14,%rdi
  call   <free@plt>
  mov    %r15,%rdi
  call   <free@plt>
  mov    $0x0,%eax
L128:
  mov    0x3bfe8(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L170
  add    $0x3bff8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L187:
  mov    (%rsi),%rsi
  lea    D191(%rip),%rdi
  call   <printf@plt>
  mov    $0x1,%eax
  jmp    L128
L140:
  lea    D144(%rip),%rdi
  call   <puts@plt>
  mov    $0x1,%eax
  jmp    L128
L135:
  mov    $0x14,%esi
  lea    D27(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  jmp    L143
L170:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: parse_data
arguments: data_tag: D86
type: string
name: parse_data
arguments: data_tag: D165
type: string
name: parse_data
arguments: data_tag: D72
type: string
name: parse_data
arguments: data_tag: D204
type: byte[8]
name: parse_data
arguments: data_tag: D209
type: f64
name: parse_data
arguments: data_tag: D99
type: byte[8]
name: parse_data
arguments: data_tag: D148
type: string
name: parse_data
arguments: data_tag: D123
type: string
name: parse_data
arguments: data_tag: D116
type: string
name: parse_data
arguments: data_tag: D54
type: string
name: parse_data
arguments: data_tag: D25
type: string
name: parse_data
arguments: data_tag: D207
type: string
name: parse_data
arguments: data_tag: D20
type: string
name: parse_data
arguments: data_tag: D13
type: string
name: parse_data
arguments: data_tag: D136
type: string
name: parse_data
arguments: data_tag: D191
type: string
name: parse_data
arguments: data_tag: D144
type: string
name: parse_data
arguments: data_tag: D27
type: string

tool: D86: We compare to the analytic function
x^4 - y^4 + 0.5*(x*y)**4
on the domain [-1,1]x[-1,1].
For FULL Lagrange polynomials of order:
	%d in x
	%d in y
and FIXED ORDER Lagrange polynomials of order:
	%d in x
	%d in y


tool: D165: Preparing grids.

tool: D72: Writing to grids.

tool: {"D204": [0x9a,0x99,0x99,0x99,0x99,0x99,0xb9,0x3f]}

tool: D209: 1

tool: {"D99": [0x7b,0x14,0xae,0x47,0xe1,0x7a,0x94,0x3f]}

tool: D148: Interpolating.

tool: D123: 	Max error = %lf
	L2 error = %lf
	Max error fixed order %lf
	L2 error fixed order %lf


tool: D116: Creating output files.

tool: D54: w

tool: D25: test_full.out

tool: D207: test_fo.out

tool: D20: #i	j	x	y	z	z_interp


tool: D13: #NX = NY = %d


tool: D136: %d	%d	%lf	%lf	%lf	%lf


tool: D191: usage %s order_x order_y


tool: D144: Interpolation order must be at least 0

tool: D27: Interpolation order can be no greater than %d


assistant: ```c
int main(int argc, char *argv[]) {
  int iflat;
  int nz_coarse = 21 * 21;
  double *x_coarse;
  double *z_coarse;
  double x_fine[101];
  double z_fine[101 * 101];
  double z_interp_full[101 * 101];
  double z_interp_fo[101 * 101];
  double error_fo, error_full;
  double l2_error_fo = 0.;
  double l2_error_full = 0.;
  double l2_error_denom = 0.;
  double max_error_full = 0.;
  double max_error_fo = 0.;
  if (argc < 3) {
    printf("usage %s order_x order_y\n", argv[0]);
    return 1;
  }
  int order_x = atoi(argv[1]);
  int order_y = atoi(argv[2]);
  if (order_x < 0 || order_y < 0) {
    printf("Interpolation order must be at least 0\n");
    return 1;
  }
  if (order_x >= 21 || order_y >= 21) {
    printf("Interpolation order can be no greater than %d\n", 21 - 1);
  }
  printf("We compare to the analytic function\n"
         "x^4 - y^4 + 0.5*(x*y)**4\n"
         "on the domain [-1,1]x[-1,1].\n"
         "For FULL Lagrange polynomials of order:\n"
         "\t%d in x\n\t%d in y\n"
         "and FIXED ORDER Lagrange polynomials of order:\n"
         "\t%d in x\n\t%d in y\n",
         21, 21, order_x, order_y);
  printf("Preparing grids.\n");
  x_coarse = (double *)malloc(sizeof(double) * 21);
  z_coarse = (double *)malloc(sizeof(double) * nz_coarse);
  printf("Writing to grids.\n");
  for (int i = 0; i < 21; i++) {
    x_coarse[i] = -1.0 + (1.0 - -1.0) / (21 - 1) * i;
  }
  for (int i = 0; i < 101; i++) {
    x_fine[i] = -1.0 + (1.0 - -1.0) / (101 - 1) * i;
  }
  for (int i = 0; i < 21; i++) {
    for (int j = 0; j < 21; j++) {
      iflat = index_2D_to_1D(i, 21, j, 21);
      z_coarse[iflat] = xyn(x_coarse[i], x_coarse[j]);
    }
  }
  for (int i = 0; i < 101; i++) {
    for (int j = 0; j < 101; j++) {
      iflat = index_2D_to_1D(i, 101, j, 101);
      z_fine[iflat] = xyn(x_fine[i], x_fine[j]);
    }
  }
  printf("Interpolating.\n");
  for (int i = 0; i < 101; i++) {
    for (int j = 0; j < 101; j++) {
      iflat = index_2D_to_1D(i, 101, j, 101);
      z_interp_fo[iflat] = lagrange_interp_2Dfo(x_fine[i], x_fine[j], order_x, order_y, x_coarse, 21, x_coarse, 21, z_coarse);
      z_interp_full[iflat] = lagrange_interp_2D(x_fine[i], x_fine[j], x_coarse, 21, x_coarse, 21, z_coarse);
      error_fo = z_interp_fo[iflat] - z_fine[iflat];
      error_full = z_interp_full[iflat] - z_fine[iflat];
      l2_error_fo += error_fo * error_fo;
      l2_error_full += error_full * error_full;
      l2_error_denom += 1. * 1.;
      max_error_fo = fmax(error_fo, max_error_fo);
      max_error_full = fmax(error_full, max_error_full);
    }
  }
  l2_error_fo = sqrt(l2_error_fo / l2_error_denom);
  l2_error_full = sqrt(l2_error_full / l2_error_denom);
  printf("\tMax error = %lf\n\tL2 error = %lf\n"
         "\tMax error fixed order %lf\n"
         "\tL2 error fixed order %lf\n",
         max_error_full, l2_error_full, max_error_fo, l2_error_fo);
  printf("Creating output files.\n");
  FILE *fp_full;
  FILE *fp_fo;
  fp_full = fopen("test_full.out", "w");
  fp_fo = fopen("test_fo.out", "w");
  fprintf(fp_full, "#i\tj\tx\ty\tz\tz_interp\n");
  fprintf(fp_fo, "#i\tj\tx\ty\tz\tz_interp\n");
  fprintf(fp_full, "#NX = NY = %d\n", 101);
  fprintf(fp_fo, "#NX = NY = %d\n", 101);
  for (int i = 0; i < 101; i++) {
    for (int j = 0; j < 101; j++) {
      iflat = index_2D_to_1D(i, 101, j, 101);
      fprintf(fp_fo, "%d\t%d\t%lf\t%lf\t%lf\t%lf\n", i, j, x_fine[i], x_fine[j], z_fine[iflat], z_interp_fo[iflat]);
      fprintf(fp_full, "%d\t%d\t%lf\t%lf\t%lf\t%lf\n", i, j, x_fine[i], x_fine[j], z_fine[iflat], z_interp_full[iflat]);
    }
  }
  fclose(fp_fo);
  fclose(fp_full);
  free(x_coarse);
  free(z_coarse);
  return 0;
}
```