user: Translate the below assembly code into C programming language:

```asm
<tracecmd_event_systems>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x60,%rsp
  mov    %rdi,-0x58(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  movq   $0x0,-0x40(%rbp)
  movl   $0x0,-0x48(%rbp)
  cmpq   $0x0,-0x58(%rbp)
  jne    L118
  mov    $0x0,%eax
  jmp    L5
L118:
  mov    -0x58(%rbp),%rax
  lea    D23(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <append_file@plt>
  mov    %rax,-0x38(%rbp)
  cmpq   $0x0,-0x38(%rbp)
  jne    L186
  mov    $0x0,%eax
  jmp    L5
L186:
  lea    -0x4c(%rbp),%rdx
  mov    -0x38(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <stat@plt>
  mov    %eax,-0x44(%rbp)
  cmpl   $0x0,-0x44(%rbp)
  js     L129
  mov    -0x4c(%rbp),%eax
  mov    %eax,%edi
  call   <S_ISDIR@plt>
  test   %eax,%eax
  je     L129
  mov    -0x38(%rbp),%rax
  mov    %rax,%rdi
  call   <opendir@plt>
  mov    %rax,-0x30(%rbp)
  cmpq   $0x0,-0x30(%rbp)
  je     L112
  jmp    L110
L83:
  mov    -0x28(%rbp),%rax
  mov    (%rax),%rax
  mov    %rax,-0x20(%rbp)
  mov    -0x20(%rbp),%rax
  lea    D4(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  je     L110
  mov    -0x20(%rbp),%rax
  lea    D1(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  jne    L38
  jmp    L110
L38:
  mov    -0x20(%rbp),%rdx
  mov    -0x38(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <append_file@plt>
  mov    %rax,-0x18(%rbp)
  lea    -0x4c(%rbp),%rdx
  mov    -0x18(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <stat@plt>
  mov    %eax,-0x44(%rbp)
  cmpl   $0x0,-0x44(%rbp)
  js     L127
  mov    -0x4c(%rbp),%eax
  mov    %eax,%edi
  call   <S_ISDIR@plt>
  test   %eax,%eax
  jne    L123
L127:
  mov    -0x18(%rbp),%rax
  mov    %rax,%rdi
  call   <free@plt>
  jmp    L110
L123:
  mov    -0x18(%rbp),%rax
  lea    D32(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <append_file@plt>
  mov    %rax,-0x10(%rbp)
  lea    -0x4c(%rbp),%rdx
  mov    -0x10(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <stat@plt>
  mov    %eax,-0x44(%rbp)
  cmpl   $0x0,-0x44(%rbp)
  js     L147
  mov    -0x48(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    %edx,-0x48(%rbp)
  mov    -0x20(%rbp),%rsi
  mov    -0x40(%rbp),%rcx
  mov    %eax,%edx
  mov    %rcx,%rdi
  call   <tracecmd_add_list@plt>
  mov    %rax,-0x40(%rbp)
L147:
  mov    -0x10(%rbp),%rax
  mov    %rax,%rdi
  call   <free@plt>
  mov    -0x18(%rbp),%rax
  mov    %rax,%rdi
  call   <free@plt>
L110:
  mov    -0x30(%rbp),%rax
  mov    %rax,%rdi
  call   <readdir@plt>
  mov    %rax,-0x28(%rbp)
  cmpq   $0x0,-0x28(%rbp)
  jne    L83
  mov    -0x30(%rbp),%rax
  mov    %rax,%rdi
  call   <closedir@plt>
  jmp    L170
L129:
  nop
  jmp    L170
L112:
  nop
L170:
  mov    -0x38(%rbp),%rax
  mov    %rax,%rdi
  call   <free@plt>
  mov    -0x40(%rbp),%rax
L5:
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L57
  call   <__stack_chk_fail@plt>
L57:
  leave
  ret
```

tool_calls: name: unpack_data
arguments: label: D23
data_type: string
name: unpack_data
arguments: label: D4
data_type: string
name: unpack_data
arguments: label: D1
data_type: string
name: unpack_data
arguments: label: D32
data_type: string

tool: D23: events

tool: D4: .

tool: D1: ..

tool: D32: enable

assistant: ```c
char **tracecmd_event_systems(const char *tracing_dir) {
  struct dirent *dent;
  char **systems = NULL;
  char *events_dir;
  struct stat st;
  DIR *dir;
  int len = 0;
  int ret;
  if (!tracing_dir)
    return NULL;
  events_dir = append_file(tracing_dir, "events");
  if (!events_dir)
    return NULL;
  ret = stat(events_dir, &st);
  if (ret < 0 || !S_ISDIR(st.st_mode))
    goto out_free;
  dir = opendir(events_dir);
  if (!dir)
    goto out_free;
  while ((dent = readdir(dir))) {
    const char *name = dent->d_name;
    char *enable;
    char *sys;
    if (strcmp(name, ".") == 0 || strcmp(name, "..") == 0)
      continue;
    sys = append_file(events_dir, name);
    ret = stat(sys, &st);
    if (ret < 0 || !S_ISDIR(st.st_mode)) {
      free(sys);
      continue;
    }
    enable = append_file(sys, "enable");
    ret = stat(enable, &st);
    if (ret >= 0)
      systems = tracecmd_add_list(systems, name, len++);
    free(enable);
    free(sys);
  }
  closedir(dir);
out_free:
  free(events_dir);
  return systems;
}
```