user: Translate the below assembly code into C programming language:

```asm
<write_matrix>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0xb0,%rsp
  mov    %rdi,-0x88(%rbp)
  mov    %rsi,-0x90(%rbp)
  mov    %edx,-0x94(%rbp)
  mov    %ecx,-0x98(%rbp)
  mov    %r8d,-0x9c(%rbp)
  mov    %r9d,-0xa0(%rbp)
  movsd  %xmm0,-0xa8(%rbp)
  movsd  %xmm1,-0xb0(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  movq   $0x0,-0x70(%rbp)
  mov    -0x98(%rbp),%eax
  sub    -0x94(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    -0xa0(%rbp),%eax
  sub    -0x9c(%rbp),%eax
  add    $0x1,%eax
  imul   %edx,%eax
  mov    %eax,-0x74(%rbp)
  mov    -0x74(%rbp),%eax
  cltq
  shl    $0x2,%rax
  mov    %rax,%rdi
  call   <malloc@plt>
  mov    %rax,-0x68(%rbp)
  movl   $0x0,-0x78(%rbp)
  cmpl   $0x0,0x10(%rbp)
  je     L26
  mov    -0x88(%rbp),%rax
  lea    D47(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <fopen@plt>
  mov    %rax,-0x70(%rbp)
  cmpq   $0x0,-0x70(%rbp)
  jne    L92
  mov    -0x88(%rbp),%rdx
  lea    -0x60(%rbp),%rax
  lea    D68(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <sprintf@plt>
  lea    -0x60(%rbp),%rax
  mov    %rax,%rdx
  lea    D19(%rip),%rax
  mov    %rax,%rsi
  mov    $0xfb,%edi
  call   <errhandler@plt>
  jmp    L92
L26:
  mov    -0x88(%rbp),%rax
  lea    D18(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <fopen@plt>
  mov    %rax,-0x70(%rbp)
  cmpq   $0x0,-0x70(%rbp)
  jne    L92
  mov    -0x88(%rbp),%rdx
  lea    -0x60(%rbp),%rax
  lea    D74(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <sprintf@plt>
  lea    -0x60(%rbp),%rax
  mov    %rax,%rdx
  lea    D19(%rip),%rax
  mov    %rax,%rsi
  mov    $0x107,%edi
  call   <errhandler@plt>
L92:
  mov    -0x9c(%rbp),%eax
  mov    %eax,-0x7c(%rbp)
  jmp    L37
L53:
  mov    -0x94(%rbp),%eax
  mov    %eax,-0x80(%rbp)
  jmp    L76
L17:
  mov    -0x80(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x90(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rdx
  mov    -0x7c(%rbp),%eax
  cltq
  shl    $0x3,%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm0
  mov    -0x78(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    %edx,-0x78(%rbp)
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x68(%rbp),%rax
  add    %rdx,%rax
  cvtsd2ss %xmm0,%xmm0
  movss  %xmm0,(%rax)
  addl   $0x1,-0x80(%rbp)
L76:
  mov    -0x80(%rbp),%eax
  cmp    -0x98(%rbp),%eax
  jle    L17
  addl   $0x1,-0x7c(%rbp)
L37:
  mov    -0x7c(%rbp),%eax
  cmp    -0xa0(%rbp),%eax
  jle    L53
  mov    -0x70(%rbp),%rcx
  mov    -0x74(%rbp),%edx
  mov    -0x68(%rbp),%rax
  mov    $0x4,%esi
  mov    %rax,%rdi
  call   <fwrite@plt>
  mov    -0x70(%rbp),%rax
  mov    %rax,%rdi
  call   <fclose@plt>
  test   %rax,%rax
  je     L99
  mov    -0x88(%rbp),%rdx
  lea    -0x60(%rbp),%rax
  lea    D21(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <sprintf@plt>
  lea    -0x60(%rbp),%rax
  mov    %rax,%rdx
  lea    D19(%rip),%rax
  mov    %rax,%rsi
  mov    $0x115,%edi
  call   <errhandler@plt>
L99:
  mov    -0x68(%rbp),%rax
  mov    %rax,%rdi
  call   <free@plt>
  nop
  mov    -0x8(%rbp),%rax
  sub    %fs:0x28,%rax
  je     L25
  call   <__stack_chk_fail@plt>
L25:
  leave
  ret
```

tool_calls: name: disassemble_data
arguments: tag: D47
type_guessed: string
name: disassemble_data
arguments: tag: D68
type_guessed: string
name: disassemble_data
arguments: tag: D19
type_guessed: string
name: disassemble_data
arguments: tag: D18
type_guessed: string
name: disassemble_data
arguments: tag: D74
type_guessed: string
name: disassemble_data
arguments: tag: D21
type_guessed: string

tool: D47: w

tool: D68: Outputfile %s cannot be created

tool: D19: /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: D18: a

tool: D74: Outputfile %s cannot be opened

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