user: Please show me the C implementation that matches the assembly code listed below:

```asm
<removeDotSegments>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x1000,%rsp
  orq    $0x0,(%rsp)
  sub    $0x30,%rsp
  mov    %rdi,-0x1028(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  movq   $0x0,-0x1010(%rbp)
  movq   $0x0,-0x1008(%rbp)
  lea    -0x1000(%rbp),%rdx
  mov    $0x0,%eax
  mov    $0x1fe,%ecx
  mov    %rdx,%rdi
  rep stos %rax,%es:(%rdi)
  lea    -0x1010(%rbp),%rax
  mov    %rax,-0x1020(%rbp)
  mov    -0x1028(%rbp),%rax
  mov    %rax,-0x1018(%rbp)
  cmpq   $0x0,-0x1028(%rbp)
  je     L62
  mov    -0x1028(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  cmp    $0xfff,%eax
  jbe    L31
  mov    $0x0,%eax
  jmp    L68
L106:
  mov    -0x1018(%rbp),%rax
  mov    $0x2,%edx
  lea    D41(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <strncmp@plt>
  test   %eax,%eax
  jne    L86
  mov    -0x1018(%rbp),%rax
  add    $0x2,%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  lea    0x1(%rax),%edx
  mov    -0x1018(%rbp),%rax
  lea    0x2(%rax),%rcx
  mov    -0x1018(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <memmove@plt>
  jmp    L31
L86:
  mov    -0x1018(%rbp),%rax
  mov    $0x3,%edx
  lea    D33(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <strncmp@plt>
  test   %eax,%eax
  jne    L239
  mov    -0x1018(%rbp),%rax
  add    $0x3,%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  lea    0x1(%rax),%edx
  mov    -0x1018(%rbp),%rax
  lea    0x3(%rax),%rcx
  mov    -0x1018(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <memmove@plt>
  jmp    L31
L239:
  mov    -0x1018(%rbp),%rax
  lea    D7(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcmp@plt>
  test   %eax,%eax
  jne    L9
  mov    -0x1018(%rbp),%rax
  add    $0x1,%rax
  movb   $0x0,(%rax)
L9:
  mov    -0x1018(%rbp),%rax
  mov    $0x3,%edx
  lea    D37(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <strncmp@plt>
  test   %eax,%eax
  jne    L56
  mov    -0x1018(%rbp),%rax
  add    $0x2,%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  lea    0x1(%rax),%edx
  mov    -0x1018(%rbp),%rax
  lea    0x2(%rax),%rcx
  mov    -0x1018(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <memmove@plt>
  jmp    L31
L56:
  mov    -0x1018(%rbp),%rax
  lea    D45(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcmp@plt>
  test   %eax,%eax
  jne    L218
  mov    -0x1018(%rbp),%rax
  add    $0x1,%rax
  movb   $0x0,(%rax)
  lea    -0x1010(%rbp),%rax
  mov    $0x2f,%esi
  mov    %rax,%rdi
  call   <strrchr@plt>
  mov    %rax,-0x1020(%rbp)
  cmpq   $0x0,-0x1020(%rbp)
  jne    L21
  lea    -0x1010(%rbp),%rax
  mov    %rax,-0x1020(%rbp)
L21:
  mov    -0x1020(%rbp),%rax
  movb   $0x0,(%rax)
  jmp    L31
L218:
  mov    -0x1018(%rbp),%rax
  mov    $0x4,%edx
  lea    D51(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <strncmp@plt>
  test   %eax,%eax
  jne    L142
  mov    -0x1018(%rbp),%rax
  add    $0x3,%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  lea    0x1(%rax),%edx
  mov    -0x1018(%rbp),%rax
  lea    0x3(%rax),%rcx
  mov    -0x1018(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <memmove@plt>
  lea    -0x1010(%rbp),%rax
  mov    $0x2f,%esi
  mov    %rax,%rdi
  call   <strrchr@plt>
  mov    %rax,-0x1020(%rbp)
  cmpq   $0x0,-0x1020(%rbp)
  jne    L53
  lea    -0x1010(%rbp),%rax
  mov    %rax,-0x1020(%rbp)
L53:
  mov    -0x1020(%rbp),%rax
  movb   $0x0,(%rax)
  jmp    L31
L142:
  mov    -0x1028(%rbp),%rax
  lea    D75(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcmp@plt>
  test   %eax,%eax
  je     L17
  mov    -0x1028(%rbp),%rax
  lea    D72(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcmp@plt>
  test   %eax,%eax
  jne    L63
L17:
  mov    -0x1028(%rbp),%rax
  movb   $0x0,(%rax)
  mov    -0x1028(%rbp),%rax
  jmp    L68
L63:
  mov    -0x1018(%rbp),%rdx
  lea    0x1(%rdx),%rax
  mov    %rax,-0x1018(%rbp)
  mov    -0x1020(%rbp),%rax
  lea    0x1(%rax),%rcx
  mov    %rcx,-0x1020(%rbp)
  movzbl (%rdx),%edx
  mov    %dl,(%rax)
  jmp    L225
L29:
  mov    -0x1018(%rbp),%rdx
  lea    0x1(%rdx),%rax
  mov    %rax,-0x1018(%rbp)
  mov    -0x1020(%rbp),%rax
  lea    0x1(%rax),%rcx
  mov    %rcx,-0x1020(%rbp)
  movzbl (%rdx),%edx
  mov    %dl,(%rax)
L225:
  mov    -0x1018(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  je     L129
  mov    -0x1018(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x2f,%al
  jne    L29
L129:
  mov    -0x1020(%rbp),%rax
  movb   $0x0,(%rax)
L31:
  mov    -0x1018(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  jne    L106
  lea    -0x1010(%rbp),%rdx
  mov    -0x1028(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcpy@plt>
  jmp    L68
L62:
  mov    $0x0,%eax
L68:
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L73
  call   <__stack_chk_fail@plt>
L73:
  leave
  ret
```

