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    $0x1a8,%rsp
  mov    %edi,0x18(%rsp)
  mov    %fs:0x28,%rax
  mov    %rax,0x198(%rsp)
  xor    %eax,%eax
  movl   $0x0,0x44(%rsp)
  movl   $0x0,0x48(%rsp)
  movl   $0x1,0x4c(%rsp)
  cmp    $0x1,%edi
  jle    L54
  lea    0x50(%rsp),%rax
  mov    %rsi,%r14
  mov    0x8(%rsi),%rsi
  lea    0x130(%rsp),%rbx
  mov    %rax,%rdi
  mov    %rax,0x28(%rsp)
  call   <strcpy@plt>
  lea    0xc0(%rsp),%rax
  mov    0x10(%r14),%rsi
  mov    %rax,%rdi
  mov    %rax,0x20(%rsp)
  call   <strcpy@plt>
  xor    %edx,%edx
  mov    $0x64,%esi
  mov    %rbx,%rdi
  call   <fill_string@plt>
  cmpl   $0x3,0x18(%rsp)
  movl   $0x0,0x10(%rsp)
  movl   $0x0,0xc(%rsp)
  movl   $0x42,0x1c(%rsp)
  jle    L23
  mov    0x18(%rsp),%eax
  movl   $0x0,0x14(%rsp)
  mov    $0x3,%ebp
  mov    $0x1,%r15d
  sub    $0x2,%eax
  mov    %eax,0x34(%rsp)
  lea    0x10(%r14),%rax
  mov    %rax,0x38(%rsp)
  jmp    L209
  nopw   0x0(%rax,%rax,1)
L162:
  mov    (%r12),%rdi
  lea    D82(%rip),%rsi
  call   <strcmp@plt>
  test   %rax,%rax
  je     L134
L66:
  mov    (%r12),%rdi
  lea    D5(%rip),%rsi
  call   <strcmp@plt>
  test   %rax,%rax
  je     L103
L187:
  add    $0x1,%ebp
  cmp    %ebp,0x18(%rsp)
  jle    L130
L209:
  movslq %ebp,%r13
  lea    D102(%rip),%rsi
  shl    $0x3,%r13
  lea    (%r14,%r13,1),%r12
  mov    (%r12),%rdi
  call   <strcmp@plt>
  mov    (%r12),%rdi
  lea    D3(%rip),%rsi
  test   %rax,%rax
  mov    0x14(%rsp),%eax
  cmove  %r15d,%eax
  mov    %eax,0x14(%rsp)
  call   <strcmp@plt>
  mov    (%r12),%rdi
  lea    D115(%rip),%rsi
  test   %rax,%rax
  mov    0xc(%rsp),%eax
  cmove  %r15d,%eax
  mov    %eax,0xc(%rsp)
  call   <strcmp@plt>
  mov    (%r12),%rdi
  lea    D112(%rip),%rsi
  test   %rax,%rax
  mov    0x10(%rsp),%eax
  cmove  %r15d,%eax
  mov    %eax,0x10(%rsp)
  call   <strcmp@plt>
  test   %rax,%rax
  jne    L162
  lea    0x8(%r14,%r13,1),%r12
  add    $0x1,%ebp
  mov    (%r12),%rdi
  call   <atoi@plt>
  mov    %eax,0x1c(%rsp)
  jmp    L162
  nopw   0x0(%rax,%rax,1)
L134:
  add    $0x1,%ebp
  movslq %ebp,%rax
  lea    (%r14,%rax,8),%r12
  mov    (%r12),%rdi
  call   <atoi@plt>
  mov    %eax,0x4c(%rsp)
  jmp    L66
