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

```asm
<main>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x40,%rsp
  mov    %edi,-0x34(%rbp)
  mov    %rsi,-0x40(%rbp)
  movq   $0x0,-0x20(%rbp)
  movq   $0x0,-0x18(%rbp)
  movq   $0x0,-0x10(%rbp)
  movq   $0x0,-0x8(%rbp)
  cmpl   $0x4,-0x34(%rbp)
  jg     L43
  mov    -0x40(%rbp),%rax
  mov    (%rax),%rax
  mov    %rax,%rsi
  lea    D74(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  jmp    L221
L43:
  mov    -0x40(%rbp),%rax
  add    $0x18,%rax
  mov    (%rax),%rax
  mov    %rax,%rdi
  call   <atoi@plt>
  mov    %eax,-0x28(%rbp)
  cmpl   $0x0,-0x28(%rbp)
  jne    L133
  lea    D93(%rip),%rax
  mov    %rax,%rdi
  call   <puts@plt>
  jmp    L35
L133:
  mov    -0x28(%rbp),%eax
  mov    %eax,%edi
  call   <malloc@plt>
  mov    %rax,-0x10(%rbp)
  mov    -0x28(%rbp),%eax
  mov    %eax,%edi
  call   <malloc@plt>
  mov    %rax,-0x8(%rbp)
  cmpq   $0x0,-0x10(%rbp)
  je     L204
  cmpq   $0x0,-0x8(%rbp)
  jne    L31
L204:
  lea    D63(%rip),%rax
  mov    %rax,%rdi
  call   <puts@plt>
  jmp    L35
L31:
  mov    -0x28(%rbp),%edx
  mov    -0x10(%rbp),%rax
  mov    $0x0,%esi
  mov    %rax,%rdi
  call   <memset@plt>
  movl   $0x4,-0x2c(%rbp)
  jmp    L255
L160:
  mov    -0x2c(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x40(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rax
  mov    %rax,%rdi
  call   <atoi@plt>
  mov    %eax,-0x24(%rbp)
  mov    -0x24(%rbp),%eax
  mov    %eax,%esi
  lea    D23(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  cmpl   $0x0,-0x24(%rbp)
  jle    L203
  mov    -0x24(%rbp),%eax
  cmp    -0x28(%rbp),%eax
  jle    L25
L203:
  mov    -0x24(%rbp),%eax
  mov    %eax,%esi
  lea    D65(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  jmp    L35
L25:
  mov    -0x24(%rbp),%eax
  cltq
  lea    -0x1(%rax),%rdx
  mov    -0x10(%rbp),%rax
  add    %rdx,%rax
  movb   $0x1,(%rax)
  addl   $0x1,-0x2c(%rbp)
L255:
  mov    -0x2c(%rbp),%eax
  cmp    -0x34(%rbp),%eax
  jl     L160
  mov    -0x40(%rbp),%rax
  add    $0x8,%rax
  mov    (%rax),%rax
  lea    D2(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <fopen@plt>
  mov    %rax,-0x20(%rbp)
  cmpq   $0x0,-0x20(%rbp)
  jne    L54
  mov    -0x40(%rbp),%rax
  add    $0x8,%rax
  mov    (%rax),%rax
  mov    %rax,%rsi
  lea    D33(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  jmp    L35
L54:
  mov    -0x40(%rbp),%rax
  add    $0x10,%rax
  mov    (%rax),%rax
  lea    D69(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <fopen@plt>
  mov    %rax,-0x18(%rbp)
  cmpq   $0x0,-0x18(%rbp)
  jne    L202
  mov    -0x40(%rbp),%rax
  add    $0x10,%rax
  mov    (%rax),%rax
  mov    %rax,%rsi
  lea    D7(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  jmp    L35
L29:
  movl   $0x0,-0x2c(%rbp)
  jmp    L92
L181:
  mov    -0x2c(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x10(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  test   %al,%al
  je     L125
  mov    -0x2c(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x8(%rbp),%rax
  lea    (%rdx,%rax,1),%rdi
  mov    -0x18(%rbp),%rax
  mov    %rax,%rcx
  mov    $0x1,%edx
  mov    $0x1,%esi
  call   <fwrite@plt>
  test   %eax,%eax
  jne    L125
  lea    D59(%rip),%rax
  mov    %rax,%rdi
  call   <puts@plt>
  jmp    L35
L125:
  addl   $0x1,-0x2c(%rbp)
L92:
  mov    -0x2c(%rbp),%eax
  cmp    -0x28(%rbp),%eax
  jl     L181
L202:
  mov    -0x20(%rbp),%rdx
  mov    -0x28(%rbp),%esi
  mov    -0x8(%rbp),%rax
  mov    %rdx,%rcx
  mov    $0x1,%edx
  mov    %rax,%rdi
  call   <fread@plt>
  test   %rax,%rax
  jne    L29
  nop
L35:
  cmpq   $0x0,-0x20(%rbp)
  je     L70
  mov    -0x20(%rbp),%rax
  mov    %rax,%rdi
  call   <fclose@plt>
L70:
  cmpq   $0x0,-0x18(%rbp)
  je     L116
  mov    -0x18(%rbp),%rax
  mov    %rax,%rdi
  call   <fclose@plt>
L116:
  cmpq   $0x0,-0x10(%rbp)
  je     L152
  mov    -0x10(%rbp),%rax
  mov    %rax,%rdi
  call   <free@plt>
L152:
  cmpq   $0x0,-0x8(%rbp)
  je     L221
  mov    -0x8(%rbp),%rax
  mov    %rax,%rdi
  call   <free@plt>
L221:
  leave
  ret
```

