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

```asm
<func_basename_dir>:
  endbr64
  push   %r15
  mov    %rdi,%r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x38,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x28(%rsp)
  mov    (%rsi),%rax
  movl   $0x0,0x1c(%rsp)
  mov    %rax,0x20(%rsp)
  lea    D28(%rip),%rax
  cmp    %rax,%rdx
  je     L205
  xor    %ebx,%ebx
  cmpb   $0x62,(%rdx)
  movb   $0x1,0xf(%rsp)
  je     L93
L121:
  xor    %ebp,%ebp
  lea    0x1c(%rsp),%r13
  lea    0x20(%rsp),%r12
  lea    D15(%rip),%r14
  cs nopw 0x0(%rax,%rax,1)
L85:
  mov    %r13,%rsi
  mov    %r12,%rdi
  call   <find_next_token@plt>
  mov    %rax,%rsi
  test   %rax,%rax
  je     L76
  mov    0x1c(%rsp),%edx
  mov    %rdx,%r9
  add    %rsi,%rdx
  jb     L129
  test   %ebx,%ebx
  je     L225
  jmp    L24
  nopl   (%rax)
L191:
  cmp    $0x2f,%al
  je     L5
  sub    $0x1,%rdx
  cmp    %rsi,%rdx
  jb     L172
L24:
  movzbl (%rdx),%eax
  cmp    $0x2e,%al
  jne    L191
L5:
  cmp    %rdx,%rsi
  ja     L129
  cmpb   $0x0,0xf(%rsp)
  jne    L33
  cmp    %rdx,%rsi
  ja     L129
  cmpb   $0x2e,(%rdx)
  je     L38
L129:
  test   %ebx,%ebx
  jne    L172
L40:
  mov    %r15,%rdi
  mov    $0x2,%edx
  lea    D0(%rip),%rsi
  call   <variable_buffer_output@plt>
  mov    %rax,%rdi
L234:
  mov    $0x1,%edx
  mov    %r14,%rsi
  mov    $0x1,%ebp
  call   <variable_buffer_output@plt>
  mov    %rax,%r15
  jmp    L85
  nopw   0x0(%rax,%rax,1)
L167:
  sub    $0x1,%rdx
  cmp    %rdx,%rsi
  ja     L40
L225:
  cmpb   $0x2f,(%rdx)
  jne    L167
  jmp    L5
L33:
  add    $0x1,%rdx
  mov    %r15,%rdi
  sub    %esi,%edx
  call   <variable_buffer_output@plt>
  mov    %rax,%rdi
  jmp    L234
  nopl   0x0(%rax,%rax,1)
L172:
  mov    %r15,%rdi
  mov    %r9d,%edx
  call   <variable_buffer_output@plt>
  mov    %rax,%rdi
  jmp    L234
  nopl   0x0(%rax,%rax,1)
L76:
  cmp    $0x1,%ebp
  adc    $0xffffffffffffffff,%r15
  mov    0x28(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L175
  add    $0x38,%rsp
  mov    %r15,%rax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L38:
  mov    %r15,%rdi
  sub    %esi,%edx
  call   <variable_buffer_output@plt>
  mov    %rax,%rdi
  jmp    L234
L205:
  movb   $0x0,0xf(%rsp)
  mov    $0x1,%ebx
  jmp    L121
L93:
  lea    0x1(%rax),%rsi
  lea    0x1(%rdx),%edi
  xor    %ebx,%ebx
  call   <strcmp@plt>
  test   %eax,%eax
  sete   %bl
  setne  0xf(%rsp)
  jmp    L121
L175:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: parse_data
arguments: label: D28
data_type: string
name: parse_data
arguments: label: D15
data_type: string
name: parse_data
arguments: label: D0
data_type: string

tool: D28: basename

tool: D15:  

tool: D0: ./

assistant: ```c
char *func_basename_dir(char *o, char **argv, const char *funcname) {
  const char *p3 = argv[0];
  const char *p2;
  int doneany = 0;
  unsigned int len = 0;
  int is_basename = ((funcname) == ("basename") || (*(funcname) == *("basename") && (*(funcname) == '\0' || !strcmp((funcname) + 1, ("basename") + 1))));
  int is_dir = !is_basename;
  while ((p2 = find_next_token(&p3, &len)) != 0) {
    const char *p = p2 + len;
    while (p >= p2 && (!is_basename || *p != '.')) {
      if (((*p) == '/'))
        break;
      --p;
    }
    if (p >= p2 && (is_dir))
      o = variable_buffer_output(o, p2, ++p - p2);
    else if (p >= p2 && (*p == '.'))
      o = variable_buffer_output(o, p2, p - p2);
    else if (is_dir)
      o = variable_buffer_output(o, "./", 2);
    else
      o = variable_buffer_output(o, p2, len);
    o = variable_buffer_output(o, " ", 1);
    doneany = 1;
  }
  if (doneany)
    --o;
  return o;
}
```