L54:
  mov    $0x42,%esi
  lea    D59(%rip),%rdi
  lea    0x130(%rsp),%rbx
  call   <printf@plt>
  lea    D35(%rip),%rsi
  lea    D0(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  mov    $0x1,%edi
  call   <exit@plt>
  lea    0x50(%rsp),%rax
  movl   $0x0,0x10(%rsp)
  mov    %rax,0x28(%rsp)
  lea    0xc0(%rsp),%rax
  movl   $0x0,0xc(%rsp)
  movl   $0x42,0x1c(%rsp)
  movl   $0x0,0x14(%rsp)
  mov    %rax,0x20(%rsp)
L130:
  mov    0x1c(%rsp),%edi
  mov    $0x1,%esi
  call   <lpp@plt>
  mov    0x28(%rsp),%rdi
  lea    D56(%rip),%rsi
  call   <fopen@plt>
  mov    %rax,%r12
  test   %rax,%rax
  je     L175
L165:
  mov    0x20(%rsp),%rdi
  lea    D22(%rip),%rsi
  call   <fopen@plt>
  mov    %rax,%rbp
  test   %rax,%rax
  je     L38
L93:
  mov    0x10(%rsp),%r9d
  mov    0xc(%rsp),%r8d
  mov    %rbx,%rcx
  mov    %rbp,%rdi
  lea    0x4c(%rsp),%r14
  lea    0x48(%rsp),%r13
  mov    %r13,%rsi
  mov    %r14,%rdx
  lea    0x44(%rsp),%r15
  call   <print_report_header@plt>
  mov    0x44(%rsp),%esi
  test   %esi,%esi
  jne    L90
  nopl   (%rax)
L37:
  mov    %r15,%rsi
  mov    %r12,%rdi
  call   <read_a_record@plt>
  mov    %r14,%rcx
  mov    %r13,%rdx
  mov    %rbx,%r8
  mov    %rax,%rdi
  mov    0x14(%rsp),%eax
  mov    %rbp,%rsi
  push   %rax
  mov    0x18(%rsp),%eax
  push   %rax
  mov    0x1c(%rsp),%r9d
  call   <write_a_record@plt>
  pop    %rax
  pop    %rdx
  mov    0x44(%rsp),%ecx
  test   %ecx,%ecx
  je     L37
L90:
  mov    %r12,%rdi
  call   <fclose@plt>
  mov    %rbp,%rdi
  call   <fclose@plt>
  mov    0x198(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L177
  add    $0x1a8,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L103:
  lea    0x1(%rbp),%eax
  lea    D74(%rip),%rsi
  mov    %rbx,%rdi
  mov    %eax,%r13d
  mov    %eax,0x30(%rsp)
  call   <strcpy@plt>
  movslq %r13d,%rax
  cmp    %eax,0x18(%rsp)
  jle    L169
  lea    (%r14,%rax,8),%r13
  mov    0x34(%rsp),%eax
  movslq %ebp,%rcx
  sub    %ebp,%eax
  add    %rcx,%rax
  mov    0x38(%rsp),%rcx
  lea    (%rcx,%rax,8),%r12
  nopw   0x0(%rax,%rax,1)
L48:
  mov    0x0(%r13),%rsi
  mov    %rbx,%rdi
  add    $0x8,%r13
  call   <strcat@plt>
  lea    D74(%rip),%rsi
  mov    %rbx,%rdi
  call   <strcat@plt>
  cmp    %r13,%r12
  jne    L48
  mov    0x30(%rsp),%eax
  mov    0x18(%rsp),%edx
  lea    -0x1(%rax,%rdx,1),%eax
  sub    %ebp,%eax
  mov    %eax,%ebp
  jmp    L187
L38:
  mov    0x20(%rsp),%rsi
  lea    D83(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  mov    $0x2,%edi
  call   <exit@plt>
  jmp    L93
L175:
  mov    0x28(%rsp),%rsi
  lea    D83(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  mov    $0x2,%edi
  call   <exit@plt>
  jmp    L165
L169:
  mov    0x30(%rsp),%ebp
  jmp    L187
L23:
  movl   $0x0,0x14(%rsp)
  jmp    L130
L177:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: unpack_data
arguments: tag: D82
datatype: string
name: unpack_data
arguments: tag: D5
datatype: string
name: unpack_data
arguments: tag: D102
datatype: string
name: unpack_data
arguments: tag: D3
datatype: string
name: unpack_data
arguments: tag: D115
datatype: string
name: unpack_data
arguments: tag: D112
datatype: string
name: unpack_data
arguments: tag: D59
datatype: string
name: unpack_data
arguments: tag: D35
datatype: string
name: unpack_data
arguments: tag: D0
datatype: string
name: unpack_data
arguments: tag: D56
datatype: string
name: unpack_data
arguments: tag: D22
datatype: string
name: unpack_data
arguments: tag: D74
datatype: string
name: unpack_data
arguments: tag: D83
datatype: string

tool: D82: -n

tool: D5: -t

tool: D102: -ds

tool: D3: -d

tool: D115: -p

tool: D112: -l

tool: D59: 

usage: kf in-file out-file -d -p -n # -l # -t ...
         -d     = put the date in the header
         -p     = put the page number in the header
         -l #   = there are # lines per page (%d default)
         -n #   = start numbering the pages with #
         -ds    = double space print the output
         -t ... = put the following title in the header

tool: D35: kf Version 1 - December 1999

tool: D0: 
%s


tool: D56: rt

tool: D22: wt

tool: D74:  

tool: D83: 
ERROR Could not open file %s

assistant: ```c
int main(int argc, char *argv[]) {
  char in_file_name[100], out_file_name[100], title[100];
  FILE *in_file, *out_file;
  int double_space = 0, file_done = 0, i, line_counter = 0, lines = 66, page_counter = 1, print_date = 0, print_page = 0, print_title = 0;
  struct word_list_struct *word_list, *temp;
  struct line_list_struct *line_list;
  if (argc < 2) {
    printf("\n\nusage: kf in-file out-file -d -p -n # -l # -t ..."
           "\n         -d     = put the date in the header"
           "\n         -p     = put the page number in the header"
           "\n         -l #   = there are # lines per page (%d default)"
           "\n         -n #   = start numbering the pages with #"
           "\n         -ds    = double space print the output"
           "\n         -t ... = put the following title in the header",
           66);
    printf("\n%s\n", "kf Version 1 - December 1999");
    exit(1);
  }
  if (argc > 1) {
    strcpy(in_file_name, argv[1]);
    strcpy(out_file_name, argv[2]);
    fill_string(title, 100, '\0');
    i = 3;
    while (i < argc) {
      if (strcmp(argv[i], "-ds") == 0)
        double_space = 1;
      if (strcmp(argv[i], "-d") == 0)
        print_date = 1;
      if (strcmp(argv[i], "-p") == 0)
        print_page = 1;
      if (strcmp(argv[i], "-l") == 0) {
        i++;
        lines = atoi(argv[i]);
      }
      if (strcmp(argv[i], "-n") == 0) {
        i++;
        page_counter = atoi(argv[i]);
      }
      if (strcmp(argv[i], "-t") == 0) {
        i++;
        strcpy(title, " ");
        while (i < argc) {
          strcat(title, argv[i]);
          strcat(title, " ");
          i++;
        }
      }
      i++;
    }
  }
  lpp(lines, 1);
  if ((in_file = fopen(in_file_name, "rt")) == NULL) {
    printf("\nERROR Could not open file %s", in_file_name);
    exit(2);
  }
  if ((out_file = fopen(out_file_name, "wt")) == NULL) {
    printf("\nERROR Could not open file %s", out_file_name);
    exit(2);
  }
  print_report_header(out_file, &line_counter, &page_counter, title, print_date, print_page);
  while (file_done == 0) {
    line_list = read_a_record(in_file, &file_done);
    write_a_record(line_list, out_file, &line_counter, &page_counter, title, print_date, print_page, double_space);
  }
  fclose(in_file);
  fclose(out_file);
}
```