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

```asm
<write_result_vtk>:
  endbr64
  push   %r15
  mov    %edx,%eax
  mov    %rdi,%r15
  push   %r14
  sub    %esi,%eax
  push   %r13
  add    $0x1,%eax
  mov    %esi,%r13d
  lea    D129(%rip),%rsi
  push   %r12
  mov    %r8,%r12
  push   %rbp
  mov    %r9,%rbp
  push   %rbx
  mov    %ecx,%ebx
  sub    $0x18,%rsp
  mov    %edx,0x4(%rsp)
  mov    %eax,(%rsp)
  call   <fopen@plt>
  test   %rax,%rax
  je     L56
  mov    %rax,%r14
  mov    %rax,%rcx
  mov    $0x1b,%edx
  mov    $0x1,%esi
  lea    D110(%rip),%rdi
  call   <fwrite@plt>
  mov    %r14,%rcx
  mov    $0xb,%edx
  mov    $0x1,%esi
  lea    D14(%rip),%rdi
  call   <fwrite@plt>
  mov    %r14,%rcx
  mov    $0x6,%edx
  mov    $0x1,%esi
  lea    D4(%rip),%rdi
  call   <fwrite@plt>
  mov    %r14,%rcx
  mov    $0x1a,%edx
  mov    $0x1,%esi
  lea    D144(%rip),%rdi
  call   <fwrite@plt>
  mov    %ebx,%edx
  lea    D57(%rip),%rsi
  xor    %eax,%eax
  mov    %r14,%rdi
  call   <fprintf@plt>
  mov    (%rsp),%r8d
  mov    0x4(%rsp),%ecx
  mov    %r13d,%edx
  mov    %ebx,%esi
  lea    D77(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  mov    %ebx,%eax
  test   %ebx,%ebx
  jle    L17
  mov    %rbp,0x8(%rsp)
  mov    $0x4,%r15d
  mov    %r12,%rbp
  mov    $0x1,%ebx
  mov    %eax,%r12d
  nopl   0x0(%rax)
L33:
  mov    0x8(%rbp),%rdx
  mov    0x10(%rbp),%rax
  mov    %r14,%rdi
  add    $0x1,%ebx
  lea    D10(%rip),%rsi
  mov    (%rdx,%r15,1),%ecx
  mov    0x0(%rbp),%rdx
  mov    (%rax,%r15,1),%r8d
  xor    %eax,%eax
  mov    (%rdx,%r15,1),%edx
  add    $0x4,%r15
  call   <fprintf@plt>
  cmp    %ebx,%r12d
  jge    L33
  mov    0x8(%rsp),%rbp
L17:
  mov    (%rsp),%edx
  lea    D88(%rip),%rsi
  mov    %r14,%rdi
  xor    %eax,%eax
  lea    (%rdx,%rdx,8),%ecx
  call   <fprintf@plt>
  mov    0x4(%rsp),%eax
  cmp    %r13d,%eax
  jl     L77
  movslq %r13d,%r12
  mov    %eax,%r15d
  mov    %r12,0x8(%rsp)
  lea    0x0(,%r12,4),%rbx
  mov    %r13d,%r12d
  nopl   0x0(%rax)
L39:
  mov    0x10(%rbp),%rax
  add    $0x1,%r12d
  mov    (%rax,%rbx,1),%edi
  mov    0x18(%rbp),%rax
  mov    (%rax,%rbx,1),%esi
  mov    0x8(%rbp),%rax
  lea    -0x1(%rdi),%r9d
  mov    %r14,%rdi
  mov    (%rax,%rbx,1),%ecx
  mov    0x0(%rbp),%rax
  lea    -0x1(%rsi),%r8d
  lea    D118(%rip),%rsi
  mov    (%rax,%rbx,1),%edx
  mov    0x30(%rbp),%rax
  sub    $0x1,%ecx
  mov    (%rax,%rbx,1),%eax
  sub    $0x1,%edx
  sub    $0x1,%eax
  push   %rax
  mov    0x38(%rbp),%rax
  mov    (%rax,%rbx,1),%eax
  sub    $0x1,%eax
  push   %rax
  mov    0x28(%rbp),%rax
  mov    (%rax,%rbx,1),%eax
  sub    $0x1,%eax
  push   %rax
  mov    0x20(%rbp),%rax
  mov    (%rax,%rbx,1),%eax
  add    $0x4,%rbx
  sub    $0x1,%eax
  push   %rax
  xor    %eax,%eax
  call   <fprintf@plt>
  add    $0x20,%rsp
  cmp    %r12d,%r15d
  jge    L39
  mov    (%rsp),%edx
  lea    D137(%rip),%rsi
  mov    %r14,%rdi
  xor    %eax,%eax
  mov    0x8(%rsp),%r12
  lea    D15(%rip),%rbx
  call   <fprintf@plt>
  mov    0x4(%rsp),%ebp
  nopl   0x0(%rax)
L88:
  mov    %r14,%rcx
  mov    $0x3,%edx
  mov    $0x1,%esi
  mov    %rbx,%rdi
  call   <fwrite@plt>
  add    $0x1,%r13d
  cmp    %r13d,%ebp
  jge    L88
  mov    (%rsp),%edx
  lea    D21(%rip),%rsi
  mov    %r14,%rdi
  xor    %eax,%eax
  lea    D109(%rip),%rbx
  call   <fprintf@plt>
  mov    %r14,%rcx
  mov    $0x2b,%edx
  mov    $0x1,%esi
  lea    D155(%rip),%rdi
  call   <fwrite@plt>
  mov    0x4(%rsp),%ebp
  mov    0x50(%rsp),%r13
  nopl   0x0(%rax,%rax,1)
L71:
  movsd  0x0(%r13,%r12,8),%xmm0
  mov    %rbx,%rsi
  mov    %r14,%rdi
  mov    $0x1,%eax
  add    $0x1,%r12
  call   <fprintf@plt>
  cmp    %r12d,%ebp
  jge    L71
L18:
  mov    %r14,%rdi
  call   <fclose@plt>
  xor    %eax,%eax
L4:
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax)
L77:
  mov    (%rsp),%ebx
  mov    %r14,%rdi
  lea    D137(%rip),%rsi
  xor    %eax,%eax
  mov    %ebx,%edx
  call   <fprintf@plt>
  mov    %ebx,%edx
  mov    %r14,%rdi
  xor    %eax,%eax
  lea    D21(%rip),%rsi
  call   <fprintf@plt>
  mov    %r14,%rcx
  mov    $0x2b,%edx
  mov    $0x1,%esi
  lea    D155(%rip),%rdi
  call   <fwrite@plt>
  jmp    L18
L56:
  mov    %r15,%rsi
  lea    D26(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  mov    $0xffffffff,%eax
  jmp    L4
```

