user: What is the c source code of the assembly code below:

```asm
<dump_ps>:
  endbr64
  push   %r15
  push   %r14
  xor    %r14d,%r14d
  push   %r13
  push   %r12
  mov    %edi,%r12d
  lea    D82(%rip),%rdi
  push   %rbp
  push   %rbx
  lea    D70(%rip),%rbx
  sub    $0x38,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x28(%rsp)
  xor    %eax,%eax
  call   <opendir@plt>
  movl   $0x0,0x4(%rsp)
  mov    %rax,%rbp
  jmp    L125
  nopl   0x0(%rax,%rax,1)
L45:
  mov    (%r15),%rax
  movsbl (%rax),%edi
  call   <isdigit@plt>
  test   %rax,%rax
  jne    L58
L125:
  mov    %rbp,%rdi
  call   <readdir@plt>
  mov    %rax,%r15
  test   %rax,%rax
  jne    L45
  xor    %r13d,%r13d
L9:
  mov    %rbp,%rdi
  call   <closedir@plt>
  mov    0x4(%rsp),%edx
  mov    %r14d,%ecx
  mov    %r12d,%edi
  lea    D142(%rip),%rsi
  xor    %eax,%eax
  call   <sockprint@plt>
  or     %r13d,%eax
  mov    0x28(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L6
  add    $0x38,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax)
L58:
  mov    (%r15),%rcx
  lea    D25(%rip),%rdx
  mov    $0x80,%esi
  mov    %rbx,%rdi
  call   <snprintf@plt>
  lea    D8(%rip),%rsi
  mov    %rbx,%rdi
  call   <fopen@plt>
  mov    %rax,%r10
  test   %rax,%rax
  je     L134
  lea    0x18(%rsp),%rdx
  lea    0x24(%rsp),%rax
  mov    %r10,%rdi
  push   %rax
  lea    D11(%rip),%r8
  lea    D30(%rip),%rcx
  push   %rdx
  lea    D44(%rip),%rsi
  push   %rdx
  push   %rdx
  lea    0x3c(%rsp),%rax
  push   %rax
  push   %rdx
  push   %rdx
  push   %rdx
  push   %rdx
  push   %rdx
  push   %rdx
  push   %rdx
  push   %rdx
  push   %rdx
  push   %rdx
  push   %rdx
  push   %rdx
  push   %rdx
  push   %rdx
  push   %rdx
  lea    0xc0(%rsp),%r9
  mov    %r10,0xa8(%rsp)
  call   <fscanf@plt>
  mov    (%r15),%rdx
  mov    %r12d,%edi
  xor    %eax,%eax
  mov    0xc4(%rsp),%r9d
  mov    0xbc(%rsp),%r8d
  add    $0xa0,%rsp
  lea    D10(%rip),%rsi
  mov    0x20(%rsp),%ecx
  call   <sockprint@plt>
  mov    0x8(%rsp),%rdi
  addl   $0x1,0x4(%rsp)
  mov    %eax,%r13d
  add    0x1c(%rsp),%r14d
  call   <fclose@plt>
  test   %r13d,%r13d
  jne    L9
  mov    (%r15),%rcx
  lea    D147(%rip),%rdx
  mov    $0x80,%esi
  mov    %rbx,%rdi
  call   <snprintf@plt>
  lea    D8(%rip),%rsi
  mov    %rbx,%rdi
  call   <fopen@plt>
  mov    %rax,%r15
  test   %rax,%rax
  je     L134
  lea    D56(%rip),%r13
  mov    $0xfff,%edx
  mov    %rax,%rcx
  mov    $0x1,%esi
  mov    %r13,%rdi
  call   <fread@plt>
  mov    %eax,%edx
  test   %eax,%eax
  jns    L102
  lea    D9(%rip),%rsi
  mov    %r12d,%edi
  call   <sockerror@plt>
  mov    %eax,%r13d
L103:
  mov    %r15,%rdi
  call   <fclose@plt>
L89:
  test   %r13d,%r13d
  je     L125
  jmp    L9
  nopl   0x0(%rax)
L134:
  mov    %rbx,%rdx
  lea    D116(%rip),%rsi
  mov    %r12d,%edi
  xor    %eax,%eax
  call   <sockprint@plt>
  mov    %eax,%r13d
  jmp    L89
  nopl   0x0(%rax)
L102:
  cltq
  movb   $0x0,0x0(%r13,%rax,1)
  je     L59
  lea    -0x1(%rdx),%eax
  lea    0x1(%r13),%rsi
  mov    %r13,%rcx
  add    %rax,%rsi
  nopw   0x0(%rax,%rax,1)
L52:
  cmpb   $0x0,(%rcx)
  jne    L8
  movb   $0x20,(%rcx)
L8:
  add    $0x1,%rcx
  cmp    %rsi,%rcx
  jne    L52
L59:
  mov    %r13,%rcx
  lea    D100(%rip),%rsi
  mov    %r12d,%edi
  xor    %eax,%eax
  call   <sockprint@plt>
  mov    %eax,%r13d
  jmp    L103
L6:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: retrieve_data
arguments: label: D82
type_guessed: string
name: retrieve_data
arguments: label: D142
type_guessed: string
name: retrieve_data
arguments: label: D25
type_guessed: string
name: retrieve_data
arguments: label: D8
type_guessed: string
name: retrieve_data
arguments: label: D44
type_guessed: string
name: retrieve_data
arguments: label: D10
type_guessed: string
name: retrieve_data
arguments: label: D147
type_guessed: string
name: retrieve_data
arguments: label: D9
type_guessed: string
name: retrieve_data
arguments: label: D116
type_guessed: string
name: retrieve_data
arguments: label: D100
type_guessed: string

tool: D82: /proc

tool: D142: # procs: %d, # threads: %d


tool: D25: /proc/%s/stat

tool: D8: r

tool: D44: %d %s %c %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d

tool: D10: %5s, ppid %5d, # threads: %2d, rss: %5d 

tool: D147: /proc/%s/cmdline

tool: D9: fread

tool: D116: Error opening %s


tool: D100: %d %s


assistant: ```c
int dump_ps(int fd) {
  int rc = 0, tnprocs = 0, tnthreads = 0;
  struct dirent *de;
  DIR *dirp = opendir("/proc");
  while ((de = readdir(dirp)) != NULL) {
    if (isdigit(de->d_name[0])) {
      FILE *fh;
      static char path[128];
      snprintf(path, sizeof(path), "/proc/%s/stat", de->d_name);
      fh = fopen(path, "r");
      if (fh) {
        static char fname[4096], dummystr[2];
        int dummy, nthreads, ppid, rss;
        fscanf(fh, "%d %s %c %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d", &dummy, fname, &dummystr[0], &ppid, &dummy, &dummy, &dummy, &dummy, &dummy, &dummy, &dummy, &dummy, &dummy, &dummy, &dummy, &dummy, &dummy, &dummy, &dummy, &nthreads, &dummy, &dummy, &dummy, &rss);
        rc |= sockprint(fd, "%5s, ppid %5d, # threads: %2d, rss: %5d ", de->d_name, ppid, nthreads, rss);
        tnprocs++;
        tnthreads += nthreads;
      }
      if (fh) {
        fclose(fh);
        if (rc)
          break;
        snprintf(path, sizeof(path), "/proc/%s/cmdline", de->d_name);
        fh = fopen(path, "r");
      }
      if (fh) {
        int len, loop;
        static char non_ret_buffer[4096];
        len = fread(non_ret_buffer, 1, sizeof(non_ret_buffer) - 1, fh);
        if (len < 0)
          rc |= sockerror(fd, "fread");
        else {
          non_ret_buffer[len] = 0x00;
          for (loop = 0; loop < len; loop++) {
            if (non_ret_buffer[loop] == 0x00)
              non_ret_buffer[loop] = ' ';
          }
          rc |= sockprint(fd, "%d %s\r\n", len, non_ret_buffer);
        }
        fclose(fh);
      } else {
        rc |= sockprint(fd, "Error opening %s\r\n", path);
      }
      if (rc)
        break;
    }
  }
  closedir(dirp);
  rc |= sockprint(fd, "# procs: %d, # threads: %d\r\n", tnprocs, tnthreads);
  return rc;
}
```