user: 请将以下的汇编代码转换成C语言代码：

```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     L46
  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    %eax,%ebx
  mov    -0x40(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  add    %ebx,%eax
  add    $0x2,%eax
  cltq
  mov    %rax,%rdi
  call   <malloc@plt>
  mov    %rax,-0x20(%rbp)
  cmpq   $0x0,-0x20(%rbp)
  je     L119
  mov    -0x40(%rbp),%rcx
  mov    -0x38(%rbp),%rdx
  mov    -0x20(%rbp),%rax
  lea    D3(%rip),%rsi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <sprintf@plt>
L119:
  mov    -0x18(%rbp),%rax
  movzbl -0x29(%rbp),%edx
  mov    %dl,(%rax)
  jmp    L0
L46:
  lea    D46(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <getenv@plt>
  mov    %rax,-0x28(%rbp)
  cmpq   $0x0,-0x28(%rbp)
  jne    L52
  lea    D25(%rip),%rax
  mov    %rax,-0x28(%rbp)
L52:
  mov    -0x28(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    %eax,%ebx
  mov    -0x40(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  add    %ebx,%eax
  add    $0x2,%eax
  cltq
  mov    %rax,%rdi
  call   <malloc@plt>
  mov    %rax,-0x20(%rbp)
  cmpq   $0x0,-0x20(%rbp)
  je     L0
  jmp    L20
L103:
  mov    -0x28(%rbp),%rax
  mov    $0x3a,%esi
  mov    %rax,%rdi
  call   <strchr@plt>
  mov    %rax,-0x18(%rbp)
  cmpq   $0x0,-0x18(%rbp)
  jne    L36
  mov    -0x28(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  movslq %eax,%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  mov    %rax,-0x18(%rbp)
L36:
  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
  mov    $0x0,%eax
  call   <sprintf@plt>
  mov    -0x18(%rbp),%rax
  movzbl -0x29(%rbp),%edx
  mov    %dl,(%rax)
  cmpb   $0x0,-0x29(%rbp)
  jne    L48
  lea    D40(%rip),%rax
  mov    %rax,-0x28(%rbp)
  jmp    L79
L48:
  mov    -0x18(%rbp),%rax
  add    $0x1,%rax
  mov    %rax,-0x28(%rbp)
L79:
  mov    -0x44(%rbp),%edx
  mov    -0x20(%rbp),%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <access@plt>
  test   %eax,%eax
  je     L58
L20:
  mov    -0x28(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  jne    L103
  jmp    L0
L58:
  nop
L0:
  mov    -0x20(%rbp),%rax
  mov    -0x8(%rbp),%rbx
  leave
  ret
```

tool_calls: name: extract_symbolic_data
arguments: data_label: D3
type_infered: string
name: extract_symbolic_data
arguments: data_label: D46
type_infered: string
name: extract_symbolic_data
arguments: data_label: D25
type_infered: string
name: extract_symbolic_data
arguments: data_label: D40
type_infered: string

tool: D3: %s/%s

tool: D46: PATH

tool: D25: .:/bin:/usr/bin

tool: 

assistant: ```c
char *pathsearch(argv0, name, modemask)
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(((int)strlen(argv0)) + ((int)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(((int)strlen(pathlist)) + ((int)strlen(name)) + 2);
    if (path != 0) {
      while (*pathlist) {
        cp = strchr(pathlist, ':');
        if (cp == 0)
          cp = &pathlist[((int)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;
}
```