#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 *);
char *malloc(int);
int /*<<< orphan*/ strcat(char *, char *);
scalar_t__ strcmp(char const *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
char *strdup(char *);
int strlen(char const *);
scalar_t__ strncmp(char *, char const *, int);
char *xdg_user_dir_lookup(const char *type) {
  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)
    return strdup("/tmp");
  config_home = getenv("XDG_CONFIG_HOME");
  if (config_home == NULL || config_home[0] == 0) {
    config_file =
        malloc(strlen(home_dir) + strlen("/.config/user-dirs.dirs") + 1);
    strcpy(config_file, home_dir);
    strcat(config_file, "/.config/user-dirs.dirs");
  } else {
    config_file = malloc(strlen(config_home) + strlen("/user-dirs.dirs") + 1);
    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 = malloc(strlen(home_dir) + 1 + strlen(p) + 1);
      strcpy(user_dir, home_dir);
      strcat(user_dir, "/");
    } else {
      user_dir = malloc(strlen(p) + 1);
      *user_dir = 0;
    }
    d = user_dir + strlen(user_dir);
    while (*p && *p != '"') {
      if ((*p == '\\') && (*(p + 1) != 0))
        p++;
      *d++ = *p++;
    }
    *d = 0;
  }
  fclose(file);
  if (user_dir)
    return user_dir;
error:
  if (strcmp(type, "DESKTOP") == 0) {
    user_dir = malloc(strlen(home_dir) + strlen("/Desktop") + 1);
    strcpy(user_dir, home_dir);
    strcat(user_dir, "/Desktop");
    return user_dir;
  } else
    return strdup(home_dir);
}


