user: 请将以下的汇编代码转换成C语言代码:

```asm
<realpath>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %r15
  mov    %rdi,%r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbx
  sub    $0x58,%rsp
  mov    %rsi,-0x48(%rbp)
  mov    %rsp,%rcx
  mov    %fs:0x28,%rax
  mov    %rax,-0x38(%rbp)
  mov    D172(%rip),%rax
  movslq (%rax),%rax
  mov    %eax,-0x6c(%rbp)
  mov    %rax,-0x58(%rbp)
  lea    0xf(%rax,%rax,1),%rax
  mov    %rax,%rdx
  and    $0xfffffffffffff000,%rax
  sub    %rax,%rcx
  and    $0xfffffffffffffff0,%rdx
  cmp    %rcx,%rsp
  je     L134
L398:
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  cmp    %rcx,%rsp
  jne    L398
L134:
  and    $0xfff,%edx
  sub    %rdx,%rsp
  test   %rdx,%rdx
  jne    L283
L125:
  mov    %rsp,-0x68(%rbp)
  test   %r15,%r15
  je     L301
  cmpq   $0x0,-0x48(%rbp)
  movq   $0x0,-0x78(%rbp)
  je     L446
L346:
  movzbl (%r15),%edx
  test   %dl,%dl
  je     L7
  mov    -0x48(%rbp),%rdi
  mov    %rdi,%r12
  cmp    $0x2f,%dl
  je     L397
  mov    D172(%rip),%rax
  mov    (%rax),%esi
  call   <getcwd@plt>
  test   %rax,%rax
  je     L392
  mov    -0x48(%rbp),%rdi
  call   <strlen@plt>
  cmp    $0x1,%rax
  jbe    L82
  mov    -0x48(%rbp),%rsi
  lea    (%rsi,%rax,1),%r12
L82:
  movzbl (%r15),%edx
L397:
  lea    -0x3c(%rbp),%rax
  movl   $0x0,-0x5c(%rbp)
  mov    %r15,%r14
  movl   $0x0,-0x60(%rbp)
  mov    %rax,-0x50(%rbp)
  nopl   0x0(%rax)
L60:
  cmp    $0x2f,%dl
  je     L438
L172:
  mov    -0x48(%rbp),%rbx
L27:
  test   %dl,%dl
  je     L3
  mov    %r14,%r15
L80:
  mov    %r15,%r13
  movzbl 0x1(%r15),%eax
  add    $0x1,%r15
  cmp    $0x2f,%al
  je     L330
  test   %al,%al
  jne    L80
L330:
  cmp    $0x2e,%dl
  je     L396
L434:
  mov    D172(%rip),%rcx
  mov    %r12,%rax
  sub    %rbx,%rax
  lea    0x1(%r15,%rax,1),%rax
  movslq (%rcx),%rdx
  sub    %r14,%rax
  cmp    %rdx,%rax
  jge    L242
  movb   $0x2f,(%r12)
  mov    %r15,%rdx
  mov    %r14,%rsi
  lea    0x1(%r12),%rdi
  sub    %r14,%rdx
  call   <memcpy@plt>
  lea    0x2(%r13),%rax
  mov    -0x50(%rbp),%rsi
  mov    %rbx,%rdi
  sub    %r14,%rax
  lea    (%r12,%rax,1),%r14
  movb   $0x0,(%r14)
  call   <lstat@plt>
  cmp    $0xffffffff,%eax
  je     L157
  mov    -0x3c(%rbp),%edi
  call   <S_ISLNK@plt>
  test   %rax,%rax
  je     L272
  mov    -0x5c(%rbp),%ecx
  lea    0x1(%rcx),%eax
  mov    %eax,-0x5c(%rbp)
  mov    D73(%rip),%rax
  cmp    %ecx,(%rax)
  jle    L323
  movslq -0x60(%rbp),%r14
  mov    -0x58(%rbp),%rbx
  mov    -0x68(%rbp),%rax
  mov    -0x48(%rbp),%rdi
  imul   %r14,%rbx
  lea    (%rax,%rbx,1),%r14
  mov    -0x6c(%rbp),%eax
  mov    %r14,%rsi
  lea    -0x1(%rax),%edx
  call   <readlink@plt>
  mov    %rax,%r13
  test   %rax,%rax
  je     L18
  mov    %r15,%rdi
  call   <strlen@plt>
  lea    0x1(%r13,%rax,1),%rdx
  cmp    %rdx,-0x58(%rbp)
  jb     L260
  lea    0x1(%rax),%rdx
  lea    (%rbx,%r13,1),%rdi
  mov    %r15,%rsi
  add    -0x68(%rbp),%rdi
  call   <memcpy@plt>
  movzbl (%r14),%edx
  xorl   $0x1,-0x60(%rbp)
  cmp    $0x2f,%dl
  cmove  -0x48(%rbp),%r12
  cmp    $0x2f,%dl
  jne    L172
L438:
  movzbl 0x1(%r14),%edx
  add    $0x1,%r14
  jmp    L60
  nopw   0x0(%rax,%rax,1)
L272:
  movzbl (%r15),%edx
  mov    %r14,%r12
  mov    %r15,%r14
  cmp    $0x2f,%dl
  jne    L27
  mov    -0x3c(%rbp),%edi
  call   <S_ISDIR@plt>
  test   %eax,%eax
  je     L408
  movzbl 0x1(%r13),%edx
  jmp    L60
  nopl   (%rax)
L396:
  mov    %r15,%rdx
  sub    %r14,%rdx
  cmp    $0x1,%rdx
  je     L110
  cmpb   $0x2e,0x1(%r14)
  jne    L434
  cmp    $0x2,%rdx
  jne    L434
  cmp    %r12,-0x48(%rbp)
  je     L110
L210:
  sub    $0x1,%r12
  cmpb   $0x2f,(%r12)
  jne    L210
L110:
  mov    %eax,%edx
  mov    %r15,%r14
  jmp    L60
L7:
  mov    -0x48(%rbp),%rax
  movb   $0x0,(%rax)
  mov    D55(%rip),%rax
  mov    (%rax),%edx
  mov    D48(%rip),%rax
  mov    %edx,(%rax)
L157:
  mov    -0x78(%rbp),%rdi
  call   <free@plt>
  xor    %eax,%eax
L284:
  mov    -0x38(%rbp),%rdx
  sub    %fs:0x28,%rdx
  jne    L307
  lea    -0x28(%rbp),%rsp
  pop    %rbx
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  pop    %rbp
  ret
L283:
  orq    $0x0,-0x8(%rsp,%rdx,1)
  jmp    L125
L3:
  cmp    %r12,-0x48(%rbp)
  je     L251
L252:
  movb   $0x0,(%r12)
  mov    -0x48(%rbp),%rax
  jmp    L284
L446:
  mov    -0x6c(%rbp),%edi
  call   <malloc@plt>
  mov    %rax,-0x48(%rbp)
  test   %rax,%rax
  je     L171
  mov    %rax,-0x78(%rbp)
  jmp    L346
L242:
  mov    D11(%rip),%rax
  mov    (%rax),%edx
  mov    D48(%rip),%rax
  mov    %edx,(%rax)
  cmp    %r12,-0x48(%rbp)
  je     L183
L227:
  movb   $0x0,(%r12)
  jmp    L157
L301:
  mov    D167(%rip),%rax
  mov    (%rax),%edx
  mov    D48(%rip),%rax
  mov    %edx,(%rax)
  xor    %eax,%eax
  jmp    L284
L323:
  mov    D64(%rip),%rax
  mov    (%rax),%edx
  mov    D48(%rip),%rax
  mov    %edx,(%rax)
  jmp    L157
L18:
  mov    D55(%rip),%rax
  mov    (%rax),%edx
  mov    D48(%rip),%rax
  mov    %edx,(%rax)
  jmp    L157
L260:
  mov    D11(%rip),%rax
  mov    (%rax),%edx
  mov    D48(%rip),%rax
  mov    %edx,(%rax)
  jmp    L157
L251:
  mov    -0x48(%rbp),%rax
  movb   $0x2f,(%rax)
  lea    0x1(%rax),%r12
  jmp    L252
L183:
  movb   $0x2f,(%r12)
  add    $0x1,%r12
  jmp    L227
L392:
  mov    -0x48(%rbp),%rax
  mov    $0x2e,%edx
  mov    %dx,(%rax)
  jmp    L157
L408:
  mov    D13(%rip),%rax
  mov    (%rax),%edx
  mov    D48(%rip),%rax
  mov    %edx,(%rax)
  jmp    L157
L171:
  xor    %eax,%eax
  jmp    L284
L307:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
char *realpath(const char *path, char *resolved) {
  struct stat sb;
  int idx = 0, nlnk = 0;
  const char *q;
  char *p, wbuf[2][MAXPATHLEN], *fres;
  size_t len;
  ssize_t n;
  if (path == NULL) {
    errno = EINVAL;
    return NULL;
  }
  if (resolved == NULL) {
    fres = resolved = malloc(MAXPATHLEN);
    if (resolved == NULL)
      return NULL;
  } else
    fres = NULL;
  p = resolved;
  if (*path == '\0') {
    *p = '\0';
    errno = ENOENT;
    goto out;
  }
  if (*path != '/') {
    if (resolved && getcwd(resolved, MAXPATHLEN) == NULL) {
      p[0] = '.';
      p[1] = '\0';
      goto out;
    }
    len = strlen(resolved);
    if (len > 1)
      p += len;
  }
loop:
  while (*path == '/')
    path++;
  if (*path == '\0') {
    if (p == resolved)
      *p++ = '/';
    *p = '\0';
    return resolved;
  }
  q = path;
  do
    q++;
  while (*q != '/' && *q != '\0');
  if (path[0] == '.') {
    if (q - path == 1) {
      path = q;
      goto loop;
    }
    if (path[1] == '.' && q - path == 2) {
      if (p != resolved)
        while (*--p != '/')
          continue;
      path = q;
      goto loop;
    }
  }
  if (p - resolved + 1 + q - path + 1 > MAXPATHLEN) {
    errno = ENAMETOOLONG;
    if (p == resolved)
      *p++ = '/';
    *p = '\0';
    goto out;
  }
  p[0] = '/';
  memcpy(&p[1], path, q - path);
  p[1 + q - path] = '\0';
  if (lstat(resolved, &sb) == -1)
    goto out;
  if (S_ISLNK(sb.st_mode)) {
    if (nlnk++ >= MAXSYMLINKS) {
      errno = ELOOP;
      goto out;
    }
    n = readlink(resolved, wbuf[idx], sizeof(wbuf[0]) - 1);
    if (n < 0)
      goto out;
    if (n == 0) {
      errno = ENOENT;
      goto out;
    }
    if (n + (len = strlen(q)) + 1 > sizeof(wbuf[0])) {
      errno = ENAMETOOLONG;
      goto out;
    }
    memcpy(&wbuf[idx][n], q, len + 1);
    path = wbuf[idx];
    idx ^= 1;
    if (*path == '/')
      p = resolved;
    goto loop;
  }
  if (*q == '/' && !S_ISDIR(sb.st_mode)) {
    errno = ENOTDIR;
    goto out;
  }
  p += 1 + q - path;
  path = q;
  goto loop;
out:
  free(fres);
  return NULL;
}
```