tool_calls: name: retrieve_data
arguments: data_tag: D74
type_guessed: string
name: retrieve_data
arguments: data_tag: D93
type_guessed: string
name: retrieve_data
arguments: data_tag: D63
type_guessed: string
name: retrieve_data
arguments: data_tag: D23
type_guessed: string
name: retrieve_data
arguments: data_tag: D65
type_guessed: string
name: retrieve_data
arguments: data_tag: D2
type_guessed: string
name: retrieve_data
arguments: data_tag: D33
type_guessed: string
name: retrieve_data
arguments: data_tag: D69
type_guessed: string
name: retrieve_data
arguments: data_tag: D7
type_guessed: string
name: retrieve_data
arguments: data_tag: D59
type_guessed: string

tool: D74: Usage: %s <InFile> <OutFile> <RowLength> <CopyCol1> [<CopyCol2> [<CopyCol3> [...]]]
Column numbers start at 1


tool: D93: Row length must be greater than Zero!!!

tool: D63: Error allocating working memory

tool: D23: Adding column number %d


tool: D65: Invalid column number %d


tool: D2: rb

tool: D33: Cannot open input file %s


tool: D69: wb

tool: D7: Cannot open output file %s


tool: D59: Error writing to output file

assistant: ```c
void main(int argc, char **argv) {
  FILE *InFile = NULL;
  FILE *OutFile = NULL;
  char *CopyFlags = NULL;
  char *SourceRow = NULL;
  int RowLength;
  int Count;
  int ColNumber;
  if (argc < 5) {
    printf("Usage: %s <InFile> <OutFile> <RowLength> <CopyCol1> [<CopyCol2> [<CopyCol3> [...]]]\nColumn numbers start at 1\n", argv[0]);
    return;
  }
  RowLength = atoi(argv[3]);
  if (!RowLength) {
    printf("Row length must be greater than Zero!!!\n");
    goto Exit;
  }
  CopyFlags = malloc(RowLength);
  SourceRow = malloc(RowLength);
  if ((!CopyFlags) || (!SourceRow)) {
    printf("Error allocating working memory\n");
    goto Exit;
  }
  memset(CopyFlags, 0, RowLength);
  for (Count = 4; Count < argc; Count++) {
    ColNumber = atoi(argv[Count]);
    printf("Adding column number %d\n", ColNumber);
    if ((ColNumber < 1) || (ColNumber > RowLength)) {
      printf("Invalid column number %d\n", ColNumber);
      goto Exit;
    }
    CopyFlags[ColNumber - 1] = 1;
  }
  InFile = fopen(argv[1], "rb");
  if (!InFile) {
    printf("Cannot open input file %s\n", argv[1]);
    goto Exit;
  }
  OutFile = fopen(argv[2], "wb");
  if (!OutFile) {
    printf("Cannot open output file %s\n", argv[2]);
    goto Exit;
  }
  while (fread(SourceRow, RowLength, 1, InFile)) {
    for (Count = 0; Count < RowLength; Count++)
      if (CopyFlags[Count])
        if (!fwrite(SourceRow + Count, 1, 1, OutFile)) {
          printf("Error writing to output file\n");
          goto Exit;
        }
  }
Exit:
  if (InFile)
    fclose(InFile);
  if (OutFile)
    fclose(OutFile);
  if (CopyFlags)
    free(CopyFlags);
  if (SourceRow)
    free(SourceRow);
}
```