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

```asm
<cap_getstr>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x848,%rsp
  mov    %rdi,0x10(%rsp)
  mov    %rcx,(%rsp)
  mov    %r8d,0xc(%rsp)
  mov    %fs:0x28,%rax
  mov    %rax,0x838(%rsp)
  mov    D22(%rip),%eax
  add    $0x1,%eax
  mov    %eax,D63(%rip)
  cmp    $0x20,%eax
  jg     L17
  mov    %rsi,%rbx
  lea    D63(%rip),%rsi
  mov    %rdx,%r13
  call   <fopen@plt>
  mov    %rax,%r14
  test   %rax,%rax
  je     L12
  lea    0x30(%rsp),%r15
  lea    D57(%rip),%r12
L67:
  mov    $0x800,%edx
  mov    %r15,%rsi
  mov    %r14,%rdi
  call   <cap_getent@plt>
  test   %rax,%rax
  jle    L172
  mov    $0x3a,%esi
  mov    %r15,%rdi
  lea    0x20(%rsp),%rbp
  call   <strchr@plt>
  mov    %r15,%rdi
  mov    %rbp,%rdx
  mov    %r12,%rsi
  movb   $0x0,(%rax)
  mov    %rax,0x18(%rsp)
  call   <strtok_r@plt>
  mov    %rax,%rdi
  test   %rax,%rax
  jne    L80
  jmp    L67
  nopl   0x0(%rax)
L100:
  xor    %edi,%edi
  mov    %rbp,%rdx
  mov    %r12,%rsi
  call   <strtok_r@plt>
  mov    %rax,%rdi
  test   %rax,%rax
  je     L67
L80:
  mov    %rbx,%rsi
  call   <strcmp@plt>
  test   %rax,%rax
  jne    L100
  mov    0x18(%rsp),%rdi
  lea    0x28(%rsp),%rbp
  lea    D71(%rip),%rbx
  mov    %rbp,%rdx
  mov    %rbx,%rsi
  add    $0x1,%rdi
  call   <strtok_r@plt>
  mov    %rax,%r15
  test   %rax,%rax
  je     L172
  lea    D38(%rip),%r12
  nopl   0x0(%rax)
L95:
  mov    $0x2,%edx
  mov    %r13,%rsi
  mov    %r15,%rdi
  call   <strncmp@plt>
  test   %rax,%rax
  jne    L5
  cmpb   $0x3d,0x2(%r15)
  je     L157
L5:
  mov    $0x3,%edx
  mov    %r12,%rsi
  mov    %r15,%rdi
  call   <strncmp@plt>
  test   %rax,%rax
  jne    L22
  mov    0xc(%rsp),%r8d
  mov    (%rsp),%rcx
  lea    0x3(%r15),%rsi
  mov    %r13,%rdx
  mov    0x10(%rsp),%rdi
  call   <cap_getstr>
  mov    %rax,%r15
  test   %rax,%rax
  jne    L106
L22:
  mov    %rbp,%rdx
  mov    %rbx,%rsi
  xor    %edi,%edi
  call   <strtok_r@plt>
  mov    %rax,%r15
  test   %rax,%rax
  jne    L95
L172:
  xor    %r15d,%r15d
L106:
  mov    %r14,%rdi
  subl   $0x1,D63(%rip)
  call   <fclose@plt>
L141:
  mov    0x838(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L176
  add    $0x848,%rsp
  mov    %r15,%rax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  cs nopw 0x0(%rax,%rax,1)
L12:
  subl   $0x1,D63(%rip)
L17:
  xor    %r15d,%r15d
  jmp    L141
  nopl   0x0(%rax)
L157:
  mov    (%rsp),%rbx
  add    $0x3,%r15
  mov    %r15,%rdi
  test   %rbx,%rbx
  je     L69
  call   <strlen@plt>
  cmp    0xc(%rsp),%eax
  jge    L17
  mov    %r15,%rsi
  mov    %rbx,%rdi
  mov    %rbx,%r15
  call   <strcpy@plt>
  jmp    L106
L69:
  call   <s_dup@plt>
  mov    %rax,%r15
  jmp    L106
L176:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: extract_symbolic_data
arguments: tag: D63
data_type: string
name: extract_symbolic_data
arguments: tag: D57
data_type: string
name: extract_symbolic_data
arguments: tag: D71
data_type: string
name: extract_symbolic_data
arguments: tag: D38
data_type: string

tool: D63: r

tool: D57: |

tool: D71: :

tool: D38: tc=

assistant: ```c
char *cap_getstr(const char *path, const char *entname, const char *strname, char *buf, int bufsize) {
  FILE *fp;
  char *cp, *tp;
  char *lcp, *ltp;
  static int rlev = 0;
  char *retval = NULL;
  char entbuf[2048];
  if (++rlev > 32)
    return NULL;
  fp = fopen(path, "r");
  if (fp == NULL)
    goto Exit;
  while (cap_getent(fp, entbuf, sizeof(entbuf)) > 0) {
    tp = strchr(entbuf, ':');
    *tp++ = '\0';
    cp = strtok_r(entbuf, "|", &lcp);
    while (cp) {
      if (strcmp(cp, entname) == 0) {
        tp = strtok_r(tp, ":", &ltp);
        while (tp) {
          if (strncmp(tp, strname, 2) == 0 && tp[2] == '=') {
            if (buf) {
              if (strlen(tp + 3) >= bufsize)
                return NULL;
              strcpy(buf, tp + 3);
              retval = buf;
            } else
              retval = s_dup(tp + 3);
            goto Exit;
          } else if (strncmp(tp, "tc=", 3) == 0) {
            retval = cap_getstr(path, tp + 3, strname, buf, bufsize);
            if (retval)
              goto Exit;
          }
          tp = strtok_r(NULL, ":", &ltp);
        }
        goto Exit;
      }
      cp = strtok_r(NULL, "|", &lcp);
    }
  }
Exit:
  --rlev;
  if (fp)
    fclose(fp);
  return retval;
}
```