user: Please show me the C implementation that matches the assembly code listed below:

```asm
<write_AVS_header>:
  endbr64
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x30,%rsp
  mov    %rdi,%rbx
  mov    %esi,%ebp
  movss  %xmm0,0x4(%rsp)
  movss  %xmm1,0xc(%rsp)
  movss  %xmm2,0x10(%rsp)
  movss  %xmm3,0x8(%rsp)
  movss  %xmm4,0x14(%rsp)
  movss  %xmm5,0x18(%rsp)
  mov    %edx,%r12d
  mov    %fs:0x28,%rax
  mov    %rax,0x28(%rsp)
  xor    %eax,%eax
  movw   $0xc0c,0x26(%rsp)
  mov    $0x0,%edi
  call   <time@plt>
  mov    %eax,0x20(%rsp)
  mov    $0x0,%eax
  test   %rbx,%rbx
  je     L2
  movss  0x18(%rsp),%xmm5
  movss  0x14(%rsp),%xmm4
  movss  0x8(%rsp),%xmm3
  movss  0x10(%rsp),%xmm2
  movss  0xc(%rsp),%xmm1
  movss  0x4(%rsp),%xmm0
  lea    D34(%rip),%rdi
  call   <printf@plt>
  movss  0x8(%rsp),%xmm6
  subss  0x4(%rsp),%xmm6
  lea    -0x1(%rbp),%eax
  pxor   %xmm0,%xmm0
  cvtsi2ss %eax,%xmm0
  movaps %xmm6,%xmm3
  divss  %xmm0,%xmm3
  movss  %xmm3,0x1c(%rsp)
  mov    %rbx,%rcx
  mov    $0x25,%edx
  mov    $0x1,%esi
  lea    D98(%rip),%rdi
  call   <fwrite@plt>
  lea    0x20(%rsp),%rdi
  call   <ctime@plt>
  mov    %rax,%rdx
  lea    D76(%rip),%rsi
  mov    %rbx,%rdi
  mov    $0x0,%eax
  call   <fprintf@plt>
  movss  0x10(%rsp),%xmm2
  addss  0x18(%rsp),%xmm2
  movss  D4(%rip),%xmm3
  mulss  %xmm3,%xmm2
  movss  0xc(%rsp),%xmm1
  addss  0x14(%rsp),%xmm1
  mulss  %xmm3,%xmm1
  movss  0x4(%rsp),%xmm0
  addss  0x8(%rsp),%xmm0
  mulss  %xmm3,%xmm0
  cvtss2sd %xmm0,%xmm0
  pxor   %xmm3,%xmm3
  cvtss2sd 0x1c(%rsp),%xmm3
  mov    %ebp,%edx
  cvtss2sd %xmm2,%xmm2
  cvtss2sd %xmm1,%xmm1
  lea    D8(%rip),%rsi
  mov    %rbx,%rdi
  mov    $0x4,%eax
  call   <fprintf@plt>
  mov    %rbx,%rcx
  mov    $0x34,%edx
  mov    $0x1,%esi
  lea    D103(%rip),%rdi
  call   <fwrite@plt>
  mov    %ebp,%edx
  lea    D42(%rip),%rsi
  mov    %rbx,%rdi
  mov    $0x0,%eax
  call   <fprintf@plt>
  mov    %ebp,%edx
  lea    D90(%rip),%rsi
  mov    %rbx,%rdi
  mov    $0x0,%eax
  call   <fprintf@plt>
  mov    %ebp,%edx
  lea    D66(%rip),%rsi
  mov    %rbx,%rdi
  mov    $0x0,%eax
  call   <fprintf@plt>
  mov    %rbx,%rcx
  mov    $0x3b,%edx
  mov    $0x1,%esi
  lea    D53(%rip),%rdi
  call   <fwrite@plt>
  mov    %rbx,%rcx
  mov    $0x36,%edx
  mov    $0x1,%esi
  lea    D51(%rip),%rdi
  call   <fwrite@plt>
  cmp    $0x66,%r12b
  lea    D148(%rip),%rdx
  lea    D25(%rip),%rax
  cmovne %rax,%rdx
  lea    D155(%rip),%rsi
  mov    %rbx,%rdi
  mov    $0x0,%eax
  call   <fprintf@plt>
  pxor   %xmm0,%xmm0
  cvtss2sd 0x4(%rsp),%xmm0
  pxor   %xmm2,%xmm2
  cvtss2sd 0x10(%rsp),%xmm2
  pxor   %xmm1,%xmm1
  cvtss2sd 0xc(%rsp),%xmm1
  lea    D95(%rip),%rsi
  mov    %rbx,%rdi
  mov    $0x3,%eax
  call   <fprintf@plt>
  pxor   %xmm0,%xmm0
  cvtss2sd 0x8(%rsp),%xmm0
  pxor   %xmm2,%xmm2
  cvtss2sd 0x18(%rsp),%xmm2
  pxor   %xmm1,%xmm1
  cvtss2sd 0x14(%rsp),%xmm1
  lea    D73(%rip),%rsi
  mov    %rbx,%rdi
  mov    $0x3,%eax
  call   <fprintf@plt>
  mov    %rbx,%rcx
  mov    $0x3e,%edx
  mov    $0x1,%esi
  lea    D70(%rip),%rdi
  call   <fwrite@plt>
  lea    0x26(%rsp),%rdi
  mov    %rbx,%rcx
  mov    $0x2,%edx
  mov    $0x1,%esi
  call   <fwrite@plt>
  mov    $0x1,%eax
L2:
  mov    0x28(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L8
  add    $0x30,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
L8:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: read_data
arguments: tag: D34
type_guessed: string
name: read_data
arguments: tag: D98
type_guessed: string
name: read_data
arguments: tag: D76
type_guessed: string
name: read_data
arguments: tag: D4
type_guessed: byte[4]
name: read_data
arguments: tag: D8
type_guessed: string
name: read_data
arguments: tag: D103
type_guessed: string
name: read_data
arguments: tag: D42
type_guessed: string
name: read_data
arguments: tag: D90
type_guessed: string
name: read_data
arguments: tag: D66
type_guessed: string
name: read_data
arguments: tag: D53
type_guessed: string
name: read_data
arguments: tag: D51
type_guessed: string
name: read_data
arguments: tag: D148
type_guessed: string
name: read_data
arguments: tag: D25
type_guessed: string
name: read_data
arguments: tag: D155
type_guessed: string
name: read_data
arguments: tag: D95
type_guessed: string
name: read_data
arguments: tag: D73
type_guessed: string
name: read_data
arguments: tag: D70
type_guessed: string

tool: D34: writing an AVS header, min (%f, %f, %f): max (%f, %f, %f)


tool: D98: # AVS field file -- generated by GEM


tool: D76: # creation date: %s

tool: {"D4": [0x00,0x00,0x00,0x3f]}

tool: D8: # Scalar field for cubic lattice: ON_GEOM_CENT resolved to (%f %f %f) %i %f 


tool: D103: ndim=3         # number of dimensions in the field 


tool: D42: dim1=%i # dimension of axis 1


tool: D90: dim2=%i # dimension of axis 2


tool: D66: dim3=%i # dimension of axis 3


tool: D53: nspace=3       # number of physical coordinates per point 


tool: D51: veclen=1       # number of data components per point 


tool: D148: float

tool: D25: double

tool: D155: data=%s    # data type (byte, integer, float, double) 


tool: D95: min_ext=%f %f %f


tool: D73: max_ext=%f %f %f


tool: D70: field=uniform  # field type (uniform, rectilinear, irregular)


assistant: ```c
int write_AVS_header(FILE *fp, int dim, float xmin, float ymin, float zmin, float xmax, float ymax, float zmax, char gridtype) {
  const char FORM_FEEDS[2] = {12, 12};
  float center_x, center_y, center_z, spacing;
  time_t tclock = time(0);
  if (fp == NULL)
    return 0;
  printf("writing an AVS header, min (%f, %f, %f): max (%f, %f, %f)\n", xmin, ymin, zmin, xmax, ymax, zmax);
  center_x = (xmin + xmax) / 2.;
  center_y = (ymin + ymax) / 2.;
  center_z = (zmin + zmax) / 2.;
  spacing = (xmax - xmin) / (float)(dim - 1);
  fprintf(fp, "# AVS field file -- generated by GEM\n");
  fprintf(fp, "# creation date: %s", ctime(&tclock));
  fprintf(fp, "# Scalar field for cubic lattice: ON_GEOM_CENT resolved to (%f %f %f) %i %f \n", center_x, center_y, center_z, dim, spacing);
  fprintf(fp, "ndim=3         # number of dimensions in the field \n");
  fprintf(fp, "dim1=%i # dimension of axis 1\n", dim);
  fprintf(fp, "dim2=%i # dimension of axis 2\n", dim);
  fprintf(fp, "dim3=%i # dimension of axis 3\n", dim);
  fprintf(fp, "nspace=3       # number of physical coordinates per point \n");
  fprintf(fp, "veclen=1       # number of data components per point \n");
  fprintf(fp, "data=%s    # data type (byte, integer, float, double) \n", ((gridtype == 'f') ? "float" : "double"));
  fprintf(fp, "min_ext=%f %f %f\n", xmin, ymin, zmin);
  fprintf(fp, "max_ext=%f %f %f\n", xmax, ymax, zmax);
  fprintf(fp, "field=uniform  # field type (uniform, rectilinear, irregular)\n");
  fwrite(FORM_FEEDS, sizeof(char), 2, fp);
  return 1;
}
```