user: 请从给定的汇编指令推导出C源代码：

```asm
<pathsearch>:
  endbr64
  push   %r15
  mov    %rdi,%r15
  push   %r14
  push   %r13
  push   %r12
  mov    %rsi,%r12
  mov    $0x2f,%esi
  push   %rbp
  push   %rbx
  mov    %edx,%ebx
  sub    $0x18,%rsp
  call   <strrchr@plt>
  test   %rax,%rax
  je     L28
  movzbl (%rax),%r14d
  movb   $0x0,(%rax)
  mov    %r15,%rdi
  mov    %rax,%rbp
  call   <strlen@plt>
  mov    %r12,%rdi
  mov    %rax,%rbx
  call   <strlen@plt>
  lea    0x2(%rbx,%rax,1),%rdi
  call   <malloc@plt>
  mov    %rax,%r13
  test   %rax,%rax
  jne    L73
L106:
  mov    %r14b,0x0(%rbp)
L109:
  add    $0x18,%rsp
  mov    %r13,%rax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  xchg   %ax,%ax
L73:
  mov    %r12,%rcx
  mov    %r15,%rdx
  lea    D15(%rip),%rsi
  mov    %rax,%rdi
  call   <sprintf@plt>
  jmp    L106
  nopw   0x0(%rax,%rax,1)
L28:
  lea    D6(%rip),%rdi
  xor    %eax,%eax
  call   <getenv@plt>
  mov    %rax,%r14
  test   %rax,%rax
  je     L78
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    %rax,%rbp
L59:
  mov    %r12,%rdi
  xor    %r13d,%r13d
  call   <strlen@plt>
  lea    0x2(%rbp,%rax,1),%rdi
  call   <malloc@plt>
  mov    %rax,%rbp
  test   %rax,%rax
  je     L109
  mov    %rax,%r13
  jmp    L49
  nopw   0x0(%rax,%rax,1)
L2:
  movzbl (%r8),%r15d
  movb   $0x0,(%r8)
  mov    %r14,%rdx
  mov    %rbp,%rdi
  lea    D15(%rip),%rsi
  mov    %r12,%rcx
  mov    %r8,0x8(%rsp)
  lea    D12(%rip),%r14
  call   <sprintf@plt>
  mov    0x8(%rsp),%r8
  mov    %ebx,%esi
  mov    %rbp,%rdi
  mov    %r15b,(%r8)
  add    $0x1,%r8
  test   %r15b,%r15b
  cmovne %r8,%r14
  call   <access@plt>
  test   %rax,%rax
  je     L109
L49:
  cmpb   $0x0,(%r14)
  je     L109
  mov    $0x3a,%esi
  mov    %r14,%rdi
  call   <strchr@plt>
  mov    %rax,%r8
  test   %rax,%rax
  jne    L2
  mov    %r14,%rdi
  call   <strlen@plt>
  lea    (%r14,%rax,1),%r8
  jmp    L2
  nopl   0x0(%rax)
L78:
  mov    $0xf,%ebp
  lea    D22(%rip),%r14
  jmp    L59
```

tool_calls: name: disassemble_data
arguments: data_label: D15
type: string
name: disassemble_data
arguments: data_label: D6
type: string
name: disassemble_data
arguments: data_label: D12
type: string
name: disassemble_data
arguments: data_label: D22
type: string

tool: D15: %s/%s

tool: D6: PATH

tool: 

tool: D22: .:/bin:/usr/bin

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;
}
```