user: 请显示与下面列出的汇编代码相匹配的C语言实现:

```asm
<eslib_file_path_check>:
  endbr64
  test   %rdi,%rdi
  je     L154
  push   %rbp
  mov    $0x800,%esi
  mov    %rdi,%rbp
  call   <strnlen@plt>
  lea    -0x1(%rax),%rdx
  cmp    $0x7fe,%rdx
  ja     L98
  cmpb   $0x2f,0x0(%rbp)
  jne    L34
  xor    %r10d,%r10d
  xor    %r9d,%r9d
  xor    %r8d,%r8d
  xor    %ecx,%ecx
  jmp    L15
  nopl   0x0(%rax,%rax,1)
L120:
  test   %r9d,%r9d
  jne    L77
  and    %r10d,%r8d
  jne    L11
  mov    $0x1,%r10d
  mov    $0x1,%r9d
L123:
  lea    0x1(%rcx),%rdi
  cmp    %rdi,%rax
  je     L168
L27:
  mov    %rdi,%rcx
L15:
  movzbl 0x0(%rbp,%rcx,1),%edx
  cmp    $0x2e,%dl
  je     L79
  cmp    $0x2f,%dl
  je     L120
  lea    0x1(%rcx),%rdi
  xor    %r10d,%r10d
  xor    %r9d,%r9d
  xor    %r8d,%r8d
  cmp    %rdi,%rax
  jne    L27
L168:
  xor    %r8d,%r8d
  cmp    $0x1,%rax
  je     L117
  cmp    $0x2f,%dl
  je     L147
  cmpb   $0x2f,-0x1(%rbp,%rcx,1)
  je     L90
L117:
  mov    %r8d,%eax
  pop    %rbp
  ret
  nopl   (%rax)
L79:
  test   %r8d,%r8d
  jne    L159
  xor    %r9d,%r9d
  mov    $0x1,%r8d
  jmp    L123
L77:
  lea    D8(%rip),%rdi
  call   <puts@plt>
L218:
  mov    %rbp,%rsi
  lea    D37(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  mov    $0xffffffff,%r8d
  pop    %rbp
  mov    %r8d,%eax
  ret
L159:
  lea    D62(%rip),%rdi
  call   <puts@plt>
  jmp    L218
L11:
  lea    D31(%rip),%rdi
  call   <puts@plt>
  jmp    L218
L90:
  cmp    $0x2e,%dl
  jne    L117
  lea    D31(%rip),%rdi
  call   <puts@plt>
  or     $0xffffffff,%r8d
  jmp    L117
  nopl   0x0(%rax,%rax,1)
L34:
  lea    D27(%rip),%rdi
  call   <puts@plt>
  jmp    L218
L154:
  mov    $0xffffffff,%eax
  ret
L98:
  mov    %rax,%rsi
  lea    D79(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  mov    $0xffffffff,%r8d
  jmp    L117
L147:
  mov    %rbp,%rsi
  lea    D10(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  or     $0xffffffff,%r8d
  jmp    L117
```

tool_calls: name: retrieve_data
arguments: label: D8
datatype: string
name: retrieve_data
arguments: label: D37
datatype: string
name: retrieve_data
arguments: label: D62
datatype: string
name: retrieve_data
arguments: label: D31
datatype: string
name: retrieve_data
arguments: label: D27
datatype: string
name: retrieve_data
arguments: label: D79
datatype: string
name: retrieve_data
arguments: label: D10
datatype: string

tool: D8: // not permitted

tool: D37: bad path: %s


tool: D62: .. not permitted

tool: D31: /. not permitted

tool: D27: path must begin with /

tool: D79: bad pathlen(%d)


tool: D10: trailing slash not permitted: %s


assistant: ```c
int eslib_file_path_check(char *path) {
  size_t len;
  size_t i;
  int adot = 0;
  int aslash = 0;
  int slashing = 0;
  if (path == NULL)
    return -1;
  len = strnlen(path, 2048);
  if (len >= 2048 || len == 0) {
    printf("bad pathlen(%d)\n", len);
    return -1;
  }
  if (path[0] != '/') {
    printf("path must begin with /\n");
    goto bad_path;
  }
  for (i = 0; i < len; ++i) {
    switch (path[i]) {
    case '.':
      if (adot) {
        printf(".. not permitted\n");
        goto bad_path;
      }
      adot = 1;
      aslash = 0;
      break;
    case '/':
      if (aslash) {
        printf("// not permitted\n");
        goto bad_path;
      }
      if (adot && slashing) {
        printf("/. not permitted\n");
        goto bad_path;
      }
      slashing = 1;
      aslash = 1;
      adot = 0;
      break;
    default:
      slashing = 0;
      adot = 0;
      aslash = 0;
      break;
    }
  }
  if (len >= 2 && path[i - 1] == '/') {
    printf("trailing slash not permitted: %s\n", path);
    return -1;
  } else if (len >= 2 && path[i - 2] == '/' && path[i - 1] == '.') {
    printf("/. not permitted\n");
    return -1;
  }
  return 0;
bad_path:
  printf("bad path: %s\n", path);
  return -1;
}
```