user: 请从给定的汇编指令推导出C源代码：

```asm
<scan_subsystem>:
  endbr64
  push   %r15
  mov    $0x200,%edx
  lea    D22(%rip),%rsi
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  mov    %rdi,%rbp
  push   %rbx
  sub    $0x628,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x618(%rsp)
  xor    %eax,%eax
  lea    0x10(%rsp),%r15
  mov    %r15,%rdi
  call   <strncpy@plt>
  mov    %r15,%rdi
  movb   $0x0,0x20f(%rsp)
  call   <strlen@plt>
  mov    $0x1ff,%edx
  mov    %r15,%rdi
  mov    %rbp,%rsi
  sub    %eax,%edx
  call   <strncat@plt>
  mov    %r15,%rdi
  call   <opendir@plt>
  test   %rax,%rax
  je     L19
  mov    %rax,%rdi
  mov    %rax,%r13
  call   <readdir@plt>
  mov    %rax,%rcx
  test   %rax,%rax
  je     L0
  lea    D0(%rip),%r14
  lea    0x410(%rsp),%rbp
  jmp    L29
  nop
L25:
  mov    %r13,%rdi
  call   <readdir@plt>
  mov    %rax,%rcx
  test   %rax,%rax
  je     L0
L29:
  mov    (%rcx),%rax
  cmpb   $0x2e,(%rax)
  je     L25
  lea    0x210(%rsp),%rbx
  mov    $0x200,%edx
  mov    %r15,%rsi
  mov    %rcx,0x8(%rsp)
  mov    %rbx,%rdi
  mov    $0x1ff,%r12d
  call   <strncpy@plt>
  mov    %rbx,%rdi
  movb   $0x0,0x40f(%rsp)
  call   <strlen@plt>
  mov    %r12d,%edx
  mov    %r14,%rsi
  mov    %rbx,%rdi
  sub    %eax,%edx
  call   <strncat@plt>
  mov    %rbx,%rdi
  call   <strlen@plt>
  mov    0x8(%rsp),%rcx
  mov    %r12d,%edx
  mov    %rbx,%rdi
  sub    %eax,%edx
  mov    (%rcx),%rsi
  call   <strncat@plt>
  mov    %rbx,%rdi
  call   <strlen@plt>
  mov    %r12d,%edx
  lea    D29(%rip),%rsi
  mov    %rbx,%rdi
  sub    %eax,%edx
  call   <strncat@plt>
  mov    %rbx,%rdi
  call   <opendir@plt>
  mov    %rax,%r12
  test   %rax,%rax
  je     L25
L46:
  mov    %r12,%rdi
  call   <readdir@plt>
  mov    %rax,%rcx
  test   %rax,%rax
  je     L40
L76:
  mov    (%rax),%rax
  mov    %rcx,0x8(%rsp)
  cmpb   $0x2e,(%rax)
  je     L46
  mov    $0x200,%edx
  mov    %rbx,%rsi
  mov    %rbp,%rdi
  call   <strncpy@plt>
  mov    %rbp,%rdi
  movb   $0x0,0x60f(%rsp)
  call   <strlen@plt>
  mov    $0x1ff,%edx
  mov    %r14,%rsi
  mov    %rbp,%rdi
  sub    %eax,%edx
  call   <strncat@plt>
  mov    %rbp,%rdi
  call   <strlen@plt>
  mov    0x8(%rsp),%rcx
  mov    $0x1ff,%edx
  mov    %rbp,%rdi
  sub    %eax,%edx
  mov    (%rcx),%rsi
  call   <strncat@plt>
  mov    %rbp,%rdi
  call   <device_list_insert@plt>
  mov    %r12,%rdi
  call   <readdir@plt>
  mov    %rax,%rcx
  test   %rax,%rax
  jne    L76
L40:
  mov    %r12,%rdi
  call   <closedir@plt>
  mov    %r13,%rdi
  call   <readdir@plt>
  mov    %rax,%rcx
  test   %rax,%rax
  jne    L29
  xchg   %ax,%ax
L0:
  mov    %r13,%rdi
  call   <closedir@plt>
L19:
  mov    0x618(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L3
  add    $0x628,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L3:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: parse_data
arguments: label: D22
type_guessed: string
name: parse_data
arguments: label: D0
type_guessed: string
name: parse_data
arguments: label: D29
type_guessed: string

tool: D22: /sys/

tool: D0: /

tool: D29: /devices

assistant: ```c
void scan_subsystem(const char *subsys) {
  char base[512];
  DIR *dir;
  struct dirent *dent;
  (strncpy(base, "/sys/", sizeof(base)), (base)[(sizeof(base)) - 1] = '\0');
  strncat(base, subsys, (sizeof(base)) - strlen(base) - 1);
  dir = opendir(base);
  if (dir != NULL) {
    for (dent = readdir(dir); dent != NULL; dent = readdir(dir)) {
      char dirname[512];
      DIR *dir2;
      struct dirent *dent2;
      if (dent->d_name[0] == '.')
        continue;
      (strncpy(dirname, base, sizeof(dirname)), (dirname)[(sizeof(dirname)) - 1] = '\0');
      strncat(dirname, "/", (sizeof(dirname)) - strlen(dirname) - 1);
      strncat(dirname, dent->d_name, (sizeof(dirname)) - strlen(dirname) - 1);
      strncat(dirname, "/devices", (sizeof(dirname)) - strlen(dirname) - 1);
      dir2 = opendir(dirname);
      if (dir2 != NULL) {
        for (dent2 = readdir(dir2); dent2 != NULL; dent2 = readdir(dir2)) {
          char dirname2[512];
          if (dent2->d_name[0] == '.')
            continue;
          (strncpy(dirname2, dirname, sizeof(dirname2)), (dirname2)[(sizeof(dirname2)) - 1] = '\0');
          strncat(dirname2, "/", (sizeof(dirname2)) - strlen(dirname2) - 1);
          strncat(dirname2, dent2->d_name, (sizeof(dirname2)) - strlen(dirname2) - 1);
          device_list_insert(dirname2);
        }
        closedir(dir2);
      }
    }
    closedir(dir);
  }
}
```