user: Demonstrate the C code that generates the assembly output below:

```asm
<write_matrix>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x88,%rsp
  mov    %rdi,0x8(%rsp)
  mov    %rsi,(%rsp)
  mov    %edx,%ebp
  mov    %ecx,%r12d
  mov    %r8d,%r14d
  mov    %r9d,%r13d
  mov    %fs:0x28,%rax
  mov    %rax,0x78(%rsp)
  xor    %eax,%eax
  mov    %ecx,%edx
  sub    %ebp,%edx
  add    $0x1,%edx
  mov    %r9d,%eax
  sub    %r8d,%eax
  add    $0x1,%eax
  imul   %eax,%edx
  mov    %edx,%r15d
  movslq %edx,%rdi
  shl    $0x2,%rdi
  call   <malloc@plt>
  mov    %rax,%rbx
  cmpl   $0x0,0xc0(%rsp)
  je     L34
  lea    D28(%rip),%rsi
  mov    0x8(%rsp),%rdi
  call   <fopen@plt>
  mov    %rax,0x10(%rsp)
  test   %rax,%rax
  je     L25
L26:
  cmp    %r14d,%r13d
  jl     L72
  movslq %r14d,%rax
  lea    0x0(,%rax,8),%rcx
  sub    %r14d,%r13d
  lea    0x1(%rax,%r13,1),%r9
  shl    $0x3,%r9
  mov    %rbx,%rdx
  neg    %rdx
  movslq %ebp,%rax
  shl    $0x3,%rax
  lea    (%rax,%rdx,2),%r13
  mov    $0x0,%r8d
  mov    %r12d,%eax
  sub    %ebp,%eax
  mov    %eax,%r11d
  lea    0x4(%rbx),%r10
  lea    0x1(%rax),%r14d
  jmp    L112
L25:
  lea    0x20(%rsp),%rax
  mov    0x8(%rsp),%rdx
  lea    D63(%rip),%rsi
  mov    %rax,0x18(%rsp)
  mov    %rax,%rdi
  call   <sprintf@plt>
  mov    0x18(%rsp),%rdx
  lea    D14(%rip),%rsi
  mov    $0xfb,%edi
  call   <errhandler@plt>
  jmp    L26
L34:
  lea    D58(%rip),%rsi
  mov    0x8(%rsp),%rdi
  call   <fopen@plt>
  mov    %rax,0x10(%rsp)
  test   %rax,%rax
  jne    L26
  lea    0x20(%rsp),%rax
  mov    0x8(%rsp),%rdx
  lea    D2(%rip),%rsi
  mov    %rax,0x18(%rsp)
  mov    %rax,%rdi
  call   <sprintf@plt>
  mov    0x18(%rsp),%rdx
  lea    D14(%rip),%rsi
  mov    $0x107,%edi
  call   <errhandler@plt>
  jmp    L26
L85:
  movslq %r8d,%rdx
  lea    (%rbx,%rdx,4),%rax
  lea    (%r11,%rdx,1),%rsi
  lea    (%r10,%rsi,4),%rdi
  neg    %rdx
  lea    0x0(%r13,%rdx,8),%rsi
  add    (%rsp),%rsi
L56:
  mov    (%rsi,%rax,2),%rdx
  pxor   %xmm0,%xmm0
  cvtsd2ss (%rdx,%rcx,1),%xmm0
  movss  %xmm0,(%rax)
  add    $0x4,%rax
  cmp    %rdi,%rax
  jne    L56
  add    %r14d,%r8d
L14:
  add    $0x8,%rcx
  cmp    %r9,%rcx
  je     L72
L112:
  cmp    %ebp,%r12d
  jge    L85
  jmp    L14
L72:
  mov    0x10(%rsp),%r14
  mov    %r14,%rcx
  mov    %r15d,%edx
  mov    $0x4,%esi
  mov    %rbx,%rdi
  call   <fwrite@plt>
  mov    %r14,%rdi
  call   <fclose@plt>
  test   %rax,%rax
  jne    L20
L98:
  mov    %rbx,%rdi
  call   <free@plt>
  mov    0x78(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L115
  add    $0x88,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L20:
  lea    0x20(%rsp),%rbp
  mov    0x8(%rsp),%rdx
  lea    D64(%rip),%rsi
  mov    %rbp,%rdi
  call   <sprintf@plt>
  mov    %rbp,%rdx
  lea    D14(%rip),%rsi
  mov    $0x115,%edi
  call   <errhandler@plt>
  jmp    L98
L115:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: retrieve_data
arguments: data_tag: D28
datatype: string
name: retrieve_data
arguments: data_tag: D63
datatype: string
name: retrieve_data
arguments: data_tag: D14
datatype: string
name: retrieve_data
arguments: data_tag: D58
datatype: string
name: retrieve_data
arguments: data_tag: D2
datatype: string
name: retrieve_data
arguments: data_tag: D64
datatype: string

tool: D28: w

tool: D63: Outputfile %s cannot be created

tool: D14: /scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/nathanwbrei/cfdlab/refs/heads/master/worksheet1/helper.c

tool: D58: a

tool: D2: Outputfile %s cannot be opened

tool: D64: Outputfile %s cannot be closed

assistant: ```c
void write_matrix(const char *szFileName, double **m, int nrl, int nrh, int ncl, int nch, double xlength, double ylength, int fFirst) {
  int i, j;
  FILE *fh = 0;
  int nSize = (nrh - nrl + 1) * (nch - ncl + 1);
  float *tmp = (float *)malloc((size_t)(nSize * sizeof(float)));
  int k = 0;
  if (fFirst) {
    fh = fopen(szFileName, "w");
    if (fh == NULL) {
      char szBuff[80];
      sprintf(szBuff, "Outputfile %s cannot be created", szFileName);
      errhandler(251, "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/nathanwbrei/cfdlab/refs/heads/master/worksheet1/helper.c", szBuff);
    }
  } else {
    fh = fopen(szFileName, "a");
    if (fh == NULL) {
      char szBuff[80];
      sprintf(szBuff, "Outputfile %s cannot be opened", szFileName);
      errhandler(263, "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/nathanwbrei/cfdlab/refs/heads/master/worksheet1/helper.c", szBuff);
    }
  }
  for (j = ncl; j <= nch; j++)
    for (i = nrl; i <= nrh; i++)
      tmp[k++] = (float)m[i][j];
  fwrite(tmp, sizeof(float), nSize, fh);
  if (fclose(fh)) {
    char szBuff[80];
    sprintf(szBuff, "Outputfile %s cannot be closed", szFileName);
    errhandler(277, "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/nathanwbrei/cfdlab/refs/heads/master/worksheet1/helper.c", szBuff);
  };
  free(tmp);
}
```