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

```asm
<main>:
  endbr64
  push   %r15
  push   %r14
  xor    %r14d,%r14d
  push   %r13
  mov    $0x1,%r13d
  push   %r12
  push   %rbp
  push   %rbx
  mov    %rsi,%rbx
  sub    $0x38,%rsp
  mov    0x10(%rsi),%rdi
  lea    D49(%rip),%rsi
  mov    %fs:0x28,%rax
  mov    %rax,0x28(%rsp)
  xor    %eax,%eax
  lea    0x18(%rsp),%r12
  lea    0x1e(%rsp),%r15
  call   <fopen@plt>
  mov    0x8(%rbx),%rdi
  lea    D57(%rip),%rsi
  lea    D50(%rip),%rbx
  mov    %rax,0x8(%rsp)
  call   <fopen@plt>
  movl   $0x0,0x18(%rsp)
  mov    %rax,%rbp
  nop
L99:
  xor    %eax,%eax
  mov    %r12,%rdx
  mov    %rbx,%rsi
  mov    %rbp,%rdi
  call   <fscanf@plt>
  test   %eax,%eax
  js     L33
  jne    L94
  mov    0x18(%rsp),%ecx
  mov    %r15,%rdx
  lea    D53(%rip),%rsi
  xor    %eax,%eax
  mov    %rbp,%rdi
  test   %ecx,%ecx
  jne    L90
  call   <fscanf@plt>
  xor    %r14d,%r14d
  jmp    L99
  nopl   0x0(%rax,%rax,1)
L94:
  cmp    $0x1,%eax
  jne    L99
  mov    0x18(%rsp),%r8d
  mov    0x8(%rsp),%rdi
  mov    %r14d,%ecx
  mov    %r13d,%edx
  lea    D71(%rip),%rsi
  add    $0x1,%r13d
  call   <fprintf@plt>
  mov    0x18(%rsp),%r14d
  jmp    L99
  nopl   0x0(%rax)
L90:
  call   <fscanf@plt>
  mov    %r15,%rsi
  lea    D59(%rip),%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  je     L33
  movl   $0x0,0x18(%rsp)
  test   %r14d,%r14d
  jne    L20
  add    $0x1,%r13d
  jmp    L99
  nop
L33:
  mov    0x8(%rsp),%rbx
  mov    0x18(%rsp),%ecx
  xor    %r8d,%r8d
  mov    %r13d,%edx
  lea    D71(%rip),%rsi
  mov    %rbx,%rdi
  call   <fprintf@plt>
  mov    %rbx,%rdi
  call   <fclose@plt>
  mov    %rbp,%rdi
  call   <fclose@plt>
  mov    0x28(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L80
  add    $0x38,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nop
L20:
  mov    0x8(%rsp),%rdi
  mov    %r13d,%edx
  xor    %r8d,%r8d
  mov    %r14d,%ecx
  lea    D71(%rip),%rsi
  add    $0x1,%r13d
  call   <fprintf@plt>
  jmp    L99
L80:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: extract_symbolic_data
arguments: data_label: D49
datatype: string
name: extract_symbolic_data
arguments: data_label: D57
datatype: string
name: extract_symbolic_data
arguments: data_label: D50
datatype: string
name: extract_symbolic_data
arguments: data_label: D53
datatype: string
name: extract_symbolic_data
arguments: data_label: D71
datatype: string
name: extract_symbolic_data
arguments: data_label: D59
datatype: string

tool: D49: a

tool: D57: r

tool: D50: %i

tool: D53: %s

tool: D71: a %i %i %i 0


tool: D59: cost

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);
}
```