user: Converte this assembly snippet into its equivalent C code:

```asm
<expath>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x1000,%rsp
  orq    $0x0,(%rsp)
  sub    $0x70,%rsp
  mov    %rdi,-0x1058(%rbp)
  mov    %rsi,-0x1060(%rbp)
  mov    %edx,-0x1064(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  movl   $0x0,-0x1044(%rbp)
  mov    -0x1058(%rbp),%rax
  mov    %rax,-0x1038(%rbp)
  movq   $0x0,-0xc10(%rbp)
  movq   $0x0,-0xc08(%rbp)
  lea    -0xc00(%rbp),%rdx
  mov    $0x0,%eax
  mov    $0x7e,%ecx
  mov    %rdx,%rdi
  rep stos %rax,%es:(%rdi)
  mov    -0x1064(%rbp),%edx
  mov    -0x1058(%rbp),%rax
  mov    %edx,%ecx
  mov    %rax,%rdx
  lea    D40(%rip),%rax
  mov    %rax,%rsi
  mov    $0x3,%edi
  mov    $0x0,%eax
  call   <trace@plt>
  mov    -0x1058(%rbp),%rax
  mov    $0x2f,%esi
  mov    %rax,%rdi
  call   <strrchr@plt>
  mov    %rax,-0x1030(%rbp)
  cmpq   $0x0,-0x1030(%rbp)
  jne    L114
  mov    -0x1058(%rbp),%rax
  mov    $0x5c,%esi
  mov    %rax,%rdi
  call   <strrchr@plt>
  mov    %rax,-0x1030(%rbp)
  cmpq   $0x0,-0x1030(%rbp)
  je     L52
L114:
  mov    -0x1030(%rbp),%rax
  add    $0x1,%rax
  mov    %rax,-0x1038(%rbp)
  mov    -0x1030(%rbp),%rax
  sub    -0x1058(%rbp),%rax
  add    $0x1,%eax
  mov    %eax,%edx
  mov    -0x1058(%rbp),%rcx
  lea    -0xc10(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <strncpy@plt>
  mov    -0x1030(%rbp),%rax
  sub    -0x1058(%rbp),%rax
  add    $0x1,%rax
  movb   $0x0,-0xc10(%rbp,%rax,1)
L52:
  movzbl -0xc10(%rbp),%eax
  test   %al,%al
  je     L135
  lea    -0xc10(%rbp),%rax
  jmp    L59
L135:
  lea    D39(%rip),%rax
L59:
  mov    %rax,%rdi
  call   <opendir@plt>
  mov    %rax,-0x1020(%rbp)
  cmpq   $0x0,-0x1020(%rbp)
  jne    L64
  mov    $0x0,%eax
  jmp    L49
L141:
  mov    -0x1018(%rbp),%rax
  mov    (%rax),%rax
  movzbl (%rax),%eax
  cmp    $0x2e,%al
  jne    L266
  jmp    L64
L266:
  mov    -0x1018(%rbp),%rax
  mov    (%rax),%rdx
  lea    -0x810(%rbp),%rax
  lea    D43(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <sprintf@plt>
  mov    -0x1038(%rbp),%rdx
  lea    -0x410(%rbp),%rax
  lea    D43(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <sprintf@plt>
  lea    -0x810(%rbp),%rax
  mov    %rax,-0x1030(%rbp)
  jmp    L163
L20:
  mov    -0x1030(%rbp),%rax
  movzbl (%rax),%eax
  movsbl %al,%eax
  mov    %eax,%edi
  call   <tolower@plt>
  mov    %eax,%edx
  mov    -0x1030(%rbp),%rax
  mov    %dl,(%rax)
  addq   $0x1,-0x1030(%rbp)
L163:
  mov    -0x1030(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  jne    L20
  lea    -0x410(%rbp),%rax
  mov    %rax,-0x1030(%rbp)
  jmp    L3
L69:
  mov    -0x1030(%rbp),%rax
  movzbl (%rax),%eax
  movsbl %al,%eax
  mov    %eax,%edi
  call   <tolower@plt>
  mov    %eax,%edx
  mov    -0x1030(%rbp),%rax
  mov    %dl,(%rax)
  addq   $0x1,-0x1030(%rbp)
L3:
  mov    -0x1030(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  jne    L69
  lea    -0x810(%rbp),%rax
  mov    %rax,-0x1030(%rbp)
  lea    -0x1040(%rbp),%rdx
  lea    -0x410(%rbp),%rax
  lea    D46(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <strtok_r@plt>
  mov    %rax,-0x1028(%rbp)
  jmp    L74
L9:
  mov    -0x1028(%rbp),%rdx
  mov    -0x1030(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strstr@plt>
  mov    %rax,-0x1030(%rbp)
  cmpq   $0x0,-0x1030(%rbp)
  je     L77
  mov    -0x1028(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  cltq
  add    %rax,-0x1030(%rbp)
  lea    -0x1040(%rbp),%rax
  mov    %rax,%rdx
  lea    D46(%rip),%rax
  mov    %rax,%rsi
  mov    $0x0,%edi
  call   <strtok_r@plt>
  mov    %rax,-0x1028(%rbp)
L74:
  cmpq   $0x0,-0x1028(%rbp)
  jne    L9
  jmp    L175
L77:
  nop
L175:
  cmpq   $0x0,-0x1030(%rbp)
  je     L64
  mov    -0x1044(%rbp),%eax
  cmp    -0x1064(%rbp),%eax
  jge    L64
  mov    -0x1018(%rbp),%rax
  mov    (%rax),%rcx
  mov    -0x1044(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    %edx,-0x1044(%rbp)
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x1060(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rax
  lea    -0xc10(%rbp),%rdx
  lea    D13(%rip),%rsi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <sprintf@plt>
L64:
  mov    -0x1020(%rbp),%rax
  mov    %rax,%rdi
  call   <readdir@plt>
  mov    %rax,-0x1018(%rbp)
  cmpq   $0x0,-0x1018(%rbp)
  jne    L141
  mov    -0x1020(%rbp),%rax
  mov    %rax,%rdi
  call   <closedir@plt>
  movl   $0x0,-0x104c(%rbp)
  jmp    L165
L94:
  mov    -0x104c(%rbp),%eax
  add    $0x1,%eax
  mov    %eax,-0x1048(%rbp)
  jmp    L55
L188:
  mov    -0x1048(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x1060(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rdx
  mov    -0x104c(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rcx
  mov    -0x1060(%rbp),%rax
  add    %rcx,%rax
  mov    (%rax),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  jle    L207
  mov    -0x104c(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x1060(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rdx
  lea    -0x1010(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcpy@plt>
  mov    -0x1048(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x1060(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rdx
  mov    -0x104c(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rcx
  mov    -0x1060(%rbp),%rax
  add    %rcx,%rax
  mov    (%rax),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcpy@plt>
  mov    -0x1048(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x1060(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rax
  lea    -0x1010(%rbp),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcpy@plt>
L207:
  addl   $0x1,-0x1048(%rbp)
L55:
  mov    -0x1048(%rbp),%eax
  cmp    -0x1044(%rbp),%eax
  jl     L188
  addl   $0x1,-0x104c(%rbp)
L165:
  mov    -0x1044(%rbp),%eax
  sub    $0x1,%eax
  cmp    %eax,-0x104c(%rbp)
  jl     L94
  movl   $0x0,-0x104c(%rbp)
  jmp    L42
L239:
  mov    -0x104c(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x1060(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rax
  mov    %rax,%rdx
  lea    D41(%rip),%rax
  mov    %rax,%rsi
  mov    $0x3,%edi
  mov    $0x0,%eax
  call   <trace@plt>
  addl   $0x1,-0x104c(%rbp)
L42:
  mov    -0x104c(%rbp),%eax
  cmp    -0x1044(%rbp),%eax
  jl     L239
  mov    -0x1044(%rbp),%eax
L49:
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L71
  call   <__stack_chk_fail@plt>
L71:
  leave
  ret
```

