user: What would the C source look like for the assembly code provided here:

```asm
<getNewLogicalPwd>:
  endbr64
  push   %r15
  push   %r14
  mov    %rsi,%r14
  push   %r13
  push   %r12
  push   %rbp
  lea    D27(%rip),%rbp
  push   %rbx
  sub    $0x18,%rsp
  cmpb   $0x2f,(%rsi)
  cmove  %rbp,%rdi
  mov    %rdi,%r13
  call   <strlen@plt>
  mov    %r14,%rdi
  mov    %eax,%ebx
  call   <strlen@plt>
  lea    0x2(%rbx,%rax,1),%edi
  movslq %edi,%rdi
  call   <malloc@plt>
  mov    %rax,%r12
  test   %rax,%rax
  je     L51
  mov    %r13,%rsi
  mov    %rax,%rdi
  call   <stpcpy@plt>
  mov    %rbp,%rsi
  mov    %r14,%rdi
  mov    %rax,%rbx
  call   <strcspn@plt>
  cmpb   $0x0,(%r14)
  mov    %rax,%r15
  je     L51
  lea    0x1(%r12),%rax
  mov    %rax,0x8(%rsp)
  nopl   0x0(%rax)
L49:
  test   %r15,%r15
  je     L1
  cmp    $0x1,%r15
  je     L8
  cmp    $0x2,%r15
  je     L34
L104:
  mov    %rbx,%r13
  cmp    0x8(%rsp),%rbx
  je     L0
  movb   $0x2f,(%rbx)
  add    $0x1,%r13
L0:
  mov    %r15,%rdx
  mov    %r14,%rsi
  lea    0x0(%r13,%r15,1),%rbx
  mov    %r13,%rdi
  call   <memcpy@plt>
L1:
  add    %r15,%r14
  mov    %rbp,%rsi
  cmpb   $0x1,(%r14)
  sbb    $0xffffffffffffffff,%r14
  mov    %r14,%rdi
  call   <strcspn@plt>
  movb   $0x0,(%rbx)
  cmpb   $0x0,(%r14)
  mov    %rax,%r15
  jne    L49
L51:
  add    $0x18,%rsp
  mov    %r12,%rax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax)
L8:
  mov    $0x1,%edx
  lea    D1(%rip),%rsi
  mov    %r14,%rdi
  call   <strncmp@plt>
  test   %rax,%rax
  je     L1
  jmp    L104
  nopl   0x0(%rax,%rax,1)
L34:
  mov    $0x2,%edx
  lea    D28(%rip),%rsi
  mov    %r14,%rdi
  call   <strncmp@plt>
  test   %rax,%rax
  jne    L104
  mov    $0x2f,%esi
  mov    %r12,%rdi
  call   <strrchr@plt>
  cmp    %rax,%r12
  je     L68
  test   %rax,%rax
  cmovne %rax,%rbx
  jmp    L1
L68:
  lea    0x1(%r12),%rbx
  jmp    L1
```

tool_calls: name: read_data
arguments: label: D27
type_guessed: string
name: read_data
arguments: label: D1
type_guessed: string
name: read_data
arguments: label: D28
type_guessed: string

tool: D27: /

tool: D1: .

tool: D28: ..

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