user: 下面的汇编指令对应的C源代码是什么:

```asm
<ttynameCheckDir>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %rbx
  sub    $0x58,%rsp
  mov    %rdi,-0x58(%rbp)
  mov    %rsi,-0x60(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x18(%rbp)
  xor    %eax,%eax
  mov    D101(%rip),%eax
  test   %eax,%eax
  jne    L155
  mov    $0x32,%edi
  call   <malloc@plt>
  mov    %rax,D15(%rip)
  mov    D15(%rip),%rax
  test   %rax,%rax
  jne    L49
  mov    $0x0,%eax
  jmp    L177
L49:
  movl   $0x32,D101(%rip)
L155:
  mov    -0x60(%rbp),%rax
  mov    %rax,%rdi
  call   <opendir@plt>
  mov    %rax,-0x40(%rbp)
  cmpq   $0x0,-0x40(%rbp)
  jne    L141
  mov    $0x0,%eax
  jmp    L177
L141:
  movl   $0x0,-0x48(%rbp)
  jmp    L33
L77:
  mov    -0x60(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  lea    0x1(%rax),%ebx
  mov    -0x38(%rbp),%rax
  mov    (%rax),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  add    %ebx,%eax
  add    $0x1,%eax
  mov    %eax,-0x44(%rbp)
  mov    D101(%rip),%eax
  cmp    %eax,-0x44(%rbp)
  jle    L156
  mov    D15(%rip),%rax
  mov    -0x44(%rbp),%edx
  mov    %edx,%esi
  mov    %rax,%rdi
  call   <realloc@plt>
  mov    %rax,D87(%rip)
  mov    D87(%rip),%rax
  test   %rax,%rax
  je     L35
  mov    -0x44(%rbp),%eax
  mov    %eax,D87(%rip)
L156:
  mov    -0x38(%rbp),%rax
  mov    (%rax),%rcx
  mov    D87(%rip),%esi
  mov    D87(%rip),%rax
  mov    -0x60(%rbp),%rdx
  mov    %rcx,%r8
  mov    %rdx,%rcx
  lea    D87(%rip),%rdx
  mov    %rax,%rdi
  call   <snprintf@plt>
  mov    D87(%rip),%rax
  lea    -0x30(%rbp),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <stat@plt>
  cmp    $0xffffffff,%eax
  jne    L165
  jmp    L33
L165:
  mov    -0x28(%rbp),%eax
  mov    %eax,%edi
  call   <S_ISCHR@plt>
  test   %rax,%rax
  je     L33
  mov    -0x58(%rbp),%rax
  mov    (%rax),%rdx
  mov    -0x30(%rbp),%rax
  cmp    %rax,%rdx
  jne    L33
  movl   $0x1,-0x48(%rbp)
  jmp    L144
L33:
  mov    -0x40(%rbp),%rax
  mov    %rax,%rdi
  call   <readdir@plt>
  mov    %rax,-0x38(%rbp)
  cmpq   $0x0,-0x38(%rbp)
  jne    L77
  jmp    L144
L35:
  nop
L144:
  mov    -0x40(%rbp),%rax
  mov    %rax,%rdi
  call   <closedir@plt>
  cmpl   $0x0,-0x48(%rbp)
  je     L50
  mov    D87(%rip),%rax
  jmp    L177
L50:
  mov    $0x0,%eax
L177:
  mov    -0x18(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L124
  call   <__stack_chk_fail@plt>
L124:
  mov    -0x8(%rbp),%rbx
  leave
  ret
```

tool_calls: name: parse_data
arguments: label: D87
type_infered: string

tool: D87: %s/%s

assistant: ```c
char *ttynameCheckDir(const struct stat *fdStat, const char *devDir) {
  DIR *dirh;
  struct dirent *dent;
  static char *ttyPath;
  static int ttyLen = 0;
  struct stat devStat;
  int found;
  int requiredLen;
  if (ttyLen == 0) {
    ttyPath = malloc(50);
    if (ttyPath == NULL)
      return NULL;
    ttyLen = 50;
  }
  dirh = opendir(devDir);
  if (dirh == NULL)
    return NULL;
  found = 0;
  while ((dent = readdir(dirh)) != NULL) {
    requiredLen = strlen(devDir) + 1 + strlen(dent->d_name) + 1;
    if (requiredLen > ttyLen) {
      ttyPath = realloc(ttyPath, requiredLen);
      if (ttyPath == NULL)
        break;
      ttyLen = requiredLen;
    }
    snprintf(ttyPath, ttyLen, "%s/%s", devDir, dent->d_name);
    if (stat(ttyPath, &devStat) == -1)
      continue;
    if (S_ISCHR(devStat.st_mode) && fdStat->st_rdev == devStat.st_rdev) {
      found = 1;
      break;
    }
  }
  closedir(dirh);
  return found ? ttyPath : NULL;
}
```