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

```asm
<main>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  mov    %rsi,%r12
  push   %rbp
  push   %rbx
  sub    $0x28,%rsp
  cmp    $0x4,%edi
  jle    L85
  mov    %edi,%r14d
  mov    0x18(%rsi),%rdi
  call   <atoi@plt>
  mov    %eax,%ebx
  test   %eax,%eax
  je     L170
  mov    %eax,%edi
  call   <malloc@plt>
  mov    %ebx,%edi
  mov    %rax,%rbp
  call   <malloc@plt>
  mov    %rax,0x10(%rsp)
  test   %rbp,%rbp
  je     L73
  test   %rax,%rax
  je     L73
  mov    %ebx,%edx
  xor    %esi,%esi
  lea    0x20(%r12),%r13
  mov    %rbp,%rdi
  call   <memset@plt>
  lea    -0x5(%r14),%eax
  lea    D3(%rip),%r14
  lea    0x28(%r12,%rax,8),%rax
  mov    %rax,0x8(%rsp)
  nopw   0x0(%rax,%rax,1)
L126:
  mov    0x0(%r13),%rdi
  call   <atoi@plt>
  mov    %r14,%rdi
  mov    %eax,%r15d
  mov    %eax,%esi
  xor    %eax,%eax
  call   <printf@plt>
  test   %r15d,%r15d
  jle    L159
  cmp    %r15d,%ebx
  jl     L159
  movslq %r15d,%rsi
  add    $0x8,%r13
  movb   $0x1,-0x1(%rbp,%rsi,1)
  cmp    0x8(%rsp),%r13
  jne    L126
  mov    0x8(%r12),%rdi
  lea    D47(%rip),%rsi
  call   <fopen@plt>
  mov    %rax,0x8(%rsp)
  test   %rax,%rax
  je     L71
  mov    0x10(%r12),%rdi
  lea    D61(%rip),%rsi
  call   <fopen@plt>
  mov    %rax,%r14
  movslq %ebx,%rax
  mov    %rax,0x18(%rsp)
  test   %r14,%r14
  je     L177
L61:
  mov    0x8(%rsp),%rcx
  mov    0x10(%rsp),%rdi
  mov    $0x1,%edx
  mov    %ebx,%esi
  call   <fread@plt>
  test   %rax,%rax
  je     L77
  test   %ebx,%ebx
  jle    L61
  mov    0x18(%rsp),%rax
  mov    0x10(%rsp),%r15
  mov    %rbp,%r12
  lea    (%rax,%rbp,1),%r13
  jmp    L51
  nopl   0x0(%rax,%rax,1)
L24:
  add    $0x1,%r12
  add    $0x1,%r15
  cmp    %r12,%r13
  je     L61
L51:
  cmpb   $0x0,(%r12)
  je     L24
  mov    %r14,%rcx
  mov    $0x1,%edx
  mov    $0x1,%esi
  mov    %r15,%rdi
  call   <fwrite@plt>
  test   %eax,%eax
  jne    L24
  lea    D83(%rip),%rdi
  call   <puts@plt>
L77:
  mov    0x8(%rsp),%rdi
  call   <fclose@plt>
  mov    %r14,%rdi
  call   <fclose@plt>
L123:
  mov    %rbp,%rdi
  call   <free@plt>
L52:
  mov    0x10(%rsp),%rax
  test   %rax,%rax
  je     L63
  add    $0x28,%rsp
  mov    %rax,%rdi
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  jmp    10e0 <free@plt>
L170:
  add    $0x28,%rsp
  lea    D60(%rip),%rdi
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  jmp    10f0 <puts@plt>
L85:
  mov    (%rsi),%rsi
  add    $0x28,%rsp
  lea    D51(%rip),%rdi
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  jmp    1120 <printf@plt>
L73:
  lea    D59(%rip),%rdi
  call   <puts@plt>
  test   %rbp,%rbp
  je     L52
  jmp    L123
L159:
  mov    %r15d,%esi
  lea    D62(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  jmp    L123
L63:
  add    $0x28,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L71:
  mov    0x8(%r12),%rsi
  lea    D72(%rip),%rdi
  call   <printf@plt>
  jmp    L123
L177:
  mov    0x10(%r12),%rsi
  lea    D12(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  mov    0x8(%rsp),%rdi
  call   <fclose@plt>
  jmp    L123
```

tool_calls: name: retrieve_data
arguments: tag: D3
type_infered: string
name: retrieve_data
arguments: tag: D47
type_infered: string
name: retrieve_data
arguments: tag: D61
type_infered: string
name: retrieve_data
arguments: tag: D83
type_infered: string
name: retrieve_data
arguments: tag: D60
type_infered: string
name: retrieve_data
arguments: tag: D51
type_infered: string
name: retrieve_data
arguments: tag: D59
type_infered: string
name: retrieve_data
arguments: tag: D62
type_infered: string
name: retrieve_data
arguments: tag: D72
type_infered: string
name: retrieve_data
arguments: tag: D12
type_infered: string

tool: D3: Adding column number %d


tool: D47: rb

tool: D61: wb

tool: D83: Error writing to output file

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

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


tool: D59: Error allocating working memory

tool: D62: Invalid column number %d


tool: D72: Cannot open input file %s


tool: D12: Cannot open output file %s


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