user: 请将这段汇编代码片段转换成等效的C代码:

```asm
<which>:
  endbr64
  push   %r15
  mov    $0x2f,%esi
  push   %r14
  push   %r13
  push   %r12
  mov    %rdi,%r12
  push   %rbp
  push   %rbx
  sub    $0x28,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x18(%rsp)
  xor    %eax,%eax
  call   <strchr@plt>
  test   %rax,%rax
  je     L5
  mov    %r12,%rdi
  call   <is_there@plt>
  test   %rax,%rax
  jne    L20
L5:
  lea    D17(%rip),%rdi
  call   <getenv@plt>
  mov    %rax,%rdi
  test   %rax,%rax
  je     L111
  call   <strdup@plt>
  mov    %rax,0x8(%rsp)
  mov    %rax,0x10(%rsp)
  test   %rax,%rax
  je     L111
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    %r12,%rdi
  mov    %eax,%ebx
  call   <strlen@plt>
  lea    0x2(%rbx,%rax,1),%eax
  movslq %eax,%rbx
  mov    %eax,(%rsp)
  mov    %rbx,%rdi
  call   <malloc@plt>
  mov    %rax,%rbp
  test   %rax,%rax
  je     L118
  lea    0x10(%rsp),%r14
  lea    D18(%rip),%r13
  lea    D21(%rip),%r15
  nopl   0x0(%rax,%rax,1)
L7:
  mov    %r13,%rsi
  mov    %r14,%rdi
  call   <strsep@plt>
  mov    %rax,%rcx
  test   %rax,%rax
  je     L117
  cmpb   $0x0,(%rcx)
  lea    D29(%rip),%rax
  mov    %r12,%r8
  mov    %r15,%rdx
  cmove  %rax,%rcx
  mov    %rbx,%rsi
  mov    %rbp,%rdi
  call   <snprintf@plt>
  cmp    %eax,(%rsp)
  jle    L7
  mov    %rbp,%rdi
  call   <is_there@plt>
  test   %rax,%rax
  je     L7
  mov    0x8(%rsp),%rdi
  call   <free@plt>
  mov    %rbp,%rcx
L105:
  mov    0x18(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L70
  add    $0x28,%rsp
  mov    %rcx,%rax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax,%rax,1)
L117:
  mov    0x10(%rsp),%rdi
  mov    %rax,(%rsp)
  call   <free@plt>
  mov    %rbp,%rdi
  call   <free@plt>
  mov    (%rsp),%rcx
  jmp    L105
  nopl   0x0(%rax)
L20:
  mov    0x18(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L70
  add    $0x28,%rsp
  mov    %r12,%rdi
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  jmp    1170 <strdup@plt>
L118:
  mov    0x8(%rsp),%rdi
  call   <free@plt>
  nopl   0x0(%rax,%rax,1)
L111:
  xor    %ecx,%ecx
  jmp    L105
L70:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: parse_data
arguments: label: D17
type_guessed: string
name: parse_data
arguments: label: D18
type_guessed: string
name: parse_data
arguments: label: D21
type_guessed: string
name: parse_data
arguments: label: D29
type_guessed: string

tool: D17: PATH

tool: D18: :

tool: D21: %s/%s

tool: D29: .

assistant: ```c
char *which(char *filename) {
  size_t max_candidate;
  char *candidate, *path, *spath;
  const char *d, *p;
  if (strchr(filename, '/') != NULL && is_there(filename))
    return (strdup(filename));
  if ((p = getenv("PATH")) == NULL)
    return (NULL);
  spath = path = strdup(p);
  if (path == NULL)
    return (NULL);
  max_candidate = strlen(path) + strlen(filename) + 2;
  if ((candidate = malloc(max_candidate)) == NULL) {
    free(spath);
    return NULL;
  }
  while ((d = strsep(&path, ":")) != NULL) {
    if (*d == '\0')
      d = ".";
    if (snprintf(candidate, max_candidate, "%s/%s", d, filename) >= (int)max_candidate)
      continue;
    if (is_there(candidate)) {
      free(spath);
      return (candidate);
    }
  }
  free(path);
  free(candidate);
  return (NULL);
}
```