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

```asm
<main>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x50,%rsp
  mov    %edi,-0x44(%rbp)
  mov    %rsi,-0x50(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  movl   $0x0,-0x34(%rbp)
  mov    -0x50(%rbp),%rax
  add    $0x10,%rax
  mov    (%rax),%rax
  lea    D14(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <fopen@plt>
  mov    %rax,-0x28(%rbp)
  mov    -0x50(%rbp),%rax
  add    $0x8,%rax
  mov    (%rax),%rax
  lea    D6(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <fopen@plt>
  mov    %rax,-0x20(%rbp)
  movl   $0x0,-0x38(%rbp)
  movl   $0x0,-0x30(%rbp)
  jmp    L114
L1:
  cmpl   $0x0,-0x2c(%rbp)
  jne    L70
  mov    -0x38(%rbp),%eax
  test   %eax,%eax
  je     L70
  lea    -0x12(%rbp),%rdx
  mov    -0x20(%rbp),%rax
  lea    D67(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <fscanf@plt>
  lea    -0x12(%rbp),%rax
  mov    %rax,%rsi
  lea    D43(%rip),%rax
  mov    %rax,%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  je     L48
  movl   $0x0,-0x38(%rbp)
  addl   $0x1,-0x34(%rbp)
  cmpl   $0x0,-0x30(%rbp)
  je     L114
  mov    -0x38(%rbp),%esi
  mov    -0x30(%rbp),%ecx
  mov    -0x34(%rbp),%edx
  mov    -0x28(%rbp),%rax
  mov    %esi,%r8d
  lea    D87(%rip),%rsi
  mov    %rax,%rdi
  call   <fprintf@plt>
  jmp    L114
L70:
  cmpl   $0x0,-0x2c(%rbp)
  jne    L19
  lea    -0x12(%rbp),%rdx
  mov    -0x20(%rbp),%rax
  lea    D67(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <fscanf@plt>
  movl   $0x0,-0x30(%rbp)
  jmp    L114
L19:
  cmpl   $0x1,-0x2c(%rbp)
  jne    L114
  addl   $0x1,-0x34(%rbp)
  mov    -0x38(%rbp),%esi
  mov    -0x30(%rbp),%ecx
  mov    -0x34(%rbp),%edx
  mov    -0x28(%rbp),%rax
  mov    %esi,%r8d
  lea    D87(%rip),%rsi
  mov    %rax,%rdi
  call   <fprintf@plt>
  mov    -0x38(%rbp),%eax
  mov    %eax,-0x30(%rbp)
L114:
  lea    -0x38(%rbp),%rdx
  mov    -0x20(%rbp),%rax
  lea    D63(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <fscanf@plt>
  mov    %eax,-0x2c(%rbp)
  cmpl   $0x0,-0x2c(%rbp)
  jns    L1
  jmp    L30
L48:
  nop
L30:
  addl   $0x1,-0x34(%rbp)
  mov    -0x38(%rbp),%ecx
  mov    -0x34(%rbp),%edx
  mov    -0x28(%rbp),%rax
  mov    $0x0,%r8d
  lea    D87(%rip),%rsi
  mov    %rax,%rdi
  call   <fprintf@plt>
  mov    -0x28(%rbp),%rax
  mov    %rax,%rdi
  call   <fclose@plt>
  mov    -0x20(%rbp),%rax
  mov    %rax,%rdi
  call   <fclose@plt>
  mov    $0x0,%eax
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L80
  call   <__stack_chk_fail@plt>
L80:
  leave
  ret
```

tool_calls: name: parse_data
arguments: label: D14
datatype: string
name: parse_data
arguments: label: D6
datatype: string
name: parse_data
arguments: label: D67
datatype: string
name: parse_data
arguments: label: D43
datatype: string
name: parse_data
arguments: label: D87
datatype: string
name: parse_data
arguments: label: D63
datatype: string

tool: D14: a

tool: D6: r

tool: D67: %s

tool: D43: cost

tool: D87: a %i %i %i 0


tool: D63: %i

assistant: ```c
int main(int argc, char **argv) {
  FILE *f1, *f2;
  int i, j = 0;
  char key[10];
  int prev_node, node, code;
  f1 = fopen(argv[2], "a");
  f2 = fopen(argv[1], "r");
  node = 0;
  prev_node = 0;
  while ((code = fscanf(f2, "%i", &node)) >= 0) {
    if (!code && node) {
      fscanf(f2, "%s", key);
      if (strcmp("cost", key) == 0)
        break;
      node = 0;
      j++;
      if (prev_node)
        fprintf(f1, "a %i %i %i 0\n", j, prev_node, node);
    } else if (!code) {
      fscanf(f2, "%s", key);
      prev_node = 0;
    } else if (code == 1) {
      j++;
      fprintf(f1, "a %i %i %i 0\n", j, prev_node, node);
      prev_node = node;
    }
  }
  j++;
  fprintf(f1, "a %i %i %i 0\n", j, node, 0);
  fclose(f1);
  fclose(f2);
}
```