tool_calls: name: unpack_data
arguments: data_tag: D40
data_type: string
name: unpack_data
arguments: data_tag: D39
data_type: string
name: unpack_data
arguments: data_tag: D43
data_type: string
name: unpack_data
arguments: data_tag: D46
data_type: string
name: unpack_data
arguments: data_tag: D13
data_type: string
name: unpack_data
arguments: data_tag: D41
data_type: string

tool: D40: expath  : path=%s nmax=%d


tool: D39: .

tool: D43: ^%s$

tool: D46: *

tool: D13: %s%s

tool: D41: expath  : file=%s


assistant: ```c
extern int expath(const char *path, char *paths[], int nmax) {
  int i, j, n = 0;
  char tmp[1024];
  struct dirent *d;
  DIR *dp;
  const char *file = path;
  char dir[1024] = "", s1[1024], s2[1024], *p, *q, *r;
  trace(3, "expath  : path=%s nmax=%d\n", path, nmax);
  if ((p = strrchr(path, '/')) || (p = strrchr(path, '\\'))) {
    file = p + 1;
    strncpy(dir, path, p - path + 1);
    dir[p - path + 1] = '\0';
  }
  if (!(dp = opendir(*dir ? dir : ".")))
    return 0;
  while ((d = readdir(dp))) {
    if (*(d->d_name) == '.')
      continue;
    sprintf(s1, "^%s$", d->d_name);
    sprintf(s2, "^%s$", file);
    for (p = s1; *p; p++)
      *p = (char)tolower((int)*p);
    for (p = s2; *p; p++)
      *p = (char)tolower((int)*p);
    for (p = s1, q = strtok_r(s2, "*", &r); q; q = strtok_r(NULL, "*", &r)) {
      if ((p = strstr(p, q)))
        p += strlen(q);
      else
        break;
    }
    if (p && n < nmax)
      sprintf(paths[n++], "%s%s", dir, d->d_name);
  }
  closedir(dp);
  for (i = 0; i < n - 1; i++) {
    for (j = i + 1; j < n; j++) {
      if (strcmp(paths[i], paths[j]) > 0) {
        strcpy(tmp, paths[i]);
        strcpy(paths[i], paths[j]);
        strcpy(paths[j], tmp);
      }
    }
  }
  for (i = 0; i < n; i++)
    trace(3, "expath  : file=%s\n", paths[i]);
  return n;
}
```