user: Translate the below assembly code into C programming language:

```asm
<pathsearch>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x18,%rsp
  mov    %rdi,%rbp
  mov    %rsi,%r14
  mov    %edx,0xc(%rsp)
  mov    $0x2f,%esi
  call   <strrchr@plt>
  test   %rax,%rax
  je     L36
  mov    %rax,%rbx
  movzbl (%rax),%r13d
  movb   $0x0,(%rax)
  mov    %rbp,%rdi
  call   <strlen@plt>
  mov    %rax,%r12
  mov    %r14,%rdi
  call   <strlen@plt>
  lea    0x2(%r12,%rax,1),%rdi
  call   <malloc@plt>
  mov    %rax,%r12
  test   %rax,%rax
  je     L45
  mov    %r14,%rcx
  mov    %rbp,%rdx
  lea    D34(%rip),%rsi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <sprintf@plt>
L45:
  mov    %r13b,(%rbx)
L50:
  mov    %r12,%rsi
  lea    D26(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    %r12,%rax
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L36:
  lea    D52(%rip),%rdi
  mov    $0x0,%eax
  call   <getenv@plt>
  mov    %rax,%rbp
  test   %rax,%rax
  lea    D9(%rip),%rax
  cmove  %rax,%rbp
  mov    %rbp,%rdi
  call   <strlen@plt>
  mov    %rax,%rbx
  mov    %r14,%rdi
  call   <strlen@plt>
  lea    0x2(%rbx,%rax,1),%rdi
  call   <malloc@plt>
  mov    %rax,%r12
  test   %rax,%rax
  je     L50
  lea    D3(%rip),%r15
  jmp    L26
L69:
  mov    %rbp,%rdi
  call   <strlen@plt>
  lea    0x0(%rbp,%rax,1),%rbx
L15:
  movzbl (%rbx),%r13d
  movb   $0x0,(%rbx)
  mov    %r14,%rcx
  mov    %rbp,%rdx
  lea    D34(%rip),%rsi
  mov    %r12,%rdi
  mov    $0x0,%eax
  call   <sprintf@plt>
  mov    %r13b,(%rbx)
  add    $0x1,%rbx
  test   %r13b,%r13b
  cmove  %r15,%rbx
  mov    %rbx,%rbp
  mov    0xc(%rsp),%esi
  mov    %r12,%rdi
  mov    $0x0,%eax
  call   <access@plt>
  test   %eax,%eax
  je     L50
L26:
  cmpb   $0x0,0x0(%rbp)
  je     L50
  mov    $0x3a,%esi
  mov    %rbp,%rdi
  call   <strchr@plt>
  mov    %rax,%rbx
  test   %rax,%rax
  jne    L15
  jmp    L69
```

tool_calls: name: parse_data
arguments: tag: D34
type_guessed: string
name: parse_data
arguments: tag: D26
type_guessed: string
name: parse_data
arguments: tag: D52
type_guessed: string
name: parse_data
arguments: tag: D9
type_guessed: string
name: parse_data
arguments: tag: D3
type_guessed: string

tool: D34: %s/%s

tool: D26: pathsearch %s


tool: D52: PATH

tool: D9: .:/bin:/usr/bin

tool: 

assistant: ```c
char *pathsearch(argv0, name, modemask)
char *argv0;
char *name;
int modemask;
{
  char *pathlist;
  char *path, *cp;
  char c;
  extern int access();
  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;
      }
    }
  }
  printf("pathsearch %s\n", path);
  return path;
}
```