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

```asm
<main>:
  endbr64
  push   %r15
  mov    $0x100,%edi
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x58,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x48(%rsp)
  xor    %eax,%eax
  mov    $0x920,%eax
  movb   $0x0,0x2f(%rsp)
  mov    %ax,0x2d(%rsp)
  call   <malloc@plt>
  mov    $0x100,%edi
  movl   $0x100,0x1c(%rsp)
  mov    %rax,0x20(%rsp)
  call   <malloc@plt>
  mov    0x20(%rsp),%rdi
  lea    D9(%rip),%rdx
  lea    D19(%rip),%rsi
  mov    %rax,%rbp
  xor    %eax,%eax
  call   <sprintf@plt>
  mov    0x20(%rsp),%rdi
  lea    D134(%rip),%rsi
  call   <fopen@plt>
  lea    D70(%rip),%rdi
  test   %rax,%rax
  je     L68
  lea    D88(%rip),%rsi
  lea    D3(%rip),%rdi
  mov    %rax,%r12
  call   <fopen@plt>
  lea    0x1c(%rsp),%r14
  lea    0x20(%rsp),%rbx
  mov    %rax,%r13
  test   %rax,%rax
  je     L169
  nopl   0x0(%rax)
L46:
  xor    %esi,%esi
  mov    $0x100,%edx
  mov    %rbp,%rdi
  call   <memset@plt>
  mov    %r12,%rdx
  mov    %r14,%rsi
  mov    %rbx,%rdi
  call   <getline@plt>
  test   %rax,%rax
  js     L36
  mov    0x20(%rsp),%r15
  mov    $0x23,%esi
  mov    %r15,%rdi
  call   <strchr@plt>
  test   %rax,%rax
  je     L30
  mov    %r13,%rsi
  mov    %r15,%rdi
  call   <fputs@plt>
  jmp    L46
  nopw   0x0(%rax,%rax,1)
L30:
  lea    0x30(%rsp),%r15
  xor    %esi,%esi
  mov    $0x14,%edx
  mov    %r15,%rdi
  call   <memset@plt>
  mov    0x20(%rsp),%rdi
  lea    D16(%rip),%rsi
  mov    %r15,%rdx
  call   <sscanf@plt>
  lea    D64(%rip),%rsi
  mov    %r15,%rdi
  call   <strstr@plt>
  test   %rax,%rax
  jne    L10
  lea    D146(%rip),%rsi
  mov    %r15,%rdi
  call   <strstr@plt>
  test   %rax,%rax
  je     L136
L10:
  mov    0x20(%rsp),%rdi
  mov    %r13,%rsi
  call   <fputs@plt>
  jmp    L46
  cs nopw 0x0(%rax,%rax,1)
L36:
  mov    %r13,%rdi
  call   <fclose@plt>
  mov    %r12,%rdi
  call   <fclose@plt>
  mov    0x20(%rsp),%rdi
  lea    D9(%rip),%rdx
  xor    %eax,%eax
  lea    D122(%rip),%rsi
  call   <sprintf@plt>
  mov    0x20(%rsp),%rdi
  call   <system@plt>
  lea    D69(%rip),%rdi
  call   <system@plt>
  mov    0x20(%rsp),%rdi
  call   <free@plt>
  mov    %rbp,%rdi
  call   <free@plt>
L144:
  mov    0x48(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L39
  add    $0x58,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L136:
  lea    0x2d(%rsp),%rax
  mov    %r12,0x8(%rsp)
  mov    $0x1,%r15d
  mov    %rax,%r12
  jmp    L95
  nopl   0x0(%rax)
L54:
  xor    %edi,%edi
  call   <strtok@plt>
  mov    %rax,%rcx
  test   %rax,%rax
  je     L52
  xor    %eax,%eax
  mov    %rbp,%rdx
  lea    D85(%rip),%rsi
  mov    %rbp,%rdi
  call   <sprintf@plt>
  cmp    $0xb,%r15d
  je     L26
L66:
  add    $0x1,%r15d
L95:
  mov    %r12,%rsi
  cmp    $0x1,%r15d
  jne    L54
  mov    0x20(%rsp),%rdi
  call   <strtok@plt>
  lea    D16(%rip),%rsi
  mov    %rbp,%rdi
  mov    %rax,%rdx
  xor    %eax,%eax
  call   <sprintf@plt>
  jmp    L66
L26:
  mov    %r13,%rsi
  mov    %rbp,%rdi
  mov    0x8(%rsp),%r12
  call   <fputs@plt>
  jmp    L46
L169:
  lea    D18(%rip),%rdi
L68:
  call   <printf@plt>
  mov    0x20(%rsp),%rdi
  call   <free@plt>
  mov    %rbp,%rdi
  call   <free@plt>
  jmp    L144
L52:
  mov    0x8(%rsp),%r12
  jmp    L46
L39:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: unpack_data
arguments: data_tag: D9
type_guessed: string
name: unpack_data
arguments: data_tag: D19
type_guessed: string
name: unpack_data
arguments: data_tag: D134
type_guessed: string
name: unpack_data
arguments: data_tag: D70
type_guessed: string
name: unpack_data
arguments: data_tag: D88
type_guessed: string
name: unpack_data
arguments: data_tag: D3
type_guessed: string
name: unpack_data
arguments: data_tag: D16
type_guessed: string
name: unpack_data
arguments: data_tag: D64
type_guessed: string
name: unpack_data
arguments: data_tag: D146
type_guessed: string
name: unpack_data
arguments: data_tag: D122
type_guessed: string
name: unpack_data
arguments: data_tag: D69
type_guessed: string
name: unpack_data
arguments: data_tag: D85
type_guessed: string
name: unpack_data
arguments: data_tag: D18
type_guessed: string

tool: D9: /usr/lib/npreal2/driver

tool: D19: %s/npreal2d.cf

tool: D134: r

tool: D70: file open error1


tool: D88: w

tool: D3: /tmp/npr_tmpfile3

tool: D16: %s

tool: D64: ttymajor

tool: D146: calloutmajor

tool: D122: cp -f /tmp/npr_tmpfile3 %s/npreal2d.cf

tool: D69: rm -f /tmp/npr_tmpfile3

tool: D85: %s	%s

tool: D18: file open error2


assistant: ```c
int main(int arg, char *argv[]) {
  int i, j, len, flag;
  char *tmpstr, *token, *minor_token, *chk;
  char delim[] = " \t";
  char major[20];
  FILE *f, *ft;
  tmpstr = (char *)malloc(256);
  len = 256;
  token = (char *)malloc(256);
  sprintf(tmpstr, "%s/npreal2d.cf", "/usr/lib/npreal2/driver");
  f = fopen(tmpstr, "r");
  if (f == NULL) {
    printf("file open error1\n");
    free(tmpstr);
    free(token);
    return (0);
  }
  ft = fopen("/tmp/npr_tmpfile3", "w");
  if (ft == NULL) {
    printf("file open error2\n");
    free(tmpstr);
    free(token);
    return (0);
  }
  for (;;) {
    flag = 0;
    memset(token, '\0', 256);
    if (getline(&tmpstr, (size_t *)&len, f) < 0) {
      break;
    }
    if (strstr(tmpstr, "#") != NULL) {
      fputs(tmpstr, ft);
      continue;
    }
    memset(major, '\0', 20);
    sscanf(tmpstr, "%s", major);
    if (strstr(major, "ttymajor") != NULL || strstr(major, "calloutmajor") != NULL) {
      fputs(tmpstr, ft);
      continue;
    }
    for (i = 0; i < 11; i++) {
      if (i == 0) {
        minor_token = strtok(tmpstr, delim);
        sprintf(token, "%s", minor_token);
      } else {
        chk = strtok(NULL, delim);
        if (chk == NULL) {
          flag = 1;
          break;
        }
        sprintf(token, "%s\t%s", token, chk);
      }
    }
    if (flag == 1) {
      continue;
    }
    fputs(token, ft);
  }
  fclose(ft);
  fclose(f);
  sprintf(tmpstr, "cp -f /tmp/npr_tmpfile3 %s/npreal2d.cf", "/usr/lib/npreal2/driver");
  system(tmpstr);
  system("rm -f /tmp/npr_tmpfile3");
  free(tmpstr);
  free(token);
  return 0;
}
```