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

```asm
<XcursorScanTheme>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x18,%rsp
  test   %rdi,%rdi
  je     L199
  mov    %rdi,%r13
  mov    %rsi,%r15
  test   %rsi,%rsi
  je     L199
  mov    $0x0,%eax
  call   <XcursorLibraryPath@plt>
  mov    %rax,%rbp
  test   %rax,%rax
  je     L98
  mov    $0x0,%r14d
  jmp    L165
L52:
  mov    %r12,%rax
  or     %r14,%rax
  je     L78
L195:
  mov    %rbx,%rdi
  call   <free@plt>
  mov    %r12,%rbx
L189:
  mov    %rbp,%rdi
  call   <_XcursorNextPath@plt>
  mov    %rax,%rbp
  test   %rbx,%rbx
  sete   %al
  test   %rbp,%rbp
  je     L107
  test   %al,%al
  je     L107
L165:
  mov    %r13,%rsi
  mov    %rbp,%rdi
  call   <_XcursorBuildThemeDir@plt>
  mov    %rax,%rbx
  test   %rax,%rax
  je     L189
  mov    %r15,%rdx
  lea    D0(%rip),%rsi
  mov    %rax,%rdi
  call   <_XcursorBuildFullname@plt>
  mov    %rax,%r12
  test   %rax,%rax
  je     L52
  lea    D41(%rip),%rsi
  mov    %rax,%rdi
  call   <fopen@plt>
  mov    %rax,0x8(%rsp)
  mov    %r12,%rdi
  call   <free@plt>
  mov    0x8(%rsp),%r12
  jmp    L52
L78:
  lea    D37(%rip),%rdx
  lea    D27(%rip),%rsi
  mov    %rbx,%rdi
  call   <_XcursorBuildFullname@plt>
  mov    %rax,%r14
  test   %rax,%rax
  je     L195
  mov    %rax,%rdi
  call   <_XcursorThemeInherits@plt>
  mov    %rax,0x8(%rsp)
  mov    %r14,%rdi
  call   <free@plt>
  mov    0x8(%rsp),%r14
  jmp    L195
L107:
  test   %r14,%r14
  je     L182
  test   %al,%al
  je     L182
  mov    %r14,%rbp
  lea    D7(%rip),%r12
  jmp    L166
L22:
  mov    %r15,%rdx
  mov    %rbp,%rsi
  mov    %r12,%rdi
  call   <printf@plt>
  mov    $0x0,%ebx
L140:
  mov    %rbp,%rdi
  call   <_XcursorNextPath@plt>
  mov    %rax,%rbp
  test   %rax,%rax
  je     L14
  test   %rbx,%rbx
  jne    L14
L166:
  mov    %r13,%rsi
  mov    %rbp,%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  je     L22
  mov    %r15,%rsi
  mov    %rbp,%rdi
  call   <XcursorScanTheme>
  mov    %rax,%rbx
  jmp    L140
L182:
  test   %r14,%r14
  je     L79
L14:
  mov    %r14,%rdi
  call   <free@plt>
L79:
  mov    %rbx,%rax
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L199:
  mov    $0x0,%ebx
  jmp    L79
L98:
  mov    %rax,%rbx
  jmp    L79
```

tool_calls: name: disassemble_data
arguments: data_label: D0
type_infered: string
name: disassemble_data
arguments: data_label: D41
type_infered: string
name: disassemble_data
arguments: data_label: D37
type_infered: string
name: disassemble_data
arguments: data_label: D27
type_infered: string
name: disassemble_data
arguments: data_label: D7
type_infered: string

tool: D0: cursors

tool: D41: r

tool: D37: index.theme

tool: 

tool: D7: Not calling XcursorScanTheme because of circular dependency: %s. %s

assistant: ```c
FILE *XcursorScanTheme(const char *theme, const char *name) {
  FILE *f = NULL;
  char *full;
  char *dir;
  const char *path;
  char *inherits = NULL;
  const char *i;
  if (!theme || !name)
    return NULL;
  for (path = XcursorLibraryPath(); path && f == NULL; path = _XcursorNextPath(path)) {
    dir = _XcursorBuildThemeDir(path, theme);
    if (dir) {
      full = _XcursorBuildFullname(dir, "cursors", name);
      if (full) {
        f = fopen(full, "r");
        free(full);
      }
      if (!f && !inherits) {
        full = _XcursorBuildFullname(dir, "", "index.theme");
        if (full) {
          inherits = _XcursorThemeInherits(full);
          free(full);
        }
      }
      free(dir);
    }
  }
  for (i = inherits; i && f == NULL; i = _XcursorNextPath(i)) {
    if (strcmp(i, theme) != 0)
      f = XcursorScanTheme(i, name);
    else
      printf("Not calling XcursorScanTheme because of circular dependency: %s. %s", i, name);
  }
  if (inherits != NULL)
    free(inherits);
  return f;
}
```