user: 请将这段汇编代码片段转换成等效的C代码:

```asm
<write_matrix2>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0xf0,%rsp
  mov    %rdi,-0xd8(%rbp)
  mov    %esi,-0xdc(%rbp)
  mov    %rdx,-0xe8(%rbp)
  mov    %ecx,-0xe0(%rbp)
  mov    %r8d,-0xec(%rbp)
  mov    %r9d,-0xf0(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  movq   $0x0,-0xb8(%rbp)
  mov    -0xd8(%rbp),%rcx
  mov    -0xdc(%rbp),%edx
  lea    -0xb0(%rbp),%rax
  lea    D28(%rip),%rsi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <sprintf@plt>
  lea    -0xb0(%rbp),%rax
  lea    D38(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <fopen@plt>
  mov    %rax,-0xb8(%rbp)
  cmpq   $0x0,-0xb8(%rbp)
  jne    L44
  lea    -0xb0(%rbp),%rdx
  lea    -0x60(%rbp),%rax
  lea    D50(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <sprintf@plt>
  lea    -0x60(%rbp),%rax
  mov    %rax,%rdx
  lea    D48(%rip),%rax
  mov    %rax,%rsi
  mov    $0x149,%edi
  call   <errhandler@plt>
L44:
  mov    0x18(%rbp),%eax
  mov    %eax,-0xbc(%rbp)
  jmp    L0
L13:
  mov    -0xf0(%rbp),%eax
  mov    %eax,-0xc0(%rbp)
  jmp    L38
L25:
  mov    -0xe0(%rbp),%eax
  mov    %eax,-0xc4(%rbp)
  jmp    L87
L10:
  mov    -0xc4(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0xe8(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rdx
  mov    -0xc0(%rbp),%eax
  cltq
  shl    $0x3,%rax
  add    %rdx,%rax
  mov    (%rax),%rdx
  mov    -0xbc(%rbp),%eax
  cltq
  shl    $0x3,%rax
  add    %rdx,%rax
  mov    (%rax),%rdx
  mov    -0xb8(%rbp),%rax
  movq   %rdx,%xmm0
  lea    D56(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  mov    $0x1,%eax
  call   <fprintf@plt>
  addl   $0x1,-0xc4(%rbp)
L87:
  mov    -0xc4(%rbp),%eax
  cmp    -0xec(%rbp),%eax
  jle    L10
  mov    -0xb8(%rbp),%rax
  mov    %rax,%rsi
  mov    $0xa,%edi
  call   <fputc@plt>
  addl   $0x1,-0xc0(%rbp)
L38:
  mov    -0xc0(%rbp),%eax
  cmp    0x10(%rbp),%eax
  jle    L25
  mov    -0xb8(%rbp),%rax
  mov    %rax,%rcx
  mov    $0x3c,%edx
  mov    $0x1,%esi
  lea    D16(%rip),%rax
  mov    %rax,%rdi
  call   <fwrite@plt>
  addl   $0x1,-0xbc(%rbp)
L0:
  mov    -0xbc(%rbp),%eax
  cmp    0x20(%rbp),%eax
  jle    L13
  mov    -0xb8(%rbp),%rax
  mov    %rax,%rdi
  call   <fclose@plt>
  test   %rax,%rax
  je     L40
  lea    -0xb0(%rbp),%rdx
  lea    -0x60(%rbp),%rax
  lea    D51(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <sprintf@plt>
  lea    -0x60(%rbp),%rax
  mov    %rax,%rdx
  lea    D48(%rip),%rax
  mov    %rax,%rsi
  mov    $0x15c,%edi
  call   <errhandler@plt>
L40:
  nop
  mov    -0x8(%rbp),%rax
  sub    %fs:0x28,%rax
  je     L42
  call   <__stack_chk_fail@plt>
L42:
  leave
  ret
```

tool_calls: name: read_data
arguments: data_tag: D28
type_guessed: string
name: read_data
arguments: data_tag: D38
type_guessed: string
name: read_data
arguments: data_tag: D50
type_guessed: string
name: read_data
arguments: data_tag: D48
type_guessed: string
name: read_data
arguments: data_tag: D56
type_guessed: string
name: read_data
arguments: data_tag: D16
type_guessed: string
name: read_data
arguments: data_tag: D51
type_guessed: string

tool: D28: debug/d%i_%s

tool: D38: w

tool: D50: Outputfile %s cannot be created

tool: D48: /scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/EvaBr/CFD-Lab/refs/heads/master/Backup/FinalProjectBackup/helper.c

tool: D56: %f 

tool: D16: -----------------------------------------------------------


tool: D51: Outputfile %s cannot be closed

assistant: ```c
void write_matrix2(const char *szDebug, int timeStepNumber, double ***m, int nrl, int nrh, int ncl, int nch, int nll, int nlh) {
  int i, j, k;
  FILE *fh = 0;
  char szFileName[80];
  sprintf(szFileName, "debug/d%i_%s", timeStepNumber, szDebug);
  fh = fopen(szFileName, "w");
  if (fh == NULL) {
    char szBuff[80];
    sprintf(szBuff, "Outputfile %s cannot be created", szFileName);
    errhandler(329, "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/EvaBr/CFD-Lab/refs/heads/master/Backup/FinalProjectBackup/helper.c", szBuff);
  }
  for (k = nll; k <= nlh; k++) {
    for (j = ncl; j <= nch; j++) {
      for (i = nrl; i <= nrh; i++) {
        fprintf(fh, "%f ", m[i][j][k]);
      }
      fprintf(fh, "\n");
    }
    fprintf(fh, "-----------------------------------------------------------\n");
  }
  if (fclose(fh)) {
    char szBuff[80];
    sprintf(szBuff, "Outputfile %s cannot be closed", szFileName);
    errhandler(348, "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/EvaBr/CFD-Lab/refs/heads/master/Backup/FinalProjectBackup/helper.c", szBuff);
  };
}
```