user: 请将以下的汇编代码转换成C语言代码:

```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     L16
  mov    -0x88(%rbp),%rax
  lea    D36(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <fopen@plt>
  mov    %rax,-0x70(%rbp)
  cmpq   $0x0,-0x70(%rbp)
  jne    L18
  mov    -0x88(%rbp),%rdx
  lea    -0x60(%rbp),%rax
  lea    D62(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <sprintf@plt>
  lea    -0x60(%rbp),%rax
  mov    %rax,%rdx
  lea    D43(%rip),%rax
  mov    %rax,%rsi
  mov    $0xfb,%edi
  call   <errhandler@plt>
  jmp    L18
L16:
  mov    -0x88(%rbp),%rax
  lea    D12(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <fopen@plt>
  mov    %rax,-0x70(%rbp)
  cmpq   $0x0,-0x70(%rbp)
  jne    L18
  mov    -0x88(%rbp),%rdx
  lea    -0x60(%rbp),%rax
  lea    D15(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <sprintf@plt>
  lea    -0x60(%rbp),%rax
  mov    %rax,%rdx
  lea    D43(%rip),%rax
  mov    %rax,%rsi
  mov    $0x107,%edi
  call   <errhandler@plt>
L18:
  mov    -0x9c(%rbp),%eax
  mov    %eax,-0x7c(%rbp)
  jmp    L60
L59:
  mov    -0x94(%rbp),%eax
  mov    %eax,-0x80(%rbp)
  jmp    L23
L55:
  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)
L23:
  mov    -0x80(%rbp),%eax
  cmp    -0x98(%rbp),%eax
  jle    L55
  addl   $0x1,-0x7c(%rbp)
L60:
  mov    -0x7c(%rbp),%eax
  cmp    -0xa0(%rbp),%eax
  jle    L59
  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     L46
  mov    -0x88(%rbp),%rdx
  lea    -0x60(%rbp),%rax
  lea    D65(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <sprintf@plt>
  lea    -0x60(%rbp),%rax
  mov    %rax,%rdx
  lea    D43(%rip),%rax
  mov    %rax,%rsi
  mov    $0x115,%edi
  call   <errhandler@plt>
L46:
  mov    -0x68(%rbp),%rax
  mov    %rax,%rdi
  call   <free@plt>
  nop
  mov    -0x8(%rbp),%rax
  sub    %fs:0x28,%rax
  je     L6
  call   <__stack_chk_fail@plt>
L6:
  leave
  ret
```

tool_calls: name: read_data
arguments: tag: D36
type_infered: string
name: read_data
arguments: tag: D62
type_infered: string
name: read_data
arguments: tag: D43
type_infered: string
name: read_data
arguments: tag: D12
type_infered: string
name: read_data
arguments: tag: D15
type_infered: string
name: read_data
arguments: tag: D65
type_infered: string

tool: D36: w

tool: D62: Outputfile %s cannot be created

tool: D43: /scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/grantathon/computational_fluid_dynamics/refs/heads/master/01_assignment/helper.c

tool: D12: a

tool: D15: Outputfile %s cannot be opened

tool: D65: 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/grantathon/computational_fluid_dynamics/refs/heads/master/01_assignment/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/grantathon/computational_fluid_dynamics/refs/heads/master/01_assignment/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/grantathon/computational_fluid_dynamics/refs/heads/master/01_assignment/helper.c", szBuff);
  };
  free(tmp);
}
```