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

```asm
<write_matrix>:
  endbr64
  push   %r15
  push   %r14
  mov    %r8d,%r14d
  push   %r13
  mov    %r9d,%r13d
  push   %r12
  push   %rbp
  mov    %rsi,%rbp
  push   %rbx
  mov    %edx,%ebx
  sub    $0x88,%rsp
  mov    0xc0(%rsp),%edx
  mov    %rdi,(%rsp)
  mov    %ecx,0x14(%rsp)
  sub    %ebx,%ecx
  mov    %edx,0x8(%rsp)
  mov    %ecx,%r12d
  add    $0x1,%r12d
  mov    %fs:0x28,%rax
  mov    %rax,0x78(%rsp)
  xor    %eax,%eax
  mov    %r9d,%eax
  sub    %r8d,%eax
  add    $0x1,%eax
  imul   %eax,%r12d
  movslq %r12d,%rdi
  shl    $0x2,%rdi
  call   <malloc@plt>
  mov    0x8(%rsp),%edx
  mov    %rax,%r15
  test   %edx,%edx
  je     L91
  mov    (%rsp),%rdi
  lea    D19(%rip),%rsi
  call   <fopen@plt>
  mov    %rax,%r8
  test   %rax,%rax
  je     L38
L7:
  cmp    %r14d,%r13d
  jl     L89
  mov    0x14(%rsp),%esi
  cmp    %ebx,%esi
  jl     L89
  movslq %r14d,%rax
  sub    %r14d,%r13d
  movslq %ebx,%rdx
  xor    %r9d,%r9d
  lea    0x1(%rax,%r13,1),%r11
  lea    0x0(,%rax,8),%rcx
  mov    %r15,%rax
  neg    %rax
  shl    $0x3,%r11
  lea    0x4(%r15),%r13
  add    %rax,%rax
  lea    (%rax,%rdx,8),%r14
  mov    %esi,%eax
  sub    %ebx,%eax
  mov    %eax,%ebx
  lea    0x1(%rax),%r10d
  nopl   (%rax)
L67:
  movslq %r9d,%rdx
  lea    (%rbx,%rdx,1),%rsi
  lea    (%r15,%rdx,4),%rax
  neg    %rdx
  lea    (%r14,%rdx,8),%rdx
  lea    0x0(%r13,%rsi,4),%rsi
  add    %rbp,%rdx
  nopw   0x0(%rax,%rax,1)
L84:
  mov    (%rdx,%rax,2),%rdi
  pxor   %xmm0,%xmm0
  add    $0x4,%rax
  cvtsd2ss (%rdi,%rcx,1),%xmm0
  movss  %xmm0,-0x4(%rax)
  cmp    %rax,%rsi
  jne    L84
  add    $0x8,%rcx
  add    %r10d,%r9d
  cmp    %r11,%rcx
  jne    L67
L89:
  mov    %r15,%rdi
  mov    %r8,%rcx
  mov    %r12d,%edx
  mov    $0x4,%esi
  mov    %r8,0x8(%rsp)
  call   <fwrite@plt>
  mov    0x8(%rsp),%rdi
  call   <fclose@plt>
  test   %rax,%rax
  jne    L49
L34:
  mov    0x78(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L56
  add    $0x88,%rsp
  mov    %r15,%rdi
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  jmp    10c0 <free@plt>
L91:
  mov    (%rsp),%rdi
  lea    D33(%rip),%rsi
  call   <fopen@plt>
  mov    %rax,%r8
  test   %rax,%rax
  jne    L7
  lea    0x20(%rsp),%r9
  mov    (%rsp),%rdx
  mov    %rax,0x18(%rsp)
  lea    D31(%rip),%rsi
  mov    %r9,%rdi
  mov    %r9,0x8(%rsp)
  call   <sprintf@plt>
  mov    0x8(%rsp),%rdx
  mov    $0x107,%edi
  lea    D9(%rip),%rsi
  call   <errhandler@plt>
  mov    0x18(%rsp),%r8
  jmp    L7
L49:
  mov    (%rsp),%rdx
  lea    0x20(%rsp),%r12
  lea    D16(%rip),%rsi
  mov    %r12,%rdi
  call   <sprintf@plt>
  mov    %r12,%rdx
  mov    $0x115,%edi
  lea    D9(%rip),%rsi
  call   <errhandler@plt>
  jmp    L34
L38:
  lea    0x20(%rsp),%r9
  mov    (%rsp),%rdx
  mov    %rax,0x18(%rsp)
  lea    D2(%rip),%rsi
  mov    %r9,%rdi
  mov    %r9,0x8(%rsp)
  call   <sprintf@plt>
  mov    0x8(%rsp),%rdx
  mov    $0xfb,%edi
  lea    D9(%rip),%rsi
  call   <errhandler@plt>
  mov    0x18(%rsp),%r8
  jmp    L7
L56:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: read_data
arguments: tag: D19
datatype: string
name: read_data
arguments: tag: D33
datatype: string
name: read_data
arguments: tag: D31
datatype: string
name: read_data
arguments: tag: D9
datatype: string
name: read_data
arguments: tag: D16
datatype: string
name: read_data
arguments: tag: D2
datatype: string

tool: D19: w

tool: D33: a

tool: D31: Outputfile %s cannot be opened

tool: D9: /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: D16: Outputfile %s cannot be closed

tool: D2: Outputfile %s cannot be created

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