user: Demonstrate the C code that generates the assembly output below:

```asm
<proc_find>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x2a8,%rsp
  mov    %rdi,0x8(%rsp)
  mov    %fs:0x28,%rax
  mov    %rax,0x298(%rsp)
  xor    %eax,%eax
  movq   $0x0,0x20(%rsp)
  movq   $0x0,0x28(%rsp)
  movq   $0x0,0x30(%rsp)
  movq   $0x0,0x38(%rsp)
  movq   $0x0,0x40(%rsp)
  movq   $0x0,0x48(%rsp)
  movq   $0x0,0x50(%rsp)
  movq   $0x0,0x58(%rsp)
  movq   $0x0,0x60(%rsp)
  movq   $0x0,0x68(%rsp)
  movq   $0x0,0x70(%rsp)
  movq   $0x0,0x78(%rsp)
  movl   $0x0,0x80(%rsp)
  lea    D17(%rip),%rdi
  call   <opendir@plt>
  test   %rax,%rax
  je     L64
  mov    %rax,%r13
  lea    D51(%rip),%r15
  lea    D33(%rip),%r14
L45:
  lea    0x90(%rsp),%r12
L61:
  mov    %r13,%rdi
  call   <readdir@plt>
  test   %rax,%rax
  je     L22
  mov    (%rax),%edi
  call   <atol@plt>
  mov    %rax,%rbx
  test   %rax,%rax
  js     L61
  mov    %rax,%rcx
  mov    %r15,%rdx
  mov    $0x200,%esi
  mov    %r12,%rdi
  call   <snprintf@plt>
  mov    %r14,%rsi
  mov    %r12,%rdi
  call   <fopen@plt>
  mov    %rax,%rbp
  test   %rax,%rax
  je     L61
  lea    0x20(%rsp),%rcx
  lea    0x18(%rsp),%rdx
  lea    0x17(%rsp),%r8
  lea    D48(%rip),%rsi
  mov    %rax,%rdi
  call   <fscanf@plt>
  cmp    $0x3,%eax
  jne    L52
  lea    0x20(%rsp),%rdi
  mov    0x8(%rsp),%rsi
  call   <strcmp@plt>
  test   %eax,%eax
  je     L1
  mov    %rbp,%rdi
  call   <fclose@plt>
  jmp    L45
L64:
  lea    D50(%rip),%rdi
  call   <perror@plt>
  mov    $0xffffffff,%eax
  jmp    L101
L52:
  lea    D0(%rip),%rsi
  mov    $0x2,%edi
  call   <ac_log@plt>
  mov    %rbp,%rdi
  call   <fclose@plt>
  mov    %r13,%rdi
  call   <closedir@plt>
  mov    $0xffffffff,%eax
  jmp    L101
L1:
  mov    %rbp,%rdi
  call   <fclose@plt>
  mov    %r13,%rdi
  call   <closedir@plt>
  mov    %ebx,%eax
  jmp    L101
L22:
  mov    %r13,%rdi
  call   <closedir@plt>
  mov    $0xffffffff,%eax
L101:
  mov    0x298(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L109
  add    $0x2a8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L109:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: extract_symbolic_data
arguments: tag: D17
data_type: string
name: extract_symbolic_data
arguments: tag: D51
data_type: string
name: extract_symbolic_data
arguments: tag: D33
data_type: string
name: extract_symbolic_data
arguments: tag: D48
data_type: string
name: extract_symbolic_data
arguments: tag: D50
data_type: string
name: extract_symbolic_data
arguments: tag: D0
data_type: string

tool: D17: /proc

tool: D51: /proc/%ld/stat

tool: D33: r

tool: D48: %ld (%[^)]) %c

tool: D50: can't open /proc

tool: D0: fscanf failed 


assistant: ```c
pid_t proc_find(const char *name) {
  DIR *dir;
  struct dirent *ent;
  char buf[512];
  long pid;
  char pname[100] = {
      0,
  };
  char state;
  FILE *fp = NULL;
  if (!(dir = opendir("/proc"))) {
    perror("can't open /proc");
    return -1;
  }
  while ((ent = readdir(dir)) != NULL) {
    long lpid = atol(ent->d_name);
    if (lpid < 0)
      continue;
    snprintf(buf, sizeof(buf), "/proc/%ld/stat", lpid);
    fp = fopen(buf, "r");
    if (fp) {
      if ((fscanf(fp, "%ld (%[^)]) %c", &pid, pname, &state)) != 3) {
        ac_log(2, "fscanf failed \n");
        fclose(fp);
        closedir(dir);
        return -1;
      }
      if (!strcmp(pname, name)) {
        fclose(fp);
        closedir(dir);
        return (pid_t)lpid;
      }
      fclose(fp);
    }
  }
  closedir(dir);
  return -1;
}
```