user: Converte this assembly snippet into its equivalent C code:

```asm
<dump_velocity_c>:
  endbr64
  push   %r15
  mov    %rsi,%r15
  push   %r14
  mov    %rdi,%r14
  push   %r13
  push   %r12
  lea    D111(%rip),%r12
  push   %rbp
  push   %rbx
  mov    %edx,%ebx
  lea    D25(%rip),%rdx
  sub    $0x228,%rsp
  mov    %ecx,(%rsp)
  mov    %rdi,%rcx
  lea    0x110(%rsp),%r13
  lea    0x10(%rsp),%rbp
  mov    %r8d,0x4(%rsp)
  mov    %r13,%rdi
  mov    %rsi,%r8
  mov    $0x100,%esi
  mov    %r9,0x8(%rsp)
  mov    %fs:0x28,%rax
  mov    %rax,0x218(%rsp)
  xor    %eax,%eax
  call   <snprintf@plt>
  mov    %r12,%rsi
  mov    %r13,%rdi
  call   <fopen@plt>
  mov    %r13,%rcx
  lea    D80(%rip),%rdx
  test   %rax,%rax
  je     L68
  mov    %rax,%rbp
  mov    %r15,%rcx
  lea    D123(%rip),%rdx
  mov    %r13,%rdi
  mov    $0x100,%esi
  xor    %eax,%eax
  call   <snprintf@plt>
  mov    %rbp,%rcx
  mov    $0x13,%edx
  mov    $0x1,%esi
  lea    D101(%rip),%rdi
  call   <fwrite@plt>
  mov    %r13,%rdx
  mov    %rbp,%rdi
  xor    %eax,%eax
  lea    D39(%rip),%rsi
  call   <fprintf@plt>
  mov    0x4(%rsp),%r8d
  mov    (%rsp),%ecx
  mov    %ebx,%edx
  lea    D42(%rip),%rsi
  mov    %rbp,%rdi
  xor    %eax,%eax
  call   <fprintf@plt>
  mov    %rbp,%rcx
  mov    $0x13,%edx
  mov    $0x1,%esi
  lea    D58(%rip),%rdi
  call   <fwrite@plt>
  mov    %rbp,%rcx
  mov    $0x14,%edx
  mov    $0x1,%esi
  lea    D82(%rip),%rdi
  call   <fwrite@plt>
  mov    %rbp,%rcx
  mov    $0x14,%edx
  mov    $0x1,%esi
  lea    D66(%rip),%rdi
  call   <fwrite@plt>
  mov    %rbp,%rdi
  call   <fclose@plt>
  mov    %r15,%r8
  mov    %r14,%rcx
  mov    $0x100,%esi
  lea    D121(%rip),%rdx
  mov    %r13,%rdi
  xor    %eax,%eax
  call   <snprintf@plt>
  mov    %r12,%rsi
  mov    %r13,%rdi
  call   <fopen@plt>
  mov    %rax,%r12
  test   %rax,%rax
  je     L61
  imul   (%rsp),%ebx
  imul   0x4(%rsp),%ebx
  lea    (%rbx,%rbx,2),%r13d
  lea    0x0(,%r13,8),%edi
  call   <malloc@plt>
  mov    %rax,%rbp
  test   %rax,%rax
  je     L50
  test   %r13d,%r13d
  jle    L10
  mov    %r13d,%edx
  mov    0x8(%rsp),%rbx
  lea    (%rax,%rdx,8),%rcx
  mov    %rax,%rdx
  neg    %rdx
  lea    (%rbx,%rdx,2),%rdx
  nopl   0x0(%rax)
L72:
  movsd  (%rdx,%rax,2),%xmm0
  add    $0x8,%rax
  movsd  %xmm0,-0x8(%rax)
  cmp    %rcx,%rax
  jne    L72
L10:
  mov    %r12,%rcx
  mov    %r13d,%edx
  mov    $0x8,%esi
  mov    %rbp,%rdi
  call   <fwrite@plt>
  mov    %rbp,%rdi
  call   <free@plt>
  mov    %r12,%rdi
  call   <fclose@plt>
L28:
  mov    0x218(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L55
  add    $0x228,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax,%rax,1)
L61:
  lea    0x10(%rsp),%rbp
  mov    %r13,%rcx
  lea    D3(%rip),%rdx
L68:
  mov    %rbp,%rdi
  mov    $0x100,%esi
  xor    %eax,%eax
  call   <snprintf@plt>
  mov    %rbp,%rdi
  call   <perror@plt>
  jmp    L28
L50:
  lea    0x10(%rsp),%rbp
  lea    D47(%rip),%rdx
  mov    $0x100,%esi
  xor    %eax,%eax
  mov    %rbp,%rdi
  call   <snprintf@plt>
  mov    %rbp,%rdi
  call   <perror@plt>
  jmp    L28
L55:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: parse_data
arguments: data_tag: D111
datatype: string
name: parse_data
arguments: data_tag: D25
datatype: string
name: parse_data
arguments: data_tag: D80
datatype: string
name: parse_data
arguments: data_tag: D123
datatype: string
name: parse_data
arguments: data_tag: D101
datatype: string
name: parse_data
arguments: data_tag: D39
datatype: string
name: parse_data
arguments: data_tag: D42
datatype: string
name: parse_data
arguments: data_tag: D58
datatype: string
name: parse_data
arguments: data_tag: D82
datatype: string
name: parse_data
arguments: data_tag: D66
datatype: string
name: parse_data
arguments: data_tag: D121
datatype: string
name: parse_data
arguments: data_tag: D3
datatype: string
name: parse_data
arguments: data_tag: D47
datatype: string

tool: D111: wb

tool: D25: %s/%s.bov

tool: D80: WARNING: Unable to create BOV file (%s)

tool: D123: %s.dat

tool: D101: VARIABLE: velocity


tool: D39: DATA_FILE: %s


tool: D42: DATA_SIZE: %d %d %d


tool: D58: DATA_COMPONENTS: 3


tool: D82: DATA_FORMAT: DOUBLE


tool: D66: DATA_ENDIAN: LITTLE


tool: D121: %s/%s.dat

tool: D3: WARNING: Unable to create DAT file (%s)

tool: D47: WARNING: Unable to allocate write buffer

assistant: ```c
void dump_velocity_c(char *dname, char *fname, int nx, int ny, int nz, double *array) {
  int i, j, k;
  FILE *fp;
  char errmsg[256];
  char buf[256];
  double *wbuf;
  snprintf(buf, 256, "%s/%s.bov", dname, fname);
  fp = fopen(buf, "wb");
  if (fp == NULL) {
    snprintf(errmsg, 256, "WARNING: Unable to create BOV file (%s)", buf);
    perror(errmsg);
    return;
  }
  snprintf(buf, 256, "%s.dat", fname);
  fprintf(fp, "VARIABLE: velocity\n");
  fprintf(fp, "DATA_FILE: %s\n", buf);
  fprintf(fp, "DATA_SIZE: %d %d %d\n", nx, ny, nz);
  fprintf(fp, "DATA_COMPONENTS: 3\n");
  fprintf(fp, "DATA_FORMAT: DOUBLE\n");
  fprintf(fp, "DATA_ENDIAN: LITTLE\n");
  fclose(fp);
  snprintf(buf, 256, "%s/%s.dat", dname, fname);
  fp = fopen(buf, "wb");
  if (fp == NULL) {
    snprintf(errmsg, 256, "WARNING: Unable to create DAT file (%s)", buf);
    perror(errmsg);
    return;
  }
  wbuf = (double *)malloc(3 * nx * ny * nz * sizeof(double));
  if (wbuf == NULL) {
    snprintf(errmsg, 256, "WARNING: Unable to allocate write buffer");
    perror(errmsg);
    return;
  }
  for (i = 0; i < 3 * nx * ny * nz; i++)
    wbuf[i] = array[2 * i];
  fwrite(wbuf, sizeof(double), 3 * nx * ny * nz, fp);
  free(wbuf);
  fclose(fp);
}
```