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

```asm
<pathsearch>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %rbx
  sub    $0x48,%rsp
  mov    %rdi,-0x38(%rbp)
  mov    %rsi,-0x40(%rbp)
  mov    %edx,-0x44(%rbp)
  mov    -0x38(%rbp),%rax
  mov    $0x2f,%esi
  mov    %rax,%rdi
  call   <strrchr@plt>
  mov    %rax,-0x18(%rbp)
  cmpq   $0x0,-0x18(%rbp)
  je     L41
  mov    -0x18(%rbp),%rax
  movzbl (%rax),%eax
  mov    %al,-0x29(%rbp)
  mov    -0x18(%rbp),%rax
  movb   $0x0,(%rax)
  mov    -0x38(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    %rax,%rbx
  mov    -0x40(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  add    %rbx,%rax
  add    $0x2,%rax
  mov    %rax,%rdi
  call   <malloc@plt>
  mov    %rax,-0x20(%rbp)
  cmpq   $0x0,-0x20(%rbp)
  je     L75
  mov    -0x40(%rbp),%rcx
  mov    -0x38(%rbp),%rdx
  mov    -0x20(%rbp),%rax
  lea    D3(%rip),%rsi
  mov    %rax,%rdi
  call   <sprintf@plt>
L75:
  mov    -0x18(%rbp),%rax
  movzbl -0x29(%rbp),%edx
  mov    %dl,(%rax)
  jmp    L55
L41:
  lea    D8(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <getenv@plt>
  mov    %rax,-0x28(%rbp)
  cmpq   $0x0,-0x28(%rbp)
  jne    L40
  lea    D6(%rip),%rax
  mov    %rax,-0x28(%rbp)
L40:
  mov    -0x28(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    %rax,%rbx
  mov    -0x40(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  add    %rbx,%rax
  add    $0x2,%rax
  mov    %rax,%rdi
  call   <malloc@plt>
  mov    %rax,-0x20(%rbp)
  cmpq   $0x0,-0x20(%rbp)
  je     L55
  jmp    L91
L53:
  mov    -0x28(%rbp),%rax
  mov    $0x3a,%esi
  mov    %rax,%rdi
  call   <strchr@plt>
  mov    %rax,-0x18(%rbp)
  cmpq   $0x0,-0x18(%rbp)
  jne    L115
  mov    -0x28(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    -0x28(%rbp),%rdx
  add    %rdx,%rax
  mov    %rax,-0x18(%rbp)
L115:
  mov    -0x18(%rbp),%rax
  movzbl (%rax),%eax
  mov    %al,-0x29(%rbp)
  mov    -0x18(%rbp),%rax
  movb   $0x0,(%rax)
  mov    -0x40(%rbp),%rcx
  mov    -0x28(%rbp),%rdx
  mov    -0x20(%rbp),%rax
  lea    D3(%rip),%rsi
  mov    %rax,%rdi
  call   <sprintf@plt>
  mov    -0x18(%rbp),%rax
  movzbl -0x29(%rbp),%edx
  mov    %dl,(%rax)
  cmpb   $0x0,-0x29(%rbp)
  jne    L45
  lea    D20(%rip),%rax
  mov    %rax,-0x28(%rbp)
  jmp    L72
L45:
  mov    -0x18(%rbp),%rax
  add    $0x1,%rax
  mov    %rax,-0x28(%rbp)
L72:
  mov    -0x44(%rbp),%edx
  mov    -0x20(%rbp),%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  call   <access@plt>
  test   %rax,%rax
  je     L116
L91:
  mov    -0x28(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  jne    L53
  jmp    L55
L116:
  nop
L55:
  mov    -0x20(%rbp),%rax
  mov    -0x8(%rbp),%rbx
  leave
  ret
```

tool_calls: name: disassemble_data
arguments: data_tag: D3
data_type: string
name: disassemble_data
arguments: data_tag: D8
data_type: string
name: disassemble_data
arguments: data_tag: D6
data_type: string
name: disassemble_data
arguments: data_tag: D20
data_type: string

tool: D3: %s/%s

tool: D8: PATH

tool: D6: .:/bin:/usr/bin

tool: 

assistant: ```c
char *pathsearch(char *argv0, char *name, int modemask) {
  char *pathlist;
  char *path, *cp;
  char c;
  cp = strrchr(argv0, '/');
  if (cp) {
    c = *cp;
    *cp = 0;
    path = (char *)malloc(strlen(argv0) + strlen(name) + 2);
    if (path)
      sprintf(path, "%s/%s", argv0, name);
    *cp = c;
  } else {
    extern char *getenv();
    pathlist = getenv("PATH");
    if (pathlist == 0)
      pathlist = ".:/bin:/usr/bin";
    path = (char *)malloc(strlen(pathlist) + strlen(name) + 2);
    if (path != 0) {
      while (*pathlist) {
        cp = strchr(pathlist, ':');
        if (cp == 0)
          cp = &pathlist[strlen(pathlist)];
        c = *cp;
        *cp = 0;
        sprintf(path, "%s/%s", pathlist, name);
        *cp = c;
        if (c == 0)
          pathlist = "";
        else
          pathlist = &cp[1];
        if (access(path, modemask) == 0)
          break;
      }
    }
  }
  return path;
}
```