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

```asm
<cw_filename>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x50,%rsp
  mov    %rdi,-0x38(%rbp)
  mov    %rsi,-0x40(%rbp)
  mov    %rdx,-0x48(%rbp)
  movl   $0x0,-0x18(%rbp)
  lea    D27(%rip),%rax
  mov    %rax,-0x10(%rbp)
  mov    -0x38(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    %eax,-0x1c(%rbp)
  cmpl   $0x0,-0x1c(%rbp)
  jle    L41
  mov    -0x1c(%rbp),%eax
  cltq
  lea    -0x1(%rax),%rdx
  mov    -0x38(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  mov    %al,-0x21(%rbp)
  movsbl -0x21(%rbp),%eax
  mov    %eax,%esi
  lea    D38(%rip),%rax
  mov    %rax,%rdi
  call   <strchr@plt>
  test   %eax,%eax
  jne    L41
  addl   $0x1,-0x1c(%rbp)
  lea    D38(%rip),%rax
  mov    %rax,-0x10(%rbp)
L41:
  mov    -0x40(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    %eax,-0x14(%rbp)
  cmpq   $0x0,-0x48(%rbp)
  je     L50
  mov    -0x48(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x2e,%al
  jne    L45
  addq   $0x1,-0x48(%rbp)
L45:
  mov    -0x48(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    %eax,-0x20(%rbp)
  jmp    L48
L50:
  movl   $0xffffffff,-0x20(%rbp)
L48:
  mov    -0x1c(%rbp),%edx
  mov    -0x14(%rbp),%eax
  add    %eax,%edx
  mov    -0x20(%rbp),%eax
  add    $0x1,%eax
  add    %edx,%eax
  add    $0x1,%eax
  mov    %eax,-0x18(%rbp)
  mov    -0x18(%rbp),%eax
  mov    %eax,%edi
  call   <malloc@plt>
  mov    %rax,-0x8(%rbp)
  cmpq   $0x0,-0x8(%rbp)
  jne    L20
  mov    $0x0,%eax
  jmp    L53
L20:
  mov    -0x1c(%rbp),%edx
  mov    -0x38(%rbp),%rcx
  mov    -0x8(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <strncpy@plt>
  mov    -0x1c(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x8(%rbp),%rax
  add    %rdx,%rax
  movb   $0x0,(%rax)
  mov    -0x10(%rbp),%rdx
  mov    -0x8(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcat@plt>
  mov    -0x40(%rbp),%rdx
  mov    -0x8(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcat@plt>
  cmpq   $0x0,-0x48(%rbp)
  je     L16
  mov    -0x8(%rbp),%rax
  lea    D3(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcat@plt>
  mov    -0x48(%rbp),%rdx
  mov    -0x8(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcat@plt>
L16:
  mov    -0x8(%rbp),%rax
L53:
  leave
  ret
```

tool_calls: name: disassemble_data
arguments: data_label: D27
data_type: string
name: disassemble_data
arguments: data_label: D38
data_type: string
name: disassemble_data
arguments: data_label: D3
data_type: string

tool: 

tool: D38: /

tool: D3: .

assistant: ```c
char *cw_filename(const char *path, const char *name, const char *ext) {
  int name_len;
  int ext_len;
  int size = 0;
  int path_len;
  char c;
  char *result;
  char *slash = "";
  path_len = strlen(path);
  if (path_len > 0) {
    c = path[path_len - 1];
    if (!strchr("/", c)) {
      path_len++;
      slash = "/";
    }
  }
  name_len = strlen(name);
  if (ext != NULL) {
    if (ext[0] == '.') {
      ext++;
    }
    ext_len = strlen(ext);
  } else
    ext_len = -1;
  size = (path_len) + name_len + (ext_len + 1) + 1;
  result = malloc(size);
  if (!result)
    return NULL;
  strncpy(result, path, path_len);
  result[path_len] = 0;
  strcat(result, slash);
  strcat(result, name);
  if (ext) {
    strcat(result, ".");
    strcat(result, ext);
  }
  return result;
}
```