user: What is the c source code of the assembly code below?

```asm
<xdg_user_dir_lookup_with_fallback>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x228,%rsp
  mov    %rdi,%rbp
  mov    %rsi,%r14
  mov    %fs:0x28,%rax
  mov    %rax,0x218(%rsp)
  xor    %eax,%eax
  lea    D9(%rip),%rdi
  call   <getenv@plt>
  test   %rax,%rax
  je     L448
  mov    %rax,%r15
  lea    D17(%rip),%rdi
  call   <getenv@plt>
  mov    %rax,%rbx
  test   %rax,%rax
  je     L36
  cmpb   $0x0,(%rax)
  jne    L363
L36:
  mov    %r15,%rdi
  call   <strlen@plt>
  mov    %eax,%ebx
  lea    D1(%rip),%rdi
  call   <strlen@plt>
  lea    0x1(%rbx,%rax,1),%edi
  call   <malloc@plt>
  mov    %rax,%rbx
  test   %rax,%rax
  jne    L180
L448:
  mov    %r14,(%rsp)
  test   %r14,%r14
  je     L328
  mov    %r14,%rdi
  call   <strdup@plt>
  mov    %rax,(%rsp)
L328:
  mov    0x218(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L80
  mov    (%rsp),%rax
  add    $0x228,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L180:
  mov    %rax,%r13
  mov    %r15,%rsi
  mov    %rax,%rdi
  call   <strcpy@plt>
  lea    D1(%rip),%rsi
  mov    %rbx,%rdi
  call   <strcat@plt>
L368:
  lea    D38(%rip),%rsi
  mov    %r13,%rdi
  call   <fopen@plt>
  mov    %rax,%r12
  mov    %r13,%rdi
  call   <free@plt>
  test   %r12,%r12
  je     L448
  movq   $0x0,(%rsp)
  lea    D40(%rip),%r13
  jmp    L231
L363:
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    %eax,%r12d
  lea    D13(%rip),%rdi
  call   <strlen@plt>
  lea    0x1(%r12,%rax,1),%edi
  call   <malloc@plt>
  mov    %rax,%r12
  test   %rax,%rax
  je     L448
  mov    %rax,%r13
  mov    %rbx,%rsi
  mov    %rax,%rdi
  call   <strcpy@plt>
  lea    D13(%rip),%rsi
  mov    %r12,%rdi
  call   <strcat@plt>
  jmp    L368
L220:
  movb   $0x0,0x10(%rsp,%rdx,1)
  jmp    L51
L390:
  lea    0x10(%rsp),%rbx
  jmp    L4
L197:
  add    $0x1,%rax
  movzbl (%rax),%edx
  cmp    $0x20,%dl
  je     L197
  cmp    $0x9,%dl
  je     L197
L97:
  cmp    $0x3d,%dl
  je     L45
L231:
  lea    0x10(%rsp),%rdi
  mov    %r12,%rdx
  mov    $0x200,%esi
  call   <fgets@plt>
  test   %rax,%rax
  je     L319
  lea    0x10(%rsp),%rdi
  call   <strlen@plt>
  test   %eax,%eax
  jle    L51
  sub    $0x1,%eax
  movslq %eax,%rdx
  cmpb   $0xa,0x10(%rsp,%rdx,1)
  je     L220
L51:
  movzbl 0x10(%rsp),%eax
  cmp    $0x20,%al
  je     L199
  cmp    $0x9,%al
  jne    L390
L199:
  lea    0x10(%rsp),%rbx
L310:
  add    $0x1,%rbx
  movzbl (%rbx),%eax
  cmp    $0x20,%al
  je     L310
  cmp    $0x9,%al
  je     L310
L4:
  mov    $0x4,%edx
  mov    %r13,%rsi
  mov    %rbx,%rdi
  call   <strncmp@plt>
  test   %rax,%rax
  jne    L231
  add    $0x4,%rbx
  mov    %rbp,%rdi
  call   <strlen@plt>
  mov    %eax,%edx
  mov    %rbp,%rsi
  mov    %rbx,%rdi
  call   <strncmp@plt>
  test   %rax,%rax
  jne    L231
  mov    %rbp,%rdi
  call   <strlen@plt>
  cltq
  add    %rax,%rbx
  mov    $0x4,%edx
  lea    D56(%rip),%rsi
  mov    %rbx,%rdi
  call   <strncmp@plt>
  test   %rax,%rax
  jne    L231
  lea    0x4(%rbx),%rax
  movzbl 0x4(%rbx),%edx
  cmp    $0x20,%dl
  je     L197
  cmp    $0x9,%dl
  je     L197
  jmp    L97
L45:
  lea    0x1(%rax),%rbx
  movzbl 0x1(%rax),%eax
  cmp    $0x20,%al
  je     L69
  cmp    $0x9,%al
  jne    L146
L69:
  add    $0x1,%rbx
  movzbl (%rbx),%eax
  cmp    $0x20,%al
  je     L69
  cmp    $0x9,%al
  je     L69
L146:
  cmp    $0x22,%al
  jne    L231
  lea    0x1(%rbx),%rax
  mov    %rax,0x8(%rsp)
  mov    $0x6,%edx
  lea    D80(%rip),%rsi
  mov    %rax,%rdi
  call   <strncmp@plt>
  test   %rax,%rax
  je     L256
  cmpb   $0x2f,0x1(%rbx)
  jne    L231
  mov    0x8(%rsp),%rdi
  call   <strlen@plt>
  lea    0x1(%rax),%edi
  call   <malloc@plt>
  mov    %rax,(%rsp)
  test   %rax,%rax
  je     L319
  mov    (%rsp),%rax
  movb   $0x0,(%rax)
  jmp    L184
L256:
  lea    0x7(%rbx),%rax
  mov    %rax,0x8(%rsp)
  mov    %r15,%rdi
  call   <strlen@plt>
  mov    %eax,%ebx
  mov    0x8(%rsp),%rdi
  call   <strlen@plt>
  lea    0x2(%rbx,%rax,1),%edi
  call   <malloc@plt>
  mov    %rax,(%rsp)
  test   %rax,%rax
  je     L319
  mov    %r15,%rsi
  mov    (%rsp),%rbx
  mov    %rbx,%rdi
  call   <strcpy@plt>
  lea    D27(%rip),%rsi
  mov    %rbx,%rdi
  call   <strcat@plt>
L184:
  mov    (%rsp),%rbx
  mov    %rbx,%rdi
  call   <strlen@plt>
  cltq
  add    %rbx,%rax
  mov    0x8(%rsp),%rcx
  movzbl (%rcx),%edx
  test   %dl,%dl
  je     L426
  cmp    $0x22,%dl
  jne    L251
L426:
  movb   $0x0,(%rax)
  jmp    L231
L371:
  lea    0x1(%rcx),%rsi
  mov    %rsi,0x8(%rsp)
  add    $0x1,%rax
  movzbl (%rcx),%edx
  mov    %dl,-0x1(%rax)
  movzbl 0x1(%rcx),%edx
  test   %dl,%dl
  je     L426
  cmp    $0x22,%dl
  je     L426
L251:
  mov    0x8(%rsp),%rcx
  cmp    $0x5c,%dl
  jne    L371
  cmpb   $0x1,0x1(%rcx)
  sbb    $0xffffffffffffffff,%rcx
  jmp    L371
L319:
  mov    %r12,%rdi
  call   <fclose@plt>
  cmpq   $0x0,(%rsp)
  jne    L328
  jmp    L448
L80:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: unpack_data
arguments: tag: D9
type_infered: string
name: unpack_data
arguments: tag: D17
type_infered: string
name: unpack_data
arguments: tag: D1
type_infered: string
name: unpack_data
arguments: tag: D38
type_infered: string
name: unpack_data
arguments: tag: D40
type_infered: string
name: unpack_data
arguments: tag: D13
type_infered: string
name: unpack_data
arguments: tag: D56
type_infered: string
name: unpack_data
arguments: tag: D80
type_infered: string
name: unpack_data
arguments: tag: D27
type_infered: string

tool: D9: HOME

tool: D17: XDG_CONFIG_HOME

tool: D1: /.config/user-dirs.dirs

tool: D38: r

tool: D40: XDG_

tool: D13: /user-dirs.dirs

tool: D56: _DIR

tool: D80: $HOME/

tool: D27: /

assistant: ```c
char *xdg_user_dir_lookup_with_fallback(const char *type, const char *fallback) {
  FILE *file;
  char *home_dir, *config_home, *config_file;
  char buffer[512];
  char *user_dir;
  char *p, *d;
  int len;
  int relative;
  home_dir = getenv("HOME");
  if (home_dir == NULL)
    goto error;
  config_home = getenv("XDG_CONFIG_HOME");
  if (config_home == NULL || config_home[0] == 0) {
    config_file = (char *)malloc(strlen(home_dir) + strlen("/.config/user-dirs.dirs") + 1);
    if (config_file == NULL)
      goto error;
    strcpy(config_file, home_dir);
    strcat(config_file, "/.config/user-dirs.dirs");
  } else {
    config_file = (char *)malloc(strlen(config_home) + strlen("/user-dirs.dirs") + 1);
    if (config_file == NULL)
      goto error;
    strcpy(config_file, config_home);
    strcat(config_file, "/user-dirs.dirs");
  }
  file = fopen(config_file, "r");
  free(config_file);
  if (file == NULL)
    goto error;
  user_dir = NULL;
  while (fgets(buffer, sizeof(buffer), file)) {
    len = strlen(buffer);
    if (len > 0 && buffer[len - 1] == '\n')
      buffer[len - 1] = 0;
    p = buffer;
    while (*p == ' ' || *p == '\t')
      p++;
    if (strncmp(p, "XDG_", 4) != 0)
      continue;
    p += 4;
    if (strncmp(p, type, strlen(type)) != 0)
      continue;
    p += strlen(type);
    if (strncmp(p, "_DIR", 4) != 0)
      continue;
    p += 4;
    while (*p == ' ' || *p == '\t')
      p++;
    if (*p != '=')
      continue;
    p++;
    while (*p == ' ' || *p == '\t')
      p++;
    if (*p != '"')
      continue;
    p++;
    relative = 0;
    if (strncmp(p, "$HOME/", 6) == 0) {
      p += 6;
      relative = 1;
    } else if (*p != '/')
      continue;
    if (relative) {
      user_dir = (char *)malloc(strlen(home_dir) + 1 + strlen(p) + 1);
      if (user_dir == NULL)
        goto error2;
      strcpy(user_dir, home_dir);
      strcat(user_dir, "/");
    } else {
      user_dir = (char *)malloc(strlen(p) + 1);
      if (user_dir == NULL)
        goto error2;
      *user_dir = 0;
    }
    d = user_dir + strlen(user_dir);
    while (*p && *p != '"') {
      if ((*p == '\\') && (*(p + 1) != 0))
        p++;
      *d++ = *p++;
    }
    *d = 0;
  }
error2:
  fclose(file);
  if (user_dir)
    return user_dir;
error:
  if (fallback)
    return strdup(fallback);
  return NULL;
}
```