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

```asm
<main>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x140,%rsp
  mov    %edi,-0x134(%rbp)
  mov    %rsi,-0x140(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  lea    D123(%rip),%rax
  mov    %rax,%rdi
  call   <printf@plt>
  lea    D7(%rip),%rax
  mov    %rax,%rdi
  call   <printf@plt>
  lea    D135(%rip),%rax
  mov    %rax,%rsi
  lea    D41(%rip),%rax
  mov    %rax,%rdi
  call   <fopen@plt>
  mov    %rax,-0x120(%rbp)
  cmpq   $0x0,-0x120(%rbp)
  je     L2
  lea    D117(%rip),%rax
  mov    %rax,%rdi
  call   <printf@plt>
  lea    D7(%rip),%rax
  mov    %rax,%rdi
  call   <printf@plt>
  lea    -0x124(%rbp),%rdx
  mov    -0x120(%rbp),%rax
  lea    D44(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <fscanf@plt>
  lea    D26(%rip),%rax
  mov    %rax,%rdi
  call   <printf@plt>
  mov    -0x124(%rbp),%edx
  lea    -0x110(%rbp),%rax
  lea    D44(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <sprintf@plt>
  lea    -0x110(%rbp),%rax
  mov    %rax,%rdi
  call   <puts@plt>
L2:
  mov    -0x120(%rbp),%rax
  mov    %rax,%rdi
  call   <fclose@plt>
  movl   $0x2a,-0x124(%rbp)
  lea    D142(%rip),%rax
  mov    %rax,%rsi
  lea    D41(%rip),%rax
  mov    %rax,%rdi
  call   <fopen@plt>
  mov    %rax,-0x118(%rbp)
  lea    D56(%rip),%rax
  mov    %rax,%rdi
  call   <printf@plt>
  mov    -0x124(%rbp),%edx
  mov    -0x118(%rbp),%rax
  lea    D44(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <fprintf@plt>
  mov    -0x118(%rbp),%rax
  mov    %rax,%rdi
  call   <fclose@plt>
  lea    D89(%rip),%rax
  mov    %rax,%rdi
  call   <printf@plt>
  lea    D7(%rip),%rax
  mov    %rax,%rdi
  call   <printf@plt>
  mov    $0x0,%eax
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L18
  call   <__stack_chk_fail@plt>
L18:
  leave
  ret
```

tool_calls: name: disassemble_data
arguments: label: D123
type_guessed: string
name: disassemble_data
arguments: label: D7
type_guessed: string
name: disassemble_data
arguments: label: D135
type_guessed: string
name: disassemble_data
arguments: label: D41
type_guessed: string
name: disassemble_data
arguments: label: D117
type_guessed: string
name: disassemble_data
arguments: label: D44
type_guessed: string
name: disassemble_data
arguments: label: D26
type_guessed: string
name: disassemble_data
arguments: label: D142
type_guessed: string
name: disassemble_data
arguments: label: D56
type_guessed: string
name: disassemble_data
arguments: label: D89
type_guessed: string

tool: D123: starting

tool: D7: 


tool: D135: r

tool: D41: test.dat

tool: D117: Reading File

tool: D44: %d

tool: D26: data is read

tool: D142: w

tool: D56: Writing file

tool: D89: Ending

assistant: ```c
int main(int argc, char *argv[]) {
  printf("starting");
  printf("\n");
  int numItems;
  FILE *infile = fopen("test.dat", "r");
  if (infile != NULL) {
    printf("Reading File");
    printf("\n");
    fscanf(infile, "%d", &numItems);
    printf("data is read");
    char line[255];
    sprintf(line, "%d", numItems);
    puts(line);
  }
  fclose(infile);
  numItems = 42;
  FILE *outfile = fopen("test.dat", "w");
  printf("Writing file");
  fprintf(outfile, "%d", numItems);
  fclose(outfile);
  printf("Ending");
  printf("\n");
}
```