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

```asm
<write_imatrix2>:
  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    D42(%rip),%rsi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <sprintf@plt>
  lea    -0xb0(%rbp),%rax
  lea    D73(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <fopen@plt>
  mov    %rax,-0xb8(%rbp)
  cmpq   $0x0,-0xb8(%rbp)
  jne    L41
  lea    -0xb0(%rbp),%rdx
  lea    -0x60(%rbp),%rax
  lea    D54(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <sprintf@plt>
  lea    -0x60(%rbp),%rax
  mov    %rax,%rdx
  lea    D67(%rip),%rax
  mov    %rax,%rsi
  mov    $0x328,%edi
  call   <errhandler@plt>
L41:
  mov    0x18(%rbp),%eax
  mov    %eax,-0xbc(%rbp)
  jmp    L68
L45:
  mov    -0xf0(%rbp),%eax
  mov    %eax,-0xc0(%rbp)
  jmp    L46
L77:
  mov    -0xe0(%rbp),%eax
  mov    %eax,-0xc4(%rbp)
  jmp    L1
L59:
  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    $0x2,%rax
  add    %rdx,%rax
  mov    (%rax),%edx
  mov    -0xb8(%rbp),%rax
  lea    D19(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <fprintf@plt>
  addl   $0x1,-0xc4(%rbp)
L1:
  mov    -0xc4(%rbp),%eax
  cmp    -0xec(%rbp),%eax
  jle    L59
  mov    -0xb8(%rbp),%rax
  mov    %rax,%rsi
  mov    $0xa,%edi
  call   <fputc@plt>
  addl   $0x1,-0xc0(%rbp)
L46:
  mov    -0xc0(%rbp),%eax
  cmp    0x10(%rbp),%eax
  jle    L77
  mov    -0xb8(%rbp),%rax
  mov    %rax,%rcx
  mov    $0x3c,%edx
  mov    $0x1,%esi
  lea    D37(%rip),%rax
  mov    %rax,%rdi
  call   <fwrite@plt>
  addl   $0x1,-0xbc(%rbp)
L68:
  mov    -0xbc(%rbp),%eax
  cmp    0x20(%rbp),%eax
  jle    L45
  mov    -0xb8(%rbp),%rax
  mov    %rax,%rdi
  call   <fclose@plt>
  test   %rax,%rax
  je     L8
  lea    -0xb0(%rbp),%rdx
  lea    -0x60(%rbp),%rax
  lea    D31(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <sprintf@plt>
  lea    -0x60(%rbp),%rax
  mov    %rax,%rdx
  lea    D67(%rip),%rax
  mov    %rax,%rsi
  mov    $0x33b,%edi
  call   <errhandler@plt>
L8:
  nop
  mov    -0x8(%rbp),%rax
  sub    %fs:0x28,%rax
  je     L82
  call   <__stack_chk_fail@plt>
L82:
  leave
  ret
```

tool_calls: name: unpack_data
arguments: data_tag: D42
type_guessed: string
name: unpack_data
arguments: data_tag: D73
type_guessed: string
name: unpack_data
arguments: data_tag: D54
type_guessed: string
name: unpack_data
arguments: data_tag: D67
type_guessed: string
name: unpack_data
arguments: data_tag: D19
type_guessed: string
name: unpack_data
arguments: data_tag: D37
type_guessed: string
name: unpack_data
arguments: data_tag: D31
type_guessed: string

tool: D42: /media/norbert/940CB6150CB5F27A/Documents/simulation/debug/d%i_%s

tool: D73: w

tool: D54: Outputfile %s cannot be created

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

tool: D19: %d 

tool: D37: -----------------------------------------------------------


tool: D31: Outputfile %s cannot be closed

assistant: ```c
void write_imatrix2(const char *szDebug, int timeStepNumber, int ***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, "/media/norbert/940CB6150CB5F27A/Documents/simulation/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(808, "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/EvaBr/CFD-Lab/refs/heads/master/Backup/FinalProject/helper.c", szBuff);
  }
  for (k = nll; k <= nlh; k++) {
    for (j = ncl; j <= nch; j++) {
      for (i = nrl; i <= nrh; i++) {
        fprintf(fh, "%d ", 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(827, "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/EvaBr/CFD-Lab/refs/heads/master/Backup/FinalProject/helper.c", szBuff);
  };
}
```