tool_calls: name: parse_data
arguments: label: D129
datatype: string
name: parse_data
arguments: label: D110
datatype: string
name: parse_data
arguments: label: D14
datatype: string
name: parse_data
arguments: label: D4
datatype: string
name: parse_data
arguments: label: D144
datatype: string
name: parse_data
arguments: label: D57
datatype: string
name: parse_data
arguments: label: D77
datatype: string
name: parse_data
arguments: label: D10
datatype: string
name: parse_data
arguments: label: D88
datatype: string
name: parse_data
arguments: label: D118
datatype: string
name: parse_data
arguments: label: D137
datatype: string
name: parse_data
arguments: label: D15
datatype: string
name: parse_data
arguments: label: D21
datatype: string
name: parse_data
arguments: label: D109
datatype: string
name: parse_data
arguments: label: D155
datatype: string
name: parse_data
arguments: label: D26
datatype: string

tool: D129: w

tool: D110: # vtk DataFile Version 3.0


tool: D14: vtk output


tool: D4: ASCII


tool: D144: DATASET UNSTRUCTURED_GRID


tool: D57: POINTS %d float


tool: D77: nodeCnt = %d, startInd= %d, endInd = %d, cellCnt=%d


tool: D10: %d %d %d


tool: D88: 
CELLS %d %d


tool: D118: 8 %d %d %d %d %d %d %d %d


tool: D137: 
CELL_TYPES %d


tool: D15: 11


tool: D21: 
CELL_DATA %d


tool: D109: %f 

tool: D155: SCALARS scalars float
LOOKUP_TABLE default


tool: D26: Error opening file %s for writing


assistant: ```c
int write_result_vtk(char *outFileName, int startIdx, int endIdx, int nodeCnt, int **points, int **elems, double *vector) {
  int i, j;
  int cellCnt = endIdx - startIdx + 1;
  FILE *fp = fopen(outFileName, "w");
  if (fp == NULL) {
    printf("Error opening file %s for writing\n", outFileName);
    return -1;
  }
  fprintf(fp, "# vtk DataFile Version 3.0\n");
  fprintf(fp, "vtk output\n");
  fprintf(fp, "ASCII\n");
  fprintf(fp, "DATASET UNSTRUCTURED_GRID\n");
  fprintf(fp, "POINTS %d float\n", nodeCnt);
  printf("nodeCnt = %d, startInd= %d, endInd = %d, cellCnt=%d\n", nodeCnt, startIdx, endIdx, cellCnt);
  for (i = 1; i <= nodeCnt; i++) {
    fprintf(fp, "%d %d %d\n", points[0][i], points[1][i], points[2][i]);
  }
  fprintf(fp, "\nCELLS %d %d\n", cellCnt, 9 * cellCnt);
  for (i = startIdx; i <= endIdx; i++) {
    fprintf(fp, "8 %d %d %d %d %d %d %d %d\n", elems[0][i] - 1, elems[1][i] - 1, elems[3][i] - 1, elems[2][i] - 1, elems[4][i] - 1, elems[5][i] - 1, elems[7][i] - 1, elems[6][i] - 1);
  }
  fprintf(fp, "\nCELL_TYPES %d\n", cellCnt);
  for (i = startIdx; i <= endIdx; i++) {
    fprintf(fp, "11\n");
  }
  fprintf(fp, "\nCELL_DATA %d\n", cellCnt);
  fprintf(fp, "SCALARS scalars float\nLOOKUP_TABLE default\n");
  for (i = startIdx; i <= endIdx; i++) {
    fprintf(fp, "%f ", vector[i]);
  }
  fclose(fp);
  return 0;
}
```