x86 assembly (clang, -O0):
<xdg_user_dir_lookup>:
push   %rbp
mov    %rsp,%rbp
sub    $0x290,%rsp
mov    %rdi,-0x10(%rbp)
lea    0xe3a(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11ff <xdg_user_dir_lookup+0x3f>
lea    0xe0f(%rip),%rdi
call   10e0 <strdup@plt>
mov    %rax,-0x8(%rbp)
jmp    1858 <xdg_user_dir_lookup+0x698>
lea    0xdff(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     122a <xdg_user_dir_lookup+0x6a>
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    127b <xdg_user_dir_lookup+0xbb>
mov    -0x20(%rbp),%rdi
call   1080 <strlen@plt>
mov    %eax,-0x254(%rbp)
lea    0xdd5(%rip),%rdi
call   1080 <strlen@plt>
mov    -0x254(%rbp),%edi
add    %eax,%edi
add    $0x1,%edi
call   10b0 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1060 <strcpy@plt>
mov    -0x30(%rbp),%rdi
lea    0xda4(%rip),%rsi
call   10d0 <strcat@plt>
jmp    12c7 <xdg_user_dir_lookup+0x107>
mov    -0x28(%rbp),%rdi
call   1080 <strlen@plt>
mov    %eax,-0x258(%rbp)
lea    0xd8c(%rip),%rdi
call   1080 <strlen@plt>
mov    -0x258(%rbp),%edi
add    %eax,%edi
add    $0x1,%edi
call   10b0 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1060 <strcpy@plt>
mov    -0x30(%rbp),%rdi
lea    0xd5b(%rip),%rsi
call   10d0 <strcat@plt>
mov    -0x30(%rbp),%rdi
lea    0xd5b(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x30(%rbp),%rdi
call   1040 <free@plt>
cmpq   $0x0,-0x18(%rbp)
jne    12f4 <xdg_user_dir_lookup+0x134>
jmp    17cc <xdg_user_dir_lookup+0x60c>
movq   $0x0,-0x238(%rbp)
lea    -0x230(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x200,%esi
call   1090 <fgets@plt>
cmp    $0x0,%rax
je     17a0 <xdg_user_dir_lookup+0x5e0>
lea    -0x230(%rbp),%rdi
call   1080 <strlen@plt>
mov    %eax,-0x24c(%rbp)
cmpl   $0x0,-0x24c(%rbp)
jle    136c <xdg_user_dir_lookup+0x1ac>
mov    -0x24c(%rbp),%eax
sub    $0x1,%eax
cltq
movsbl -0x230(%rbp,%rax,1),%eax
ff
cmp    $0xa,%eax
jne    136c <xdg_user_dir_lookup+0x1ac>
mov    -0x24c(%rbp),%eax
sub    $0x1,%eax
cltq
movb   $0x0,-0x230(%rbp,%rax,1)
lea    -0x230(%rbp),%rax
mov    %rax,-0x240(%rbp)
mov    -0x240(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x1,%al
cmp    $0x20,%ecx
mov    %al,-0x259(%rbp)
je     13ab <xdg_user_dir_lookup+0x1eb>
mov    -0x240(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x9,%eax
sete   %al
mov    %al,-0x259(%rbp)
mov    -0x259(%rbp),%al
test   $0x1,%al
jne    13be <xdg_user_dir_lookup+0x1fe>
jmp    13d5 <xdg_user_dir_lookup+0x215>
mov    -0x240(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x240(%rbp)
jmp    137a <xdg_user_dir_lookup+0x1ba>
mov    -0x240(%rbp),%rdi
lea    0xc4c(%rip),%rsi
mov    $0x4,%edx
call   1050 <strncmp@plt>
cmp    $0x0,%rax
je     13fc <xdg_user_dir_lookup+0x23c>
jmp    12ff <xdg_user_dir_lookup+0x13f>
mov    -0x240(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x240(%rbp)
mov    -0x240(%rbp),%rax
mov    %rax,-0x270(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x268(%rbp)
mov    -0x10(%rbp),%rdi
call   1080 <strlen@plt>
mov    -0x270(%rbp),%rdi
mov    -0x268(%rbp),%rsi
mov    %eax,%edx
call   1050 <strncmp@plt>
cmp    $0x0,%rax
je     1454 <xdg_user_dir_lookup+0x294>
jmp    12ff <xdg_user_dir_lookup+0x13f>
mov    -0x10(%rbp),%rdi
call   1080 <strlen@plt>
mov    %eax,%ecx
mov    -0x240(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x240(%rbp)
mov    -0x240(%rbp),%rdi
lea    0xbb3(%rip),%rsi
mov    $0x4,%edx
call   1050 <strncmp@plt>
cmp    $0x0,%rax
je     149a <xdg_user_dir_lookup+0x2da>
jmp    12ff <xdg_user_dir_lookup+0x13f>
mov    -0x240(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x240(%rbp)
mov    -0x240(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x1,%al
cmp    $0x20,%ecx
mov    %al,-0x271(%rbp)
je     14dd <xdg_user_dir_lookup+0x31d>
mov    -0x240(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x9,%eax
sete   %al
mov    %al,-0x271(%rbp)
mov    -0x271(%rbp),%al
test   $0x1,%al
jne    14f0 <xdg_user_dir_lookup+0x330>
jmp    1507 <xdg_user_dir_lookup+0x347>
mov    -0x240(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x240(%rbp)
jmp    14ac <xdg_user_dir_lookup+0x2ec>
mov    -0x240(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3d,%eax
je     151f <xdg_user_dir_lookup+0x35f>
jmp    12ff <xdg_user_dir_lookup+0x13f>
mov    -0x240(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x240(%rbp)
mov    -0x240(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x1,%al
cmp    $0x20,%ecx
mov    %al,-0x272(%rbp)
je     1562 <xdg_user_dir_lookup+0x3a2>
mov    -0x240(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x9,%eax
sete   %al
mov    %al,-0x272(%rbp)
mov    -0x272(%rbp),%al
test   $0x1,%al
jne    1575 <xdg_user_dir_lookup+0x3b5>
jmp    158c <xdg_user_dir_lookup+0x3cc>
mov    -0x240(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x240(%rbp)
jmp    1531 <xdg_user_dir_lookup+0x371>
mov    -0x240(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x22,%eax
je     15a4 <xdg_user_dir_lookup+0x3e4>
jmp    12ff <xdg_user_dir_lookup+0x13f>
mov    -0x240(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x240(%rbp)
movl   $0x0,-0x250(%rbp)
mov    -0x240(%rbp),%rdi
lea    0xa6b(%rip),%rsi
mov    $0x6,%edx
call   1050 <strncmp@plt>
cmp    $0x0,%rax
jne    1603 <xdg_user_dir_lookup+0x443>
mov    -0x240(%rbp),%rax
add    $0x6,%rax
mov    %rax,-0x240(%rbp)
movl   $0x1,-0x250(%rbp)
jmp    1620 <xdg_user_dir_lookup+0x460>
mov    -0x240(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
je     161b <xdg_user_dir_lookup+0x45b>
jmp    12ff <xdg_user_dir_lookup+0x13f>
jmp    1620 <xdg_user_dir_lookup+0x460>
cmpl   $0x0,-0x250(%rbp)
je     168a <xdg_user_dir_lookup+0x4ca>
mov    -0x20(%rbp),%rdi
call   1080 <strlen@plt>
add    $0x1,%eax
mov    %eax,-0x278(%rbp)
mov    -0x240(%rbp),%rdi
call   1080 <strlen@plt>
mov    -0x278(%rbp),%edi
add    %eax,%edi
add    $0x1,%edi
call   10b0 <malloc@plt>
mov    %rax,-0x238(%rbp)
mov    -0x238(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1060 <strcpy@plt>
mov    -0x238(%rbp),%rdi
lea    0x9be(%rip),%rsi
call   10d0 <strcat@plt>
jmp    16b1 <xdg_user_dir_lookup+0x4f1>
mov    -0x240(%rbp),%rdi
call   1080 <strlen@plt>
mov    %eax,%edi
add    $0x1,%edi
call   10b0 <malloc@plt>
mov    %rax,-0x238(%rbp)
mov    -0x238(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x238(%rbp),%rax
mov    %rax,-0x280(%rbp)
mov    -0x238(%rbp),%rdi
call   1080 <strlen@plt>
mov    %eax,%ecx
mov    -0x280(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x248(%rbp)
mov    -0x240(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x281(%rbp)
je     1712 <xdg_user_dir_lookup+0x552>
mov    -0x240(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x22,%eax
setne  %al
mov    %al,-0x281(%rbp)
mov    -0x281(%rbp),%al
test   $0x1,%al
jne    1725 <xdg_user_dir_lookup+0x565>
jmp    1791 <xdg_user_dir_lookup+0x5d1>
mov    -0x240(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5c,%eax
jne    175e <xdg_user_dir_lookup+0x59e>
mov    -0x240(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x0,%eax
je     175e <xdg_user_dir_lookup+0x59e>
mov    -0x240(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x240(%rbp)
mov    -0x240(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x240(%rbp)
mov    (%rax),%cl
mov    -0x248(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x248(%rbp)
mov    %cl,(%rax)
jmp    16e1 <xdg_user_dir_lookup+0x521>
mov    -0x248(%rbp),%rax
movb   $0x0,(%rax)
jmp    12ff <xdg_user_dir_lookup+0x13f>
mov    -0x18(%rbp),%rdi
call   1070 <fclose@plt>
cmpq   $0x0,-0x238(%rbp)
je     17c7 <xdg_user_dir_lookup+0x607>
mov    -0x238(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1858 <xdg_user_dir_lookup+0x698>
jmp    17cc <xdg_user_dir_lookup+0x60c>
mov    -0x10(%rbp),%rdi
lea    0x869(%rip),%rsi
call   10a0 <strcmp@plt>
cmp    $0x0,%rax
jne    184b <xdg_user_dir_lookup+0x68b>
mov    -0x20(%rbp),%rdi
call   1080 <strlen@plt>
mov    %eax,-0x288(%rbp)
lea    0x84c(%rip),%rdi
call   1080 <strlen@plt>
mov    -0x288(%rbp),%edi
add    %eax,%edi
add    $0x1,%edi
call   10b0 <malloc@plt>
mov    %rax,-0x238(%rbp)
mov    -0x238(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1060 <strcpy@plt>
mov    -0x238(%rbp),%rdi
lea    0x812(%rip),%rsi
call   10d0 <strcat@plt>
mov    -0x238(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1858 <xdg_user_dir_lookup+0x698>
mov    -0x20(%rbp),%rdi
call   10e0 <strdup@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x290,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xdg_user_dir_lookup>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x228,%rsp
mov    %rdi,0x10(%rsp)
lea    0xe33(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     1504 <xdg_user_dir_lookup+0x344>
mov    %rax,%r15
lea    0xe10(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     1236 <xdg_user_dir_lookup+0x76>
mov    %rax,%rbx
cmpb   $0x0,(%rax)
je     1236 <xdg_user_dir_lookup+0x76>
mov    %rbx,%rdi
call   1080 <strlen@plt>
mov    %eax,%ebp
lea    0xe05(%rip),%r14
mov    %r14,%rdi
call   1080 <strlen@plt>
lea    (%rax,%rbp,1),%edi
add    $0x1,%edi
call   10b0 <malloc@plt>
mov    %rax,%rbp
mov    %rax,%rdi
mov    %rbx,%rsi
jmp    1263 <xdg_user_dir_lookup+0xa3>
mov    %r15,%rdi
call   1080 <strlen@plt>
mov    %eax,%ebx
lea    0xdce(%rip),%r14
mov    %r14,%rdi
call   1080 <strlen@plt>
lea    (%rbx,%rax,1),%edi
add    $0x1,%edi
call   10b0 <malloc@plt>
mov    %rax,%rbp
mov    %rax,%rdi
mov    %r15,%rsi
call   1060 <strcpy@plt>
mov    %rbp,%rdi
mov    %r14,%rsi
call   10d0 <strcat@plt>
lea    0xdb3(%rip),%rsi
mov    %rbp,%rdi
call   10c0 <fopen@plt>
mov    %rax,%rbx
mov    %rbp,%rdi
call   1040 <free@plt>
test   %rbx,%rbx
je     1542 <xdg_user_dir_lookup+0x382>
lea    0x20(%rsp),%rdi
mov    $0x200,%esi
mov    %rbx,%rdx
call   1090 <fgets@plt>
test   %rax,%rax
je     153a <xdg_user_dir_lookup+0x37a>
xor    %r12d,%r12d
lea    0x20(%rsp),%rbp
mov    %r15,0x8(%rsp)
mov    %r12,0x18(%rsp)
jmp    12ee <xdg_user_dir_lookup+0x12e>
cs nopw 0x0(%rax,%rax,1)
nop
lea    0x20(%rsp),%rbp
mov    %rbp,%rdi
mov    $0x200,%esi
mov    %rbx,%rdx
call   1090 <fgets@plt>
test   %rax,%rax
je     1521 <xdg_user_dir_lookup+0x361>
mov    %rbp,%rdi
call   1080 <strlen@plt>
test   %eax,%eax
jle    1309 <xdg_user_dir_lookup+0x149>
add    $0xffffffff,%eax
cmpb   $0xa,0x20(%rsp,%rax,1)
jne    1309 <xdg_user_dir_lookup+0x149>
movb   $0x0,0x20(%rsp,%rax,1)
lea    0x29(%rsp),%r15
lea    0x2a(%rsp),%r12
lea    0x30(%rsp),%r14
lea    0x24(%rsp),%rbp
jmp    1330 <xdg_user_dir_lookup+0x170>
nop
add    $0x1,%rbp
add    $0x1,%r14
add    $0x1,%r12
add    $0x1,%r15
movzbl -0x4(%rbp),%eax
cmp    $0x20,%al
je     1320 <xdg_user_dir_lookup+0x160>
cmp    $0x9,%al
je     1320 <xdg_user_dir_lookup+0x160>
lea    -0x4(%rbp),%rdi
lea    0xce8(%rip),%rsi
mov    $0x4,%edx
call   1050 <strncmp@plt>
test   %rax,%rax
jne    12d0 <xdg_user_dir_lookup+0x110>
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    12d0 <xdg_user_dir_lookup+0x110>
mov    0x10(%rsp),%rdi
call   1080 <strlen@plt>
movslq %eax,%r13
mov    %rbp,%rdi
add    %r13,%rdi
lea    0xc97(%rip),%rsi
mov    $0x4,%edx
call   1050 <strncmp@plt>
test   %rax,%rax
jne    12d0 <xdg_user_dir_lookup+0x110>
lea    0x4(,%r13,1),%rax
add    %rbp,%rax
add    %r13,%r14
add    %r13,%r12
add    %r13,%r15
jmp    13e0 <xdg_user_dir_lookup+0x220>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%rax
add    $0x1,%r14
add    $0x1,%r12
add    $0x1,%r15
movzbl (%rax),%ecx
cmp    $0x9,%cl
je     13d0 <xdg_user_dir_lookup+0x210>
cmp    $0x20,%cl
je     13d0 <xdg_user_dir_lookup+0x210>
cmp    $0x3d,%cl
je     140c <xdg_user_dir_lookup+0x24c>
jmp    12d0 <xdg_user_dir_lookup+0x110>
nopw   0x0(%rax,%rax,1)
add    $0x1,%r14
add    $0x1,%r12
add    $0x1,%r15
movzbl (%r15),%eax
cmp    $0x9,%al
je     1400 <xdg_user_dir_lookup+0x240>
cmp    $0x20,%al
je     1400 <xdg_user_dir_lookup+0x240>
cmp    $0x22,%al
jne    12d0 <xdg_user_dir_lookup+0x110>
mov    %r12,%rdi
lea    0xc0f(%rip),%rsi
mov    $0x6,%edx
call   1050 <strncmp@plt>
test   %rax,%rax
je     1464 <xdg_user_dir_lookup+0x2a4>
cmpb   $0x2f,(%r12)
jne    12d0 <xdg_user_dir_lookup+0x110>
mov    %r12,%rdi
call   1080 <strlen@plt>
lea    0x1(%rax),%edi
call   10b0 <malloc@plt>
movb   $0x0,(%rax)
mov    %r12,%r14
mov    %rax,%r12
mov    0x8(%rsp),%r15
jmp    14a3 <xdg_user_dir_lookup+0x2e3>
mov    0x8(%rsp),%r15
mov    %r15,%rdi
call   1080 <strlen@plt>
mov    %eax,%ebp
mov    %r14,%rdi
call   1080 <strlen@plt>
lea    (%rax,%rbp,1),%edi
add    $0x2,%edi
call   10b0 <malloc@plt>
mov    %rax,%r12
mov    %rax,%rdi
mov    %r15,%rsi
call   1060 <strcpy@plt>
mov    %r12,%rdi
lea    0xba0(%rip),%rsi
call   10d0 <strcat@plt>
mov    %r12,%rdi
call   1080 <strlen@plt>
cltq
add    %r12,%rax
jmp    14c0 <xdg_user_dir_lookup+0x300>
movzbl (%r14),%ecx
add    $0x1,%r14
mov    %cl,(%rax)
add    $0x1,%rax
movzbl (%r14),%ecx
cmp    $0x5c,%cl
je     14d4 <xdg_user_dir_lookup+0x314>
test   %cl,%cl
je     14e1 <xdg_user_dir_lookup+0x321>
cmp    $0x22,%cl
jne    14b6 <xdg_user_dir_lookup+0x2f6>
jmp    14e1 <xdg_user_dir_lookup+0x321>
cmpb   $0x0,0x1(%r14)
je     14b2 <xdg_user_dir_lookup+0x2f2>
add    $0x1,%r14
jmp    14b2 <xdg_user_dir_lookup+0x2f2>
movb   $0x0,(%rax)
lea    0x20(%rsp),%rbp
mov    %rbp,%rdi
mov    $0x200,%esi
mov    %rbx,%rdx
call   1090 <fgets@plt>
test   %rax,%rax
jne    12be <xdg_user_dir_lookup+0xfe>
jmp    152b <xdg_user_dir_lookup+0x36b>
lea    0xaf5(%rip),%rdi
add    $0x228,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    10e0 <strdup@plt>
mov    0x8(%rsp),%r15
mov    0x18(%rsp),%r12
mov    %rbx,%rdi
call   1070 <fclose@plt>
test   %r12,%r12
jne    15a2 <xdg_user_dir_lookup+0x3e2>
jmp    1542 <xdg_user_dir_lookup+0x382>
mov    %rbx,%rdi
call   1070 <fclose@plt>
lea    0xaf7(%rip),%rsi
mov    0x10(%rsp),%rdi
call   10a0 <strcmp@plt>
test   %rax,%rax
je     1565 <xdg_user_dir_lookup+0x3a5>
mov    %r15,%rdi
call   10e0 <strdup@plt>
mov    %rax,%r12
jmp    15a2 <xdg_user_dir_lookup+0x3e2>
mov    %r15,%rdi
call   1080 <strlen@plt>
mov    %eax,%ebx
lea    0xad2(%rip),%r14
mov    %r14,%rdi
call   1080 <strlen@plt>
lea    (%rbx,%rax,1),%edi
add    $0x1,%edi
call   10b0 <malloc@plt>
mov    %rax,%r12
mov    %rax,%rdi
mov    %r15,%rsi
call   1060 <strcpy@plt>
mov    %r12,%rdi
mov    %r14,%rsi
call   10d0 <strcat@plt>
mov    %r12,%rax
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 = [5 x i8] c"/tmp\00"
@.str.2 = [16 x i8] c"XDG_CONFIG_HOME\00"
@.str.3 = [24 x i8] c"/.config/user-dirs.dirs\00"
@.str.4 = [16 x i8] c"/user-dirs.dirs\00"
@.str.5 = [2 x i8] c"r\00"
@.str.6 = [5 x i8] c"XDG_\00"
@.str.7 = [5 x i8] c"_DIR\00"
@.str.8 = [7 x i8] c"$HOME/\00"
@.str.9 = [2 x i8] c"/\00"
@.str.10 = [8 x i8] c"DESKTOP\00"
@.str.11 = [9 x i8] c"/Desktop\00"
define i8* @xdg_user_dir_lookup(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca [512 x i8]
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i32
store i8* %0, i8** %3
%14 = call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i8* %14, i8** %5
%15 = load i8*, i8** %5
%16 = icmp eq i8* %15, null
br i1 %16, label %17, label %19
17: ; preds = %1
%18 = call i8* @strdup(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
store i8* %18, i8** %2
br label %282
19: ; preds = %1
%20 = call i8* @getenv(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
store i8* %20, i8** %6
%21 = load i8*, i8** %6
%22 = icmp eq i8* %21, null
br i1 %22, label %29, label %23
23: ; preds = %19
%24 = load i8*, i8** %6
%25 = getelementptr inbounds i8, i8* %24, i64 0
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = icmp eq i32 %27, 0
br i1 %28, label %29, label %41
29: ; preds = %23, %19
%30 = load i8*, i8** %5
%31 = call i32 @strlen(i8* %30)
%32 = call i32 @strlen(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0))
%33 = add nsw i32 %31, %32
%34 = add nsw i32 %33, 1
%35 = call i8* @malloc(i32 %34)
store i8* %35, i8** %7
%36 = load i8*, i8** %7
%37 = load i8*, i8** %5
%38 = call i32 @strcpy(i8* %36, i8* %37)
%39 = load i8*, i8** %7
%40 = call i32 @strcat(i8* %39, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0))
br label %53
41: ; preds = %23
%42 = load i8*, i8** %6
%43 = call i32 @strlen(i8* %42)
%44 = call i32 @strlen(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
%45 = add nsw i32 %43, %44
%46 = add nsw i32 %45, 1
%47 = call i8* @malloc(i32 %46)
store i8* %47, i8** %7
%48 = load i8*, i8** %7
%49 = load i8*, i8** %6
%50 = call i32 @strcpy(i8* %48, i8* %49)
%51 = load i8*, i8** %7
%52 = call i32 @strcat(i8* %51, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
br label %53
53: ; preds = %41, %29
%54 = load i8*, i8** %7
%55 = call i32* @fopen(i8* %54, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
store i32* %55, i32** %4
%56 = load i8*, i8** %7
%57 = call i32 @free(i8* %56)
%58 = load i32*, i32** %4
%59 = icmp eq i32* %58, null
br i1 %59, label %60, label %61
60: ; preds = %53
br label %262
61: ; preds = %53
store i8* null, i8** %9
br label %62
62: ; preds = %252, %189, %174, %150, %126, %116, %106, %61
%63 = getelementptr inbounds [512 x i8], [512 x i8]* %8, i64 0, i64 0
%64 = load i32*, i32** %4
%65 = call i64 @fgets(i8* %63, i32 512, i32* %64)
%66 = icmp ne i64 %65, 0
br i1 %66, label %67, label %254
67: ; preds = %62
%68 = getelementptr inbounds [512 x i8], [512 x i8]* %8, i64 0, i64 0
%69 = call i32 @strlen(i8* %68)
store i32 %69, i32* %12
%70 = load i32, i32* %12
%71 = icmp sgt i32 %70, 0
br i1 %71, label %72, label %85
72: ; preds = %67
%73 = load i32, i32* %12
%74 = sub nsw i32 %73, 1
%75 = sext i32 %74 to i64
%76 = getelementptr inbounds [512 x i8], [512 x i8]* %8, i64 0, i64 %75
%77 = load i8, i8* %76
%78 = sext i8 %77 to i32
%79 = icmp eq i32 %78, 10
br i1 %79, label %80, label %85
80: ; preds = %72
%81 = load i32, i32* %12
%82 = sub nsw i32 %81, 1
%83 = sext i32 %82 to i64
%84 = getelementptr inbounds [512 x i8], [512 x i8]* %8, i64 0, i64 %83
store i8 0, i8* %84
br label %85
85: ; preds = %80, %72, %67
%86 = getelementptr inbounds [512 x i8], [512 x i8]* %8, i64 0, i64 0
store i8* %86, i8** %10
br label %87
87: ; preds = %99, %85
%88 = load i8*, i8** %10
%89 = load i8, i8* %88
%90 = sext i8 %89 to i32
%91 = icmp eq i32 %90, 32
br i1 %91, label %97, label %92
92: ; preds = %87
%93 = load i8*, i8** %10
%94 = load i8, i8* %93
%95 = sext i8 %94 to i32
%96 = icmp eq i32 %95, 9
br label %97
97: ; preds = %92, %87
%98 = phi i1 [ true, %87 ], [ %96, %92 ]
br i1 %98, label %99, label %102
99: ; preds = %97
%100 = load i8*, i8** %10
%101 = getelementptr inbounds i8, i8* %100, i32 1
store i8* %101, i8** %10
br label %87
102: ; preds = %97
%103 = load i8*, i8** %10
%104 = call i64 @strncmp(i8* %103, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i32 4)
%105 = icmp ne i64 %104, 0
br i1 %105, label %106, label %107
106: ; preds = %102
br label %62
107: ; preds = %102
%108 = load i8*, i8** %10
%109 = getelementptr inbounds i8, i8* %108, i64 4
store i8* %109, i8** %10
%110 = load i8*, i8** %10
%111 = load i8*, i8** %3
%112 = load i8*, i8** %3
%113 = call i32 @strlen(i8* %112)
%114 = call i64 @strncmp(i8* %110, i8* %111, i32 %113)
%115 = icmp ne i64 %114, 0
br i1 %115, label %116, label %117
116: ; preds = %107
br label %62
117: ; preds = %107
%118 = load i8*, i8** %3
%119 = call i32 @strlen(i8* %118)
%120 = load i8*, i8** %10
%121 = sext i32 %119 to i64
%122 = getelementptr inbounds i8, i8* %120, i64 %121
store i8* %122, i8** %10
%123 = load i8*, i8** %10
%124 = call i64 @strncmp(i8* %123, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i32 4)
%125 = icmp ne i64 %124, 0
br i1 %125, label %126, label %127
126: ; preds = %117
br label %62
127: ; preds = %117
%128 = load i8*, i8** %10
%129 = getelementptr inbounds i8, i8* %128, i64 4
store i8* %129, i8** %10
br label %130
130: ; preds = %142, %127
%131 = load i8*, i8** %10
%132 = load i8, i8* %131
%133 = sext i8 %132 to i32
%134 = icmp eq i32 %133, 32
br i1 %134, label %140, label %135
135: ; preds = %130
%136 = load i8*, i8** %10
%137 = load i8, i8* %136
%138 = sext i8 %137 to i32
%139 = icmp eq i32 %138, 9
br label %140
140: ; preds = %135, %130
%141 = phi i1 [ true, %130 ], [ %139, %135 ]
br i1 %141, label %142, label %145
142: ; preds = %140
%143 = load i8*, i8** %10
%144 = getelementptr inbounds i8, i8* %143, i32 1
store i8* %144, i8** %10
br label %130
145: ; preds = %140
%146 = load i8*, i8** %10
%147 = load i8, i8* %146
%148 = sext i8 %147 to i32
%149 = icmp ne i32 %148, 61
br i1 %149, label %150, label %151
150: ; preds = %145
br label %62
151: ; preds = %145
%152 = load i8*, i8** %10
%153 = getelementptr inbounds i8, i8* %152, i32 1
store i8* %153, i8** %10
br label %154
154: ; preds = %166, %151
%155 = load i8*, i8** %10
%156 = load i8, i8* %155
%157 = sext i8 %156 to i32
%158 = icmp eq i32 %157, 32
br i1 %158, label %164, label %159
159: ; preds = %154
%160 = load i8*, i8** %10
%161 = load i8, i8* %160
%162 = sext i8 %161 to i32
%163 = icmp eq i32 %162, 9
br label %164
164: ; preds = %159, %154
%165 = phi i1 [ true, %154 ], [ %163, %159 ]
br i1 %165, label %166, label %169
166: ; preds = %164
%167 = load i8*, i8** %10
%168 = getelementptr inbounds i8, i8* %167, i32 1
store i8* %168, i8** %10
br label %154
169: ; preds = %164
%170 = load i8*, i8** %10
%171 = load i8, i8* %170
%172 = sext i8 %171 to i32
%173 = icmp ne i32 %172, 34
br i1 %173, label %174, label %175
174: ; preds = %169
br label %62
175: ; preds = %169
%176 = load i8*, i8** %10
%177 = getelementptr inbounds i8, i8* %176, i32 1
store i8* %177, i8** %10
store i32 0, i32* %13
%178 = load i8*, i8** %10
%179 = call i64 @strncmp(i8* %178, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0), i32 6)
%180 = icmp eq i64 %179, 0
br i1 %180, label %181, label %184
181: ; preds = %175
%182 = load i8*, i8** %10
%183 = getelementptr inbounds i8, i8* %182, i64 6
store i8* %183, i8** %10
store i32 1, i32* %13
br label %191
184: ; preds = %175
%185 = load i8*, i8** %10
%186 = load i8, i8* %185
%187 = sext i8 %186 to i32
%188 = icmp ne i32 %187, 47
br i1 %188, label %189, label %190
189: ; preds = %184
br label %62
190: ; preds = %184
br label %191
191: ; preds = %190, %181
%192 = load i32, i32* %13
%193 = icmp ne i32 %192, 0
br i1 %193, label %194, label %208
194: ; preds = %191
%195 = load i8*, i8** %5
%196 = call i32 @strlen(i8* %195)
%197 = add nsw i32 %196, 1
%198 = load i8*, i8** %10
%199 = call i32 @strlen(i8* %198)
%200 = add nsw i32 %197, %199
%201 = add nsw i32 %200, 1
%202 = call i8* @malloc(i32 %201)
store i8* %202, i8** %9
%203 = load i8*, i8** %9
%204 = load i8*, i8** %5
%205 = call i32 @strcpy(i8* %203, i8* %204)
%206 = load i8*, i8** %9
%207 = call i32 @strcat(i8* %206, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
br label %214
208: ; preds = %191
%209 = load i8*, i8** %10
%210 = call i32 @strlen(i8* %209)
%211 = add nsw i32 %210, 1
%212 = call i8* @malloc(i32 %211)
store i8* %212, i8** %9
%213 = load i8*, i8** %9
store i8 0, i8* %213
br label %214
214: ; preds = %208, %194
%215 = load i8*, i8** %9
%216 = load i8*, i8** %9
%217 = call i32 @strlen(i8* %216)
%218 = sext i32 %217 to i64
%219 = getelementptr inbounds i8, i8* %215, i64 %218
store i8* %219, i8** %11
br label %220
220: ; preds = %246, %214
%221 = load i8*, i8** %10
%222 = load i8, i8* %221
%223 = sext i8 %222 to i32
%224 = icmp ne i32 %223, 0
br i1 %224, label %225, label %230
225: ; preds = %220
%226 = load i8*, i8** %10
%227 = load i8, i8* %226
%228 = sext i8 %227 to i32
%229 = icmp ne i32 %228, 34
br label %230
230: ; preds = %225, %220
%231 = phi i1 [ false, %220 ], [ %229, %225 ]
br i1 %231, label %232, label %252
232: ; preds = %230
%233 = load i8*, i8** %10
%234 = load i8, i8* %233
%235 = sext i8 %234 to i32
%236 = icmp eq i32 %235, 92
br i1 %236, label %237, label %246
237: ; preds = %232
%238 = load i8*, i8** %10
%239 = getelementptr inbounds i8, i8* %238, i64 1
%240 = load i8, i8* %239
%241 = sext i8 %240 to i32
%242 = icmp ne i32 %241, 0
br i1 %242, label %243, label %246
243: ; preds = %237
%244 = load i8*, i8** %10
%245 = getelementptr inbounds i8, i8* %244, i32 1
store i8* %245, i8** %10
br label %246
246: ; preds = %243, %237, %232
%247 = load i8*, i8** %10
%248 = getelementptr inbounds i8, i8* %247, i32 1
store i8* %248, i8** %10
%249 = load i8, i8* %247
%250 = load i8*, i8** %11
%251 = getelementptr inbounds i8, i8* %250, i32 1
store i8* %251, i8** %11
store i8 %249, i8* %250
br label %220
252: ; preds = %230
%253 = load i8*, i8** %11
store i8 0, i8* %253
br label %62
254: ; preds = %62
%255 = load i32*, i32** %4
%256 = call i32 @fclose(i32* %255)
%257 = load i8*, i8** %9
%258 = icmp ne i8* %257, null
br i1 %258, label %259, label %261
259: ; preds = %254
%260 = load i8*, i8** %9
store i8* %260, i8** %2
br label %282
261: ; preds = %254
br label %262
262: ; preds = %261, %60
%263 = load i8*, i8** %3
%264 = call i64 @strcmp(i8* %263, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.10, i64 0, i64 0))
%265 = icmp eq i64 %264, 0
br i1 %265, label %266, label %279
266: ; preds = %262
%267 = load i8*, i8** %5
%268 = call i32 @strlen(i8* %267)
%269 = call i32 @strlen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.11, i64 0, i64 0))
%270 = add nsw i32 %268, %269
%271 = add nsw i32 %270, 1
%272 = call i8* @malloc(i32 %271)
store i8* %272, i8** %9
%273 = load i8*, i8** %9
%274 = load i8*, i8** %5
%275 = call i32 @strcpy(i8* %273, i8* %274)
%276 = load i8*, i8** %9
%277 = call i32 @strcat(i8* %276, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.11, i64 0, i64 0))
%278 = load i8*, i8** %9
store i8* %278, i8** %2
br label %282
279: ; preds = %262
%280 = load i8*, i8** %5
%281 = call i8* @strdup(i8* %280)
store i8* %281, i8** %2
br label %282
282: ; preds = %279, %266, %259, %17
%283 = load i8*, i8** %2
ret i8* %283
}

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