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
  lea    -0x8000(%rsp),%r11
L125:
  sub    $0x1000,%rsp
  orq    $0x0,(%rsp)
  cmp    %r11,%rsp
  jne    L125
  sub    $0xc28,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x8c18(%rsp)
  xor    %eax,%eax
  mov    0x8(%rsi),%rdi
  lea    D53(%rip),%rsi
  call   <fopen@plt>
  mov    %rax,0x8(%rsp)
  mov    $0xffffffff,%ebp
  test   %rax,%rax
  je     L24
  mov    $0x0,%ebp
  mov    $0x1,%r12d
  lea    0xc10(%rsp),%rbx
  jmp    L104
L121:
  mov    $0xfffffffd,%ebp
  mov    $0x1,%r14d
  jmp    L36
L10:
  mov    %r12d,%edx
  lea    D1(%rip),%rsi
  mov    %r15,%rdi
  mov    $0x0,%eax
  call   <sprintf@plt>
  mov    %r15,%rdi
  call   <system@plt>
  jmp    L65
L48:
  test   %r14d,%r14d
  jne    L24
  add    $0x1,%r12d
L104:
  mov    0x8(%rsp),%rdx
  mov    $0x8000,%esi
  mov    %rbx,%rdi
  call   <fgets@plt>
  test   %rax,%rax
  mov    $0xfffffffe,%eax
  cmove  %eax,%ebp
  mov    %rbx,%rdi
  call   <strlen@plt>
  cmp    $0x8000,%eax
  je     L50
  test   %ebp,%ebp
  setne  %r14b
  movzbl %r14b,%r14d
  mov    %rbx,%rdi
  call   <strlen@plt>
  test   %eax,%eax
  jle    L48
L36:
  lea    0x10(%rsp),%r13
  mov    %r12d,%edx
  lea    D55(%rip),%rsi
  mov    %r13,%rdi
  mov    $0x0,%eax
  call   <sprintf@plt>
  lea    0x410(%rsp),%r15
  mov    %r13,%rdx
  lea    D59(%rip),%rsi
  mov    %r15,%rdi
  mov    $0x0,%eax
  call   <sprintf@plt>
  lea    D47(%rip),%rsi
  mov    %r15,%rdi
  call   <fopen@plt>
  mov    %rax,%r15
  mov    %rbx,%rdx
  lea    D46(%rip),%rsi
  mov    %rax,%rdi
  call   <fprintf@plt>
  mov    %r15,%rdi
  call   <fclose@plt>
  lea    0x810(%rsp),%r15
  mov    %r13,%rdx
  lea    D40(%rip),%rsi
  mov    %r15,%rdi
  mov    $0x0,%eax
  call   <sprintf@plt>
  mov    %r15,%rdi
  call   <system@plt>
  movslq %r12d,%rax
  imul   $0x68db8bad,%rax,%rax
  sar    $0x2d,%rax
  mov    %r12d,%edx
  sar    $0x1f,%edx
  sub    %edx,%eax
  imul   $0x4e20,%eax,%eax
  cmp    %eax,%r12d
  je     L10
L65:
  cmp    $0xf4240,%r12d
  jle    L48
L24:
  mov    0x8c18(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L64
  mov    %ebp,%eax
  add    $0x8c28,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L50:
  mov    %rbx,%rdi
  call   <strlen@plt>
  test   %eax,%eax
  jg     L121
  mov    $0xfffffffd,%ebp
  jmp    L24
L64:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: extract_symbolic_data
arguments: data_label: D53
type_infered: string
name: extract_symbolic_data
arguments: data_label: D1
type_infered: string
name: extract_symbolic_data
arguments: data_label: D55
type_infered: string
name: extract_symbolic_data
arguments: data_label: D59
type_infered: string
name: extract_symbolic_data
arguments: data_label: D47
type_infered: string
name: extract_symbolic_data
arguments: data_label: D46
type_infered: string
name: extract_symbolic_data
arguments: data_label: D40
type_infered: string

tool: D53: r

tool: D1: x-snap %09d

tool: D55: %08d

tool: D59: %s.json

tool: D47: w

tool: D46: %s

tool: D40: cs-extract-cert %s

assistant: ```c
int main(int argc, char *argv[]) {
  int done;
  FILE *errlog;
  FILE *fcs;
  int index;
  char line[32 * 1024];
  int status;
  char *status_gets;
  status = 0;
  errlog = stderr;
  index = 1;
  done = 0;
  fcs = fopen(argv[1], "r");
  if (fcs == NULL) {
    status = -1;
    done = 1;
  };
  while (!done) {
    status_gets = fgets(line, sizeof(line), fcs);
    if (status_gets == NULL) {
      status = -2;
    };
    if (sizeof(line) == strlen(line)) {
      status = -3;
    };
    if (status != 0)
      done = 1;
    if (strlen(line) > 0) {
      char sample_name_base[1024];
      char sample_filename[1024];
      FILE *fjson;
      char command[1024];
      sprintf(sample_name_base, "%08d", index);
      sprintf(sample_filename, "%s.json", sample_name_base);
      fjson = fopen(sample_filename, "w");
      fprintf(fjson, "%s", line);
      fclose(fjson);
      sprintf(command, "cs-extract-cert %s", sample_name_base);
      system(command);
      if (0 == (index % 20000)) {
        sprintf(command, "x-snap %09d", index);
        system(command);
      };
      if (index > 1000000)
        done = 1;
    };
    if (!done)
      index++;
  };
  return (status);
}
```