user: Translate the below assembly code into C programming language:

```asm
<write_mesh>:
  endbr64
  push   %r15
  push   %r14
  lea    D33(%rip),%r14
  push   %r13
  push   %r12
  mov    %esi,%r12d
  lea    D19(%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    L49
  lea    -0x1(%r12),%eax
  lea    D38(%rip),%rbp
  lea    (%rax,%rax,2),%rax
  lea    0x18(%rbx,%rax,8),%r12
  cs nopw 0x0(%rax,%rax,1)
L19:
  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    L19
L49:
  mov    0x60(%rsp),%edx
  mov    %r14,%rsi
  mov    %r15,%rdi
  xor    %eax,%eax
  call   <fprintf@plt>
  mov    0x60(%rsp),%ecx
  test   %ecx,%ecx
  jle    L40
  mov    0x60(%rsp),%eax
  mov    0x68(%rsp),%rbx
  lea    D13(%rip),%rbp
  mov    0x70(%rsp),%r13
  sub    $0x1,%eax
  shl    $0x4,%rax
  lea    0x10(%rbx,%rax,1),%r12
  nopl   0x0(%rax)
L53:
  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    L53
L40:
  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    L38
  mov    0x18(%rsp),%rbx
  sub    $0x1,%eax
  mov    0x10(%rsp),%rbp
  lea    D9(%rip),%r12
  lea    0x4(%rbx,%rax,4),%r13
  nopl   (%rax)
L48:
  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    L48
L38:
  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: unpack_data
arguments: label: D33
datatype: string
name: unpack_data
arguments: label: D19
datatype: string
name: unpack_data
arguments: label: D38
datatype: string
name: unpack_data
arguments: label: D13
datatype: string
name: unpack_data
arguments: label: D9
datatype: string

tool: D33: %5d


tool: D19: w

tool: D38: %20.15lf %20.15lf %20.15lf


tool: D13: %4d %4d %4d %4d  %d


tool: D9: %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;
}
```