#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 */

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ free(char *);
char *getenv(char *);
int /*<<< orphan*/ gethostname(char *, int);
char *malloc(int);
int /*<<< orphan*/ sprintf(char *, char *, int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcpy(char *, char const *);
int strlen(char const *);
int /*<<< orphan*/ xf86pathIsAbsolute(char const *);
int /*<<< orphan*/ xf86pathIsSafe(char const *);
char *DoSubstitution(const char *template, const char *cmdline,
                     const char *projroot, int *cmdlineUsed, int *envUsed) {
  char *result;
  int i, l;
  static const char *env = NULL, *home = NULL;
  static char *hostname = NULL;
  static char majorvers[3] = "";
  if (!template)
    return NULL;
  if (cmdlineUsed)
    *cmdlineUsed = 0;
  if (envUsed)
    *envUsed = 0;
  result = malloc(1024 + 1);
  l = 0;
  for (i = 0; template[i]; i++) {
    if (template[i] != '%') {
      result[l++] = template[i];
      do {
        if (l > 1024) {
          do {
            free(result);
            return NULL;
          } while (0);
        }
      } while (0);
    } else {
      switch (template[++i]) {
      case 'A':
        if (cmdline && xf86pathIsAbsolute(cmdline)) {
          do {
            if (strlen(cmdline) + l > 1024) {
              do {
                free(result);
                return NULL;
              } while (0);
            } else {
              strcpy(result + l, cmdline);
              l += strlen(cmdline);
            }
          } while (0);
          if (cmdlineUsed)
            *cmdlineUsed = 1;
        } else
          do {
            free(result);
            return NULL;
          } while (0);
        break;
      case 'R':
        if (cmdline && !xf86pathIsAbsolute(cmdline)) {
          do {
            if (strlen(cmdline) + l > 1024) {
              do {
                free(result);
                return NULL;
              } while (0);
            } else {
              strcpy(result + l, cmdline);
              l += strlen(cmdline);
            }
          } while (0);
          if (cmdlineUsed)
            *cmdlineUsed = 1;
        } else
          do {
            free(result);
            return NULL;
          } while (0);
        break;
      case 'S':
        if (cmdline && xf86pathIsSafe(cmdline)) {
          do {
            if (strlen(cmdline) + l > 1024) {
              do {
                free(result);
                return NULL;
              } while (0);
            } else {
              strcpy(result + l, cmdline);
              l += strlen(cmdline);
            }
          } while (0);
          if (cmdlineUsed)
            *cmdlineUsed = 1;
        } else
          do {
            free(result);
            return NULL;
          } while (0);
        break;
      case 'X':
        do {
          if (strlen("XF86Config") + l > 1024) {
            do {
              free(result);
              return NULL;
            } while (0);
          } else {
            strcpy(result + l, "XF86Config");
            l += strlen("XF86Config");
          }
        } while (0);
        break;
      case 'H':
        if (!hostname) {
          if ((hostname = malloc(32 + 1))) {
            if (gethostname(hostname, 32) == 0) {
              hostname[32] = '\0';
            } else {
              free(hostname);
              hostname = NULL;
            }
          }
        }
        if (hostname)
          do {
            if (strlen(hostname) + l > 1024) {
              do {
                free(result);
                return NULL;
              } while (0);
            } else {
              strcpy(result + l, hostname);
              l += strlen(hostname);
            }
          } while (0);
        break;
      case 'E':
        if (!env)
          env = getenv("XF86CONFIG");
        if (env && xf86pathIsAbsolute(env)) {
          do {
            if (strlen(env) + l > 1024) {
              do {
                free(result);
                return NULL;
              } while (0);
            } else {
              strcpy(result + l, env);
              l += strlen(env);
            }
          } while (0);
          if (envUsed)
            *envUsed = 1;
        } else
          do {
            free(result);
            return NULL;
          } while (0);
        break;
      case 'F':
        if (!env)
          env = getenv("XF86CONFIG");
        if (env && !xf86pathIsAbsolute(env)) {
          do {
            if (strlen(env) + l > 1024) {
              do {
                free(result);
                return NULL;
              } while (0);
            } else {
              strcpy(result + l, env);
              l += strlen(env);
            }
          } while (0);
          if (envUsed)
            *envUsed = 1;
        } else
          do {
            free(result);
            return NULL;
          } while (0);
        break;
      case 'G':
        if (!env)
          env = getenv("XF86CONFIG");
        if (env && xf86pathIsSafe(env)) {
          do {
            if (strlen(env) + l > 1024) {
              do {
                free(result);
                return NULL;
              } while (0);
            } else {
              strcpy(result + l, env);
              l += strlen(env);
            }
          } while (0);
          if (envUsed)
            *envUsed = 1;
        } else
          do {
            free(result);
            return NULL;
          } while (0);
        break;
      case 'D':
        if (!home)
          home = getenv("HOME");
        if (home && xf86pathIsAbsolute(home))
          do {
            if (strlen(home) + l > 1024) {
              do {
                free(result);
                return NULL;
              } while (0);
            } else {
              strcpy(result + l, home);
              l += strlen(home);
            }
          } while (0);
        else
          do {
            free(result);
            return NULL;
          } while (0);
        break;
      case 'P':
        if (projroot && xf86pathIsAbsolute(projroot))
          do {
            if (strlen(projroot) + l > 1024) {
              do {
                free(result);
                return NULL;
              } while (0);
            } else {
              strcpy(result + l, projroot);
              l += strlen(projroot);
            }
          } while (0);
        else
          do {
            free(result);
            return NULL;
          } while (0);
        break;
      case 'M':
        if (!majorvers[0]) {
          if (4 < 0 || 4 > 99) {
            fprintf(stderr, "XF86_VERSION_MAJOR is out of range\n");
            do {
              free(result);
              return NULL;
            } while (0);
          } else
            sprintf(majorvers, "%d", 4);
        }
        do {
          if (strlen(majorvers) + l > 1024) {
            do {
              free(result);
              return NULL;
            } while (0);
          } else {
            strcpy(result + l, majorvers);
            l += strlen(majorvers);
          }
        } while (0);
        break;
      case '%':
        result[l++] = '%';
        do {
          if (l > 1024) {
            do {
              free(result);
              return NULL;
            } while (0);
          }
        } while (0);
        break;
      default:
        fprintf(stderr, "invalid escape %%%c found in path template\n",
                template[i]);
        do {
          free(result);
          return NULL;
        } while (0);
        break;
      }
    }
  }
  return result;
}


x86 assembly (clang, -O0):
<DoSubstitution>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11d4 <DoSubstitution+0x34>
movq   $0x0,-0x8(%rbp)
jmp    1ba8 <DoSubstitution+0xa08>
cmpq   $0x0,-0x28(%rbp)
je     11e9 <DoSubstitution+0x49>
mov    -0x28(%rbp),%rax
movl   $0x0,(%rax)
cmpq   $0x0,-0x30(%rbp)
je     11fe <DoSubstitution+0x5e>
mov    -0x30(%rbp),%rax
movl   $0x0,(%rax)
mov    $0x401,%edi
call   1090 <malloc@plt>
mov    %rax,-0x38(%rbp)
movl   $0x0,-0x40(%rbp)
movl   $0x0,-0x3c(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x3c(%rbp),%rcx
cmpb   $0x0,(%rax,%rcx,1)
je     1ba0 <DoSubstitution+0xa00>
mov    -0x10(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x25,%eax
je     1293 <DoSubstitution+0xf3>
mov    -0x10(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x38(%rbp),%rax
mov    -0x40(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x40(%rbp)
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
cmpl   $0x400,-0x40(%rbp)
jle    1289 <DoSubstitution+0xe9>
jmp    1273 <DoSubstitution+0xd3>
mov    -0x38(%rbp),%rdi
call   1040 <free@plt>
movq   $0x0,-0x8(%rbp)
jmp    1ba8 <DoSubstitution+0xa08>
jmp    128e <DoSubstitution+0xee>
jmp    1b8d <DoSubstitution+0x9ed>
mov    -0x10(%rbp),%rcx
movslq -0x3c(%rbp),%rax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x3c(%rbp)
movsbl 0x1(%rax,%rcx,1),%eax
add    $0xffffffdb,%eax
mov    %eax,%ecx
mov    %rcx,-0x48(%rbp)
sub    $0x33,%eax
ja     1b4f <DoSubstitution+0x9af>
mov    -0x48(%rbp),%rax
lea    0xd3b(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
cmpq   $0x0,-0x18(%rbp)
je     1364 <DoSubstitution+0x1c4>
mov    -0x18(%rbp),%rdi
call   10a0 <xf86pathIsAbsolute@plt>
cmp    $0x0,%eax
je     1364 <DoSubstitution+0x1c4>
jmp    12f0 <DoSubstitution+0x150>
mov    -0x18(%rbp),%rdi
call   1070 <strlen@plt>
add    -0x40(%rbp),%eax
cmp    $0x400,%eax
jle    1322 <DoSubstitution+0x182>
jmp    130c <DoSubstitution+0x16c>
mov    -0x38(%rbp),%rdi
call   1040 <free@plt>
movq   $0x0,-0x8(%rbp)
jmp    1ba8 <DoSubstitution+0xa08>
mov    -0x38(%rbp),%rdi
movslq -0x40(%rbp),%rax
add    %rax,%rdi
mov    -0x18(%rbp),%rsi
call   1050 <strcpy@plt>
mov    -0x18(%rbp),%rdi
call   1070 <strlen@plt>
add    -0x40(%rbp),%eax
mov    %eax,-0x40(%rbp)
jmp    134a <DoSubstitution+0x1aa>
cmpq   $0x0,-0x28(%rbp)
je     135f <DoSubstitution+0x1bf>
mov    -0x28(%rbp),%rax
movl   $0x1,(%rax)
jmp    137f <DoSubstitution+0x1df>
jmp    1369 <DoSubstitution+0x1c9>
mov    -0x38(%rbp),%rdi
call   1040 <free@plt>
movq   $0x0,-0x8(%rbp)
jmp    1ba8 <DoSubstitution+0xa08>
jmp    1b88 <DoSubstitution+0x9e8>
cmpq   $0x0,-0x18(%rbp)
je     141a <DoSubstitution+0x27a>
mov    -0x18(%rbp),%rdi
call   10a0 <xf86pathIsAbsolute@plt>
cmp    $0x0,%eax
jne    141a <DoSubstitution+0x27a>
jmp    13a6 <DoSubstitution+0x206>
mov    -0x18(%rbp),%rdi
call   1070 <strlen@plt>
add    -0x40(%rbp),%eax
cmp    $0x400,%eax
jle    13d8 <DoSubstitution+0x238>
jmp    13c2 <DoSubstitution+0x222>
mov    -0x38(%rbp),%rdi
call   1040 <free@plt>
movq   $0x0,-0x8(%rbp)
jmp    1ba8 <DoSubstitution+0xa08>
mov    -0x38(%rbp),%rdi
movslq -0x40(%rbp),%rax
add    %rax,%rdi
mov    -0x18(%rbp),%rsi
call   1050 <strcpy@plt>
mov    -0x18(%rbp),%rdi
call   1070 <strlen@plt>
add    -0x40(%rbp),%eax
mov    %eax,-0x40(%rbp)
jmp    1400 <DoSubstitution+0x260>
cmpq   $0x0,-0x28(%rbp)
je     1415 <DoSubstitution+0x275>
mov    -0x28(%rbp),%rax
movl   $0x1,(%rax)
jmp    1435 <DoSubstitution+0x295>
jmp    141f <DoSubstitution+0x27f>
mov    -0x38(%rbp),%rdi
call   1040 <free@plt>
movq   $0x0,-0x8(%rbp)
jmp    1ba8 <DoSubstitution+0xa08>
jmp    1b88 <DoSubstitution+0x9e8>
cmpq   $0x0,-0x18(%rbp)
je     14d0 <DoSubstitution+0x330>
mov    -0x18(%rbp),%rdi
call   1060 <xf86pathIsSafe@plt>
cmp    $0x0,%eax
je     14d0 <DoSubstitution+0x330>
jmp    145c <DoSubstitution+0x2bc>
mov    -0x18(%rbp),%rdi
call   1070 <strlen@plt>
add    -0x40(%rbp),%eax
cmp    $0x400,%eax
jle    148e <DoSubstitution+0x2ee>
jmp    1478 <DoSubstitution+0x2d8>
mov    -0x38(%rbp),%rdi
call   1040 <free@plt>
movq   $0x0,-0x8(%rbp)
jmp    1ba8 <DoSubstitution+0xa08>
mov    -0x38(%rbp),%rdi
movslq -0x40(%rbp),%rax
add    %rax,%rdi
mov    -0x18(%rbp),%rsi
call   1050 <strcpy@plt>
mov    -0x18(%rbp),%rdi
call   1070 <strlen@plt>
add    -0x40(%rbp),%eax
mov    %eax,-0x40(%rbp)
jmp    14b6 <DoSubstitution+0x316>
cmpq   $0x0,-0x28(%rbp)
je     14cb <DoSubstitution+0x32b>
mov    -0x28(%rbp),%rax
movl   $0x1,(%rax)
jmp    14eb <DoSubstitution+0x34b>
jmp    14d5 <DoSubstitution+0x335>
mov    -0x38(%rbp),%rdi
call   1040 <free@plt>
movq   $0x0,-0x8(%rbp)
jmp    1ba8 <DoSubstitution+0xa08>
jmp    1b88 <DoSubstitution+0x9e8>
jmp    14f5 <DoSubstitution+0x355>
lea    0xbd4(%rip),%rdi
call   1070 <strlen@plt>
add    -0x40(%rbp),%eax
cmp    $0x400,%eax
jle    152a <DoSubstitution+0x38a>
jmp    1514 <DoSubstitution+0x374>
mov    -0x38(%rbp),%rdi
call   1040 <free@plt>
movq   $0x0,-0x8(%rbp)
jmp    1ba8 <DoSubstitution+0xa08>
mov    -0x38(%rbp),%rdi
movslq -0x40(%rbp),%rax
add    %rax,%rdi
lea    0xb94(%rip),%rsi
call   1050 <strcpy@plt>
lea    0xb88(%rip),%rdi
call   1070 <strlen@plt>
add    -0x40(%rbp),%eax
mov    %eax,-0x40(%rbp)
jmp    1558 <DoSubstitution+0x3b8>
jmp    1b88 <DoSubstitution+0x9e8>
cmpq   $0x0,0x2b23(%rip)
jne    15d1 <DoSubstitution+0x431>
mov    $0x21,%edi
call   1090 <malloc@plt>
mov    %rax,0x2b0c(%rip)
cmp    $0x0,%rax
je     15cc <DoSubstitution+0x42c>
mov    0x2afb(%rip),%rdi
mov    $0x20,%esi
call   10b0 <gethostname@plt>
cmp    $0x0,%eax
jne    15b0 <DoSubstitution+0x410>
mov    0x2ae1(%rip),%rax
movb   $0x0,0x20(%rax)
jmp    15c7 <DoSubstitution+0x427>
mov    0x2ad1(%rip),%rdi
call   1040 <free@plt>
movq   $0x0,0x2ac1(%rip)
jmp    15cc <DoSubstitution+0x42c>
jmp    15d1 <DoSubstitution+0x431>
cmpq   $0x0,0x2aaf(%rip)
je     164c <DoSubstitution+0x4ac>
jmp    15e4 <DoSubstitution+0x444>
mov    0x2a9d(%rip),%rdi
call   1070 <strlen@plt>
add    -0x40(%rbp),%eax
cmp    $0x400,%eax
jle    1619 <DoSubstitution+0x479>
jmp    1603 <DoSubstitution+0x463>
mov    -0x38(%rbp),%rdi
call   1040 <free@plt>
movq   $0x0,-0x8(%rbp)
jmp    1ba8 <DoSubstitution+0xa08>
mov    -0x38(%rbp),%rdi
movslq -0x40(%rbp),%rax
add    %rax,%rdi
mov    0x2a5d(%rip),%rsi
call   1050 <strcpy@plt>
mov    0x2a51(%rip),%rdi
call   1070 <strlen@plt>
add    -0x40(%rbp),%eax
mov    %eax,-0x40(%rbp)
jmp    1647 <DoSubstitution+0x4a7>
jmp    164c <DoSubstitution+0x4ac>
jmp    1b88 <DoSubstitution+0x9e8>
cmpq   $0x0,0x2a1f(%rip)
jne    1672 <DoSubstitution+0x4d2>
lea    0xa75(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,0x2a06(%rip)
cmpq   $0x0,0x29fe(%rip)
je     1717 <DoSubstitution+0x577>
mov    0x29f1(%rip),%rdi
call   10a0 <xf86pathIsAbsolute@plt>
cmp    $0x0,%eax
je     1717 <DoSubstitution+0x577>
jmp    169a <DoSubstitution+0x4fa>
mov    0x29d7(%rip),%rdi
call   1070 <strlen@plt>
add    -0x40(%rbp),%eax
cmp    $0x400,%eax
jle    16cf <DoSubstitution+0x52f>
jmp    16b9 <DoSubstitution+0x519>
mov    -0x38(%rbp),%rdi
call   1040 <free@plt>
movq   $0x0,-0x8(%rbp)
jmp    1ba8 <DoSubstitution+0xa08>
mov    -0x38(%rbp),%rdi
movslq -0x40(%rbp),%rax
add    %rax,%rdi
mov    0x2997(%rip),%rsi
call   1050 <strcpy@plt>
mov    0x298b(%rip),%rdi
call   1070 <strlen@plt>
add    -0x40(%rbp),%eax
mov    %eax,-0x40(%rbp)
jmp    16fd <DoSubstitution+0x55d>
cmpq   $0x0,-0x30(%rbp)
je     1712 <DoSubstitution+0x572>
mov    -0x30(%rbp),%rax
movl   $0x1,(%rax)
jmp    1732 <DoSubstitution+0x592>
jmp    171c <DoSubstitution+0x57c>
mov    -0x38(%rbp),%rdi
call   1040 <free@plt>
movq   $0x0,-0x8(%rbp)
jmp    1ba8 <DoSubstitution+0xa08>
jmp    1b88 <DoSubstitution+0x9e8>
cmpq   $0x0,0x2939(%rip)
jne    1758 <DoSubstitution+0x5b8>
lea    0x98f(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,0x2920(%rip)
cmpq   $0x0,0x2918(%rip)
je     17fd <DoSubstitution+0x65d>
mov    0x290b(%rip),%rdi
call   10a0 <xf86pathIsAbsolute@plt>
cmp    $0x0,%eax
jne    17fd <DoSubstitution+0x65d>
jmp    1780 <DoSubstitution+0x5e0>
mov    0x28f1(%rip),%rdi
call   1070 <strlen@plt>
add    -0x40(%rbp),%eax
cmp    $0x400,%eax
jle    17b5 <DoSubstitution+0x615>
jmp    179f <DoSubstitution+0x5ff>
mov    -0x38(%rbp),%rdi
call   1040 <free@plt>
movq   $0x0,-0x8(%rbp)
jmp    1ba8 <DoSubstitution+0xa08>
mov    -0x38(%rbp),%rdi
movslq -0x40(%rbp),%rax
add    %rax,%rdi
mov    0x28b1(%rip),%rsi
call   1050 <strcpy@plt>
mov    0x28a5(%rip),%rdi
call   1070 <strlen@plt>
add    -0x40(%rbp),%eax
mov    %eax,-0x40(%rbp)
jmp    17e3 <DoSubstitution+0x643>
cmpq   $0x0,-0x30(%rbp)
je     17f8 <DoSubstitution+0x658>
mov    -0x30(%rbp),%rax
movl   $0x1,(%rax)
jmp    1818 <DoSubstitution+0x678>
jmp    1802 <DoSubstitution+0x662>
mov    -0x38(%rbp),%rdi
call   1040 <free@plt>
movq   $0x0,-0x8(%rbp)
jmp    1ba8 <DoSubstitution+0xa08>
jmp    1b88 <DoSubstitution+0x9e8>
cmpq   $0x0,0x2853(%rip)
jne    183e <DoSubstitution+0x69e>
lea    0x8a9(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,0x283a(%rip)
cmpq   $0x0,0x2832(%rip)
je     18e3 <DoSubstitution+0x743>
mov    0x2825(%rip),%rdi
call   1060 <xf86pathIsSafe@plt>
cmp    $0x0,%eax
je     18e3 <DoSubstitution+0x743>
jmp    1866 <DoSubstitution+0x6c6>
mov    0x280b(%rip),%rdi
call   1070 <strlen@plt>
add    -0x40(%rbp),%eax
cmp    $0x400,%eax
jle    189b <DoSubstitution+0x6fb>
jmp    1885 <DoSubstitution+0x6e5>
mov    -0x38(%rbp),%rdi
call   1040 <free@plt>
movq   $0x0,-0x8(%rbp)
jmp    1ba8 <DoSubstitution+0xa08>
mov    -0x38(%rbp),%rdi
movslq -0x40(%rbp),%rax
add    %rax,%rdi
mov    0x27cb(%rip),%rsi
call   1050 <strcpy@plt>
mov    0x27bf(%rip),%rdi
call   1070 <strlen@plt>
add    -0x40(%rbp),%eax
mov    %eax,-0x40(%rbp)
jmp    18c9 <DoSubstitution+0x729>
cmpq   $0x0,-0x30(%rbp)
je     18de <DoSubstitution+0x73e>
mov    -0x30(%rbp),%rax
movl   $0x1,(%rax)
jmp    18fe <DoSubstitution+0x75e>
jmp    18e8 <DoSubstitution+0x748>
mov    -0x38(%rbp),%rdi
call   1040 <free@plt>
movq   $0x0,-0x8(%rbp)
jmp    1ba8 <DoSubstitution+0xa08>
jmp    1b88 <DoSubstitution+0x9e8>
cmpq   $0x0,0x2775(%rip)
jne    1924 <DoSubstitution+0x784>
lea    0x7ce(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,0x275c(%rip)
cmpq   $0x0,0x2754(%rip)
je     19b4 <DoSubstitution+0x814>
mov    0x2747(%rip),%rdi
call   10a0 <xf86pathIsAbsolute@plt>
cmp    $0x0,%eax
je     19b4 <DoSubstitution+0x814>
jmp    194c <DoSubstitution+0x7ac>
mov    0x272d(%rip),%rdi
call   1070 <strlen@plt>
add    -0x40(%rbp),%eax
cmp    $0x400,%eax
jle    1981 <DoSubstitution+0x7e1>
jmp    196b <DoSubstitution+0x7cb>
mov    -0x38(%rbp),%rdi
call   1040 <free@plt>
movq   $0x0,-0x8(%rbp)
jmp    1ba8 <DoSubstitution+0xa08>
mov    -0x38(%rbp),%rdi
movslq -0x40(%rbp),%rax
add    %rax,%rdi
mov    0x26ed(%rip),%rsi
call   1050 <strcpy@plt>
mov    0x26e1(%rip),%rdi
call   1070 <strlen@plt>
add    -0x40(%rbp),%eax
mov    %eax,-0x40(%rbp)
jmp    19af <DoSubstitution+0x80f>
jmp    19cf <DoSubstitution+0x82f>
jmp    19b9 <DoSubstitution+0x819>
mov    -0x38(%rbp),%rdi
call   1040 <free@plt>
movq   $0x0,-0x8(%rbp)
jmp    1ba8 <DoSubstitution+0xa08>
jmp    1b88 <DoSubstitution+0x9e8>
cmpq   $0x0,-0x20(%rbp)
je     1a55 <DoSubstitution+0x8b5>
mov    -0x20(%rbp),%rdi
call   10a0 <xf86pathIsAbsolute@plt>
cmp    $0x0,%eax
je     1a55 <DoSubstitution+0x8b5>
jmp    19f6 <DoSubstitution+0x856>
mov    -0x20(%rbp),%rdi
call   1070 <strlen@plt>
add    -0x40(%rbp),%eax
cmp    $0x400,%eax
jle    1a28 <DoSubstitution+0x888>
jmp    1a12 <DoSubstitution+0x872>
mov    -0x38(%rbp),%rdi
call   1040 <free@plt>
movq   $0x0,-0x8(%rbp)
jmp    1ba8 <DoSubstitution+0xa08>
mov    -0x38(%rbp),%rdi
movslq -0x40(%rbp),%rax
add    %rax,%rdi
mov    -0x20(%rbp),%rsi
call   1050 <strcpy@plt>
mov    -0x20(%rbp),%rdi
call   1070 <strlen@plt>
add    -0x40(%rbp),%eax
mov    %eax,-0x40(%rbp)
jmp    1a50 <DoSubstitution+0x8b0>
jmp    1a70 <DoSubstitution+0x8d0>
jmp    1a5a <DoSubstitution+0x8ba>
mov    -0x38(%rbp),%rdi
call   1040 <free@plt>
movq   $0x0,-0x8(%rbp)
jmp    1ba8 <DoSubstitution+0xa08>
jmp    1b88 <DoSubstitution+0x9e8>
cmpb   $0x0,0x2614(%rip)
jne    1a9a <DoSubstitution+0x8fa>
lea    0x2607(%rip),%rdi
lea    0x65b(%rip),%rsi
mov    $0x4,%edx
call   10c0 <sprintf@plt>
jmp    1a9f <DoSubstitution+0x8ff>
lea    0x25ea(%rip),%rdi
call   1070 <strlen@plt>
add    -0x40(%rbp),%eax
cmp    $0x400,%eax
jle    1ad4 <DoSubstitution+0x934>
jmp    1abe <DoSubstitution+0x91e>
mov    -0x38(%rbp),%rdi
call   1040 <free@plt>
movq   $0x0,-0x8(%rbp)
jmp    1ba8 <DoSubstitution+0xa08>
mov    -0x38(%rbp),%rdi
movslq -0x40(%rbp),%rax
add    %rax,%rdi
lea    0x25aa(%rip),%rsi
call   1050 <strcpy@plt>
lea    0x259e(%rip),%rdi
call   1070 <strlen@plt>
add    -0x40(%rbp),%eax
mov    %eax,-0x40(%rbp)
jmp    1b02 <DoSubstitution+0x962>
jmp    1b88 <DoSubstitution+0x9e8>
mov    -0x38(%rbp),%rax
mov    -0x40(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x40(%rbp)
movslq %ecx,%rcx
movb   $0x25,(%rax,%rcx,1)
cmpl   $0x400,-0x40(%rbp)
jle    1b45 <DoSubstitution+0x9a5>
jmp    1b2f <DoSubstitution+0x98f>
mov    -0x38(%rbp),%rdi
call   1040 <free@plt>
movq   $0x0,-0x8(%rbp)
jmp    1ba8 <DoSubstitution+0xa08>
jmp    1b4a <DoSubstitution+0x9aa>
jmp    1b88 <DoSubstitution+0x9e8>
mov    0x248a(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsbl (%rax,%rcx,1),%edx
lea    0x583(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x38(%rbp),%rdi
call   1040 <free@plt>
movq   $0x0,-0x8(%rbp)
jmp    1ba8 <DoSubstitution+0xa08>
jmp    1b8d <DoSubstitution+0x9ed>
jmp    1b92 <DoSubstitution+0x9f2>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    121a <DoSubstitution+0x7a>
mov    -0x38(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<DoSubstitution>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rsi,0x10(%rsp)
test   %rdi,%rdi
je     1655 <DoSubstitution+0x4b5>
mov    %rdi,%r13
test   %rcx,%rcx
je     11ca <DoSubstitution+0x2a>
movl   $0x0,(%rcx)
mov    %rdx,0x28(%rsp)
mov    %rcx,0x18(%rsp)
test   %r8,%r8
je     11e0 <DoSubstitution+0x40>
movl   $0x0,(%r8)
mov    %r8,0x20(%rsp)
mov    $0x401,%edi
call   1090 <malloc@plt>
mov    %rax,0x8(%rsp)
xor    %r15d,%r15d
lea    0xe02(%rip),%rbx
lea    0x2e8b(%rip),%r12
xor    %r14d,%r14d
jmp    121e <DoSubstitution+0x7e>
movl   $0x1,(%rcx)
lea    0x2e79(%rip),%r12
add    $0x1,%r15d
mov    %eax,%r14d
movslq %r15d,%rax
movzbl 0x0(%r13,%rax,1),%ecx
cmp    $0x25,%cl
je     1260 <DoSubstitution+0xc0>
test   %cl,%cl
je     165c <DoSubstitution+0x4bc>
movslq %r14d,%rax
mov    0x8(%rsp),%rdx
mov    %cl,(%rdx,%rax,1)
cmp    $0x400,%r14d
jge    164b <DoSubstitution+0x4ab>
add    $0x1,%r14d
mov    %r14d,%eax
jmp    1217 <DoSubstitution+0x77>
cs nopw 0x0(%rax,%rax,1)
nop
movsbl 0x1(%r13,%rax,1),%edx
lea    -0x25(%rdx),%ecx
cmp    $0x33,%ecx
ja     1634 <DoSubstitution+0x494>
add    $0x1,%rax
mov    %eax,%r15d
movslq (%rbx,%rcx,4),%rax
add    %rbx,%rax
jmp    *%rax
movslq %r14d,%rax
mov    0x8(%rsp),%rcx
movb   $0x25,(%rcx,%rax,1)
cmp    $0x400,%r14d
jl     124c <DoSubstitution+0xac>
jmp    164b <DoSubstitution+0x4ab>
cmpq   $0x0,0x10(%rsp)
je     164b <DoSubstitution+0x4ab>
mov    0x10(%rsp),%rdi
call   10a0 <xf86pathIsAbsolute@plt>
jmp    1555 <DoSubstitution+0x3b5>
mov    0x2dc2(%rip),%rax
test   %rax,%rax
jne    12df <DoSubstitution+0x13f>
lea    0xe1c(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,0x2daa(%rip)
test   %rax,%rax
je     164b <DoSubstitution+0x4ab>
mov    %rax,%rdi
call   10a0 <xf86pathIsAbsolute@plt>
test   %eax,%eax
je     164b <DoSubstitution+0x4ab>
mov    0x2d8a(%rip),%rdi
call   1070 <strlen@plt>
add    %r14d,%eax
cmp    $0x401,%eax
jge    164b <DoSubstitution+0x4ab>
movslq %r14d,%rdi
add    0x8(%rsp),%rdi
mov    0x2d68(%rip),%rsi
call   1050 <strcpy@plt>
mov    0x2d5c(%rip),%rdi
jmp    15d8 <DoSubstitution+0x438>
mov    0x2d48(%rip),%rax
test   %rax,%rax
jne    1351 <DoSubstitution+0x1b1>
lea    0xd9f(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,0x2d30(%rip)
test   %rax,%rax
je     164b <DoSubstitution+0x4ab>
mov    %rax,%rdi
call   10a0 <xf86pathIsAbsolute@plt>
jmp    13c4 <DoSubstitution+0x224>
mov    0x2d16(%rip),%rax
test   %rax,%rax
jne    1383 <DoSubstitution+0x1e3>
lea    0xd6d(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,0x2cfe(%rip)
test   %rax,%rax
je     164b <DoSubstitution+0x4ab>
mov    %rax,%rdi
call   10a0 <xf86pathIsAbsolute@plt>
test   %eax,%eax
je     13cc <DoSubstitution+0x22c>
jmp    164b <DoSubstitution+0x4ab>
mov    0x2cdd(%rip),%rax
test   %rax,%rax
jne    13bc <DoSubstitution+0x21c>
lea    0xd34(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,0x2cc5(%rip)
test   %rax,%rax
je     164b <DoSubstitution+0x4ab>
mov    %rax,%rdi
call   1060 <xf86pathIsSafe@plt>
test   %eax,%eax
je     164b <DoSubstitution+0x4ab>
mov    0x2ca5(%rip),%rdi
call   1070 <strlen@plt>
add    %r14d,%eax
cmp    $0x401,%eax
jge    164b <DoSubstitution+0x4ab>
movslq %r14d,%rdi
add    0x8(%rsp),%rdi
mov    0x2c83(%rip),%rsi
call   1050 <strcpy@plt>
mov    0x2c77(%rip),%rdi
call   1070 <strlen@plt>
add    %r14d,%eax
mov    0x20(%rsp),%rcx
test   %rcx,%rcx
jne    120a <DoSubstitution+0x6a>
jmp    1210 <DoSubstitution+0x70>
mov    0x2c65(%rip),%rdi
test   %rdi,%rdi
je     15e5 <DoSubstitution+0x445>
call   1070 <strlen@plt>
add    %r14d,%eax
cmp    $0x401,%eax
jge    164b <DoSubstitution+0x4ab>
movslq %r14d,%rdi
add    0x8(%rsp),%rdi
mov    0x2c3a(%rip),%rsi
call   1050 <strcpy@plt>
mov    0x2c2e(%rip),%rdi
jmp    15d8 <DoSubstitution+0x438>
cmpb   $0x0,0x2c2a(%rip)
jne    1487 <DoSubstitution+0x2e7>
lea    0x2c21(%rip),%rdi
lea    0xc75(%rip),%rsi
mov    $0x4,%edx
call   10c0 <sprintf@plt>
lea    0x2c09(%rip),%r12
mov    %r12,%rdi
call   1070 <strlen@plt>
add    %r14d,%eax
cmp    $0x401,%eax
jge    164b <DoSubstitution+0x4ab>
movslq %r14d,%rdi
add    0x8(%rsp),%rdi
mov    %r12,%rsi
call   1050 <strcpy@plt>
mov    %r12,%rdi
call   1070 <strlen@plt>
add    %r14d,%eax
jmp    1217 <DoSubstitution+0x77>
mov    0x28(%rsp),%rdi
test   %rdi,%rdi
je     164b <DoSubstitution+0x4ab>
call   10a0 <xf86pathIsAbsolute@plt>
mov    0x28(%rsp),%r12
test   %eax,%eax
je     164b <DoSubstitution+0x4ab>
mov    %r13,0x30(%rsp)
mov    0x8(%rsp),%r13
mov    %r12,%rdi
call   1070 <strlen@plt>
add    %r14d,%eax
cmp    $0x401,%eax
jge    1670 <DoSubstitution+0x4d0>
movslq %r14d,%rdi
add    %r13,%rdi
mov    %r12,%rsi
call   1050 <strcpy@plt>
mov    %r12,%rdi
call   1070 <strlen@plt>
add    %r14d,%eax
mov    0x30(%rsp),%r13
jmp    1210 <DoSubstitution+0x70>
cmpq   $0x0,0x10(%rsp)
je     164b <DoSubstitution+0x4ab>
mov    0x10(%rsp),%rdi
call   10a0 <xf86pathIsAbsolute@plt>
test   %eax,%eax
je     155d <DoSubstitution+0x3bd>
jmp    164b <DoSubstitution+0x4ab>
cmpq   $0x0,0x10(%rsp)
je     164b <DoSubstitution+0x4ab>
mov    0x10(%rsp),%rdi
call   1060 <xf86pathIsSafe@plt>
test   %eax,%eax
je     164b <DoSubstitution+0x4ab>
mov    0x10(%rsp),%rdi
call   1070 <strlen@plt>
add    %r14d,%eax
cmp    $0x401,%eax
jge    164b <DoSubstitution+0x4ab>
movslq %r14d,%rdi
add    0x8(%rsp),%rdi
mov    0x10(%rsp),%rbp
mov    %rbp,%rsi
call   1050 <strcpy@plt>
mov    %rbp,%rdi
call   1070 <strlen@plt>
add    %r14d,%eax
mov    0x18(%rsp),%rcx
test   %rcx,%rcx
jne    120a <DoSubstitution+0x6a>
jmp    1210 <DoSubstitution+0x70>
lea    0xb21(%rip),%rbp
mov    %rbp,%rdi
call   1070 <strlen@plt>
add    %r14d,%eax
cmp    $0x401,%eax
jge    164b <DoSubstitution+0x4ab>
movslq %r14d,%rdi
add    0x8(%rsp),%rdi
mov    %rbp,%rsi
call   1050 <strcpy@plt>
mov    %rbp,%rdi
call   1070 <strlen@plt>
add    %r14d,%eax
jmp    1210 <DoSubstitution+0x70>
mov    $0x21,%edi
call   1090 <malloc@plt>
mov    %rax,0x2a92(%rip)
test   %rax,%rax
je     1623 <DoSubstitution+0x483>
mov    %rax,%rdi
mov    $0x20,%esi
call   10b0 <gethostname@plt>
mov    0x2a79(%rip),%rdi
test   %eax,%eax
je     162b <DoSubstitution+0x48b>
call   1040 <free@plt>
movq   $0x0,0x2a65(%rip)
mov    %r14d,%eax
jmp    1210 <DoSubstitution+0x70>
movb   $0x0,0x20(%rdi)
jmp    142c <DoSubstitution+0x28c>
mov    0x29a5(%rip),%rax
mov    (%rax),%edi
lea    0xaaa(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    0x8(%rsp),%rdi
call   1040 <free@plt>
xor    %eax,%eax
mov    %rax,0x8(%rsp)
mov    0x8(%rsp),%rax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %r13,%rdi
jmp    1650 <DoSubstitution+0x4b0>

LLVM IR (-O0):
@DoSubstitution.env = internal global i8* null
@DoSubstitution.home = internal global i8* null
@DoSubstitution.hostname = internal global i8* null
@DoSubstitution.majorvers = internal global [3 x i8] zeroinitializer
@.str = [11 x i8] c"XF86Config\00"
@.str.1 = [11 x i8] c"XF86CONFIG\00"
@.str.2 = [5 x i8] c"HOME\00"
@.str.3 = [3 x i8] c"%d\00"
@stderr = global i32 0
@.str.4 = [44 x i8] c"invalid escape %%%c found in path template\0A\00"
define i8* @DoSubstitution(i8* %0, i8* %1, i8* %2, i32* %3, i32* %4) {
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32*
%11 = alloca i32*
%12 = alloca i8*
%13 = alloca i32
%14 = alloca i32
store i8* %0, i8** %7
store i8* %1, i8** %8
store i8* %2, i8** %9
store i32* %3, i32** %10
store i32* %4, i32** %11
%15 = load i8*, i8** %7
%16 = icmp ne i8* %15, null
br i1 %16, label %18, label %17
17: ; preds = %5
store i8* null, i8** %6
br label %560
18: ; preds = %5
%19 = load i32*, i32** %10
%20 = icmp ne i32* %19, null
br i1 %20, label %21, label %23
21: ; preds = %18
%22 = load i32*, i32** %10
store i32 0, i32* %22
br label %23
23: ; preds = %21, %18
%24 = load i32*, i32** %11
%25 = icmp ne i32* %24, null
br i1 %25, label %26, label %28
26: ; preds = %23
%27 = load i32*, i32** %11
store i32 0, i32* %27
br label %28
28: ; preds = %26, %23
%29 = call i8* @malloc(i32 1025)
store i8* %29, i8** %12
store i32 0, i32* %14
store i32 0, i32* %13
br label %30
30: ; preds = %555, %28
%31 = load i8*, i8** %7
%32 = load i32, i32* %13
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8, i8* %31, i64 %33
%35 = load i8, i8* %34
%36 = icmp ne i8 %35, 0
br i1 %36, label %37, label %558
37: ; preds = %30
%38 = load i8*, i8** %7
%39 = load i32, i32* %13
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i8, i8* %38, i64 %40
%42 = load i8, i8* %41
%43 = sext i8 %42 to i32
%44 = icmp ne i32 %43, 37
br i1 %44, label %45, label %66
45: ; preds = %37
%46 = load i8*, i8** %7
%47 = load i32, i32* %13
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i8, i8* %46, i64 %48
%50 = load i8, i8* %49
%51 = load i8*, i8** %12
%52 = load i32, i32* %14
%53 = add nsw i32 %52, 1
store i32 %53, i32* %14
%54 = sext i32 %52 to i64
%55 = getelementptr inbounds i8, i8* %51, i64 %54
store i8 %50, i8* %55
br label %56
56: ; preds = %45
%57 = load i32, i32* %14
%58 = icmp sgt i32 %57, 1024
br i1 %58, label %59, label %64
59: ; preds = %56
br label %60
60: ; preds = %59
%61 = load i8*, i8** %12
%62 = call i32 @free(i8* %61)
store i8* null, i8** %6
br label %560
63: ; No predecessors!
br label %64
64: ; preds = %63, %56
br label %65
65: ; preds = %64
br label %554
66: ; preds = %37
%67 = load i8*, i8** %7
%68 = load i32, i32* %13
%69 = add nsw i32 %68, 1
store i32 %69, i32* %13
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds i8, i8* %67, i64 %70
%72 = load i8, i8* %71
%73 = sext i8 %72 to i32
switch i32 %73, label %540 [
i32 65, label %74
i32 82, label %117
i32 83, label %160
i32 88, label %203
i32 72, label %225
i32 69, label %272
i32 70, label %320
i32 71, label %368
i32 68, label %416
i32 80, label %459
i32 77, label %497
i32 37, label %524
]
74: ; preds = %66
%75 = load i8*, i8** %8
%76 = icmp ne i8* %75, null
br i1 %76, label %77, label %111
77: ; preds = %74
%78 = load i8*, i8** %8
%79 = call i32 @xf86pathIsAbsolute(i8* %78)
%80 = icmp ne i32 %79, 0
br i1 %80, label %81, label %111
81: ; preds = %77
br label %82
82: ; preds = %81
%83 = load i8*, i8** %8
%84 = call i32 @strlen(i8* %83)
%85 = load i32, i32* %14
%86 = add nsw i32 %84, %85
%87 = icmp sgt i32 %86, 1024
br i1 %87, label %88, label %93
88: ; preds = %82
br label %89
89: ; preds = %88
%90 = load i8*, i8** %12
%91 = call i32 @free(i8* %90)
store i8* null, i8** %6
br label %560
92: ; No predecessors!
br label %104
93: ; preds = %82
%94 = load i8*, i8** %12
%95 = load i32, i32* %14
%96 = sext i32 %95 to i64
%97 = getelementptr inbounds i8, i8* %94, i64 %96
%98 = load i8*, i8** %8
%99 = call i32 @strcpy(i8* %97, i8* %98)
%100 = load i8*, i8** %8
%101 = call i32 @strlen(i8* %100)
%102 = load i32, i32* %14
%103 = add nsw i32 %102, %101
store i32 %103, i32* %14
br label %104
104: ; preds = %93, %92
br label %105
105: ; preds = %104
%106 = load i32*, i32** %10
%107 = icmp ne i32* %106, null
br i1 %107, label %108, label %110
108: ; preds = %105
%109 = load i32*, i32** %10
store i32 1, i32* %109
br label %110
110: ; preds = %108, %105
br label %116
111: ; preds = %77, %74
br label %112
112: ; preds = %111
%113 = load i8*, i8** %12
%114 = call i32 @free(i8* %113)
store i8* null, i8** %6
br label %560
115: ; No predecessors!
br label %116
116: ; preds = %115, %110
br label %553
117: ; preds = %66
%118 = load i8*, i8** %8
%119 = icmp ne i8* %118, null
br i1 %119, label %120, label %154
120: ; preds = %117
%121 = load i8*, i8** %8
%122 = call i32 @xf86pathIsAbsolute(i8* %121)
%123 = icmp ne i32 %122, 0
br i1 %123, label %154, label %124
124: ; preds = %120
br label %125
125: ; preds = %124
%126 = load i8*, i8** %8
%127 = call i32 @strlen(i8* %126)
%128 = load i32, i32* %14
%129 = add nsw i32 %127, %128
%130 = icmp sgt i32 %129, 1024
br i1 %130, label %131, label %136
131: ; preds = %125
br label %132
132: ; preds = %131
%133 = load i8*, i8** %12
%134 = call i32 @free(i8* %133)
store i8* null, i8** %6
br label %560
135: ; No predecessors!
br label %147
136: ; preds = %125
%137 = load i8*, i8** %12
%138 = load i32, i32* %14
%139 = sext i32 %138 to i64
%140 = getelementptr inbounds i8, i8* %137, i64 %139
%141 = load i8*, i8** %8
%142 = call i32 @strcpy(i8* %140, i8* %141)
%143 = load i8*, i8** %8
%144 = call i32 @strlen(i8* %143)
%145 = load i32, i32* %14
%146 = add nsw i32 %145, %144
store i32 %146, i32* %14
br label %147
147: ; preds = %136, %135
br label %148
148: ; preds = %147
%149 = load i32*, i32** %10
%150 = icmp ne i32* %149, null
br i1 %150, label %151, label %153
151: ; preds = %148
%152 = load i32*, i32** %10
store i32 1, i32* %152
br label %153
153: ; preds = %151, %148
br label %159
154: ; preds = %120, %117
br label %155
155: ; preds = %154
%156 = load i8*, i8** %12
%157 = call i32 @free(i8* %156)
store i8* null, i8** %6
br label %560
158: ; No predecessors!
br label %159
159: ; preds = %158, %153
br label %553
160: ; preds = %66
%161 = load i8*, i8** %8
%162 = icmp ne i8* %161, null
br i1 %162, label %163, label %197
163: ; preds = %160
%164 = load i8*, i8** %8
%165 = call i32 @xf86pathIsSafe(i8* %164)
%166 = icmp ne i32 %165, 0
br i1 %166, label %167, label %197
167: ; preds = %163
br label %168
168: ; preds = %167
%169 = load i8*, i8** %8
%170 = call i32 @strlen(i8* %169)
%171 = load i32, i32* %14
%172 = add nsw i32 %170, %171
%173 = icmp sgt i32 %172, 1024
br i1 %173, label %174, label %179
174: ; preds = %168
br label %175
175: ; preds = %174
%176 = load i8*, i8** %12
%177 = call i32 @free(i8* %176)
store i8* null, i8** %6
br label %560
178: ; No predecessors!
br label %190
179: ; preds = %168
%180 = load i8*, i8** %12
%181 = load i32, i32* %14
%182 = sext i32 %181 to i64
%183 = getelementptr inbounds i8, i8* %180, i64 %182
%184 = load i8*, i8** %8
%185 = call i32 @strcpy(i8* %183, i8* %184)
%186 = load i8*, i8** %8
%187 = call i32 @strlen(i8* %186)
%188 = load i32, i32* %14
%189 = add nsw i32 %188, %187
store i32 %189, i32* %14
br label %190
190: ; preds = %179, %178
br label %191
191: ; preds = %190
%192 = load i32*, i32** %10
%193 = icmp ne i32* %192, null
br i1 %193, label %194, label %196
194: ; preds = %191
%195 = load i32*, i32** %10
store i32 1, i32* %195
br label %196
196: ; preds = %194, %191
br label %202
197: ; preds = %163, %160
br label %198
198: ; preds = %197
%199 = load i8*, i8** %12
%200 = call i32 @free(i8* %199)
store i8* null, i8** %6
br label %560
201: ; No predecessors!
br label %202
202: ; preds = %201, %196
br label %553
203: ; preds = %66
br label %204
204: ; preds = %203
%205 = call i32 @strlen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%206 = load i32, i32* %14
%207 = add nsw i32 %205, %206
%208 = icmp sgt i32 %207, 1024
br i1 %208, label %209, label %214
209: ; preds = %204
br label %210
210: ; preds = %209
%211 = load i8*, i8** %12
%212 = call i32 @free(i8* %211)
store i8* null, i8** %6
br label %560
213: ; No predecessors!
br label %223
214: ; preds = %204
%215 = load i8*, i8** %12
%216 = load i32, i32* %14
%217 = sext i32 %216 to i64
%218 = getelementptr inbounds i8, i8* %215, i64 %217
%219 = call i32 @strcpy(i8* %218, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%220 = call i32 @strlen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%221 = load i32, i32* %14
%222 = add nsw i32 %221, %220
store i32 %222, i32* %14
br label %223
223: ; preds = %214, %213
br label %224
224: ; preds = %223
br label %553
225: ; preds = %66
%226 = load i8*, i8** @DoSubstitution.hostname
%227 = icmp ne i8* %226, null
br i1 %227, label %243, label %228
228: ; preds = %225
%229 = call i8* @malloc(i32 33)
store i8* %229, i8** @DoSubstitution.hostname
%230 = icmp ne i8* %229, null
br i1 %230, label %231, label %242
231: ; preds = %228
%232 = load i8*, i8** @DoSubstitution.hostname
%233 = call i32 @gethostname(i8* %232, i32 32)
%234 = icmp eq i32 %233, 0
br i1 %234, label %235, label %238
235: ; preds = %231
%236 = load i8*, i8** @DoSubstitution.hostname
%237 = getelementptr inbounds i8, i8* %236, i64 32
store i8 0, i8* %237
br label %241
238: ; preds = %231
%239 = load i8*, i8** @DoSubstitution.hostname
%240 = call i32 @free(i8* %239)
store i8* null, i8** @DoSubstitution.hostname
br label %241
241: ; preds = %238, %235
br label %242
242: ; preds = %241, %228
br label %243
243: ; preds = %242, %225
%244 = load i8*, i8** @DoSubstitution.hostname
%245 = icmp ne i8* %244, null
br i1 %245, label %246, label %271
246: ; preds = %243
br label %247
247: ; preds = %246
%248 = load i8*, i8** @DoSubstitution.hostname
%249 = call i32 @strlen(i8* %248)
%250 = load i32, i32* %14
%251 = add nsw i32 %249, %250
%252 = icmp sgt i32 %251, 1024
br i1 %252, label %253, label %258
253: ; preds = %247
br label %254
254: ; preds = %253
%255 = load i8*, i8** %12
%256 = call i32 @free(i8* %255)
store i8* null, i8** %6
br label %560
257: ; No predecessors!
br label %269
258: ; preds = %247
%259 = load i8*, i8** %12
%260 = load i32, i32* %14
%261 = sext i32 %260 to i64
%262 = getelementptr inbounds i8, i8* %259, i64 %261
%263 = load i8*, i8** @DoSubstitution.hostname
%264 = call i32 @strcpy(i8* %262, i8* %263)
%265 = load i8*, i8** @DoSubstitution.hostname
%266 = call i32 @strlen(i8* %265)
%267 = load i32, i32* %14
%268 = add nsw i32 %267, %266
store i32 %268, i32* %14
br label %269
269: ; preds = %258, %257
br label %270
270: ; preds = %269
br label %271
271: ; preds = %270, %243
br label %553
272: ; preds = %66
%273 = load i8*, i8** @DoSubstitution.env
%274 = icmp ne i8* %273, null
br i1 %274, label %277, label %275
275: ; preds = %272
%276 = call i8* @getenv(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
store i8* %276, i8** @DoSubstitution.env
br label %277
277: ; preds = %275, %272
%278 = load i8*, i8** @DoSubstitution.env
%279 = icmp ne i8* %278, null
br i1 %279, label %280, label %314
280: ; preds = %277
%281 = load i8*, i8** @DoSubstitution.env
%282 = call i32 @xf86pathIsAbsolute(i8* %281)
%283 = icmp ne i32 %282, 0
br i1 %283, label %284, label %314
284: ; preds = %280
br label %285
285: ; preds = %284
%286 = load i8*, i8** @DoSubstitution.env
%287 = call i32 @strlen(i8* %286)
%288 = load i32, i32* %14
%289 = add nsw i32 %287, %288
%290 = icmp sgt i32 %289, 1024
br i1 %290, label %291, label %296
291: ; preds = %285
br label %292
292: ; preds = %291
%293 = load i8*, i8** %12
%294 = call i32 @free(i8* %293)
store i8* null, i8** %6
br label %560
295: ; No predecessors!
br label %307
296: ; preds = %285
%297 = load i8*, i8** %12
%298 = load i32, i32* %14
%299 = sext i32 %298 to i64
%300 = getelementptr inbounds i8, i8* %297, i64 %299
%301 = load i8*, i8** @DoSubstitution.env
%302 = call i32 @strcpy(i8* %300, i8* %301)
%303 = load i8*, i8** @DoSubstitution.env
%304 = call i32 @strlen(i8* %303)
%305 = load i32, i32* %14
%306 = add nsw i32 %305, %304
store i32 %306, i32* %14
br label %307
307: ; preds = %296, %295
br label %308
308: ; preds = %307
%309 = load i32*, i32** %11
%310 = icmp ne i32* %309, null
br i1 %310, label %311, label %313
311: ; preds = %308
%312 = load i32*, i32** %11
store i32 1, i32* %312
br label %313
313: ; preds = %311, %308
br label %319
314: ; preds = %280, %277
br label %315
315: ; preds = %314
%316 = load i8*, i8** %12
%317 = call i32 @free(i8* %316)
store i8* null, i8** %6
br label %560
318: ; No predecessors!
br label %319
319: ; preds = %318, %313
br label %553
320: ; preds = %66
%321 = load i8*, i8** @DoSubstitution.env
%322 = icmp ne i8* %321, null
br i1 %322, label %325, label %323
323: ; preds = %320
%324 = call i8* @getenv(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
store i8* %324, i8** @DoSubstitution.env
br label %325
325: ; preds = %323, %320
%326 = load i8*, i8** @DoSubstitution.env
%327 = icmp ne i8* %326, null
br i1 %327, label %328, label %362
328: ; preds = %325
%329 = load i8*, i8** @DoSubstitution.env
%330 = call i32 @xf86pathIsAbsolute(i8* %329)
%331 = icmp ne i32 %330, 0
br i1 %331, label %362, label %332
332: ; preds = %328
br label %333
333: ; preds = %332
%334 = load i8*, i8** @DoSubstitution.env
%335 = call i32 @strlen(i8* %334)
%336 = load i32, i32* %14
%337 = add nsw i32 %335, %336
%338 = icmp sgt i32 %337, 1024
br i1 %338, label %339, label %344
339: ; preds = %333
br label %340
340: ; preds = %339
%341 = load i8*, i8** %12
%342 = call i32 @free(i8* %341)
store i8* null, i8** %6
br label %560
343: ; No predecessors!
br label %355
344: ; preds = %333
%345 = load i8*, i8** %12
%346 = load i32, i32* %14
%347 = sext i32 %346 to i64
%348 = getelementptr inbounds i8, i8* %345, i64 %347
%349 = load i8*, i8** @DoSubstitution.env
%350 = call i32 @strcpy(i8* %348, i8* %349)
%351 = load i8*, i8** @DoSubstitution.env
%352 = call i32 @strlen(i8* %351)
%353 = load i32, i32* %14
%354 = add nsw i32 %353, %352
store i32 %354, i32* %14
br label %355
355: ; preds = %344, %343
br label %356
356: ; preds = %355
%357 = load i32*, i32** %11
%358 = icmp ne i32* %357, null
br i1 %358, label %359, label %361
359: ; preds = %356
%360 = load i32*, i32** %11
store i32 1, i32* %360
br label %361
361: ; preds = %359, %356
br label %367
362: ; preds = %328, %325
br label %363
363: ; preds = %362
%364 = load i8*, i8** %12
%365 = call i32 @free(i8* %364)
store i8* null, i8** %6
br label %560
366: ; No predecessors!
br label %367
367: ; preds = %366, %361
br label %553
368: ; preds = %66
%369 = load i8*, i8** @DoSubstitution.env
%370 = icmp ne i8* %369, null
br i1 %370, label %373, label %371
371: ; preds = %368
%372 = call i8* @getenv(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
store i8* %372, i8** @DoSubstitution.env
br label %373
373: ; preds = %371, %368
%374 = load i8*, i8** @DoSubstitution.env
%375 = icmp ne i8* %374, null
br i1 %375, label %376, label %410
376: ; preds = %373
%377 = load i8*, i8** @DoSubstitution.env
%378 = call i32 @xf86pathIsSafe(i8* %377)
%379 = icmp ne i32 %378, 0
br i1 %379, label %380, label %410
380: ; preds = %376
br label %381
381: ; preds = %380
%382 = load i8*, i8** @DoSubstitution.env
%383 = call i32 @strlen(i8* %382)
%384 = load i32, i32* %14
%385 = add nsw i32 %383, %384
%386 = icmp sgt i32 %385, 1024
br i1 %386, label %387, label %392
387: ; preds = %381
br label %388
388: ; preds = %387
%389 = load i8*, i8** %12
%390 = call i32 @free(i8* %389)
store i8* null, i8** %6
br label %560
391: ; No predecessors!
br label %403
392: ; preds = %381
%393 = load i8*, i8** %12
%394 = load i32, i32* %14
%395 = sext i32 %394 to i64
%396 = getelementptr inbounds i8, i8* %393, i64 %395
%397 = load i8*, i8** @DoSubstitution.env
%398 = call i32 @strcpy(i8* %396, i8* %397)
%399 = load i8*, i8** @DoSubstitution.env
%400 = call i32 @strlen(i8* %399)
%401 = load i32, i32* %14
%402 = add nsw i32 %401, %400
store i32 %402, i32* %14
br label %403
403: ; preds = %392, %391
br label %404
404: ; preds = %403
%405 = load i32*, i32** %11
%406 = icmp ne i32* %405, null
br i1 %406, label %407, label %409
407: ; preds = %404
%408 = load i32*, i32** %11
store i32 1, i32* %408
br label %409
409: ; preds = %407, %404
br label %415
410: ; preds = %376, %373
br label %411
411: ; preds = %410
%412 = load i8*, i8** %12
%413 = call i32 @free(i8* %412)
store i8* null, i8** %6
br label %560
414: ; No predecessors!
br label %415
415: ; preds = %414, %409
br label %553
416: ; preds = %66
%417 = load i8*, i8** @DoSubstitution.home
%418 = icmp ne i8* %417, null
br i1 %418, label %421, label %419
419: ; preds = %416
%420 = call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
store i8* %420, i8** @DoSubstitution.home
br label %421
421: ; preds = %419, %416
%422 = load i8*, i8** @DoSubstitution.home
%423 = icmp ne i8* %422, null
br i1 %423, label %424, label %453
424: ; preds = %421
%425 = load i8*, i8** @DoSubstitution.home
%426 = call i32 @xf86pathIsAbsolute(i8* %425)
%427 = icmp ne i32 %426, 0
br i1 %427, label %428, label %453
428: ; preds = %424
br label %429
429: ; preds = %428
%430 = load i8*, i8** @DoSubstitution.home
%431 = call i32 @strlen(i8* %430)
%432 = load i32, i32* %14
%433 = add nsw i32 %431, %432
%434 = icmp sgt i32 %433, 1024
br i1 %434, label %435, label %440
435: ; preds = %429
br label %436
436: ; preds = %435
%437 = load i8*, i8** %12
%438 = call i32 @free(i8* %437)
store i8* null, i8** %6
br label %560
439: ; No predecessors!
br label %451
440: ; preds = %429
%441 = load i8*, i8** %12
%442 = load i32, i32* %14
%443 = sext i32 %442 to i64
%444 = getelementptr inbounds i8, i8* %441, i64 %443
%445 = load i8*, i8** @DoSubstitution.home
%446 = call i32 @strcpy(i8* %444, i8* %445)
%447 = load i8*, i8** @DoSubstitution.home
%448 = call i32 @strlen(i8* %447)
%449 = load i32, i32* %14
%450 = add nsw i32 %449, %448
store i32 %450, i32* %14
br label %451
451: ; preds = %440, %439
br label %452
452: ; preds = %451
br label %458
453: ; preds = %424, %421
br label %454
454: ; preds = %453
%455 = load i8*, i8** %12
%456 = call i32 @free(i8* %455)
store i8* null, i8** %6
br label %560
457: ; No predecessors!
br label %458
458: ; preds = %457, %452
br label %553
459: ; preds = %66
%460 = load i8*, i8** %9
%461 = icmp ne i8* %460, null
br i1 %461, label %462, label %491
462: ; preds = %459
%463 = load i8*, i8** %9
%464 = call i32 @xf86pathIsAbsolute(i8* %463)
%465 = icmp ne i32 %464, 0
br i1 %465, label %466, label %491
466: ; preds = %462
br label %467
467: ; preds = %466
%468 = load i8*, i8** %9
%469 = call i32 @strlen(i8* %468)
%470 = load i32, i32* %14
%471 = add nsw i32 %469, %470
%472 = icmp sgt i32 %471, 1024
br i1 %472, label %473, label %478
473: ; preds = %467
br label %474
474: ; preds = %473
%475 = load i8*, i8** %12
%476 = call i32 @free(i8* %475)
store i8* null, i8** %6
br label %560
477: ; No predecessors!
br label %489
478: ; preds = %467
%479 = load i8*, i8** %12
%480 = load i32, i32* %14
%481 = sext i32 %480 to i64
%482 = getelementptr inbounds i8, i8* %479, i64 %481
%483 = load i8*, i8** %9
%484 = call i32 @strcpy(i8* %482, i8* %483)
%485 = load i8*, i8** %9
%486 = call i32 @strlen(i8* %485)
%487 = load i32, i32* %14
%488 = add nsw i32 %487, %486
store i32 %488, i32* %14
br label %489
489: ; preds = %478, %477
br label %490
490: ; preds = %489
br label %496
491: ; preds = %462, %459
br label %492
492: ; preds = %491
%493 = load i8*, i8** %12
%494 = call i32 @free(i8* %493)
store i8* null, i8** %6
br label %560
495: ; No predecessors!
br label %496
496: ; preds = %495, %490
br label %553
497: ; preds = %66
%498 = load i8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @DoSubstitution.majorvers, i64 0, i64 0)
%499 = icmp ne i8 %498, 0
br i1 %499, label %502, label %500
500: ; preds = %497
%501 = call i32 @sprintf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @DoSubstitution.majorvers, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 4)
br label %502
502: ; preds = %500, %497
br label %503
503: ; preds = %502
%504 = call i32 @strlen(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @DoSubstitution.majorvers, i64 0, i64 0))
%505 = load i32, i32* %14
%506 = add nsw i32 %504, %505
%507 = icmp sgt i32 %506, 1024
br i1 %507, label %508, label %513
508: ; preds = %503
br label %509
509: ; preds = %508
%510 = load i8*, i8** %12
%511 = call i32 @free(i8* %510)
store i8* null, i8** %6
br label %560
512: ; No predecessors!
br label %522
513: ; preds = %503
%514 = load i8*, i8** %12
%515 = load i32, i32* %14
%516 = sext i32 %515 to i64
%517 = getelementptr inbounds i8, i8* %514, i64 %516
%518 = call i32 @strcpy(i8* %517, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @DoSubstitution.majorvers, i64 0, i64 0))
%519 = call i32 @strlen(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @DoSubstitution.majorvers, i64 0, i64 0))
%520 = load i32, i32* %14
%521 = add nsw i32 %520, %519
store i32 %521, i32* %14
br label %522
522: ; preds = %513, %512
br label %523
523: ; preds = %522
br label %553
524: ; preds = %66
%525 = load i8*, i8** %12
%526 = load i32, i32* %14
%527 = add nsw i32 %526, 1
store i32 %527, i32* %14
%528 = sext i32 %526 to i64
%529 = getelementptr inbounds i8, i8* %525, i64 %528
store i8 37, i8* %529
br label %530
530: ; preds = %524
%531 = load i32, i32* %14
%532 = icmp sgt i32 %531, 1024
br i1 %532, label %533, label %538
533: ; preds = %530
br label %534
534: ; preds = %533
%535 = load i8*, i8** %12
%536 = call i32 @free(i8* %535)
store i8* null, i8** %6
br label %560
537: ; No predecessors!
br label %538
538: ; preds = %537, %530
br label %539
539: ; preds = %538
br label %553
540: ; preds = %66
%541 = load i32, i32* @stderr
%542 = load i8*, i8** %7
%543 = load i32, i32* %13
%544 = sext i32 %543 to i64
%545 = getelementptr inbounds i8, i8* %542, i64 %544
%546 = load i8, i8* %545
%547 = sext i8 %546 to i32
%548 = call i32 (i32, i8*, ...) @fprintf(i32 %541, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.4, i64 0, i64 0), i32 %547)
br label %549
549: ; preds = %540
%550 = load i8*, i8** %12
%551 = call i32 @free(i8* %550)
store i8* null, i8** %6
br label %560
552: ; No predecessors!
br label %553
553: ; preds = %552, %539, %523, %496, %458, %415, %367, %319, %271, %224, %202, %159, %116
br label %554
554: ; preds = %553, %65
br label %555
555: ; preds = %554
%556 = load i32, i32* %13
%557 = add nsw i32 %556, 1
store i32 %557, i32* %13
br label %30
558: ; preds = %30
%559 = load i8*, i8** %12
store i8* %559, i8** %6
br label %560
560: ; preds = %558, %549, %534, %509, %492, %474, %454, %436, %411, %388, %363, %340, %315, %292, %254, %210, %198, %175, %155, %132, %112, %89, %60, %17
%561 = load i8*, i8** %6
ret i8* %561
}

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