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

```asm
<clear_hooks>:
  endbr64
  push   %r15
  push   %r14
  mov    %rdi,%r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x18,%rsp
  call   <strlen@plt>
  mov    %r14,%rdi
  mov    %eax,0x8(%rsp)
  call   <opendir@plt>
  test   %rax,%rax
  je     L74
  movl   $0x0,0xc(%rsp)
  mov    %rax,%r12
  xor    %ebp,%ebp
  lea    D26(%rip),%rbx
  lea    D59(%rip),%r13
  nopw   0x0(%rax,%rax,1)
L92:
  mov    %r12,%rdi
  call   <readdir@plt>
  mov    %rax,%r15
  test   %rax,%rax
  je     L63
L47:
  mov    (%r15),%rdi
  mov    %rbx,%rsi
  call   <strcmp@plt>
  test   %rax,%rax
  je     L92
  mov    (%r15),%rdi
  mov    %r13,%rsi
  call   <strcmp@plt>
  test   %rax,%rax
  je     L92
  mov    (%r15),%rdi
  call   <strlen@plt>
  mov    0x8(%rsp),%edx
  lea    0x2(%rdx,%rax,1),%esi
  test   %rbp,%rbp
  je     L64
  mov    %rbp,%rdi
  mov    %esi,0x4(%rsp)
  call   <realloc@plt>
  mov    0x4(%rsp),%esi
  test   %rax,%rax
  mov    %rax,%rbp
  je     L57
L19:
  mov    (%r15),%r8
  mov    %rbp,%rdi
  mov    %r14,%rcx
  lea    D0(%rip),%rdx
  call   <snprintf@plt>
  mov    %rbp,%rdi
  call   <unlink@plt>
  test   %rax,%rax
  je     L92
  lea    D7(%rip),%rdi
  call   <perror@plt>
  mov    %r12,%rdi
  movl   $0xffffffff,0xc(%rsp)
  call   <readdir@plt>
  mov    %rax,%r15
  test   %rax,%rax
  jne    L47
  nopw   0x0(%rax,%rax,1)
L63:
  mov    %r12,%rdi
  call   <closedir@plt>
  test   %rbp,%rbp
  je     L44
  mov    %rbp,%rdi
  call   <free@plt>
L44:
  mov    0xc(%rsp),%eax
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax,%rax,1)
L64:
  mov    %esi,%edi
  mov    %esi,0x4(%rsp)
  call   <malloc@plt>
  mov    0x4(%rsp),%esi
  test   %rax,%rax
  mov    %rax,%rbp
  jne    L19
  lea    D21(%rip),%rdi
  call   <perror@plt>
  mov    %r12,%rdi
  call   <closedir@plt>
L74:
  movl   $0xffffffff,0xc(%rsp)
  jmp    L44
L57:
  lea    D17(%rip),%rdi
  call   <perror@plt>
  mov    %r12,%rdi
  call   <closedir@plt>
  movl   $0xffffffff,0xc(%rsp)
  jmp    L44
```

tool_calls: name: retrieve_data
arguments: data_label: D26
type_guessed: string
name: retrieve_data
arguments: data_label: D59
type_guessed: string
name: retrieve_data
arguments: data_label: D0
type_guessed: string
name: retrieve_data
arguments: data_label: D7
type_guessed: string
name: retrieve_data
arguments: data_label: D21
type_guessed: string
name: retrieve_data
arguments: data_label: D17
type_guessed: string

tool: D26: .

tool: D59: ..

tool: D0: %s/%s

tool: D7: unlink failed

tool: D21: malloc path failed

tool: D17: realloc path failed

assistant: ```c
int clear_hooks(char *dirname) {
  DIR *dir;
  struct dirent *ent;
  char *path = NULL;
  char *new_path;
  int path_len;
  int dirname_len;
  int status = 0;
  dirname_len = strlen(dirname);
  if ((dir = opendir(dirname)) != NULL) {
    while ((ent = readdir(dir)) != NULL) {
      if (strcmp(ent->d_name, ".") == 0 || strcmp(ent->d_name, "..") == 0) {
        continue;
      }
      path_len = dirname_len + strlen(ent->d_name) + 2;
      if (path == NULL) {
        path = malloc(path_len);
        if (path == NULL) {
          perror("malloc path failed");
          closedir(dir);
          return -1;
        }
      } else {
        new_path = realloc(path, path_len);
        if (new_path == NULL) {
          perror("realloc path failed");
          closedir(dir);
          return -1;
        }
        path = new_path;
      }
      snprintf(path, path_len, "%s/%s", dirname, ent->d_name);
      if (unlink(path) != 0) {
        perror("unlink failed");
        status = -1;
      }
    }
    closedir(dir);
    if (path != NULL) {
      free(path);
    }
  } else {
    status = -1;
  }
  return status;
}
```