user: Translate the below assembly code into C programming language:

```asm
<close_nonstd_fds>:
  endbr64
  push   %r15
  lea    D17(%rip),%rdi
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x48,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x38(%rsp)
  xor    %eax,%eax
  movq   $0x0,(%rsp)
  movq   $0x0,0x8(%rsp)
  call   <opendir@plt>
  mov    %rax,%rbp
  test   %rax,%rax
  je     L32
  lea    D16(%rip),%r12
  lea    D4(%rip),%r13
  lea    D44(%rip),%r14
L96:
  mov    %rbp,%rdi
  call   <readdir@plt>
  mov    %rax,%rbx
  test   %rax,%rax
  je     L0
L7:
  mov    (%rsp),%rdi
  call   <free@plt>
  mov    0x8(%rsp),%rdi
  call   <free@plt>
  mov    (%rbx),%rdi
  mov    %r12,%rsi
  call   <strcmp@plt>
  test   %rax,%rax
  je     L96
  mov    (%rbx),%rdi
  mov    %r13,%rsi
  call   <strcmp@plt>
  test   %rax,%rax
  je     L96
  mov    (%rbx),%rdx
  lea    0x8(%rsp),%rdi
  mov    %r14,%rsi
  call   <asprintf@plt>
  cmp    $0xffffffff,%eax
  je     L32
  xor    %eax,%eax
  call   <getpid@plt>
  mov    %rsp,%rdi
  lea    D46(%rip),%rsi
  mov    %rax,%rdx
  call   <asprintf@plt>
  cmp    $0xffffffff,%eax
  je     L32
  lea    0x10(%rsp),%r15
  mov    $0x20,%esi
  mov    %r15,%rdi
  call   <bzero@plt>
  mov    0x8(%rsp),%rdi
  mov    $0x1f,%edx
  mov    %r15,%rsi
  call   <readlink@plt>
  cmp    $0xffffffff,%eax
  je     L32
  mov    (%rsp),%rdi
  mov    %r15,%rsi
  call   <strcmp@plt>
  test   %rax,%rax
  je     L96
  mov    (%rbx),%rdi
  call   <atoi@plt>
  cmp    $0x2,%eax
  jbe    L96
  mov    %eax,%edi
  call   <close@plt>
  mov    %rbp,%rdi
  call   <readdir@plt>
  mov    %rax,%rbx
  test   %rax,%rax
  jne    L7
L0:
  xor    %r12d,%r12d
L57:
  mov    %rbp,%rdi
  call   <closedir@plt>
  mov    (%rsp),%rdi
  call   <free@plt>
  mov    0x8(%rsp),%rdi
  call   <free@plt>
  mov    0x38(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L115
  add    $0x48,%rsp
  mov    %r12d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L32:
  mov    $0xffffffff,%r12d
  jmp    L57
L115:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: parse_data
arguments: data_tag: D17
type: string
name: parse_data
arguments: data_tag: D16
type: string
name: parse_data
arguments: data_tag: D4
type: string
name: parse_data
arguments: data_tag: D44
type: string
name: parse_data
arguments: data_tag: D46
type: string

tool: D17: /proc/self/fd

tool: D16: .

tool: D4: ..

tool: D44: /proc/self/fd/%s

tool: D46: /proc/%d/fd

assistant: ```c
int close_nonstd_fds(void) {
  const int procpidfdmax = 32;
  int rv = -1;
  int fd = -1;
  char *cmp = NULL;
  char *sym = NULL;
  char phys[procpidfdmax];
  DIR *dir = NULL;
  struct dirent *ent = NULL;
  dir = opendir("/proc/self/fd");
  if (!dir) {
    goto out;
  }
  while ((ent = readdir(dir)) != NULL) {
    free(cmp);
    free(sym);
    if (strcmp(ent->d_name, ".") == 0)
      continue;
    if (strcmp(ent->d_name, "..") == 0)
      continue;
    if (asprintf(&sym, "/proc/self/fd/%s", ent->d_name) == -1)
      goto out;
    if (asprintf(&cmp, "/proc/%d/fd", getpid()) == -1)
      goto out;
    bzero(phys, sizeof(phys));
    if (readlink(sym, phys, procpidfdmax - 1) == -1)
      goto out;
    if (strcmp(cmp, phys) == 0)
      continue;
    fd = atoi(ent->d_name);
    switch (fd) {
    case 0:
    case 1:
    case 2:
      break;
    default:
      close(fd);
    }
  }
  rv = 0;
out:
  closedir(dir);
  dir = NULL;
  ent = NULL;
  free(cmp);
  free(sym);
  cmp = sym = NULL;
  return rv;
}
```