tool_calls: name: retrieve_data
arguments: data_label: D41
datatype: string
name: retrieve_data
arguments: data_label: D33
datatype: string
name: retrieve_data
arguments: data_label: D7
datatype: string
name: retrieve_data
arguments: data_label: D37
datatype: string
name: retrieve_data
arguments: data_label: D45
datatype: string
name: retrieve_data
arguments: data_label: D51
datatype: string
name: retrieve_data
arguments: data_label: D75
datatype: string
name: retrieve_data
arguments: data_label: D72
datatype: string

tool: D41: ./

tool: D33: ../

tool: D7: /.

tool: D37: /./

tool: D45: /..

tool: D51: /../

tool: D75: .

tool: D72: ..

assistant: ```c
char *removeDotSegments(char *pcPath) {
  char cBuffer[4096] = "";
  char *d = cBuffer, *s = pcPath;
  if (pcPath) {
    if (strlen(pcPath) >= sizeof(cBuffer)) {
      return NULL;
    }
    while (*s) {
      if (!strncmp(s, "./", 2)) {
        memmove(s, s + 2, strlen(s + 2) + 1);
        continue;
      }
      if (!strncmp(s, "../", 3)) {
        memmove(s, s + 3, strlen(s + 3) + 1);
        continue;
      }
      if (!strcmp(s, "/.")) {
        s[1] = '\0';
      }
      if (!strncmp(s, "/./", 3)) {
        memmove(s, s + 2, strlen(s + 2) + 1);
        continue;
      }
      if (!strcmp(s, "/..")) {
        s[1] = '\0';
        if (!(d = strrchr(cBuffer, '/'))) {
          d = cBuffer;
        }
        *d = '\0';
        continue;
      }
      if (!strncmp(s, "/../", 4)) {
        memmove(s, s + 3, strlen(s + 3) + 1);
        if (!(d = strrchr(cBuffer, '/'))) {
          d = cBuffer;
        }
        *d = '\0';
        continue;
      }
      if (!strcmp(pcPath, ".") || !strcmp(pcPath, "..")) {
        *pcPath = '\0';
        return pcPath;
      }
      *d++ = *s++;
      while (*s && *s != '/')
        *d++ = *s++;
      *d = '\0';
    }
    return strcpy(pcPath, cBuffer);
  }
  return NULL;
}
```