user: 请从给定的汇编指令推导出C源代码：

```asm
<canonicalize>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbx
  sub    $0x28,%rsp
  mov    D27(%rip),%r13
  mov    %fs:0x28,%rax
  mov    %rax,-0x38(%rbp)
  xor    %eax,%eax
  cmp    %edx,0x0(%r13)
  jg     L179
  mov    %rdi,%r14
  mov    %rsi,%r12
  mov    %edx,%ebx
  call   <strlen@plt>
  cmp    0x0(%r13),%eax
  jg     L126
  mov    %r12,%rsi
  mov    %r14,%rdi
  call   <realpath@plt>
  test   %rax,%rax
  je     L186
  mov    %r12,%rdi
  call   <collapse@plt>
  xor    %eax,%eax
L208:
  mov    -0x38(%rbp),%rdx
  sub    %fs:0x28,%rdx
  jne    L148
  lea    -0x28(%rbp),%rsp
  pop    %rbx
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  pop    %rbp
  ret
  nopl   0x0(%rax,%rax,1)
L186:
  mov    0x0(%r13),%edx
  mov    %rsp,%rsi
  mov    %rsp,-0x50(%rbp)
  lea    0x1(%rdx),%eax
  cltq
  add    $0xf,%rax
  mov    %rax,%rcx
  and    $0xfffffffffffff000,%rax
  sub    %rax,%rsi
  and    $0xfffffffffffffff0,%rcx
  cmp    %rsi,%rsp
  je     L69
L146:
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  cmp    %rsi,%rsp
  jne    L146
L69:
  and    $0xfff,%ecx
  sub    %rcx,%rsp
  test   %rcx,%rcx
  je     L1
  orq    $0x0,-0x8(%rsp,%rcx,1)
L1:
  mov    %r14,%rsi
  mov    %rsp,%rdi
  mov    %rsp,%r15
  call   <strncpy@plt>
  movslq 0x0(%r13),%rax
  mov    %rsp,%rdi
  movb   $0x0,(%rsp,%rax,1)
  call   <strlen@plt>
  movslq %eax,%r13
  lea    (%rsp,%r13,1),%rax
  mov    %rax,-0x48(%rbp)
  mov    %rax,%r13
  cmp    %rax,%rsp
  jb     L131
  jmp    L202
  nopl   0x0(%rax,%rax,1)
L102:
  cmpb   $0x2f,0x0(%r13)
  je     L119
L131:
  mov    %r13,%r14
  sub    $0x1,%r13
  cmp    %r13,%r15
  jb     L102
  je     L202
L119:
  movb   $0x0,0x0(%r13)
  mov    %r12,%rsi
  mov    %r15,%rdi
  call   <realpath@plt>
  cmp    %r13,-0x48(%rbp)
  mov    $0x0,%ecx
  mov    %rax,%r10
  mov    $0x2f,%eax
  cmove  %ecx,%eax
  mov    %al,0x0(%r13)
  test   %r10,%r10
  jne    L74
  mov    D15(%rip),%rax
  mov    D26(%rip),%rdx
  mov    (%rax),%rax
  cmp    (%rdx),%rax
  je     L112
  mov    D72(%rip),%rdx
  cmp    (%rdx),%rax
  je     L112
  mov    D3(%rip),%rdx
  cmp    (%rdx),%rax
  je     L112
  mov    $0xffffffff,%eax
L39:
  mov    -0x50(%rbp),%rsp
  jmp    L208
  xchg   %ax,%ax
L112:
  cmp    %r13,%r15
  jb     L131
L202:
  mov    %r15,%rsi
  mov    %r12,%rdi
  call   <strcpy@plt>
  mov    %r12,%rdi
  call   <collapse@plt>
  xor    %eax,%eax
  jmp    L39
L74:
  mov    %r10,%rdi
  mov    %r10,-0x48(%rbp)
  call   <strlen@plt>
  mov    %r13,%rdi
  mov    %eax,%r12d
  call   <strlen@plt>
  add    %r12d,%eax
  cmp    %ebx,%eax
  jge    L242
  mov    -0x48(%rbp),%r10
  movslq %r12d,%rax
  test   %r12d,%r12d
  jle    L232
  cmpb   $0x2f,-0x1(%r10,%rax,1)
  jne    L232
  cmpb   $0x2f,0x0(%r13)
  cmove  %r14,%r13
L232:
  lea    (%r10,%rax,1),%rdi
  mov    %r13,%rsi
  mov    %r10,-0x48(%rbp)
  call   <strcpy@plt>
  mov    -0x48(%rbp),%rdi
  call   <collapse@plt>
  xor    %eax,%eax
  jmp    L39
L242:
  mov    D59(%rip),%rax
  mov    (%rax),%rdx
  mov    D15(%rip),%rax
  mov    %rdx,(%rax)
  mov    $0xffffffff,%eax
  jmp    L39
L179:
  mov    D68(%rip),%rax
  mov    (%rax),%rdx
  mov    D15(%rip),%rax
  mov    %rdx,(%rax)
  mov    $0xffffffff,%eax
  jmp    L208
L126:
  mov    D59(%rip),%rax
  mov    (%rax),%rdx
  mov    D15(%rip),%rax
  mov    %rdx,(%rax)
  mov    $0xffffffff,%eax
  jmp    L208
L148:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int canonicalize(char *original, char *resolved, int len) {
  if (len < PATH_MAX) {
    errno = EINVAL;
    return -1;
  }
  if (strlen(original) > PATH_MAX) {
    errno = ENAMETOOLONG;
    return -1;
  }
  if (realpath(original, resolved)) {
    collapse(resolved);
    return 0;
  } else {
    char *p, *end, *r = NULL;
    char path[PATH_MAX + 1];
    strncpy(path, original, PATH_MAX);
    path[PATH_MAX] = '\0';
    end = path + strlen(path);
    for (p = end; p > path;) {
      while ((--p > path) && (*p != '/'))
        ;
      if (p == path)
        break;
      *p = '\0';
      r = realpath(path, resolved);
      *p = (p == end) ? '\0' : '/';
      if (r != NULL) {
        break;
      } else if (errno == ENOENT || errno == ENOTDIR || errno == EACCES) {
        continue;
      } else {
        return -1;
      }
    }
    if (r != NULL) {
      int rn = strlen(r);
      if (rn + (int)strlen(p) >= len) {
        errno = ENAMETOOLONG;
        return -1;
      }
      if ((rn > 0) && (r[rn - 1] == '/') && (*p == '/')) {
        p++;
      }
      strcpy(r + rn, p);
      collapse(r);
      return 0;
    } else {
      strcpy(resolved, path);
      collapse(resolved);
      return 0;
    }
  }
}
```