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

```asm
<main>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0xf8,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0xe8(%rsp)
  xor    %eax,%eax
  lea    D275(%rip),%rsi
  lea    D68(%rip),%rdi
  call   <fopen@plt>
  mov    %rax,%rbp
  lea    D167(%rip),%rsi
  lea    D164(%rip),%rdi
  call   <fopen@plt>
  mov    %rax,0x38(%rsp)
  test   %rbp,%rbp
  je     L145
L111:
  pxor   %xmm2,%xmm2
  movsd  %xmm2,0x30(%rsp)
  movsd  %xmm2,0x28(%rsp)
  mov    $0x0,%ebx
  lea    D27(%rip),%r15
  lea    D101(%rip),%r14
  lea    0x48(%rsp),%r13
  lea    D242(%rip),%r12
  jmp    L49
L145:
  lea    D49(%rip),%rdi
  call   <puts@plt>
  mov    $0x0,%edi
  call   <exit@plt>
  jmp    L111
L109:
  lea    0xb0(%rsp),%rcx
  lea    0x70(%rsp),%rdx
  mov    %r13,%r9
  lea    0x40(%rsp),%r8
  mov    %r12,%rsi
  mov    %rbp,%rdi
  call   <fscanf@plt>
  movsd  0x28(%rsp),%xmm3
  addsd  0x40(%rsp),%xmm3
  movsd  %xmm3,0x28(%rsp)
  movsd  0x30(%rsp),%xmm4
  addsd  0x48(%rsp),%xmm4
  movsd  %xmm4,0x30(%rsp)
  add    $0x1,%ebx
  cmp    $0x64,%ebx
  je     L65
L49:
  mov    %rbp,%rdi
  call   <feof@plt>
  test   %rax,%rax
  je     L109
  mov    %ebx,%esi
  mov    %r15,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    %r14,%rdi
  call   <puts@plt>
  mov    $0x0,%edi
  call   <exit@plt>
  jmp    L109
L65:
  mov    %rbp,%rdi
  call   <fclose@plt>
  lea    D275(%rip),%rsi
  lea    D180(%rip),%rdi
  call   <fopen@plt>
  mov    %rax,%rbp
  test   %rax,%rax
  je     L17
L94:
  pxor   %xmm0,%xmm0
  movsd  %xmm0,0x20(%rsp)
  movsd  %xmm0,0x18(%rsp)
  mov    $0x0,%ebx
  lea    D27(%rip),%r15
  lea    D101(%rip),%r12
  lea    0x58(%rsp),%r14
  lea    D242(%rip),%r13
  jmp    L159
L17:
  lea    D275(%rip),%rsi
  lea    D68(%rip),%rdi
  call   <fopen@plt>
  mov    %rax,%rbp
  test   %rax,%rax
  jne    L94
  lea    D314(%rip),%rdi
  call   <puts@plt>
  mov    $0x0,%edi
  call   <exit@plt>
  jmp    L94
L108:
  lea    0xb0(%rsp),%rcx
  lea    0x70(%rsp),%rdx
  mov    %r14,%r9
  lea    0x50(%rsp),%r8
  mov    %r13,%rsi
  mov    %rbp,%rdi
  call   <fscanf@plt>
  movsd  0x18(%rsp),%xmm5
  addsd  0x50(%rsp),%xmm5
  movsd  %xmm5,0x18(%rsp)
  movsd  0x20(%rsp),%xmm6
  addsd  0x58(%rsp),%xmm6
  movsd  %xmm6,0x20(%rsp)
  add    $0x1,%ebx
  cmp    $0x64,%ebx
  je     L128
L159:
  mov    %rbp,%rdi
  call   <feof@plt>
  test   %rax,%rax
  je     L108
  mov    %ebx,%esi
  mov    %r15,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    %r12,%rdi
  call   <puts@plt>
  mov    $0x0,%edi
  call   <exit@plt>
  jmp    L108
L128:
  mov    %rbp,%rdi
  call   <fclose@plt>
  lea    D275(%rip),%rsi
  lea    D146(%rip),%rdi
  call   <fopen@plt>
  mov    %rax,%rbp
  test   %rax,%rax
  je     L157
L113:
  pxor   %xmm2,%xmm2
  movsd  %xmm2,0x10(%rsp)
  movsd  %xmm2,0x8(%rsp)
  mov    $0x0,%ebx
  lea    D27(%rip),%r13
  lea    D101(%rip),%r12
  lea    0x68(%rsp),%r15
  lea    D242(%rip),%r14
  jmp    L134
L157:
  lea    D275(%rip),%rsi
  lea    D180(%rip),%rdi
  call   <fopen@plt>
  mov    %rax,%rbp
  test   %rax,%rax
  jne    L113
  lea    D21(%rip),%rdi
  call   <puts@plt>
  mov    $0x0,%edi
  call   <exit@plt>
  jmp    L113
L197:
  lea    0xb0(%rsp),%rcx
  lea    0x70(%rsp),%rdx
  mov    %r15,%r9
  lea    0x60(%rsp),%r8
  mov    %r14,%rsi
  mov    %rbp,%rdi
  call   <fscanf@plt>
  movsd  0x8(%rsp),%xmm7
  addsd  0x60(%rsp),%xmm7
  movsd  %xmm7,0x8(%rsp)
  movsd  0x10(%rsp),%xmm1
  addsd  0x68(%rsp),%xmm1
  movsd  %xmm1,0x10(%rsp)
  add    $0x1,%ebx
  cmp    $0x64,%ebx
  je     L85
L134:
  mov    %rbp,%rdi
  call   <feof@plt>
  test   %rax,%rax
  je     L197
  mov    %ebx,%esi
  mov    %r13,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    %r12,%rdi
  call   <puts@plt>
  mov    $0x0,%edi
  call   <exit@plt>
  jmp    L197
L85:
  movsd  0x28(%rsp),%xmm0
  divsd  D64(%rip),%xmm0
  movapd %xmm7,%xmm2
  divsd  D64(%rip),%xmm2
  movsd  0x18(%rsp),%xmm1
  divsd  D64(%rip),%xmm1
  lea    D36(%rip),%rsi
  mov    0x38(%rsp),%rbx
  mov    %rbx,%rdi
  call   <fprintf@plt>
  movsd  0x30(%rsp),%xmm0
  divsd  D64(%rip),%xmm0
  movsd  0x10(%rsp),%xmm2
  divsd  D64(%rip),%xmm2
  movsd  0x20(%rsp),%xmm1
  divsd  D64(%rip),%xmm1
  lea    D261(%rip),%rsi
  mov    %rbx,%rdi
  call   <fprintf@plt>
  mov    %rbx,%rdi
  call   <fclose@plt>
  mov    %rbp,%rdi
  call   <fclose@plt>
  mov    0xe8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L106
  mov    $0x0,%eax
  add    $0xf8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L106:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: extract_symbolic_data
arguments: data_tag: D275
type: string
name: extract_symbolic_data
arguments: data_tag: D68
type: string
name: extract_symbolic_data
arguments: data_tag: D167
type: string
name: extract_symbolic_data
arguments: data_tag: D164
type: string
name: extract_symbolic_data
arguments: data_tag: D27
type: string
name: extract_symbolic_data
arguments: data_tag: D101
type: string
name: extract_symbolic_data
arguments: data_tag: D242
type: string
name: extract_symbolic_data
arguments: data_tag: D49
type: string
name: extract_symbolic_data
arguments: data_tag: D180
type: string
name: extract_symbolic_data
arguments: data_tag: D314
type: string
name: extract_symbolic_data
arguments: data_tag: D146
type: string
name: extract_symbolic_data
arguments: data_tag: D21
type: string
name: extract_symbolic_data
arguments: data_tag: D64
type: f64
name: extract_symbolic_data
arguments: data_tag: D36
type: string
name: extract_symbolic_data
arguments: data_tag: D261
type: string

tool: D275: r

tool: D68: orig.txt

tool: D167: w

tool: D164: output.txt

tool: D27: ERROR: You need 100 datum instead of %d


tool: D101: run 'make run' longer to get enough information


tool: D242: %s %s %lf %lf


tool: D49: ERROR opening input file orig.txt

tool: D180: opt.txt

tool: D314: ERROR opening input file opt.txt

tool: D146: hash.txt

tool: D21: ERROR opening input file hash1.txt

tool: D64: 100

tool: D36: append() %lf %lf %lf


tool: D261: findName() %lf %lf %lf

assistant: ```c
int main(void) {
  FILE *fp = fopen("orig.txt", "r");
  FILE *output = fopen("output.txt", "w");
  if (!fp) {
    printf("ERROR opening input file orig.txt\n");
    exit(0);
  }
  int i = 0;
  char append[50], find[50];
  double orig_sum_a = 0.0, orig_sum_f = 0.0, orig_a, orig_f;
  for (i = 0; i < 100; i++) {
    if (feof(fp)) {
      printf("ERROR: You need 100 datum instead of %d\n", i);
      printf("run 'make run' longer to get enough information\n\n");
      exit(0);
    }
    fscanf(fp, "%s %s %lf %lf\n", append, find, &orig_a, &orig_f);
    orig_sum_a += orig_a;
    orig_sum_f += orig_f;
  }
  fclose(fp);
  fp = fopen("opt.txt", "r");
  if (!fp) {
    fp = fopen("orig.txt", "r");
    if (!fp) {
      printf("ERROR opening input file opt.txt\n");
      exit(0);
    }
  }
  double opt_sum_a = 0.0, opt_sum_f = 0.0, opt_a, opt_f;
  for (i = 0; i < 100; i++) {
    if (feof(fp)) {
      printf("ERROR: You need 100 datum instead of %d\n", i);
      printf("run 'make run' longer to get enough information\n\n");
      exit(0);
    }
    fscanf(fp, "%s %s %lf %lf\n", append, find, &opt_a, &opt_f);
    opt_sum_a += opt_a;
    opt_sum_f += opt_f;
  }
  fclose(fp);
  fp = fopen("hash.txt", "r");
  if (!fp) {
    fp = fopen("opt.txt", "r");
    if (!fp) {
      printf("ERROR opening input file hash1.txt\n");
      exit(0);
    }
  }
  double hash_sum_a = 0.0, hash_sum_f = 0.0, hash_a, hash_f;
  for (i = 0; i < 100; i++) {
    if (feof(fp)) {
      printf("ERROR: You need 100 datum instead of %d\n", i);
      printf("run 'make run' longer to get enough information\n\n");
      exit(0);
    }
    fscanf(fp, "%s %s %lf %lf\n", append, find, &hash_a, &hash_f);
    hash_sum_a += hash_a;
    hash_sum_f += hash_f;
  }
  fprintf(output, "append() %lf %lf %lf\n", orig_sum_a / 100.0, opt_sum_a / 100.0, hash_sum_a / 100);
  fprintf(output, "findName() %lf %lf %lf", orig_sum_f / 100.0, opt_sum_f / 100.0, hash_sum_f / 100.0);
  fclose(output);
  fclose(fp);
  return 0;
}
```