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

```asm
<getNewLogicalPwd>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %rbx
  sub    $0x48,%rsp
  mov    %rdi,-0x48(%rbp)
  mov    %rsi,-0x50(%rbp)
  mov    -0x50(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x2f,%al
  jne    L27
  lea    D19(%rip),%rax
  mov    %rax,-0x48(%rbp)
L27:
  mov    -0x48(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    %eax,%ebx
  mov    -0x50(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  add    %ebx,%eax
  add    $0x2,%eax
  cltq
  mov    %rax,-0x28(%rbp)
  mov    -0x28(%rbp),%rax
  mov    %rax,%rdi
  call   <malloc@plt>
  mov    %rax,-0x20(%rbp)
  cmpq   $0x0,-0x20(%rbp)
  jne    L134
  mov    $0x0,%eax
  jmp    L81
L134:
  mov    -0x48(%rbp),%rdx
  mov    -0x20(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <stpcpy@plt>
  mov    %rax,-0x40(%rbp)
  mov    -0x50(%rbp),%rax
  mov    %rax,-0x38(%rbp)
  mov    -0x38(%rbp),%rax
  lea    D19(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcspn@plt>
  mov    %rax,-0x30(%rbp)
  jmp    L31
L34:
  cmpq   $0x0,-0x30(%rbp)
  je     L63
  cmpq   $0x1,-0x30(%rbp)
  jne    L99
  mov    -0x38(%rbp),%rax
  mov    $0x1,%edx
  lea    D47(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <strncmp@plt>
  test   %rax,%rax
  je     L63
L99:
  cmpq   $0x2,-0x30(%rbp)
  jne    L42
  mov    -0x38(%rbp),%rax
  mov    $0x2,%edx
  lea    D37(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <strncmp@plt>
  test   %rax,%rax
  jne    L42
  mov    -0x20(%rbp),%rax
  mov    $0x2f,%esi
  mov    %rax,%rdi
  call   <strrchr@plt>
  mov    %rax,-0x18(%rbp)
  mov    -0x18(%rbp),%rax
  cmp    -0x20(%rbp),%rax
  jne    L93
  mov    -0x20(%rbp),%rax
  add    $0x1,%rax
  mov    %rax,-0x40(%rbp)
  jmp    L157
L93:
  cmpq   $0x0,-0x18(%rbp)
  je     L157
  mov    -0x18(%rbp),%rax
  mov    %rax,-0x40(%rbp)
  jmp    L157
L42:
  mov    -0x20(%rbp),%rax
  add    $0x1,%rax
  cmp    %rax,-0x40(%rbp)
  je     L92
  mov    -0x40(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x40(%rbp)
  movb   $0x2f,(%rax)
L92:
  mov    -0x30(%rbp),%rdx
  mov    -0x38(%rbp),%rcx
  mov    -0x40(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <memcpy@plt>
  mov    -0x30(%rbp),%rax
  add    %rax,-0x40(%rbp)
  jmp    L63
L157:
  nop
L63:
  mov    -0x30(%rbp),%rax
  add    %rax,-0x38(%rbp)
  mov    -0x38(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  je     L17
  addq   $0x1,-0x38(%rbp)
L17:
  mov    -0x38(%rbp),%rax
  lea    D19(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcspn@plt>
  mov    %rax,-0x30(%rbp)
  mov    -0x40(%rbp),%rax
  movb   $0x0,(%rax)
L31:
  mov    -0x38(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  jne    L34
  mov    -0x20(%rbp),%rax
L81:
  mov    -0x8(%rbp),%rbx
  leave
  ret
```

tool_calls: name: extract_symbolic_data
arguments: data_tag: D19
type_guessed: string
name: extract_symbolic_data
arguments: data_tag: D47
type_guessed: string
name: extract_symbolic_data
arguments: data_tag: D37
type_guessed: string

tool: D19: /

tool: D47: .

tool: D37: ..

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