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

```asm
<write_mesh>:
  endbr64
  push   %r15
  push   %r14
  lea    D49(%rip),%r14
  push   %r13
  push   %r12
  mov    %esi,%r12d
  lea    D0(%rip),%rsi
  push   %rbp
  push   %rbx
  mov    %rdx,%rbx
  sub    $0x28,%rsp
  mov    %ecx,0xc(%rsp)
  mov    %r8,0x10(%rsp)
  mov    %r9,0x18(%rsp)
  call   <fopen@plt>
  mov    %r12d,%edx
  mov    %r14,%rsi
  mov    %rax,%r15
  mov    %rax,%rdi
  xor    %eax,%eax
  call   <fprintf@plt>
  test   %r12d,%r12d
  jle    L9
  lea    -0x1(%r12),%eax
  lea    D34(%rip),%rbp
  lea    (%rax,%rax,2),%rax
  lea    0x18(%rbx,%rax,8),%r12
  cs nopw 0x0(%rax,%rax,1)
L52:
  cvttsd2si (%rbx),%edx
  movsd  0x8(%rbx),%xmm0
  mov    %rbp,%rsi
  mov    %r15,%rdi
  movsd  0x10(%rbx),%xmm1
  mov    $0x2,%eax
  add    $0x18,%rbx
  call   <fprintf@plt>
  cmp    %rbx,%r12
  jne    L52
L9:
  mov    0x60(%rsp),%edx
  mov    %r14,%rsi
  mov    %r15,%rdi
  xor    %eax,%eax
  call   <fprintf@plt>
  mov    0x60(%rsp),%ecx
  test   %ecx,%ecx
  jle    L2
  mov    0x60(%rsp),%eax
  mov    0x68(%rsp),%rbx
  lea    D8(%rip),%rbp
  mov    0x70(%rsp),%r13
  sub    $0x1,%eax
  shl    $0x4,%rax
  lea    0x10(%rbx,%rax,1),%r12
  nopl   0x0(%rax)
L48:
  mov    0x0(%r13),%eax
  sub    $0x8,%rsp
  mov    0xc(%rbx),%r9d
  mov    %rbp,%rsi
  mov    0x8(%rbx),%r8d
  mov    0x4(%rbx),%ecx
  mov    %r15,%rdi
  add    $0x10,%rbx
  push   %rax
  mov    -0x10(%rbx),%edx
  xor    %eax,%eax
  add    $0x4,%r13
  call   <fprintf@plt>
  pop    %rax
  pop    %rdx
  cmp    %rbx,%r12
  jne    L48
L2:
  mov    0xc(%rsp),%ebx
  mov    %r14,%rsi
  mov    %r15,%rdi
  xor    %eax,%eax
  mov    %ebx,%edx
  call   <fprintf@plt>
  mov    %ebx,%eax
  test   %ebx,%ebx
  jle    L49
  mov    0x18(%rsp),%rbx
  sub    $0x1,%eax
  mov    0x10(%rsp),%rbp
  lea    D45(%rip),%r12
  lea    0x4(%rbx,%rax,4),%r13
  nopl   (%rax)
L56:
  mov    0x4(%rbp),%ecx
  mov    (%rbx),%r9d
  mov    %r12,%rsi
  mov    %r15,%rdi
  mov    0x8(%rbp),%r8d
  mov    0x0(%rbp),%edx
  xor    %eax,%eax
  add    $0x4,%rbx
  add    $0xc,%rbp
  call   <fprintf@plt>
  cmp    %r13,%rbx
  jne    L56
L49:
  mov    %r15,%rdi
  call   <fclose@plt>
  add    $0x28,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
```

tool_calls: name: parse_data
arguments: data_tag: D49
type_guessed: string
name: parse_data
arguments: data_tag: D0
type_guessed: string
name: parse_data
arguments: data_tag: D34
type_guessed: string
name: parse_data
arguments: data_tag: D8
type_guessed: string
name: parse_data
arguments: data_tag: D45
type_guessed: string

tool: D49: %5d


tool: D0: w

tool: D34: %20.15lf %20.15lf %20.15lf


tool: D8: %4d %4d %4d %4d  %d


tool: D45: %4d %4d %4d  %d


assistant: ```c
int write_mesh(char *fn, int nV, double *vertex, int nF, int *face, int *facematerial, int nT, int *tetra, int *tetramaterial) {
  int i;
  FILE *f;
  f = fopen(fn, "w");
  fprintf(f, "%5d\n", nV);
  for (i = 0; i < nV; i++) {
    fprintf(f, "%20.15lf %20.15lf %20.15lf\n", vertex[3 * i + 0], vertex[3 * i + 1], vertex[3 * i + 2]);
  }
  fprintf(f, "%5d\n", nT);
  for (i = 0; i < nT; i++) {
    fprintf(f, "%4d %4d %4d %4d  %d\n", tetra[4 * i + 0], tetra[4 * i + 1], tetra[4 * i + 2], tetra[4 * i + 3], tetramaterial[i]);
  }
  fprintf(f, "%5d\n", nF);
  for (i = 0; i < nF; i++) {
    fprintf(f, "%4d %4d %4d  %d\n", face[3 * i + 0], face[3 * i + 1], face[3 * i + 2], facematerial[i]);
  }
  fclose(f);
  return 0;
}
```