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

```asm
<getNewLogicalPwd>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x18,%rsp
  mov    %rsi,%rbx
  cmpb   $0x2f,(%rsi)
  lea    D6(%rip),%rax
  cmovne %rdi,%rax
  mov    %rax,%rbp
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    %eax,%r12d
  mov    %rbx,%rdi
  call   <strlen@plt>
  lea    0x2(%r12,%rax,1),%edi
  movslq %edi,%rdi
  call   <malloc@plt>
  mov    %rax,0x8(%rsp)
  test   %rax,%rax
  je     L105
  mov    %rax,%r15
  mov    %rbp,%rsi
  mov    %rax,%rdi
  call   <stpcpy@plt>
  mov    %rax,%r12
  lea    D6(%rip),%rsi
  mov    %rbx,%rdi
  call   <strcspn@plt>
  mov    %rax,%rbp
  cmpb   $0x0,(%rbx)
  je     L105
  add    $0x1,%r15
  lea    D6(%rip),%r14
  jmp    L82
L110:
  mov    $0x1,%edx
  lea    D0(%rip),%rsi
  mov    %rbx,%rdi
  call   <strncmp@plt>
  test   %rax,%rax
  je     L59
  jmp    L9
L87:
  mov    $0x2,%edx
  lea    D3(%rip),%rsi
  mov    %rbx,%rdi
  call   <strncmp@plt>
  test   %rax,%rax
  jne    L9
  mov    $0x2f,%esi
  mov    0x8(%rsp),%r13
  mov    %r13,%rdi
  call   <strrchr@plt>
  cmp    %rax,%r13
  je     L100
  test   %rax,%rax
  cmovne %rax,%r12
  jmp    L59
L100:
  lea    0x1(%rax),%r12
  jmp    L59
L65:
  mov    %rbp,%rdx
  mov    %rbx,%rsi
  mov    %r13,%rdi
  call   <memcpy@plt>
  lea    0x0(%r13,%rbp,1),%r12
L59:
  add    %rbp,%rbx
  cmpb   $0x1,(%rbx)
  sbb    $0xffffffffffffffff,%rbx
  mov    %r14,%rsi
  mov    %rbx,%rdi
  call   <strcspn@plt>
  mov    %rax,%rbp
  movb   $0x0,(%r12)
  cmpb   $0x0,(%rbx)
  je     L105
L82:
  test   %rbp,%rbp
  je     L59
  cmp    $0x1,%rbp
  je     L110
  cmp    $0x2,%rbp
  je     L87
L9:
  mov    %r12,%r13
  cmp    %r15,%r12
  je     L65
  lea    0x1(%r12),%r13
  movb   $0x2f,(%r12)
  jmp    L65
L105:
  mov    0x8(%rsp),%rax
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
```

tool_calls: name: unpack_data
arguments: data_tag: D6
data_type: string
name: unpack_data
arguments: data_tag: D0
data_type: string
name: unpack_data
arguments: data_tag: D3
data_type: string

tool: D6: /

tool: D0: .

tool: D3: ..

assistant: ```c
char *getNewLogicalPwd(const char *oldPwd, const char *dir) {
  if (*dir == '/') {
    oldPwd = "/";
  }
  size_t newSize = strlen(oldPwd) + strlen(dir) + 2;
  char *newPwd = malloc(newSize);
  if (!newPwd)
    return NULL;
  char *pwdEnd = stpcpy(newPwd, oldPwd);
  const char *component = dir;
  size_t componentLength = strcspn(component, "/");
  while (*component) {
    if (componentLength == 0 || (componentLength == 1 && strncmp(component, ".", 1) == 0)) {
    } else if (componentLength == 2 && strncmp(component, "..", 2) == 0) {
      char *lastSlash = strrchr(newPwd, '/');
      if (lastSlash == newPwd) {
        pwdEnd = newPwd + 1;
      } else if (lastSlash) {
        pwdEnd = lastSlash;
      }
    } else {
      if (pwdEnd != newPwd + 1) {
        *pwdEnd++ = '/';
      }
      memcpy(pwdEnd, component, componentLength);
      pwdEnd += componentLength;
    }
    component += componentLength;
    if (*component)
      component++;
    componentLength = strcspn(component, "/");
    *pwdEnd = '\0';
  }
  return newPwd;
}
```