user: 请显示与下面列出的汇编代码相匹配的C语言实现：

```asm
<func_basename_dir>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x38,%rsp
  mov    %rdi,%rbp
  mov    %fs:0x28,%rax
  mov    %rax,0x28(%rsp)
  xor    %eax,%eax
  mov    (%rsi),%rax
  mov    %rax,0x20(%rsp)
  movl   $0x0,0x1c(%rsp)
  mov    $0x1,%ebx
  lea    D28(%rip),%rax
  cmp    %rax,%rdx
  je     L96
  mov    $0x0,%ebx
  cmpb   $0x62,(%rdx)
  je     L37
L96:
  test   %ebx,%ebx
  sete   %r15b
  movl   $0x0,0xc(%rsp)
  lea    0x1c(%rsp),%r13
  lea    0x20(%rsp),%r12
  lea    D27(%rip),%r14
  jmp    L183
L37:
  lea    0x1(%rax),%rsi
  lea    0x1(%rdx),%edi
  call   <strcmp@plt>
  test   %eax,%eax
  sete   %bl
  movzbl %bl,%ebx
  jmp    L96
L11:
  cmpb   $0x2f,(%rdx)
  je     L29
  sub    $0x1,%rdx
  cmp    %rdx,%rsi
  ja     L12
L69:
  test   %ebx,%ebx
  je     L11
  cmpb   $0x2e,(%rdx)
  jne    L11
  cmp    %rdx,%rsi
  jbe    L139
L12:
  test   %ebx,%ebx
  jne    L23
  mov    $0x2,%edx
  lea    D18(%rip),%rsi
  mov    %rbp,%rdi
  call   <variable_buffer_output@plt>
  mov    %rax,%rdi
  jmp    L79
L29:
  cmp    %rdx,%rsi
  setbe  %cl
  test   %r15b,%r15b
  je     L2
  test   %cl,%cl
  je     L2
  add    $0x1,%rdx
  sub    %esi,%edx
  mov    %rbp,%rdi
  call   <variable_buffer_output@plt>
  mov    %rax,%rdi
L79:
  mov    $0x1,%edx
  mov    %r14,%rsi
  call   <variable_buffer_output@plt>
  mov    %rax,%rbp
  movl   $0x1,0xc(%rsp)
L183:
  mov    %r13,%rsi
  mov    %r12,%rdi
  call   <find_next_token@plt>
  mov    %rax,%rsi
  test   %rax,%rax
  je     L46
  mov    0x1c(%rsp),%eax
  mov    %eax,%edx
  add    %rsi,%rdx
  jae    L69
  cmp    %rdx,%rsi
  setbe  %cl
L2:
  test   %cl,%cl
  je     L12
L139:
  cmpb   $0x2e,(%rdx)
  je     L166
L23:
  mov    %eax,%edx
  mov    %rbp,%rdi
  call   <variable_buffer_output@plt>
  mov    %rax,%rdi
  jmp    L79
L166:
  sub    %esi,%edx
  mov    %rbp,%rdi
  call   <variable_buffer_output@plt>
  mov    %rax,%rdi
  jmp    L79
L46:
  cmpl   $0x1,0xc(%rsp)
  adc    $0xffffffffffffffff,%rbp
  mov    0x28(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L91
  mov    %rbp,%rax
  add    $0x38,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L91:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: parse_data
arguments: label: D28
type_infered: string
name: parse_data
arguments: label: D27
type_infered: string
name: parse_data
arguments: label: D18
type_infered: string

tool: D28: basename

tool: D27:  

tool: D18: ./

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