#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
typedef int /*<<< orphan*/ buffer;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ free(char *);
char *getenv(char *);
scalar_t__ malloc(int);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
char *strdup(char const *);
int strlen(char const *);
scalar_t__ strncmp(char *, char const *, int);
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;
}


x86 assembly (clang, -O0):
<xdg_user_dir_lookup_with_fallback>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2a0,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
lea    0xe41(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    11e3 <xdg_user_dir_lookup_with_fallback+0x33>
jmp    17fb <xdg_user_dir_lookup_with_fallback+0x64b>
lea    0xe16(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     120e <xdg_user_dir_lookup_with_fallback+0x5e>
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    126f <xdg_user_dir_lookup_with_fallback+0xbf>
mov    -0x28(%rbp),%rdi
call   1080 <strlen@plt>
mov    %eax,-0x264(%rbp)
lea    0xdec(%rip),%rdi
call   1080 <strlen@plt>
mov    -0x264(%rbp),%edi
add    %eax,%edi
add    $0x1,%edi
call   10a0 <malloc@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    124d <xdg_user_dir_lookup_with_fallback+0x9d>
jmp    17fb <xdg_user_dir_lookup_with_fallback+0x64b>
mov    -0x38(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1060 <strcpy@plt>
mov    -0x38(%rbp),%rdi
lea    0xdab(%rip),%rsi
call   10c0 <strcat@plt>
jmp    12cb <xdg_user_dir_lookup_with_fallback+0x11b>
mov    -0x30(%rbp),%rdi
call   1080 <strlen@plt>
mov    %eax,-0x268(%rbp)
lea    0xd93(%rip),%rdi
call   1080 <strlen@plt>
mov    -0x268(%rbp),%edi
add    %eax,%edi
add    $0x1,%edi
call   10a0 <malloc@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    12ae <xdg_user_dir_lookup_with_fallback+0xfe>
jmp    17fb <xdg_user_dir_lookup_with_fallback+0x64b>
mov    -0x38(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1060 <strcpy@plt>
mov    -0x38(%rbp),%rdi
lea    0xd52(%rip),%rsi
call   10c0 <strcat@plt>
mov    -0x38(%rbp),%rdi
lea    0xd52(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x38(%rbp),%rdi
call   1040 <free@plt>
cmpq   $0x0,-0x20(%rbp)
jne    12f8 <xdg_user_dir_lookup_with_fallback+0x148>
jmp    17fb <xdg_user_dir_lookup_with_fallback+0x64b>
movq   $0x0,-0x248(%rbp)
lea    -0x240(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    $0x200,%esi
call   1090 <fgets@plt>
cmp    $0x0,%rax
je     17ca <xdg_user_dir_lookup_with_fallback+0x61a>
lea    -0x240(%rbp),%rdi
call   1080 <strlen@plt>
mov    %eax,-0x25c(%rbp)
cmpl   $0x0,-0x25c(%rbp)
jle    1370 <xdg_user_dir_lookup_with_fallback+0x1c0>
mov    -0x25c(%rbp),%eax
sub    $0x1,%eax
cltq
movsbl -0x240(%rbp,%rax,1),%eax
ff
cmp    $0xa,%eax
jne    1370 <xdg_user_dir_lookup_with_fallback+0x1c0>
mov    -0x25c(%rbp),%eax
sub    $0x1,%eax
cltq
movb   $0x0,-0x240(%rbp,%rax,1)
lea    -0x240(%rbp),%rax
mov    %rax,-0x250(%rbp)
mov    -0x250(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x1,%al
cmp    $0x20,%ecx
mov    %al,-0x269(%rbp)
je     13af <xdg_user_dir_lookup_with_fallback+0x1ff>
mov    -0x250(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x9,%eax
sete   %al
mov    %al,-0x269(%rbp)
mov    -0x269(%rbp),%al
test   $0x1,%al
jne    13c2 <xdg_user_dir_lookup_with_fallback+0x212>
jmp    13d9 <xdg_user_dir_lookup_with_fallback+0x229>
mov    -0x250(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x250(%rbp)
jmp    137e <xdg_user_dir_lookup_with_fallback+0x1ce>
mov    -0x250(%rbp),%rdi
lea    0xc43(%rip),%rsi
mov    $0x4,%edx
call   1050 <strncmp@plt>
cmp    $0x0,%rax
je     1400 <xdg_user_dir_lookup_with_fallback+0x250>
jmp    1303 <xdg_user_dir_lookup_with_fallback+0x153>
mov    -0x250(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x250(%rbp)
mov    -0x250(%rbp),%rax
mov    %rax,-0x280(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x278(%rbp)
mov    -0x10(%rbp),%rdi
call   1080 <strlen@plt>
mov    -0x280(%rbp),%rdi
mov    -0x278(%rbp),%rsi
mov    %eax,%edx
call   1050 <strncmp@plt>
cmp    $0x0,%rax
je     1458 <xdg_user_dir_lookup_with_fallback+0x2a8>
jmp    1303 <xdg_user_dir_lookup_with_fallback+0x153>
mov    -0x10(%rbp),%rdi
call   1080 <strlen@plt>
mov    %eax,%ecx
mov    -0x250(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x250(%rbp)
mov    -0x250(%rbp),%rdi
lea    0xbaa(%rip),%rsi
mov    $0x4,%edx
call   1050 <strncmp@plt>
cmp    $0x0,%rax
je     149e <xdg_user_dir_lookup_with_fallback+0x2ee>
jmp    1303 <xdg_user_dir_lookup_with_fallback+0x153>
mov    -0x250(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x250(%rbp)
mov    -0x250(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x1,%al
cmp    $0x20,%ecx
mov    %al,-0x281(%rbp)
je     14e1 <xdg_user_dir_lookup_with_fallback+0x331>
mov    -0x250(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x9,%eax
sete   %al
mov    %al,-0x281(%rbp)
mov    -0x281(%rbp),%al
test   $0x1,%al
jne    14f4 <xdg_user_dir_lookup_with_fallback+0x344>
jmp    150b <xdg_user_dir_lookup_with_fallback+0x35b>
mov    -0x250(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x250(%rbp)
jmp    14b0 <xdg_user_dir_lookup_with_fallback+0x300>
mov    -0x250(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3d,%eax
je     1523 <xdg_user_dir_lookup_with_fallback+0x373>
jmp    1303 <xdg_user_dir_lookup_with_fallback+0x153>
mov    -0x250(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x250(%rbp)
mov    -0x250(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x1,%al
cmp    $0x20,%ecx
mov    %al,-0x282(%rbp)
je     1566 <xdg_user_dir_lookup_with_fallback+0x3b6>
mov    -0x250(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x9,%eax
sete   %al
mov    %al,-0x282(%rbp)
mov    -0x282(%rbp),%al
test   $0x1,%al
jne    1579 <xdg_user_dir_lookup_with_fallback+0x3c9>
jmp    1590 <xdg_user_dir_lookup_with_fallback+0x3e0>
mov    -0x250(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x250(%rbp)
jmp    1535 <xdg_user_dir_lookup_with_fallback+0x385>
mov    -0x250(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x22,%eax
je     15a8 <xdg_user_dir_lookup_with_fallback+0x3f8>
jmp    1303 <xdg_user_dir_lookup_with_fallback+0x153>
mov    -0x250(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x250(%rbp)
movl   $0x0,-0x260(%rbp)
mov    -0x250(%rbp),%rdi
lea    0xa62(%rip),%rsi
mov    $0x6,%edx
call   1050 <strncmp@plt>
cmp    $0x0,%rax
jne    1607 <xdg_user_dir_lookup_with_fallback+0x457>
mov    -0x250(%rbp),%rax
add    $0x6,%rax
mov    %rax,-0x250(%rbp)
movl   $0x1,-0x260(%rbp)
jmp    1624 <xdg_user_dir_lookup_with_fallback+0x474>
mov    -0x250(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
je     161f <xdg_user_dir_lookup_with_fallback+0x46f>
jmp    1303 <xdg_user_dir_lookup_with_fallback+0x153>
jmp    1624 <xdg_user_dir_lookup_with_fallback+0x474>
cmpl   $0x0,-0x260(%rbp)
je     16a1 <xdg_user_dir_lookup_with_fallback+0x4f1>
mov    -0x28(%rbp),%rdi
call   1080 <strlen@plt>
add    $0x1,%eax
mov    %eax,-0x288(%rbp)
mov    -0x250(%rbp),%rdi
call   1080 <strlen@plt>
mov    -0x288(%rbp),%edi
add    %eax,%edi
add    $0x1,%edi
call   10a0 <malloc@plt>
mov    %rax,-0x248(%rbp)
cmpq   $0x0,-0x248(%rbp)
jne    1679 <xdg_user_dir_lookup_with_fallback+0x4c9>
jmp    17cf <xdg_user_dir_lookup_with_fallback+0x61f>
mov    -0x248(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1060 <strcpy@plt>
mov    -0x248(%rbp),%rdi
lea    0x9a2(%rip),%rsi
call   10c0 <strcat@plt>
jmp    16db <xdg_user_dir_lookup_with_fallback+0x52b>
mov    -0x250(%rbp),%rdi
call   1080 <strlen@plt>
mov    %eax,%edi
add    $0x1,%edi
call   10a0 <malloc@plt>
mov    %rax,-0x248(%rbp)
cmpq   $0x0,-0x248(%rbp)
jne    16d1 <xdg_user_dir_lookup_with_fallback+0x521>
jmp    17cf <xdg_user_dir_lookup_with_fallback+0x61f>
mov    -0x248(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x248(%rbp),%rax
mov    %rax,-0x290(%rbp)
mov    -0x248(%rbp),%rdi
call   1080 <strlen@plt>
mov    %eax,%ecx
mov    -0x290(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x258(%rbp)
mov    -0x250(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x291(%rbp)
je     173c <xdg_user_dir_lookup_with_fallback+0x58c>
mov    -0x250(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x22,%eax
setne  %al
mov    %al,-0x291(%rbp)
mov    -0x291(%rbp),%al
test   $0x1,%al
jne    174f <xdg_user_dir_lookup_with_fallback+0x59f>
jmp    17bb <xdg_user_dir_lookup_with_fallback+0x60b>
mov    -0x250(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5c,%eax
jne    1788 <xdg_user_dir_lookup_with_fallback+0x5d8>
mov    -0x250(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x0,%eax
je     1788 <xdg_user_dir_lookup_with_fallback+0x5d8>
mov    -0x250(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x250(%rbp)
mov    -0x250(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x250(%rbp)
mov    (%rax),%cl
mov    -0x258(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x258(%rbp)
mov    %cl,(%rax)
jmp    170b <xdg_user_dir_lookup_with_fallback+0x55b>
mov    -0x258(%rbp),%rax
movb   $0x0,(%rax)
jmp    1303 <xdg_user_dir_lookup_with_fallback+0x153>
jmp    17cf <xdg_user_dir_lookup_with_fallback+0x61f>
mov    -0x20(%rbp),%rdi
call   1070 <fclose@plt>
cmpq   $0x0,-0x248(%rbp)
je     17f6 <xdg_user_dir_lookup_with_fallback+0x646>
mov    -0x248(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1820 <xdg_user_dir_lookup_with_fallback+0x670>
jmp    17fb <xdg_user_dir_lookup_with_fallback+0x64b>
cmpq   $0x0,-0x18(%rbp)
je     1818 <xdg_user_dir_lookup_with_fallback+0x668>
mov    -0x18(%rbp),%rdi
call   10d0 <strdup@plt>
mov    %rax,-0x8(%rbp)
jmp    1820 <xdg_user_dir_lookup_with_fallback+0x670>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x2a0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xdg_user_dir_lookup_with_fallback>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x228,%rsp
mov    %rsi,%r12
mov    %rdi,0x10(%rsp)
lea    0xe3b(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     1547 <xdg_user_dir_lookup_with_fallback+0x397>
mov    %rax,%r13
lea    0xe18(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     123b <xdg_user_dir_lookup_with_fallback+0x8b>
mov    %rax,%rbx
cmpb   $0x0,(%rax)
je     123b <xdg_user_dir_lookup_with_fallback+0x8b>
mov    %rbx,%rdi
call   1080 <strlen@plt>
mov    %eax,%ebp
lea    0xe0d(%rip),%rdi
call   1080 <strlen@plt>
lea    (%rax,%rbp,1),%edi
add    $0x1,%edi
call   10a0 <malloc@plt>
test   %rax,%rax
je     1547 <xdg_user_dir_lookup_with_fallback+0x397>
mov    %rax,%rbp
mov    %rax,%rdi
mov    %rbx,%rsi
call   1060 <strcpy@plt>
lea    0xddf(%rip),%rsi
jmp    127a <xdg_user_dir_lookup_with_fallback+0xca>
mov    %r13,%rdi
call   1080 <strlen@plt>
mov    %eax,%ebx
lea    0xdc4(%rip),%rdi
call   1080 <strlen@plt>
lea    (%rbx,%rax,1),%edi
add    $0x1,%edi
call   10a0 <malloc@plt>
test   %rax,%rax
je     1547 <xdg_user_dir_lookup_with_fallback+0x397>
mov    %rax,%rbp
mov    %rax,%rdi
mov    %r13,%rsi
call   1060 <strcpy@plt>
lea    0xd96(%rip),%rsi
mov    %rbp,%rdi
call   10c0 <strcat@plt>
lea    0xd9f(%rip),%rsi
mov    %rbp,%rdi
call   10b0 <fopen@plt>
mov    %rax,%rbx
mov    %rbp,%rdi
call   1040 <free@plt>
test   %rbx,%rbx
je     1547 <xdg_user_dir_lookup_with_fallback+0x397>
lea    0x20(%rsp),%rdi
mov    $0x200,%esi
mov    %rbx,%rdx
call   1090 <fgets@plt>
test   %rax,%rax
je     1556 <xdg_user_dir_lookup_with_fallback+0x3a6>
xor    %eax,%eax
mov    %rax,0x8(%rsp)
lea    0x20(%rsp),%rbp
mov    %r12,(%rsp)
mov    %r13,0x18(%rsp)
jmp    12fe <xdg_user_dir_lookup_with_fallback+0x14e>
nopw   0x0(%rax,%rax,1)
lea    0x20(%rsp),%rbp
mov    %rbp,%rdi
mov    $0x200,%esi
mov    %rbx,%rdx
call   1090 <fgets@plt>
test   %rax,%rax
je     1531 <xdg_user_dir_lookup_with_fallback+0x381>
mov    %rbp,%rdi
call   1080 <strlen@plt>
test   %eax,%eax
jle    1319 <xdg_user_dir_lookup_with_fallback+0x169>
add    $0xffffffff,%eax
cmpb   $0xa,0x20(%rsp,%rax,1)
jne    1319 <xdg_user_dir_lookup_with_fallback+0x169>
movb   $0x0,0x20(%rsp,%rax,1)
lea    0x29(%rsp),%r12
lea    0x2a(%rsp),%r15
lea    0x30(%rsp),%r14
lea    0x24(%rsp),%rbp
jmp    1340 <xdg_user_dir_lookup_with_fallback+0x190>
nop
add    $0x1,%rbp
add    $0x1,%r14
add    $0x1,%r15
add    $0x1,%r12
movzbl -0x4(%rbp),%eax
cmp    $0x20,%al
je     1330 <xdg_user_dir_lookup_with_fallback+0x180>
cmp    $0x9,%al
je     1330 <xdg_user_dir_lookup_with_fallback+0x180>
lea    -0x4(%rbp),%rdi
lea    0xcd3(%rip),%rsi
mov    $0x4,%edx
call   1050 <strncmp@plt>
test   %rax,%rax
jne    12e0 <xdg_user_dir_lookup_with_fallback+0x130>
mov    %rbx,%r13
mov    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   1080 <strlen@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    %r13,%rbx
mov    %eax,%edx
call   1050 <strncmp@plt>
test   %rax,%rax
jne    12e0 <xdg_user_dir_lookup_with_fallback+0x130>
mov    0x10(%rsp),%rdi
call   1080 <strlen@plt>
movslq %eax,%r13
mov    %rbp,%rdi
add    %r13,%rdi
lea    0xc82(%rip),%rsi
mov    $0x4,%edx
call   1050 <strncmp@plt>
test   %rax,%rax
jne    12e0 <xdg_user_dir_lookup_with_fallback+0x130>
lea    0x4(,%r13,1),%rax
add    %rbp,%rax
add    %r13,%r14
add    %r13,%r15
add    %r13,%r12
jmp    13f0 <xdg_user_dir_lookup_with_fallback+0x240>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%rax
add    $0x1,%r14
add    $0x1,%r15
add    $0x1,%r12
movzbl (%rax),%ecx
cmp    $0x9,%cl
je     13e0 <xdg_user_dir_lookup_with_fallback+0x230>
cmp    $0x20,%cl
je     13e0 <xdg_user_dir_lookup_with_fallback+0x230>
cmp    $0x3d,%cl
je     141c <xdg_user_dir_lookup_with_fallback+0x26c>
jmp    12e0 <xdg_user_dir_lookup_with_fallback+0x130>
nopw   0x0(%rax,%rax,1)
add    $0x1,%r14
add    $0x1,%r15
add    $0x1,%r12
movzbl (%r12),%eax
cmp    $0x9,%al
je     1410 <xdg_user_dir_lookup_with_fallback+0x260>
cmp    $0x20,%al
je     1410 <xdg_user_dir_lookup_with_fallback+0x260>
cmp    $0x22,%al
jne    12e0 <xdg_user_dir_lookup_with_fallback+0x130>
mov    %r15,%rdi
lea    0xbf9(%rip),%rsi
mov    $0x6,%edx
call   1050 <strncmp@plt>
test   %rax,%rax
je     147c <xdg_user_dir_lookup_with_fallback+0x2cc>
cmpb   $0x2f,(%r15)
jne    12e0 <xdg_user_dir_lookup_with_fallback+0x130>
mov    %r15,%rdi
call   1080 <strlen@plt>
lea    0x1(%rax),%edi
call   10a0 <malloc@plt>
test   %rax,%rax
mov    (%rsp),%r12
je     1556 <xdg_user_dir_lookup_with_fallback+0x3a6>
movb   $0x0,(%rax)
mov    %r15,%r14
mov    %rax,%r15
jmp    14c8 <xdg_user_dir_lookup_with_fallback+0x318>
mov    0x18(%rsp),%r13
mov    %r13,%rdi
call   1080 <strlen@plt>
mov    %eax,%ebp
mov    %r14,%rdi
call   1080 <strlen@plt>
lea    (%rax,%rbp,1),%edi
add    $0x2,%edi
call   10a0 <malloc@plt>
test   %rax,%rax
mov    (%rsp),%r12
je     1556 <xdg_user_dir_lookup_with_fallback+0x3a6>
mov    %rax,%r15
mov    %rax,%rdi
mov    %r13,%rsi
call   1060 <strcpy@plt>
mov    %r15,%rdi
lea    0xb76(%rip),%rsi
call   10c0 <strcat@plt>
lea    0x20(%rsp),%rbp
mov    %r15,%rdi
call   1080 <strlen@plt>
cltq
mov    %r15,%rcx
mov    %r15,0x8(%rsp)
add    %r15,%rax
jmp    14f2 <xdg_user_dir_lookup_with_fallback+0x342>
movzbl (%r14),%ecx
add    $0x1,%r14
mov    %cl,(%rax)
add    $0x1,%rax
movzbl (%r14),%ecx
cmp    $0x5c,%cl
je     1506 <xdg_user_dir_lookup_with_fallback+0x356>
test   %cl,%cl
je     1513 <xdg_user_dir_lookup_with_fallback+0x363>
cmp    $0x22,%cl
jne    14e8 <xdg_user_dir_lookup_with_fallback+0x338>
jmp    1513 <xdg_user_dir_lookup_with_fallback+0x363>
cmpb   $0x0,0x1(%r14)
je     14e4 <xdg_user_dir_lookup_with_fallback+0x334>
add    $0x1,%r14
jmp    14e4 <xdg_user_dir_lookup_with_fallback+0x334>
movb   $0x0,(%rax)
mov    %rbp,%rdi
mov    $0x200,%esi
mov    %rbx,%rdx
call   1090 <fgets@plt>
test   %rax,%rax
jne    12fe <xdg_user_dir_lookup_with_fallback+0x14e>
jmp    1535 <xdg_user_dir_lookup_with_fallback+0x385>
mov    (%rsp),%r12
mov    %rbx,%rdi
call   1070 <fclose@plt>
mov    0x8(%rsp),%rax
test   %rax,%rax
jne    1565 <xdg_user_dir_lookup_with_fallback+0x3b5>
test   %r12,%r12
je     1563 <xdg_user_dir_lookup_with_fallback+0x3b3>
mov    %r12,%rdi
call   10d0 <strdup@plt>
jmp    1565 <xdg_user_dir_lookup_with_fallback+0x3b5>
mov    %rbx,%rdi
call   1070 <fclose@plt>
test   %r12,%r12
jne    154c <xdg_user_dir_lookup_with_fallback+0x39c>
xor    %eax,%eax
add    $0x228,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"HOME\00"
@.str.1 = [16 x i8] c"XDG_CONFIG_HOME\00"
@.str.2 = [24 x i8] c"/.config/user-dirs.dirs\00"
@.str.3 = [16 x i8] c"/user-dirs.dirs\00"
@.str.4 = [2 x i8] c"r\00"
@.str.5 = [5 x i8] c"XDG_\00"
@.str.6 = [5 x i8] c"_DIR\00"
@.str.7 = [7 x i8] c"$HOME/\00"
@.str.8 = [2 x i8] c"/\00"
define i8* @xdg_user_dir_lookup_with_fallback(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca [512 x i8]
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i32
%15 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
%16 = call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i8* %16, i8** %7
%17 = load i8*, i8** %7
%18 = icmp eq i8* %17, null
br i1 %18, label %19, label %20
19: ; preds = %2
br label %284
20: ; preds = %2
%21 = call i8* @getenv(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
store i8* %21, i8** %8
%22 = load i8*, i8** %8
%23 = icmp eq i8* %22, null
br i1 %23, label %30, label %24
24: ; preds = %20
%25 = load i8*, i8** %8
%26 = getelementptr inbounds i8, i8* %25, i64 0
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp eq i32 %28, 0
br i1 %29, label %30, label %47
30: ; preds = %24, %20
%31 = load i8*, i8** %7
%32 = call i32 @strlen(i8* %31)
%33 = call i32 @strlen(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%34 = add nsw i32 %32, %33
%35 = add nsw i32 %34, 1
%36 = call i64 @malloc(i32 %35)
%37 = inttoptr i64 %36 to i8*
store i8* %37, i8** %9
%38 = load i8*, i8** %9
%39 = icmp eq i8* %38, null
br i1 %39, label %40, label %41
40: ; preds = %30
br label %284
41: ; preds = %30
%42 = load i8*, i8** %9
%43 = load i8*, i8** %7
%44 = call i32 @strcpy(i8* %42, i8* %43)
%45 = load i8*, i8** %9
%46 = call i32 @strcat(i8* %45, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
br label %64
47: ; preds = %24
%48 = load i8*, i8** %8
%49 = call i32 @strlen(i8* %48)
%50 = call i32 @strlen(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
%51 = add nsw i32 %49, %50
%52 = add nsw i32 %51, 1
%53 = call i64 @malloc(i32 %52)
%54 = inttoptr i64 %53 to i8*
store i8* %54, i8** %9
%55 = load i8*, i8** %9
%56 = icmp eq i8* %55, null
br i1 %56, label %57, label %58
57: ; preds = %47
br label %284
58: ; preds = %47
%59 = load i8*, i8** %9
%60 = load i8*, i8** %8
%61 = call i32 @strcpy(i8* %59, i8* %60)
%62 = load i8*, i8** %9
%63 = call i32 @strcat(i8* %62, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
br label %64
64: ; preds = %58, %41
%65 = load i8*, i8** %9
%66 = call i32* @fopen(i8* %65, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32* %66, i32** %6
%67 = load i8*, i8** %9
%68 = call i32 @free(i8* %67)
%69 = load i32*, i32** %6
%70 = icmp eq i32* %69, null
br i1 %70, label %71, label %72
71: ; preds = %64
br label %284
72: ; preds = %64
store i8* null, i8** %11
br label %73
73: ; preds = %273, %200, %185, %161, %137, %127, %117, %72
%74 = getelementptr inbounds [512 x i8], [512 x i8]* %10, i64 0, i64 0
%75 = load i32*, i32** %6
%76 = call i64 @fgets(i8* %74, i32 512, i32* %75)
%77 = icmp ne i64 %76, 0
br i1 %77, label %78, label %275
78: ; preds = %73
%79 = getelementptr inbounds [512 x i8], [512 x i8]* %10, i64 0, i64 0
%80 = call i32 @strlen(i8* %79)
store i32 %80, i32* %14
%81 = load i32, i32* %14
%82 = icmp sgt i32 %81, 0
br i1 %82, label %83, label %96
83: ; preds = %78
%84 = load i32, i32* %14
%85 = sub nsw i32 %84, 1
%86 = sext i32 %85 to i64
%87 = getelementptr inbounds [512 x i8], [512 x i8]* %10, i64 0, i64 %86
%88 = load i8, i8* %87
%89 = sext i8 %88 to i32
%90 = icmp eq i32 %89, 10
br i1 %90, label %91, label %96
91: ; preds = %83
%92 = load i32, i32* %14
%93 = sub nsw i32 %92, 1
%94 = sext i32 %93 to i64
%95 = getelementptr inbounds [512 x i8], [512 x i8]* %10, i64 0, i64 %94
store i8 0, i8* %95
br label %96
96: ; preds = %91, %83, %78
%97 = getelementptr inbounds [512 x i8], [512 x i8]* %10, i64 0, i64 0
store i8* %97, i8** %12
br label %98
98: ; preds = %110, %96
%99 = load i8*, i8** %12
%100 = load i8, i8* %99
%101 = sext i8 %100 to i32
%102 = icmp eq i32 %101, 32
br i1 %102, label %108, label %103
103: ; preds = %98
%104 = load i8*, i8** %12
%105 = load i8, i8* %104
%106 = sext i8 %105 to i32
%107 = icmp eq i32 %106, 9
br label %108
108: ; preds = %103, %98
%109 = phi i1 [ true, %98 ], [ %107, %103 ]
br i1 %109, label %110, label %113
110: ; preds = %108
%111 = load i8*, i8** %12
%112 = getelementptr inbounds i8, i8* %111, i32 1
store i8* %112, i8** %12
br label %98
113: ; preds = %108
%114 = load i8*, i8** %12
%115 = call i64 @strncmp(i8* %114, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i32 4)
%116 = icmp ne i64 %115, 0
br i1 %116, label %117, label %118
117: ; preds = %113
br label %73
118: ; preds = %113
%119 = load i8*, i8** %12
%120 = getelementptr inbounds i8, i8* %119, i64 4
store i8* %120, i8** %12
%121 = load i8*, i8** %12
%122 = load i8*, i8** %4
%123 = load i8*, i8** %4
%124 = call i32 @strlen(i8* %123)
%125 = call i64 @strncmp(i8* %121, i8* %122, i32 %124)
%126 = icmp ne i64 %125, 0
br i1 %126, label %127, label %128
127: ; preds = %118
br label %73
128: ; preds = %118
%129 = load i8*, i8** %4
%130 = call i32 @strlen(i8* %129)
%131 = load i8*, i8** %12
%132 = sext i32 %130 to i64
%133 = getelementptr inbounds i8, i8* %131, i64 %132
store i8* %133, i8** %12
%134 = load i8*, i8** %12
%135 = call i64 @strncmp(i8* %134, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i32 4)
%136 = icmp ne i64 %135, 0
br i1 %136, label %137, label %138
137: ; preds = %128
br label %73
138: ; preds = %128
%139 = load i8*, i8** %12
%140 = getelementptr inbounds i8, i8* %139, i64 4
store i8* %140, i8** %12
br label %141
141: ; preds = %153, %138
%142 = load i8*, i8** %12
%143 = load i8, i8* %142
%144 = sext i8 %143 to i32
%145 = icmp eq i32 %144, 32
br i1 %145, label %151, label %146
146: ; preds = %141
%147 = load i8*, i8** %12
%148 = load i8, i8* %147
%149 = sext i8 %148 to i32
%150 = icmp eq i32 %149, 9
br label %151
151: ; preds = %146, %141
%152 = phi i1 [ true, %141 ], [ %150, %146 ]
br i1 %152, label %153, label %156
153: ; preds = %151
%154 = load i8*, i8** %12
%155 = getelementptr inbounds i8, i8* %154, i32 1
store i8* %155, i8** %12
br label %141
156: ; preds = %151
%157 = load i8*, i8** %12
%158 = load i8, i8* %157
%159 = sext i8 %158 to i32
%160 = icmp ne i32 %159, 61
br i1 %160, label %161, label %162
161: ; preds = %156
br label %73
162: ; preds = %156
%163 = load i8*, i8** %12
%164 = getelementptr inbounds i8, i8* %163, i32 1
store i8* %164, i8** %12
br label %165
165: ; preds = %177, %162
%166 = load i8*, i8** %12
%167 = load i8, i8* %166
%168 = sext i8 %167 to i32
%169 = icmp eq i32 %168, 32
br i1 %169, label %175, label %170
170: ; preds = %165
%171 = load i8*, i8** %12
%172 = load i8, i8* %171
%173 = sext i8 %172 to i32
%174 = icmp eq i32 %173, 9
br label %175
175: ; preds = %170, %165
%176 = phi i1 [ true, %165 ], [ %174, %170 ]
br i1 %176, label %177, label %180
177: ; preds = %175
%178 = load i8*, i8** %12
%179 = getelementptr inbounds i8, i8* %178, i32 1
store i8* %179, i8** %12
br label %165
180: ; preds = %175
%181 = load i8*, i8** %12
%182 = load i8, i8* %181
%183 = sext i8 %182 to i32
%184 = icmp ne i32 %183, 34
br i1 %184, label %185, label %186
185: ; preds = %180
br label %73
186: ; preds = %180
%187 = load i8*, i8** %12
%188 = getelementptr inbounds i8, i8* %187, i32 1
store i8* %188, i8** %12
store i32 0, i32* %15
%189 = load i8*, i8** %12
%190 = call i64 @strncmp(i8* %189, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i32 6)
%191 = icmp eq i64 %190, 0
br i1 %191, label %192, label %195
192: ; preds = %186
%193 = load i8*, i8** %12
%194 = getelementptr inbounds i8, i8* %193, i64 6
store i8* %194, i8** %12
store i32 1, i32* %15
br label %202
195: ; preds = %186
%196 = load i8*, i8** %12
%197 = load i8, i8* %196
%198 = sext i8 %197 to i32
%199 = icmp ne i32 %198, 47
br i1 %199, label %200, label %201
200: ; preds = %195
br label %73
201: ; preds = %195
br label %202
202: ; preds = %201, %192
%203 = load i32, i32* %15
%204 = icmp ne i32 %203, 0
br i1 %204, label %205, label %224
205: ; preds = %202
%206 = load i8*, i8** %7
%207 = call i32 @strlen(i8* %206)
%208 = add nsw i32 %207, 1
%209 = load i8*, i8** %12
%210 = call i32 @strlen(i8* %209)
%211 = add nsw i32 %208, %210
%212 = add nsw i32 %211, 1
%213 = call i64 @malloc(i32 %212)
%214 = inttoptr i64 %213 to i8*
store i8* %214, i8** %11
%215 = load i8*, i8** %11
%216 = icmp eq i8* %215, null
br i1 %216, label %217, label %218
217: ; preds = %205
br label %276
218: ; preds = %205
%219 = load i8*, i8** %11
%220 = load i8*, i8** %7
%221 = call i32 @strcpy(i8* %219, i8* %220)
%222 = load i8*, i8** %11
%223 = call i32 @strcat(i8* %222, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
br label %235
224: ; preds = %202
%225 = load i8*, i8** %12
%226 = call i32 @strlen(i8* %225)
%227 = add nsw i32 %226, 1
%228 = call i64 @malloc(i32 %227)
%229 = inttoptr i64 %228 to i8*
store i8* %229, i8** %11
%230 = load i8*, i8** %11
%231 = icmp eq i8* %230, null
br i1 %231, label %232, label %233
232: ; preds = %224
br label %276
233: ; preds = %224
%234 = load i8*, i8** %11
store i8 0, i8* %234
br label %235
235: ; preds = %233, %218
%236 = load i8*, i8** %11
%237 = load i8*, i8** %11
%238 = call i32 @strlen(i8* %237)
%239 = sext i32 %238 to i64
%240 = getelementptr inbounds i8, i8* %236, i64 %239
store i8* %240, i8** %13
br label %241
241: ; preds = %267, %235
%242 = load i8*, i8** %12
%243 = load i8, i8* %242
%244 = sext i8 %243 to i32
%245 = icmp ne i32 %244, 0
br i1 %245, label %246, label %251
246: ; preds = %241
%247 = load i8*, i8** %12
%248 = load i8, i8* %247
%249 = sext i8 %248 to i32
%250 = icmp ne i32 %249, 34
br label %251
251: ; preds = %246, %241
%252 = phi i1 [ false, %241 ], [ %250, %246 ]
br i1 %252, label %253, label %273
253: ; preds = %251
%254 = load i8*, i8** %12
%255 = load i8, i8* %254
%256 = sext i8 %255 to i32
%257 = icmp eq i32 %256, 92
br i1 %257, label %258, label %267
258: ; preds = %253
%259 = load i8*, i8** %12
%260 = getelementptr inbounds i8, i8* %259, i64 1
%261 = load i8, i8* %260
%262 = sext i8 %261 to i32
%263 = icmp ne i32 %262, 0
br i1 %263, label %264, label %267
264: ; preds = %258
%265 = load i8*, i8** %12
%266 = getelementptr inbounds i8, i8* %265, i32 1
store i8* %266, i8** %12
br label %267
267: ; preds = %264, %258, %253
%268 = load i8*, i8** %12
%269 = getelementptr inbounds i8, i8* %268, i32 1
store i8* %269, i8** %12
%270 = load i8, i8* %268
%271 = load i8*, i8** %13
%272 = getelementptr inbounds i8, i8* %271, i32 1
store i8* %272, i8** %13
store i8 %270, i8* %271
br label %241
273: ; preds = %251
%274 = load i8*, i8** %13
store i8 0, i8* %274
br label %73
275: ; preds = %73
br label %276
276: ; preds = %275, %232, %217
%277 = load i32*, i32** %6
%278 = call i32 @fclose(i32* %277)
%279 = load i8*, i8** %11
%280 = icmp ne i8* %279, null
br i1 %280, label %281, label %283
281: ; preds = %276
%282 = load i8*, i8** %11
store i8* %282, i8** %3
br label %291
283: ; preds = %276
br label %284
284: ; preds = %283, %71, %57, %40, %19
%285 = load i8*, i8** %5
%286 = icmp ne i8* %285, null
br i1 %286, label %287, label %290
287: ; preds = %284
%288 = load i8*, i8** %5
%289 = call i8* @strdup(i8* %288)
store i8* %289, i8** %3
br label %291
290: ; preds = %284
store i8* null, i8** %3
br label %291
291: ; preds = %290, %287, %281
%292 = load i8*, i8** %3
ret i8* %292
}

LLVM IR (-O2):
@.str = [5 x i8] c"HOME\00"
@.str.1 = [16 x i8] c"XDG_CONFIG_HOME\00"
@.str.2 = [24 x i8] c"/.config/user-dirs.dirs\00"
@.str.3 = [16 x i8] c"/user-dirs.dirs\00"
@.str.4 = [2 x i8] c"r\00"
@.str.5 = [5 x i8] c"XDG_\00"
@.str.6 = [5 x i8] c"_DIR\00"
@.str.7 = [7 x i8] c"$HOME/\00"
@.str.8 = [2 x i8] c"/\00"
define i8* @xdg_user_dir_lookup_with_fallback(i8* %0, i8* %1) {
%3 = alloca [512 x i8]
%4 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%5 = tail call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i8* %5, null
br i1 %6, label %146, label %7
7: ; preds = %2
%8 = tail call i8* @getenv(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
%9 = icmp eq i8* %8, null
br i1 %9, label %13, label %10
10: ; preds = %7
%11 = load i8, i8* %8
%12 = icmp eq i8 %11, 0
br i1 %12, label %13, label %24
13: ; preds = %10, %7
%14 = tail call i32 @strlen(i8* %5)
%15 = tail call i32 @strlen(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%16 = add i32 %14, 1
%17 = add i32 %16, %15
%18 = tail call i64 @malloc(i32 %17)
%19 = inttoptr i64 %18 to i8*
%20 = icmp eq i64 %18, 0
br i1 %20, label %146, label %21
21: ; preds = %13
%22 = tail call i32 @strcpy(i8* %19, i8* %5)
%23 = tail call i32 @strcat(i8* %19, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
br label %35
24: ; preds = %10
%25 = tail call i32 @strlen(i8* %8)
%26 = tail call i32 @strlen(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
%27 = add i32 %25, 1
%28 = add i32 %27, %26
%29 = tail call i64 @malloc(i32 %28)
%30 = inttoptr i64 %29 to i8*
%31 = icmp eq i64 %29, 0
br i1 %31, label %146, label %32
32: ; preds = %24
%33 = tail call i32 @strcpy(i8* %30, i8* %8)
%34 = tail call i32 @strcat(i8* %30, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
br label %35
35: ; preds = %32, %21
%36 = phi i8* [ %19, %21 ], [ %30, %32 ]
%37 = tail call i32* @fopen(i8* %36, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%38 = tail call i32 @free(i8* %36)
%39 = icmp eq i32* %37, null
br i1 %39, label %146, label %40
40: ; preds = %35
%41 = call i64 @fgets(i8* %4, i32 512, i32* %37)
%42 = icmp eq i64 %41, 0
br i1 %42, label %144, label %43
43: ; preds = %40, %137
%44 = phi i8* [ %118, %137 ], [ null, %40 ]
br label %45
45: ; preds = %43, %64
%46 = call i32 @strlen(i8* %4)
%47 = icmp sgt i32 %46, 0
br i1 %47, label %48, label %55
48: ; preds = %45
%49 = add nsw i32 %46, -1
%50 = zext i32 %49 to i64
%51 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 %50
%52 = load i8, i8* %51
%53 = icmp eq i8 %52, 10
br i1 %53, label %54, label %55
54: ; preds = %48
store i8 0, i8* %51
br label %55
55: ; preds = %54, %48, %45
br label %56
56: ; preds = %55, %59
%57 = phi i8* [ %60, %59 ], [ %4, %55 ]
%58 = load i8, i8* %57
switch i8 %58, label %61 [
i8 32, label %59
i8 9, label %59
]
59: ; preds = %56, %56
%60 = getelementptr inbounds i8, i8* %57, i64 1
br label %56
61: ; preds = %56
%62 = call i64 @strncmp(i8* %57, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i32 4)
%63 = icmp eq i64 %62, 0
br i1 %63, label %67, label %64
64: ; preds = %80, %85, %61, %67, %72, %94
%65 = call i64 @fgets(i8* %4, i32 512, i32* %37)
%66 = icmp eq i64 %65, 0
br i1 %66, label %140, label %45
67: ; preds = %61
%68 = getelementptr inbounds i8, i8* %57, i64 4
%69 = call i32 @strlen(i8* %0)
%70 = call i64 @strncmp(i8* %68, i8* %0, i32 %69)
%71 = icmp eq i64 %70, 0
br i1 %71, label %72, label %64
72: ; preds = %67
%73 = call i32 @strlen(i8* %0)
%74 = sext i32 %73 to i64
%75 = getelementptr inbounds i8, i8* %68, i64 %74
%76 = call i64 @strncmp(i8* %75, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i32 4)
%77 = icmp eq i64 %76, 0
br i1 %77, label %78, label %64
78: ; preds = %72
%79 = getelementptr inbounds i8, i8* %75, i64 4
br label %80
80: ; preds = %83, %78
%81 = phi i8* [ %79, %78 ], [ %84, %83 ]
%82 = load i8, i8* %81
switch i8 %82, label %64 [
i8 32, label %83
i8 9, label %83
i8 61, label %85
]
83: ; preds = %80, %80
%84 = getelementptr inbounds i8, i8* %81, i64 1
br label %80
85: ; preds = %80, %89
%86 = phi i8* [ %87, %89 ], [ %81, %80 ]
%87 = getelementptr inbounds i8, i8* %86, i64 1
%88 = load i8, i8* %87
switch i8 %88, label %64 [
i8 32, label %89
i8 9, label %89
i8 34, label %90
]
89: ; preds = %85, %85
br label %85
90: ; preds = %85
%91 = getelementptr inbounds i8, i8* %86, i64 2
%92 = call i64 @strncmp(i8* %91, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i32 6)
%93 = icmp eq i64 %92, 0
br i1 %93, label %97, label %94
94: ; preds = %90
%95 = load i8, i8* %91
%96 = icmp eq i8 %95, 47
br i1 %96, label %109, label %64
97: ; preds = %90
%98 = getelementptr inbounds i8, i8* %86, i64 8
%99 = call i32 @strlen(i8* %5)
%100 = call i32 @strlen(i8* %98)
%101 = add i32 %99, 2
%102 = add i32 %101, %100
%103 = call i64 @malloc(i32 %102)
%104 = inttoptr i64 %103 to i8*
%105 = icmp eq i64 %103, 0
br i1 %105, label %144, label %106
106: ; preds = %97
%107 = call i32 @strcpy(i8* %104, i8* %5)
%108 = call i32 @strcat(i8* %104, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
br label %116
109: ; preds = %94
%110 = call i32 @strlen(i8* %91)
%111 = add nsw i32 %110, 1
%112 = call i64 @malloc(i32 %111)
%113 = inttoptr i64 %112 to i8*
%114 = icmp eq i64 %112, 0
br i1 %114, label %144, label %115
115: ; preds = %109
store i8 0, i8* %113
br label %116
116: ; preds = %115, %106
%117 = phi i8* [ %98, %106 ], [ %91, %115 ]
%118 = phi i8* [ %104, %106 ], [ %113, %115 ]
%119 = call i32 @strlen(i8* %118)
%120 = sext i32 %119 to i64
%121 = getelementptr inbounds i8, i8* %118, i64 %120
br label %122
122: ; preds = %132, %116
%123 = phi i8* [ %117, %116 ], [ %135, %132 ]
%124 = phi i8* [ %121, %116 ], [ %136, %132 ]
%125 = load i8, i8* %123
switch i8 %125, label %132 [
i8 0, label %137
i8 34, label %137
i8 92, label %126
]
126: ; preds = %122
%127 = getelementptr inbounds i8, i8* %123, i64 1
%128 = load i8, i8* %127
%129 = icmp eq i8 %128, 0
%130 = select i1 %129, i8* %123, i8* %127
%131 = load i8, i8* %130
br label %132
132: ; preds = %126, %122
%133 = phi i8 [ %125, %122 ], [ %131, %126 ]
%134 = phi i8* [ %123, %122 ], [ %130, %126 ]
%135 = getelementptr inbounds i8, i8* %134, i64 1
%136 = getelementptr inbounds i8, i8* %124, i64 1
store i8 %133, i8* %124
br label %122
137: ; preds = %122, %122
store i8 0, i8* %124
%138 = call i64 @fgets(i8* %4, i32 512, i32* %37)
%139 = icmp eq i64 %138, 0
br i1 %139, label %140, label %43
140: ; preds = %137, %64
%141 = phi i8* [ %44, %64 ], [ %118, %137 ]
%142 = call i32 @fclose(i32* %37)
%143 = icmp eq i8* %141, null
br i1 %143, label %146, label %150
144: ; preds = %109, %97, %40
%145 = call i32 @fclose(i32* %37)
br label %146
146: ; preds = %144, %140, %35, %24, %13, %2
%147 = icmp eq i8* %1, null
br i1 %147, label %150, label %148
148: ; preds = %146
%149 = call i8* @strdup(i8* %1)
br label %150
150: ; preds = %146, %140, %148
%151 = phi i8* [ %149, %148 ], [ %141, %140 ], [ null, %146 ]
ret i8* %151
}