user: Please show me the C implementation that matches the assembly code listed below:

```asm
<find_pname>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x450,%rsp
  mov    %rdi,-0x448(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  lea    D12(%rip),%rax
  mov    %rax,%rdi
  call   <opendir@plt>
  mov    %rax,-0x438(%rbp)
  cmpq   $0x0,-0x438(%rbp)
  jne    L5
  lea    D26(%rip),%rax
  mov    %rax,%rdi
  call   <perror@plt>
  mov    $0xffffffff,%eax
  jmp    L94
L17:
  mov    -0x430(%rbp),%rax
  mov    (%rax),%eax
  lea    -0x440(%rbp),%rcx
  mov    $0xa,%edx
  mov    %rcx,%rsi
  mov    %eax,%edi
  call   <strtol@plt>
  mov    %rax,-0x428(%rbp)
  mov    -0x440(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  je     L42
  jmp    L5
L42:
  mov    -0x428(%rbp),%rdx
  lea    -0x410(%rbp),%rax
  mov    %rdx,%rcx
  lea    D1(%rip),%rdx
  mov    $0x400,%esi
  mov    %rax,%rdi
  call   <snprintf@plt>
  lea    -0x410(%rbp),%rax
  lea    D49(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <fopen@plt>
  mov    %rax,-0x420(%rbp)
  cmpq   $0x0,-0x420(%rbp)
  je     L5
  mov    -0x420(%rbp),%rdx
  lea    -0x410(%rbp),%rax
  mov    $0x400,%esi
  mov    %rax,%rdi
  call   <fgets@plt>
  test   %rax,%rax
  je     L72
  lea    -0x410(%rbp),%rax
  lea    D18(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strtok@plt>
  mov    %rax,-0x418(%rbp)
  mov    -0x448(%rbp),%rdx
  mov    -0x418(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcmp@plt>
  test   %eax,%eax
  jne    L72
  mov    -0x420(%rbp),%rax
  mov    %rax,%rdi
  call   <fclose@plt>
  mov    -0x438(%rbp),%rax
  mov    %rax,%rdi
  call   <closedir@plt>
  mov    -0x428(%rbp),%rax
  jmp    L94
L72:
  mov    -0x420(%rbp),%rax
  mov    %rax,%rdi
  call   <fclose@plt>
L5:
  mov    -0x438(%rbp),%rax
  mov    %rax,%rdi
  call   <readdir@plt>
  mov    %rax,-0x430(%rbp)
  cmpq   $0x0,-0x430(%rbp)
  jne    L17
  mov    -0x438(%rbp),%rax
  mov    %rax,%rdi
  call   <closedir@plt>
  mov    $0xffffffff,%eax
L94:
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L59
  call   <__stack_chk_fail@plt>
L59:
  leave
  ret
```

tool_calls: name: extract_symbolic_data
arguments: label: D12
type_infered: string
name: extract_symbolic_data
arguments: label: D26
type_infered: string
name: extract_symbolic_data
arguments: label: D1
type_infered: string
name: extract_symbolic_data
arguments: label: D49
type_infered: string
name: extract_symbolic_data
arguments: label: D18
type_infered: string

tool: D12: /proc

tool: D26: cant open /proc folder

tool: D1: /proc/%ld/cmdline

tool: D49: r

tool: D18:  

assistant: ```c
pid_t find_pname(const char *name) {
  DIR *dir;
  struct dirent *ent;
  char *endptr;
  char buf[1024];
  if ((dir = opendir("/proc")) == NULL) {
    perror("cant open /proc folder");
    return -1;
  }
  while ((ent = readdir(dir)) != NULL) {
    long lpid = strtol(ent->d_name, &endptr, 10);
    if (*endptr != '\0') {
      continue;
    }
    snprintf(buf, sizeof(buf), "/proc/%ld/cmdline", lpid);
    FILE *fp = fopen(buf, "r");
    if (fp) {
      if (fgets(buf, sizeof(buf), fp) != NULL) {
        char *first = strtok(buf, " ");
        if (!strcmp(first, name)) {
          fclose(fp);
          closedir(dir);
          return (pid_t)lpid;
        }
      }
      fclose(fp);
    }
  }
  closedir(dir);
  return -1;
}
```