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

/* Variables and functions */
int STDERR_FILENO;
int STDOUT_FILENO;
int chdir(char *);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fdopen(int, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
char *getenv(char *);
int /*<<< orphan*/ setenv(char *, char *, int);
int /*<<< orphan*/ snprintf(char *, size_t, char *, char *, char *);
int /*<<< orphan*/ *stderr;
int /*<<< orphan*/ *stdout;
char *strerror(int /*<<< orphan*/);
char **xcalloc(size_t, int);
int /*<<< orphan*/ xfree(char *);
int /*<<< orphan*/ xfree_list(char **, int);
char *xmalloc(size_t);
int xmax(int, int /*<<< orphan*/);
scalar_t__ xstrcmp(char *, char *);
char *xstrdup(char *);
char *xstrjoin(char **, int, char *);
int xstrlen(char *);
char **xstrsplit(char *, char *, size_t *);
int sd_cd(int argc, char **argv, int in, int out, int err) {
  char *target;
  FILE *fdout = stdout, *fderr = stderr;
  do {
    if (out != STDOUT_FILENO)
      if (out == err)
        fdout = fderr;
      else
        fdout = fdopen(out, "a");
    else
      fdout = stdout;
    if (err != STDERR_FILENO)
      fderr = fdopen(err, "a");
    else
      fderr = stderr;
  } while (0);
  ;
  if (argc > 1) {
    fprintf(fderr, "ERROR: too many arguments\n");
    fprintf(fderr, "usage: cd [directory]\n");
    do {
      if (out != STDOUT_FILENO)
        fclose(fdout);
      if (err != STDERR_FILENO && err != out)
        fclose(fderr);
    } while (0);
    ;
    return 1;
  }
  if (argc == 0 || xstrcmp(argv[0], "~") == 0) {
    target = xstrdup(getenv("HOME"));
  } else {
    if (xstrcmp(argv[0], "-") == 0) {
      target = xstrdup(getenv("OLDPWD"));
    } else if (*argv[0] == '~') {
      char *home = getenv("HOME");
      char *tmp = xmalloc(xstrlen(argv[0]));
      size_t len;
      int i = 0, j = 1;
      for (; argv[0][j] != '\0'; tmp[i] = argv[0][j], i++, j++)
        ;
      tmp[i] = '\0';
      len = xstrlen(home) + xstrlen(tmp) + 1;
      target = xmalloc(len);
      snprintf(target, len, "%s%s", home, tmp);
      xfree(tmp);
    } else {
      target = xstrdup(argv[0]);
    }
  }
  if (chdir(target) == -1) {
    xfree(target);
    fprintf(fderr, "cd: %s\n", strerror(errno));
    do {
      if (out != STDOUT_FILENO)
        fclose(fdout);
      if (err != STDERR_FILENO && err != out)
        fclose(fderr);
    } while (0);
    ;
    return 2;
  } else {
    if (argc != 0 && xstrcmp(argv[0], "-") == 0) {
      char *tmp = getenv("OLDPWD");
      setenv("OLDPWD", getenv("PWD"), 1);
      setenv("PWD", tmp, 1);
      xfree(target);
      do {
        if (out != STDOUT_FILENO)
          fclose(fdout);
        if (err != STDERR_FILENO && err != out)
          fclose(fderr);
      } while (0);
      ;
      return 0;
    }
    setenv("OLDPWD", getenv("PWD"), 1);
    if (*target == '/') {
      setenv("PWD", target, 1);
    } else if (xstrcmp(target, ".") != 0) {
      char *oldpwd = getenv("OLDPWD"), *res;
      size_t s_old, s_tar;
      char **old_tab, **tar_tab, **full;
      int i, j;
      old_tab = xstrsplit(oldpwd, "/", &s_old);
      tar_tab = xstrsplit(target, "/", &s_tar);
      full = xcalloc((s_old + s_tar), sizeof(char *));
      for (i = 0, j = 0; i < (int)s_old; i++, j++) {
        full[j] = xstrdup(old_tab[i]);
      }
      for (i = 0; i < (int)s_tar; i++, j++) {
        full[j] = xstrdup(tar_tab[i]);
      }
      xfree_list(old_tab, s_old);
      xfree_list(tar_tab, s_tar);
      i = 0;
      j = 0;
      while (i < (int)(s_old + s_tar)) {
        if (xstrcmp(full[i], "..") == 0) {
          j = xmax(j - 1, 0);
          xfree(full[j]);
          full[j] = NULL;
          xfree(full[i]);
          full[i] = NULL;
          i++;
          continue;
        } else if (xstrcmp(full[i], ".") == 0) {
          xfree(full[i]);
          full[i] = NULL;
          i++;
          continue;
        }
        full[j] = full[i];
        j++;
        i++;
      }
      res = xstrjoin(full, j, "/");
      if (xstrcmp(res, "") != 0)
        setenv("PWD", res, 1);
      else
        setenv("PWD", "/", 1);
      xfree_list(full, j);
      xfree(res);
    }
  }
  xfree(target);
  do {
    if (out != STDOUT_FILENO)
      fclose(fdout);
    if (err != STDERR_FILENO && err != out)
      fclose(fderr);
  } while (0);
  ;
  (void)in;
  return 0;
}


x86 assembly (clang, -O0):
<sd_cd>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
mov    0x2d7d(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
mov    0x2d87(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%eax
mov    0x2d8e(%rip),%rcx
cmp    (%rcx),%eax
je     129b <sd_cd+0x7b>
mov    -0x18(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jne    1283 <sd_cd+0x63>
mov    -0x38(%rbp),%rax
mov    %rax,-0x30(%rbp)
jmp    1296 <sd_cd+0x76>
mov    -0x18(%rbp),%edi
lea    0xd73(%rip),%rsi
call   1120 <fdopen@plt>
mov    %rax,-0x30(%rbp)
jmp    12a9 <sd_cd+0x89>
mov    0x2d1e(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
mov    -0x1c(%rbp),%eax
mov    0x2d15(%rip),%rcx
cmp    (%rcx),%eax
je     12d3 <sd_cd+0xb3>
mov    -0x1c(%rbp),%edi
lea    0xd3b(%rip),%rsi
call   1120 <fdopen@plt>
mov    %rax,-0x38(%rbp)
jmp    12e1 <sd_cd+0xc1>
mov    0x2cfe(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x38(%rbp)
jmp    12e6 <sd_cd+0xc6>
cmpl   $0x1,-0x8(%rbp)
jle    1367 <sd_cd+0x147>
mov    -0x38(%rbp),%rdi
lea    0xd07(%rip),%rsi
mov    $0x0,%al
call   10e0 <fprintf@plt>
mov    -0x38(%rbp),%rdi
lea    0xd10(%rip),%rsi
mov    $0x0,%al
call   10e0 <fprintf@plt>
mov    -0x18(%rbp),%eax
mov    0x2cd2(%rip),%rcx
cmp    (%rcx),%eax
je     132f <sd_cd+0x10f>
mov    -0x30(%rbp),%rdi
call   1080 <fclose@plt>
mov    -0x1c(%rbp),%eax
mov    0x2c8f(%rip),%rcx
cmp    (%rcx),%eax
je     1356 <sd_cd+0x136>
mov    -0x1c(%rbp),%eax
cmp    -0x18(%rbp),%eax
je     1356 <sd_cd+0x136>
mov    -0x38(%rbp),%rdi
call   1080 <fclose@plt>
jmp    135b <sd_cd+0x13b>
movl   $0x1,-0x4(%rbp)
jmp    1aa1 <sd_cd+0x881>
cmpl   $0x0,-0x8(%rbp)
je     138e <sd_cd+0x16e>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xcb5(%rip),%rsi
call   10f0 <xstrcmp@plt>
cmp    $0x0,%rax
jne    13ab <sd_cd+0x18b>
lea    0xca1(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,%rdi
call   10d0 <xstrdup@plt>
mov    %rax,-0x28(%rbp)
jmp    1503 <sd_cd+0x2e3>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xc82(%rip),%rsi
call   10f0 <xstrcmp@plt>
cmp    $0x0,%rax
jne    13e5 <sd_cd+0x1c5>
lea    0xc6e(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,%rdi
call   10d0 <xstrdup@plt>
mov    %rax,-0x28(%rbp)
jmp    14fe <sd_cd+0x2de>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%eax
cmp    $0x7e,%eax
jne    14e9 <sd_cd+0x2c9>
lea    0xc37(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x40(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1110 <xstrlen@plt>
movslq %eax,%rdi
call   10c0 <xmalloc@plt>
mov    %rax,-0x48(%rbp)
movl   $0x0,-0x54(%rbp)
movl   $0x1,-0x58(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movslq -0x58(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     147b <sd_cd+0x25b>
jmp    144b <sd_cd+0x22b>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movslq -0x58(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x48(%rbp),%rax
movslq -0x54(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
mov    -0x58(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x58(%rbp)
jmp    142e <sd_cd+0x20e>
mov    -0x48(%rbp),%rax
movslq -0x54(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x40(%rbp),%rdi
call   1110 <xstrlen@plt>
mov    %eax,-0xa4(%rbp)
mov    -0x48(%rbp),%rdi
call   1110 <xstrlen@plt>
mov    %eax,%ecx
mov    -0xa4(%rbp),%eax
add    %ecx,%eax
add    $0x1,%eax
cltq
mov    %rax,-0x50(%rbp)
mov    -0x50(%rbp),%rdi
call   10c0 <xmalloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x50(%rbp),%rsi
mov    -0x40(%rbp),%rcx
mov    -0x48(%rbp),%r8
lea    0xb6e(%rip),%rdx
call   10b0 <snprintf@plt>
mov    -0x48(%rbp),%rdi
call   10a0 <xfree@plt>
jmp    14f9 <sd_cd+0x2d9>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   10d0 <xstrdup@plt>
mov    %rax,-0x28(%rbp)
jmp    14fe <sd_cd+0x2de>
jmp    1503 <sd_cd+0x2e3>
mov    -0x28(%rbp),%rdi
call   1090 <chdir@plt>
cmp    $0xffffffff,%eax
jne    15a2 <sd_cd+0x382>
mov    -0x28(%rbp),%rdi
call   10a0 <xfree@plt>
mov    -0x38(%rbp),%rax
mov    %rax,-0xb0(%rbp)
mov    0x2aa0(%rip),%rax
mov    (%rax),%edi
call   1130 <strerror@plt>
mov    -0xb0(%rbp),%rdi
mov    %rax,%rdx
lea    0xb01(%rip),%rsi
mov    $0x0,%al
call   10e0 <fprintf@plt>
mov    -0x18(%rbp),%eax
mov    0x2a97(%rip),%rcx
cmp    (%rcx),%eax
je     156a <sd_cd+0x34a>
mov    -0x30(%rbp),%rdi
call   1080 <fclose@plt>
mov    -0x1c(%rbp),%eax
mov    0x2a54(%rip),%rcx
cmp    (%rcx),%eax
je     1591 <sd_cd+0x371>
mov    -0x1c(%rbp),%eax
cmp    -0x18(%rbp),%eax
je     1591 <sd_cd+0x371>
mov    -0x38(%rbp),%rdi
call   1080 <fclose@plt>
jmp    1596 <sd_cd+0x376>
movl   $0x2,-0x4(%rbp)
jmp    1aa1 <sd_cd+0x881>
cmpl   $0x0,-0x8(%rbp)
je     166a <sd_cd+0x44a>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xa81(%rip),%rsi
call   10f0 <xstrcmp@plt>
cmp    $0x0,%rax
jne    166a <sd_cd+0x44a>
lea    0xa6d(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x60(%rbp)
lea    0xa60(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,%rsi
lea    0xa4e(%rip),%rdi
mov    $0x1,%edx
call   1070 <setenv@plt>
mov    -0x60(%rbp),%rsi
lea    0xa3c(%rip),%rdi
mov    $0x1,%edx
call   1070 <setenv@plt>
mov    -0x28(%rbp),%rdi
call   10a0 <xfree@plt>
mov    -0x18(%rbp),%eax
mov    0x29cf(%rip),%rcx
cmp    (%rcx),%eax
je     1632 <sd_cd+0x412>
mov    -0x30(%rbp),%rdi
call   1080 <fclose@plt>
mov    -0x1c(%rbp),%eax
mov    0x298c(%rip),%rcx
cmp    (%rcx),%eax
je     1659 <sd_cd+0x439>
mov    -0x1c(%rbp),%eax
cmp    -0x18(%rbp),%eax
je     1659 <sd_cd+0x439>
mov    -0x38(%rbp),%rdi
call   1080 <fclose@plt>
jmp    165e <sd_cd+0x43e>
movl   $0x0,-0x4(%rbp)
jmp    1aa1 <sd_cd+0x881>
lea    0x9cf(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,%rsi
lea    0x9bd(%rip),%rdi
mov    $0x1,%edx
call   1070 <setenv@plt>
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
jne    16b4 <sd_cd+0x494>
mov    -0x28(%rbp),%rsi
lea    0x99b(%rip),%rdi
mov    $0x1,%edx
call   1070 <setenv@plt>
jmp    1a45 <sd_cd+0x825>
mov    -0x28(%rbp),%rdi
lea    0x995(%rip),%rsi
call   10f0 <xstrcmp@plt>
cmp    $0x0,%rax
je     1a40 <sd_cd+0x820>
lea    0x968(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x68(%rbp)
mov    -0x68(%rbp),%rdi
lea    0x968(%rip),%rsi
lea    -0x78(%rbp),%rdx
call   1040 <xstrsplit@plt>
mov    %rax,-0x88(%rbp)
mov    -0x28(%rbp),%rdi
lea    0x94d(%rip),%rsi
lea    -0x80(%rbp),%rdx
call   1040 <xstrsplit@plt>
mov    %rax,-0x90(%rbp)
mov    -0x78(%rbp),%rdi
add    -0x80(%rbp),%rdi
mov    $0x8,%esi
call   1140 <xcalloc@plt>
mov    %rax,-0x98(%rbp)
movl   $0x0,-0x9c(%rbp)
movl   $0x0,-0xa0(%rbp)
mov    -0x9c(%rbp),%eax
mov    -0x78(%rbp),%rcx
cmp    %ecx,%eax
jge    17a2 <sd_cd+0x582>
mov    -0x88(%rbp),%rax
movslq -0x9c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   10d0 <xstrdup@plt>
mov    %rax,%rdx
mov    -0x98(%rbp),%rax
movslq -0xa0(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x9c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x9c(%rbp)
mov    -0xa0(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xa0(%rbp)
jmp    1741 <sd_cd+0x521>
movl   $0x0,-0x9c(%rbp)
mov    -0x9c(%rbp),%eax
mov    -0x80(%rbp),%rcx
cmp    %ecx,%eax
jge    180d <sd_cd+0x5ed>
mov    -0x90(%rbp),%rax
movslq -0x9c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   10d0 <xstrdup@plt>
mov    %rax,%rdx
mov    -0x98(%rbp),%rax
movslq -0xa0(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x9c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x9c(%rbp)
mov    -0xa0(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xa0(%rbp)
jmp    17ac <sd_cd+0x58c>
mov    -0x88(%rbp),%rdi
mov    -0x78(%rbp),%rax
mov    %eax,%esi
call   1060 <xfree_list@plt>
mov    -0x90(%rbp),%rdi
mov    -0x80(%rbp),%rax
mov    %eax,%esi
call   1060 <xfree_list@plt>
movl   $0x0,-0x9c(%rbp)
movl   $0x0,-0xa0(%rbp)
mov    -0x9c(%rbp),%eax
mov    -0x78(%rbp),%rcx
add    -0x80(%rbp),%rcx
cmp    %ecx,%eax
jge    19bc <sd_cd+0x79c>
mov    -0x98(%rbp),%rax
movslq -0x9c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0x7df(%rip),%rsi
call   10f0 <xstrcmp@plt>
cmp    $0x0,%rax
jne    1907 <sd_cd+0x6e7>
mov    -0xa0(%rbp),%edi
sub    $0x1,%edi
xor    %esi,%esi
call   1100 <xmax@plt>
mov    %eax,-0xa0(%rbp)
mov    -0x98(%rbp),%rax
movslq -0xa0(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   10a0 <xfree@plt>
mov    -0x98(%rbp),%rax
movslq -0xa0(%rbp),%rcx
movq   $0x0,(%rax,%rcx,8)
mov    -0x98(%rbp),%rax
movslq -0x9c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   10a0 <xfree@plt>
mov    -0x98(%rbp),%rax
movslq -0x9c(%rbp),%rcx
movq   $0x0,(%rax,%rcx,8)
mov    -0x9c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x9c(%rbp)
jmp    1845 <sd_cd+0x625>
mov    -0x98(%rbp),%rax
movslq -0x9c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0x734(%rip),%rsi
call   10f0 <xstrcmp@plt>
cmp    $0x0,%rax
jne    1970 <sd_cd+0x750>
mov    -0x98(%rbp),%rax
movslq -0x9c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   10a0 <xfree@plt>
mov    -0x98(%rbp),%rax
movslq -0x9c(%rbp),%rcx
movq   $0x0,(%rax,%rcx,8)
mov    -0x9c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x9c(%rbp)
jmp    1845 <sd_cd+0x625>
jmp    1975 <sd_cd+0x755>
mov    -0x98(%rbp),%rax
movslq -0x9c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
mov    -0x98(%rbp),%rax
movslq -0xa0(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0xa0(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xa0(%rbp)
mov    -0x9c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x9c(%rbp)
jmp    1845 <sd_cd+0x625>
mov    -0x98(%rbp),%rdi
mov    -0xa0(%rbp),%esi
lea    0x681(%rip),%rdx
call   1050 <xstrjoin@plt>
mov    %rax,-0x70(%rbp)
mov    -0x70(%rbp),%rdi
lea    0x64f(%rip),%rsi
call   10f0 <xstrcmp@plt>
cmp    $0x0,%rax
je     1a0d <sd_cd+0x7ed>
mov    -0x70(%rbp),%rsi
lea    0x642(%rip),%rdi
mov    $0x1,%edx
call   1070 <setenv@plt>
jmp    1a25 <sd_cd+0x805>
lea    0x62c(%rip),%rdi
lea    0x636(%rip),%rsi
mov    $0x1,%edx
call   1070 <setenv@plt>
mov    -0x98(%rbp),%rdi
mov    -0xa0(%rbp),%esi
call   1060 <xfree_list@plt>
mov    -0x70(%rbp),%rdi
call   10a0 <xfree@plt>
jmp    1a45 <sd_cd+0x825>
jmp    1a4a <sd_cd+0x82a>
mov    -0x28(%rbp),%rdi
call   10a0 <xfree@plt>
mov    -0x18(%rbp),%eax
mov    0x2593(%rip),%rcx
cmp    (%rcx),%eax
je     1a6e <sd_cd+0x84e>
mov    -0x30(%rbp),%rdi
call   1080 <fclose@plt>
mov    -0x1c(%rbp),%eax
mov    0x2550(%rip),%rcx
cmp    (%rcx),%eax
je     1a95 <sd_cd+0x875>
mov    -0x1c(%rbp),%eax
cmp    -0x18(%rbp),%eax
je     1a95 <sd_cd+0x875>
mov    -0x38(%rbp),%rdi
call   1080 <fclose@plt>
jmp    1a9a <sd_cd+0x87a>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sd_cd>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %r8d,%ebx
mov    %ecx,%r15d
mov    %rsi,%r14
mov    %edi,%r12d
mov    0x2d9f(%rip),%rax
cmp    %ecx,(%rax)
jne    125e <sd_cd+0x2e>
mov    0x2d64(%rip),%rax
jmp    126a <sd_cd+0x3a>
cmp    %ebx,%r15d
jne    126f <sd_cd+0x3f>
mov    0x2d6e(%rip),%rax
mov    (%rax),%rax
jmp    127e <sd_cd+0x4e>
lea    0xd8a(%rip),%rsi
mov    %r15d,%edi
call   1120 <fdopen@plt>
mov    %rax,0x28(%rsp)
mov    0x2d3e(%rip),%r13
cmp    %ebx,0x0(%r13)
jne    1398 <sd_cd+0x168>
mov    0x2d3d(%rip),%rax
mov    (%rax),%rbp
cmp    $0x2,%r12d
jge    13b3 <sd_cd+0x183>
mov    %rbp,0x38(%rsp)
test   %r12d,%r12d
mov    %ebx,0x24(%rsp)
mov    %r15d,0xc(%rsp)
mov    %r12d,0x44(%rsp)
je     141c <sd_cd+0x1ec>
mov    (%r14),%rdi
lea    0xd66(%rip),%rsi
call   10f0 <xstrcmp@plt>
test   %rax,%rax
je     141c <sd_cd+0x1ec>
mov    (%r14),%rdi
lea    0xd55(%rip),%rsi
call   10f0 <xstrcmp@plt>
test   %rax,%rax
je     1435 <sd_cd+0x205>
mov    (%r14),%r12
cmpb   $0x7e,(%r12)
jne    143e <sd_cd+0x20e>
lea    0xd2d(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,%r13
mov    %r12,%rdi
call   1110 <xstrlen@plt>
movslq %eax,%rdi
call   10c0 <xmalloc@plt>
mov    %rax,%r12
mov    (%r14),%rax
mov    0x1(%rax),%cl
xor    %eax,%eax
test   %cl,%cl
je     1344 <sd_cd+0x114>
mov    %cl,(%r12,%rax,1)
mov    (%r14),%rcx
movzbl 0x2(%rcx,%rax,1),%ecx
add    $0x1,%rax
test   %cl,%cl
jne    1330 <sd_cd+0x100>
mov    %eax,%eax
movb   $0x0,(%r12,%rax,1)
mov    %r13,%rdi
call   1110 <xstrlen@plt>
mov    %eax,%ebx
mov    %r12,%rdi
call   1110 <xstrlen@plt>
add    %ebx,%eax
add    $0x1,%eax
movslq %eax,%rbx
mov    %rbx,%rdi
call   10c0 <xmalloc@plt>
mov    %rax,%rbp
lea    0xccd(%rip),%rdx
mov    %rax,%rdi
mov    %rbx,%rsi
mov    %r13,%rcx
mov    %r12,%r8
call   10b0 <snprintf@plt>
mov    %r12,%rdi
call   10a0 <xfree@plt>
mov    %rbp,%r12
jmp    1449 <sd_cd+0x219>
lea    0xc61(%rip),%rsi
mov    %ebx,%edi
call   1120 <fdopen@plt>
mov    %rax,%rbp
cmp    $0x2,%r12d
jl     12a8 <sd_cd+0x78>
lea    0xc48(%rip),%rdi
mov    $0x1a,%esi
mov    $0x1,%edx
mov    %rbp,%rcx
call   1130 <fwrite@plt>
lea    0xc4a(%rip),%rdi
mov    $0x16,%esi
mov    $0x1,%edx
mov    %rbp,%rcx
call   1130 <fwrite@plt>
mov    0x2c04(%rip),%rax
cmp    %r15d,(%rax)
je     13fb <sd_cd+0x1cb>
mov    0x28(%rsp),%rdi
call   1080 <fclose@plt>
mov    $0x1,%r14d
cmp    %r15d,%ebx
je     1824 <sd_cd+0x5f4>
cmp    %ebx,0x0(%r13)
je     1824 <sd_cd+0x5f4>
mov    %rbp,%rdi
jmp    181f <sd_cd+0x5ef>
lea    0xc13(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,%rdi
call   10d0 <xstrdup@plt>
mov    %rax,%r12
jmp    1450 <sd_cd+0x220>
lea    0xc01(%rip),%rdi
jmp    1423 <sd_cd+0x1f3>
mov    %r12,%rdi
call   10d0 <xstrdup@plt>
mov    %rax,%r12
mov    0x2b78(%rip),%r13
mov    %r12,%rdi
call   1090 <chdir@plt>
cmp    $0xffffffff,%eax
je     14cd <sd_cd+0x29d>
mov    %r12,0x30(%rsp)
cmpl   $0x0,0x44(%rsp)
je     1481 <sd_cd+0x251>
mov    (%r14),%rdi
lea    0xbc8(%rip),%rsi
call   10f0 <xstrcmp@plt>
test   %rax,%rax
je     179d <sd_cd+0x56d>
lea    0xbb8(%rip),%rdi
call   1030 <getenv@plt>
lea    0xba9(%rip),%rdi
mov    %rax,%rsi
mov    $0x1,%edx
call   1070 <setenv@plt>
mov    0x30(%rsp),%rbx
cmpb   $0x2f,(%rbx)
jne    1539 <sd_cd+0x309>
lea    0xb8a(%rip),%rdi
mov    %rbx,%rsi
mov    $0x1,%edx
call   1070 <setenv@plt>
mov    0xc(%rsp),%r12d
jmp    175b <sd_cd+0x52b>
mov    %r12,%rdi
call   10a0 <xfree@plt>
mov    0x2af4(%rip),%rax
mov    (%rax),%edi
call   1140 <strerror@plt>
lea    0xb5f(%rip),%rsi
mov    0x38(%rsp),%rbx
mov    %rbx,%rdi
mov    %rax,%rdx
xor    %eax,%eax
call   10e0 <fprintf@plt>
mov    0x2aed(%rip),%rax
mov    0xc(%rsp),%ebp
cmp    %ebp,(%rax)
je     1515 <sd_cd+0x2e5>
mov    0x28(%rsp),%rdi
call   1080 <fclose@plt>
mov    $0x2,%r14d
mov    0x24(%rsp),%eax
cmp    %ebp,%eax
je     1824 <sd_cd+0x5f4>
cmp    %eax,0x0(%r13)
je     1824 <sd_cd+0x5f4>
mov    %rbx,%rdi
jmp    181f <sd_cd+0x5ef>
lea    0xb14(%rip),%rsi
mov    %rbx,%rdi
call   10f0 <xstrcmp@plt>
test   %rax,%rax
mov    0xc(%rsp),%r12d
je     175b <sd_cd+0x52b>
lea    0xae0(%rip),%rdi
call   1030 <getenv@plt>
lea    0xae8(%rip),%rbp
lea    0x18(%rsp),%rdx
mov    %rax,%rdi
mov    %rbp,%rsi
call   1040 <xstrsplit@plt>
mov    %rax,%r14
lea    0x10(%rsp),%rdx
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1040 <xstrsplit@plt>
mov    %rax,%r15
mov    0x10(%rsp),%rdi
add    0x18(%rsp),%rdi
mov    $0x8,%esi
call   1150 <xcalloc@plt>
mov    %rax,%rbx
mov    0x18(%rsp),%rsi
xor    %ebp,%ebp
test   %esi,%esi
jle    15de <sd_cd+0x3ae>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    (%r14,%rbp,8),%rdi
call   10d0 <xstrdup@plt>
mov    %rax,(%rbx,%rbp,8)
add    $0x1,%rbp
mov    0x18(%rsp),%rsi
movslq %esi,%rax
cmp    %rax,%rbp
jl     15c0 <sd_cd+0x390>
cmpl   $0x0,0x10(%rsp)
jle    1611 <sd_cd+0x3e1>
lea    (%rbx,%rbp,8),%rbp
xor    %r13d,%r13d
nopl   0x0(%rax)
mov    (%r15,%r13,8),%rdi
call   10d0 <xstrdup@plt>
mov    %rax,0x0(%rbp,%r13,8)
add    $0x1,%r13
movslq 0x10(%rsp),%rax
cmp    %rax,%r13
jl     15f0 <sd_cd+0x3c0>
mov    0x18(%rsp),%rsi
mov    %r14,%rdi
call   1060 <xfree_list@plt>
mov    0x10(%rsp),%esi
mov    %r15,%rdi
call   1060 <xfree_list@plt>
mov    0x10(%rsp),%eax
add    0x18(%rsp),%eax
xor    %r13d,%r13d
test   %eax,%eax
jle    16fa <sd_cd+0x4ca>
lea    0xa14(%rip),%r14
xor    %ebp,%ebp
movslq %ebp,%r15
lea    0x1(%r15),%ebp
nopl   0x0(%rax,%rax,1)
mov    (%rbx,%r15,8),%rdi
mov    %r14,%rsi
call   10f0 <xstrcmp@plt>
test   %rax,%rax
je     169f <sd_cd+0x46f>
mov    (%rbx,%r15,8),%rdi
lea    0x9e8(%rip),%rsi
call   10f0 <xstrcmp@plt>
mov    (%rbx,%r15,8),%rdi
test   %rax,%rax
jne    16df <sd_cd+0x4af>
call   10a0 <xfree@plt>
movq   $0x0,(%rbx,%r15,8)
mov    0x10(%rsp),%eax
add    0x18(%rsp),%eax
add    $0x1,%r15
cltq
add    $0x1,%ebp
cmp    %rax,%r15
jl     1650 <sd_cd+0x420>
jmp    16fa <sd_cd+0x4ca>
add    $0xffffffff,%r13d
mov    %r13d,%edi
xor    %esi,%esi
call   1100 <xmax@plt>
mov    %eax,%r12d
movslq %eax,%r13
mov    (%rbx,%r13,8),%rdi
call   10a0 <xfree@plt>
movq   $0x0,(%rbx,%r13,8)
mov    %r12,%r13
mov    0xc(%rsp),%r12d
mov    (%rbx,%r15,8),%rdi
call   10a0 <xfree@plt>
movq   $0x0,(%rbx,%r15,8)
jmp    16ea <sd_cd+0x4ba>
movslq %r13d,%r13
mov    %rdi,(%rbx,%r13,8)
add    $0x1,%r13d
mov    0x10(%rsp),%eax
add    0x18(%rsp),%eax
cmp    %eax,%ebp
jl     1641 <sd_cd+0x411>
mov    %rbx,%rdi
mov    %r13d,%esi
lea    0x94a(%rip),%rbp
mov    %rbp,%rdx
call   1050 <xstrjoin@plt>
mov    %rax,%r14
lea    0x91a(%rip),%rsi
mov    %rax,%rdi
call   10f0 <xstrcmp@plt>
test   %rax,%rax
cmovne %r14,%rbp
lea    0x911(%rip),%rdi
mov    %rbp,%rsi
mov    $0x1,%edx
call   1070 <setenv@plt>
mov    %rbx,%rdi
mov    %r13d,%esi
call   1060 <xfree_list@plt>
mov    %r14,%rdi
call   10a0 <xfree@plt>
mov    0x2872(%rip),%r13
mov    0x30(%rsp),%rbx
mov    %rbx,%rdi
call   10a0 <xfree@plt>
mov    0x2886(%rip),%rax
cmp    %r12d,(%rax)
je     1779 <sd_cd+0x549>
mov    0x28(%rsp),%rdi
call   1080 <fclose@plt>
xor    %r14d,%r14d
mov    0x24(%rsp),%eax
cmp    %r12d,%eax
je     1824 <sd_cd+0x5f4>
cmp    %eax,0x0(%r13)
je     1824 <sd_cd+0x5f4>
mov    0x38(%rsp),%rdi
jmp    181f <sd_cd+0x5ef>
mov    0x38(%rsp),%r15
lea    0x894(%rip),%rbx
mov    %rbx,%rdi
call   1030 <getenv@plt>
mov    %rax,%rbp
lea    0x885(%rip),%r14
mov    %r14,%rdi
call   1030 <getenv@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
mov    $0x1,%edx
call   1070 <setenv@plt>
mov    %r14,%rdi
mov    %rbp,%rsi
mov    $0x1,%edx
call   1070 <setenv@plt>
mov    0x30(%rsp),%rdi
call   10a0 <xfree@plt>
mov    0x27fc(%rip),%rax
mov    0xc(%rsp),%ebp
cmp    %ebp,(%rax)
je     1806 <sd_cd+0x5d6>
mov    0x28(%rsp),%rdi
call   1080 <fclose@plt>
xor    %r14d,%r14d
mov    0x24(%rsp),%ecx
cmp    %ebp,%ecx
mov    0x27b2(%rip),%rax
je     1824 <sd_cd+0x5f4>
cmp    %ecx,(%rax)
je     1824 <sd_cd+0x5f4>
mov    %r15,%rdi
call   1080 <fclose@plt>
mov    %r14d,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stdout = global i32* null
@stderr = global i32* null
@STDOUT_FILENO = global i32 0
@.str = [2 x i8] c"a\00"
@STDERR_FILENO = global i32 0
@.str.1 = [27 x i8] c"ERROR: too many arguments\0A\00"
@.str.2 = [23 x i8] c"usage: cd [directory]\0A\00"
@.str.3 = [2 x i8] c"~\00"
@.str.4 = [5 x i8] c"HOME\00"
@.str.5 = [2 x i8] c"-\00"
@.str.6 = [7 x i8] c"OLDPWD\00"
@.str.7 = [5 x i8] c"%s%s\00"
@.str.8 = [8 x i8] c"cd: %s\0A\00"
@errno = global i32 0
@.str.9 = [4 x i8] c"PWD\00"
@.str.10 = [2 x i8] c".\00"
@.str.11 = [2 x i8] c"/\00"
@.str.12 = [3 x i8] c"..\00"
@.str.13 = [1 x i8] zeroinitializer
define i32 @sd_cd(i32 %0, i8** %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8**
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i8*
%13 = alloca i32*
%14 = alloca i32*
%15 = alloca i8*
%16 = alloca i8*
%17 = alloca i64
%18 = alloca i32
%19 = alloca i32
%20 = alloca i8*
%21 = alloca i8*
%22 = alloca i8*
%23 = alloca i64
%24 = alloca i64
%25 = alloca i8**
%26 = alloca i8**
%27 = alloca i8**
%28 = alloca i32
%29 = alloca i32
store i32 %0, i32* %7
store i8** %1, i8*** %8
store i32 %2, i32* %9
store i32 %3, i32* %10
store i32 %4, i32* %11
%30 = load i32*, i32** @stdout
store i32* %30, i32** %13
%31 = load i32*, i32** @stderr
store i32* %31, i32** %14
br label %32
32: ; preds = %5
%33 = load i32, i32* %10
%34 = load i32, i32* @STDOUT_FILENO
%35 = icmp ne i32 %33, %34
br i1 %35, label %36, label %46
36: ; preds = %32
%37 = load i32, i32* %10
%38 = load i32, i32* %11
%39 = icmp eq i32 %37, %38
br i1 %39, label %40, label %42
40: ; preds = %36
%41 = load i32*, i32** %14
store i32* %41, i32** %13
br label %45
42: ; preds = %36
%43 = load i32, i32* %10
%44 = call i32* @fdopen(i32 %43, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %44, i32** %13
br label %45
45: ; preds = %42, %40
br label %48
46: ; preds = %32
%47 = load i32*, i32** @stdout
store i32* %47, i32** %13
br label %48
48: ; preds = %46, %45
%49 = load i32, i32* %11
%50 = load i32, i32* @STDERR_FILENO
%51 = icmp ne i32 %49, %50
br i1 %51, label %52, label %55
52: ; preds = %48
%53 = load i32, i32* %11
%54 = call i32* @fdopen(i32 %53, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %54, i32** %14
br label %57
55: ; preds = %48
%56 = load i32*, i32** @stderr
store i32* %56, i32** %14
br label %57
57: ; preds = %55, %52
br label %58
58: ; preds = %57
%59 = load i32, i32* %7
%60 = icmp sgt i32 %59, 1
br i1 %60, label %61, label %86
61: ; preds = %58
%62 = load i32*, i32** %14
%63 = call i32 (i32*, i8*, ...) @fprintf(i32* %62, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
%64 = load i32*, i32** %14
%65 = call i32 (i32*, i8*, ...) @fprintf(i32* %64, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
br label %66
66: ; preds = %61
%67 = load i32, i32* %10
%68 = load i32, i32* @STDOUT_FILENO
%69 = icmp ne i32 %67, %68
br i1 %69, label %70, label %73
70: ; preds = %66
%71 = load i32*, i32** %13
%72 = call i32 @fclose(i32* %71)
br label %73
73: ; preds = %70, %66
%74 = load i32, i32* %11
%75 = load i32, i32* @STDERR_FILENO
%76 = icmp ne i32 %74, %75
br i1 %76, label %77, label %84
77: ; preds = %73
%78 = load i32, i32* %11
%79 = load i32, i32* %10
%80 = icmp ne i32 %78, %79
br i1 %80, label %81, label %84
81: ; preds = %77
%82 = load i32*, i32** %14
%83 = call i32 @fclose(i32* %82)
br label %84
84: ; preds = %81, %77, %73
br label %85
85: ; preds = %84
store i32 1, i32* %6
br label %442
86: ; preds = %58
%87 = load i32, i32* %7
%88 = icmp eq i32 %87, 0
br i1 %88, label %95, label %89
89: ; preds = %86
%90 = load i8**, i8*** %8
%91 = getelementptr inbounds i8*, i8** %90, i64 0
%92 = load i8*, i8** %91
%93 = call i64 @xstrcmp(i8* %92, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%94 = icmp eq i64 %93, 0
br i1 %94, label %95, label %98
95: ; preds = %89, %86
%96 = call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%97 = call i8* @xstrdup(i8* %96)
store i8* %97, i8** %12
br label %177
98: ; preds = %89
%99 = load i8**, i8*** %8
%100 = getelementptr inbounds i8*, i8** %99, i64 0
%101 = load i8*, i8** %100
%102 = call i64 @xstrcmp(i8* %101, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%103 = icmp eq i64 %102, 0
br i1 %103, label %104, label %107
104: ; preds = %98
%105 = call i8* @getenv(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
%106 = call i8* @xstrdup(i8* %105)
store i8* %106, i8** %12
br label %176
107: ; preds = %98
%108 = load i8**, i8*** %8
%109 = getelementptr inbounds i8*, i8** %108, i64 0
%110 = load i8*, i8** %109
%111 = load i8, i8* %110
%112 = sext i8 %111 to i32
%113 = icmp eq i32 %112, 126
br i1 %113, label %114, label %170
114: ; preds = %107
%115 = call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
store i8* %115, i8** %15
%116 = load i8**, i8*** %8
%117 = getelementptr inbounds i8*, i8** %116, i64 0
%118 = load i8*, i8** %117
%119 = call i32 @xstrlen(i8* %118)
%120 = sext i32 %119 to i64
%121 = call i8* @xmalloc(i64 %120)
store i8* %121, i8** %16
store i32 0, i32* %18
store i32 1, i32* %19
br label %122
122: ; preds = %133, %114
%123 = load i8**, i8*** %8
%124 = getelementptr inbounds i8*, i8** %123, i64 0
%125 = load i8*, i8** %124
%126 = load i32, i32* %19
%127 = sext i32 %126 to i64
%128 = getelementptr inbounds i8, i8* %125, i64 %127
%129 = load i8, i8* %128
%130 = sext i8 %129 to i32
%131 = icmp ne i32 %130, 0
br i1 %131, label %132, label %149
132: ; preds = %122
br label %133
133: ; preds = %132
%134 = load i8**, i8*** %8
%135 = getelementptr inbounds i8*, i8** %134, i64 0
%136 = load i8*, i8** %135
%137 = load i32, i32* %19
%138 = sext i32 %137 to i64
%139 = getelementptr inbounds i8, i8* %136, i64 %138
%140 = load i8, i8* %139
%141 = load i8*, i8** %16
%142 = load i32, i32* %18
%143 = sext i32 %142 to i64
%144 = getelementptr inbounds i8, i8* %141, i64 %143
store i8 %140, i8* %144
%145 = load i32, i32* %18
%146 = add nsw i32 %145, 1
store i32 %146, i32* %18
%147 = load i32, i32* %19
%148 = add nsw i32 %147, 1
store i32 %148, i32* %19
br label %122
149: ; preds = %122
%150 = load i8*, i8** %16
%151 = load i32, i32* %18
%152 = sext i32 %151 to i64
%153 = getelementptr inbounds i8, i8* %150, i64 %152
store i8 0, i8* %153
%154 = load i8*, i8** %15
%155 = call i32 @xstrlen(i8* %154)
%156 = load i8*, i8** %16
%157 = call i32 @xstrlen(i8* %156)
%158 = add nsw i32 %155, %157
%159 = add nsw i32 %158, 1
%160 = sext i32 %159 to i64
store i64 %160, i64* %17
%161 = load i64, i64* %17
%162 = call i8* @xmalloc(i64 %161)
store i8* %162, i8** %12
%163 = load i8*, i8** %12
%164 = load i64, i64* %17
%165 = load i8*, i8** %15
%166 = load i8*, i8** %16
%167 = call i32 @snprintf(i8* %163, i64 %164, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i8* %165, i8* %166)
%168 = load i8*, i8** %16
%169 = call i32 @xfree(i8* %168)
br label %175
170: ; preds = %107
%171 = load i8**, i8*** %8
%172 = getelementptr inbounds i8*, i8** %171, i64 0
%173 = load i8*, i8** %172
%174 = call i8* @xstrdup(i8* %173)
store i8* %174, i8** %12
br label %175
175: ; preds = %170, %149
br label %176
176: ; preds = %175, %104
br label %177
177: ; preds = %176, %95
%178 = load i8*, i8** %12
%179 = call i32 @chdir(i8* %178)
%180 = icmp eq i32 %179, -1
br i1 %180, label %181, label %208
181: ; preds = %177
%182 = load i8*, i8** %12
%183 = call i32 @xfree(i8* %182)
%184 = load i32*, i32** %14
%185 = load i32, i32* @errno
%186 = call i8* @strerror(i32 %185)
%187 = call i32 (i32*, i8*, ...) @fprintf(i32* %184, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), i8* %186)
br label %188
188: ; preds = %181
%189 = load i32, i32* %10
%190 = load i32, i32* @STDOUT_FILENO
%191 = icmp ne i32 %189, %190
br i1 %191, label %192, label %195
192: ; preds = %188
%193 = load i32*, i32** %13
%194 = call i32 @fclose(i32* %193)
br label %195
195: ; preds = %192, %188
%196 = load i32, i32* %11
%197 = load i32, i32* @STDERR_FILENO
%198 = icmp ne i32 %196, %197
br i1 %198, label %199, label %206
199: ; preds = %195
%200 = load i32, i32* %11
%201 = load i32, i32* %10
%202 = icmp ne i32 %200, %201
br i1 %202, label %203, label %206
203: ; preds = %199
%204 = load i32*, i32** %14
%205 = call i32 @fclose(i32* %204)
br label %206
206: ; preds = %203, %199, %195
br label %207
207: ; preds = %206
store i32 2, i32* %6
br label %442
208: ; preds = %177
%209 = load i32, i32* %7
%210 = icmp ne i32 %209, 0
br i1 %210, label %211, label %245
211: ; preds = %208
%212 = load i8**, i8*** %8
%213 = getelementptr inbounds i8*, i8** %212, i64 0
%214 = load i8*, i8** %213
%215 = call i64 @xstrcmp(i8* %214, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%216 = icmp eq i64 %215, 0
br i1 %216, label %217, label %245
217: ; preds = %211
%218 = call i8* @getenv(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
store i8* %218, i8** %20
%219 = call i8* @getenv(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0))
%220 = call i32 @setenv(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i8* %219, i32 1)
%221 = load i8*, i8** %20
%222 = call i32 @setenv(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), i8* %221, i32 1)
%223 = load i8*, i8** %12
%224 = call i32 @xfree(i8* %223)
br label %225
225: ; preds = %217
%226 = load i32, i32* %10
%227 = load i32, i32* @STDOUT_FILENO
%228 = icmp ne i32 %226, %227
br i1 %228, label %229, label %232
229: ; preds = %225
%230 = load i32*, i32** %13
%231 = call i32 @fclose(i32* %230)
br label %232
232: ; preds = %229, %225
%233 = load i32, i32* %11
%234 = load i32, i32* @STDERR_FILENO
%235 = icmp ne i32 %233, %234
br i1 %235, label %236, label %243
236: ; preds = %232
%237 = load i32, i32* %11
%238 = load i32, i32* %10
%239 = icmp ne i32 %237, %238
br i1 %239, label %240, label %243
240: ; preds = %236
%241 = load i32*, i32** %14
%242 = call i32 @fclose(i32* %241)
br label %243
243: ; preds = %240, %236, %232
br label %244
244: ; preds = %243
store i32 0, i32* %6
br label %442
245: ; preds = %211, %208
%246 = call i8* @getenv(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0))
%247 = call i32 @setenv(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i8* %246, i32 1)
%248 = load i8*, i8** %12
%249 = load i8, i8* %248
%250 = sext i8 %249 to i32
%251 = icmp eq i32 %250, 47
br i1 %251, label %252, label %255
252: ; preds = %245
%253 = load i8*, i8** %12
%254 = call i32 @setenv(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), i8* %253, i32 1)
br label %417
255: ; preds = %245
%256 = load i8*, i8** %12
%257 = call i64 @xstrcmp(i8* %256, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0))
%258 = icmp ne i64 %257, 0
br i1 %258, label %259, label %416
259: ; preds = %255
%260 = call i8* @getenv(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
store i8* %260, i8** %21
%261 = load i8*, i8** %21
%262 = call i8** @xstrsplit(i8* %261, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0), i64* %23)
store i8** %262, i8*** %25
%263 = load i8*, i8** %12
%264 = call i8** @xstrsplit(i8* %263, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0), i64* %24)
store i8** %264, i8*** %26
%265 = load i64, i64* %23
%266 = load i64, i64* %24
%267 = add i64 %265, %266
%268 = call i8** @xcalloc(i64 %267, i32 8)
store i8** %268, i8*** %27
store i32 0, i32* %28
store i32 0, i32* %29
br label %269
269: ; preds = %285, %259
%270 = load i32, i32* %28
%271 = load i64, i64* %23
%272 = trunc i64 %271 to i32
%273 = icmp slt i32 %270, %272
br i1 %273, label %274, label %290
274: ; preds = %269
%275 = load i8**, i8*** %25
%276 = load i32, i32* %28
%277 = sext i32 %276 to i64
%278 = getelementptr inbounds i8*, i8** %275, i64 %277
%279 = load i8*, i8** %278
%280 = call i8* @xstrdup(i8* %279)
%281 = load i8**, i8*** %27
%282 = load i32, i32* %29
%283 = sext i32 %282 to i64
%284 = getelementptr inbounds i8*, i8** %281, i64 %283
store i8* %280, i8** %284
br label %285
285: ; preds = %274
%286 = load i32, i32* %28
%287 = add nsw i32 %286, 1
store i32 %287, i32* %28
%288 = load i32, i32* %29
%289 = add nsw i32 %288, 1
store i32 %289, i32* %29
br label %269
290: ; preds = %269
store i32 0, i32* %28
br label %291
291: ; preds = %307, %290
%292 = load i32, i32* %28
%293 = load i64, i64* %24
%294 = trunc i64 %293 to i32
%295 = icmp slt i32 %292, %294
br i1 %295, label %296, label %312
296: ; preds = %291
%297 = load i8**, i8*** %26
%298 = load i32, i32* %28
%299 = sext i32 %298 to i64
%300 = getelementptr inbounds i8*, i8** %297, i64 %299
%301 = load i8*, i8** %300
%302 = call i8* @xstrdup(i8* %301)
%303 = load i8**, i8*** %27
%304 = load i32, i32* %29
%305 = sext i32 %304 to i64
%306 = getelementptr inbounds i8*, i8** %303, i64 %305
store i8* %302, i8** %306
br label %307
307: ; preds = %296
%308 = load i32, i32* %28
%309 = add nsw i32 %308, 1
store i32 %309, i32* %28
%310 = load i32, i32* %29
%311 = add nsw i32 %310, 1
store i32 %311, i32* %29
br label %291
312: ; preds = %291
%313 = load i8**, i8*** %25
%314 = load i64, i64* %23
%315 = trunc i64 %314 to i32
%316 = call i32 @xfree_list(i8** %313, i32 %315)
%317 = load i8**, i8*** %26
%318 = load i64, i64* %24
%319 = trunc i64 %318 to i32
%320 = call i32 @xfree_list(i8** %317, i32 %319)
store i32 0, i32* %28
store i32 0, i32* %29
br label %321
321: ; preds = %384, %370, %336, %312
%322 = load i32, i32* %28
%323 = load i64, i64* %23
%324 = load i64, i64* %24
%325 = add i64 %323, %324
%326 = trunc i64 %325 to i32
%327 = icmp slt i32 %322, %326
br i1 %327, label %328, label %398
328: ; preds = %321
%329 = load i8**, i8*** %27
%330 = load i32, i32* %28
%331 = sext i32 %330 to i64
%332 = getelementptr inbounds i8*, i8** %329, i64 %331
%333 = load i8*, i8** %332
%334 = call i64 @xstrcmp(i8* %333, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.12, i64 0, i64 0))
%335 = icmp eq i64 %334, 0
br i1 %335, label %336, label %362
336: ; preds = %328
%337 = load i32, i32* %29
%338 = sub nsw i32 %337, 1
%339 = call i32 @xmax(i32 %338, i32 0)
store i32 %339, i32* %29
%340 = load i8**, i8*** %27
%341 = load i32, i32* %29
%342 = sext i32 %341 to i64
%343 = getelementptr inbounds i8*, i8** %340, i64 %342
%344 = load i8*, i8** %343
%345 = call i32 @xfree(i8* %344)
%346 = load i8**, i8*** %27
%347 = load i32, i32* %29
%348 = sext i32 %347 to i64
%349 = getelementptr inbounds i8*, i8** %346, i64 %348
store i8* null, i8** %349
%350 = load i8**, i8*** %27
%351 = load i32, i32* %28
%352 = sext i32 %351 to i64
%353 = getelementptr inbounds i8*, i8** %350, i64 %352
%354 = load i8*, i8** %353
%355 = call i32 @xfree(i8* %354)
%356 = load i8**, i8*** %27
%357 = load i32, i32* %28
%358 = sext i32 %357 to i64
%359 = getelementptr inbounds i8*, i8** %356, i64 %358
store i8* null, i8** %359
%360 = load i32, i32* %28
%361 = add nsw i32 %360, 1
store i32 %361, i32* %28
br label %321
362: ; preds = %328
%363 = load i8**, i8*** %27
%364 = load i32, i32* %28
%365 = sext i32 %364 to i64
%366 = getelementptr inbounds i8*, i8** %363, i64 %365
%367 = load i8*, i8** %366
%368 = call i64 @xstrcmp(i8* %367, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0))
%369 = icmp eq i64 %368, 0
br i1 %369, label %370, label %383
370: ; preds = %362
%371 = load i8**, i8*** %27
%372 = load i32, i32* %28
%373 = sext i32 %372 to i64
%374 = getelementptr inbounds i8*, i8** %371, i64 %373
%375 = load i8*, i8** %374
%376 = call i32 @xfree(i8* %375)
%377 = load i8**, i8*** %27
%378 = load i32, i32* %28
%379 = sext i32 %378 to i64
%380 = getelementptr inbounds i8*, i8** %377, i64 %379
store i8* null, i8** %380
%381 = load i32, i32* %28
%382 = add nsw i32 %381, 1
store i32 %382, i32* %28
br label %321
383: ; preds = %362
br label %384
384: ; preds = %383
%385 = load i8**, i8*** %27
%386 = load i32, i32* %28
%387 = sext i32 %386 to i64
%388 = getelementptr inbounds i8*, i8** %385, i64 %387
%389 = load i8*, i8** %388
%390 = load i8**, i8*** %27
%391 = load i32, i32* %29
%392 = sext i32 %391 to i64
%393 = getelementptr inbounds i8*, i8** %390, i64 %392
store i8* %389, i8** %393
%394 = load i32, i32* %29
%395 = add nsw i32 %394, 1
store i32 %395, i32* %29
%396 = load i32, i32* %28
%397 = add nsw i32 %396, 1
store i32 %397, i32* %28
br label %321
398: ; preds = %321
%399 = load i8**, i8*** %27
%400 = load i32, i32* %29
%401 = call i8* @xstrjoin(i8** %399, i32 %400, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0))
store i8* %401, i8** %22
%402 = load i8*, i8** %22
%403 = call i64 @xstrcmp(i8* %402, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.13, i64 0, i64 0))
%404 = icmp ne i64 %403, 0
br i1 %404, label %405, label %408
405: ; preds = %398
%406 = load i8*, i8** %22
%407 = call i32 @setenv(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), i8* %406, i32 1)
br label %410
408: ; preds = %398
%409 = call i32 @setenv(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0), i32 1)
br label %410
410: ; preds = %408, %405
%411 = load i8**, i8*** %27
%412 = load i32, i32* %29
%413 = call i32 @xfree_list(i8** %411, i32 %412)
%414 = load i8*, i8** %22
%415 = call i32 @xfree(i8* %414)
br label %416
416: ; preds = %410, %255
br label %417
417: ; preds = %416, %252
br label %418
418: ; preds = %417
%419 = load i8*, i8** %12
%420 = call i32 @xfree(i8* %419)
br label %421
421: ; preds = %418
%422 = load i32, i32* %10
%423 = load i32, i32* @STDOUT_FILENO
%424 = icmp ne i32 %422, %423
br i1 %424, label %425, label %428
425: ; preds = %421
%426 = load i32*, i32** %13
%427 = call i32 @fclose(i32* %426)
br label %428
428: ; preds = %425, %421
%429 = load i32, i32* %11
%430 = load i32, i32* @STDERR_FILENO
%431 = icmp ne i32 %429, %430
br i1 %431, label %432, label %439
432: ; preds = %428
%433 = load i32, i32* %11
%434 = load i32, i32* %10
%435 = icmp ne i32 %433, %434
br i1 %435, label %436, label %439
436: ; preds = %432
%437 = load i32*, i32** %14
%438 = call i32 @fclose(i32* %437)
br label %439
439: ; preds = %436, %432, %428
br label %440
440: ; preds = %439
%441 = load i32, i32* %9
store i32 0, i32* %6
br label %442
442: ; preds = %440, %244, %207, %85
%443 = load i32, i32* %6
ret i32 %443
}

LLVM IR (-O2):
@stdout = global i32* null
@stderr = global i32* null
@STDOUT_FILENO = global i32 0
@.str = [2 x i8] c"a\00"
@STDERR_FILENO = global i32 0
@.str.1 = [27 x i8] c"ERROR: too many arguments\0A\00"
@.str.2 = [23 x i8] c"usage: cd [directory]\0A\00"
@.str.3 = [2 x i8] c"~\00"
@.str.4 = [5 x i8] c"HOME\00"
@.str.5 = [2 x i8] c"-\00"
@.str.6 = [7 x i8] c"OLDPWD\00"
@.str.7 = [5 x i8] c"%s%s\00"
@.str.8 = [8 x i8] c"cd: %s\0A\00"
@errno = global i32 0
@.str.9 = [4 x i8] c"PWD\00"
@.str.10 = [2 x i8] c".\00"
@.str.11 = [2 x i8] c"/\00"
@.str.12 = [3 x i8] c"..\00"
@.str.13 = [1 x i8] zeroinitializer
define i32 @sd_cd(i32 %0, i8** nocapture %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca i64
%7 = alloca i64
%8 = load i32, i32* @STDOUT_FILENO
%9 = icmp eq i32 %8, %3
br i1 %9, label %15, label %10
10: ; preds = %5
%11 = load i32*, i32** @stderr
%12 = icmp eq i32 %3, %4
br i1 %12, label %17, label %13
13: ; preds = %10
%14 = tail call i32* @fdopen(i32 %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %17
15: ; preds = %5
%16 = load i32*, i32** @stdout
br label %17
17: ; preds = %10, %13, %15
%18 = phi i32* [ %14, %13 ], [ %16, %15 ], [ %11, %10 ]
%19 = load i32, i32* @STDERR_FILENO
%20 = icmp eq i32 %19, %4
br i1 %20, label %23, label %21
21: ; preds = %17
%22 = tail call i32* @fdopen(i32 %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %25
23: ; preds = %17
%24 = load i32*, i32** @stderr
br label %25
25: ; preds = %23, %21
%26 = phi i32* [ %22, %21 ], [ %24, %23 ]
%27 = icmp sgt i32 %0, 1
br i1 %27, label %28, label %42
28: ; preds = %25
%29 = tail call i64 @fwrite(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i64 26, i64 1, i32* %26)
%30 = tail call i64 @fwrite(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i64 22, i64 1, i32* %26)
%31 = load i32, i32* @STDOUT_FILENO
%32 = icmp eq i32 %31, %3
br i1 %32, label %35, label %33
33: ; preds = %28
%34 = tail call i32 @fclose(i32* %18)
br label %35
35: ; preds = %33, %28
%36 = load i32, i32* @STDERR_FILENO
%37 = icmp eq i32 %36, %4
%38 = icmp eq i32 %4, %3
%39 = or i1 %38, %37
br i1 %39, label %275, label %40
40: ; preds = %35
%41 = tail call i32 @fclose(i32* %26)
br label %275
42: ; preds = %25
%43 = icmp eq i32 %0, 0
br i1 %43, label %48, label %44
44: ; preds = %42
%45 = load i8*, i8** %1
%46 = tail call i64 @xstrcmp(i8* %45, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%47 = icmp eq i64 %46, 0
br i1 %47, label %48, label %51
48: ; preds = %44, %42
%49 = tail call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%50 = tail call i8* @xstrdup(i8* %49)
br label %96
51: ; preds = %44
%52 = load i8*, i8** %1
%53 = tail call i64 @xstrcmp(i8* %52, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%54 = icmp eq i64 %53, 0
br i1 %54, label %55, label %58
55: ; preds = %51
%56 = tail call i8* @getenv(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
%57 = tail call i8* @xstrdup(i8* %56)
br label %96
58: ; preds = %51
%59 = load i8*, i8** %1
%60 = load i8, i8* %59
%61 = icmp eq i8 %60, 126
br i1 %61, label %62, label %94
62: ; preds = %58
%63 = tail call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%64 = tail call i32 @xstrlen(i8* %59)
%65 = sext i32 %64 to i64
%66 = tail call i8* @xmalloc(i64 %65)
%67 = load i8*, i8** %1
%68 = getelementptr inbounds i8, i8* %67, i64 1
%69 = load i8, i8* %68
%70 = icmp eq i8 %69, 0
br i1 %70, label %82, label %71
71: ; preds = %62, %71
%72 = phi i64 [ %77, %71 ], [ 1, %62 ]
%73 = phi i64 [ %76, %71 ], [ 0, %62 ]
%74 = phi i8 [ %80, %71 ], [ %69, %62 ]
%75 = getelementptr inbounds i8, i8* %66, i64 %73
store i8 %74, i8* %75
%76 = add nuw i64 %73, 1
%77 = add nuw i64 %72, 1
%78 = load i8*, i8** %1
%79 = getelementptr inbounds i8, i8* %78, i64 %77
%80 = load i8, i8* %79
%81 = icmp eq i8 %80, 0
br i1 %81, label %82, label %71
82: ; preds = %71, %62
%83 = phi i64 [ 0, %62 ], [ %76, %71 ]
%84 = and i64 %83, 4294967295
%85 = getelementptr inbounds i8, i8* %66, i64 %84
store i8 0, i8* %85
%86 = tail call i32 @xstrlen(i8* %63)
%87 = tail call i32 @xstrlen(i8* %66)
%88 = add i32 %86, 1
%89 = add i32 %88, %87
%90 = sext i32 %89 to i64
%91 = tail call i8* @xmalloc(i64 %90)
%92 = tail call i32 @snprintf(i8* %91, i64 %90, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i8* %63, i8* %66)
%93 = tail call i32 @xfree(i8* %66)
br label %96
94: ; preds = %58
%95 = tail call i8* @xstrdup(i8* %59)
br label %96
96: ; preds = %55, %94, %82, %48
%97 = phi i8* [ %50, %48 ], [ %57, %55 ], [ %91, %82 ], [ %95, %94 ]
%98 = tail call i32 @chdir(i8* %97)
%99 = icmp eq i32 %98, -1
br i1 %99, label %100, label %116
100: ; preds = %96
%101 = tail call i32 @xfree(i8* %97)
%102 = load i32, i32* @errno
%103 = tail call i8* @strerror(i32 %102)
%104 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %26, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), i8* %103)
%105 = load i32, i32* @STDOUT_FILENO
%106 = icmp eq i32 %105, %3
br i1 %106, label %109, label %107
107: ; preds = %100
%108 = tail call i32 @fclose(i32* %18)
br label %109
109: ; preds = %107, %100
%110 = load i32, i32* @STDERR_FILENO
%111 = icmp eq i32 %110, %4
%112 = icmp eq i32 %4, %3
%113 = or i1 %112, %111
br i1 %113, label %275, label %114
114: ; preds = %109
%115 = tail call i32 @fclose(i32* %26)
br label %275
116: ; preds = %96
br i1 %43, label %138, label %117
117: ; preds = %116
%118 = load i8*, i8** %1
%119 = tail call i64 @xstrcmp(i8* %118, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%120 = icmp eq i64 %119, 0
br i1 %120, label %121, label %138
121: ; preds = %117
%122 = tail call i8* @getenv(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
%123 = tail call i8* @getenv(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0))
%124 = tail call i32 @setenv(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i8* %123, i32 1)
%125 = tail call i32 @setenv(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), i8* %122, i32 1)
%126 = tail call i32 @xfree(i8* %97)
%127 = load i32, i32* @STDOUT_FILENO
%128 = icmp eq i32 %127, %3
br i1 %128, label %131, label %129
129: ; preds = %121
%130 = tail call i32 @fclose(i32* %18)
br label %131
131: ; preds = %129, %121
%132 = load i32, i32* @STDERR_FILENO
%133 = icmp eq i32 %132, %4
%134 = icmp eq i32 %4, %3
%135 = or i1 %134, %133
br i1 %135, label %275, label %136
136: ; preds = %131
%137 = tail call i32 @fclose(i32* %26)
br label %275
138: ; preds = %117, %116
%139 = tail call i8* @getenv(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0))
%140 = tail call i32 @setenv(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i8* %139, i32 1)
%141 = load i8, i8* %97
%142 = icmp eq i8 %141, 47
br i1 %142, label %143, label %145
143: ; preds = %138
%144 = tail call i32 @setenv(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), i8* %97, i32 1)
br label %262
145: ; preds = %138
%146 = tail call i64 @xstrcmp(i8* %97, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0))
%147 = icmp eq i64 %146, 0
br i1 %147, label %262, label %148
148: ; preds = %145
%149 = tail call i8* @getenv(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
%150 = bitcast i64* %6 to i8*
%151 = bitcast i64* %7 to i8*
%152 = call i8** @xstrsplit(i8* %149, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0), i64* %6)
%153 = call i8** @xstrsplit(i8* %97, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0), i64* %7)
%154 = load i64, i64* %6
%155 = load i64, i64* %7
%156 = add i64 %155, %154
%157 = call i8** @xcalloc(i64 %156, i32 8)
%158 = load i64, i64* %6
%159 = trunc i64 %158 to i32
%160 = icmp sgt i32 %159, 0
br i1 %160, label %169, label %163
161: ; preds = %169
%162 = and i64 %175, 4294967295
br label %163
163: ; preds = %161, %148
%164 = phi i64 [ %158, %148 ], [ %176, %161 ]
%165 = phi i64 [ 0, %148 ], [ %162, %161 ]
%166 = load i64, i64* %7
%167 = trunc i64 %166 to i32
%168 = icmp sgt i32 %167, 0
br i1 %168, label %180, label %195
169: ; preds = %148, %169
%170 = phi i64 [ %175, %169 ], [ 0, %148 ]
%171 = getelementptr inbounds i8*, i8** %152, i64 %170
%172 = load i8*, i8** %171
%173 = call i8* @xstrdup(i8* %172)
%174 = getelementptr inbounds i8*, i8** %157, i64 %170
store i8* %173, i8** %174
%175 = add nuw nsw i64 %170, 1
%176 = load i64, i64* %6
%177 = shl i64 %176, 32
%178 = ashr exact i64 %177, 32
%179 = icmp slt i64 %175, %178
br i1 %179, label %169, label %161
180: ; preds = %163, %180
%181 = phi i64 [ %187, %180 ], [ 0, %163 ]
%182 = phi i64 [ %188, %180 ], [ %165, %163 ]
%183 = getelementptr inbounds i8*, i8** %153, i64 %181
%184 = load i8*, i8** %183
%185 = call i8* @xstrdup(i8* %184)
%186 = getelementptr inbounds i8*, i8** %157, i64 %182
store i8* %185, i8** %186
%187 = add nuw nsw i64 %181, 1
%188 = add nuw nsw i64 %182, 1
%189 = load i64, i64* %7
%190 = shl i64 %189, 32
%191 = ashr exact i64 %190, 32
%192 = icmp slt i64 %187, %191
br i1 %192, label %180, label %193
193: ; preds = %180
%194 = load i64, i64* %6
br label %195
195: ; preds = %193, %163
%196 = phi i64 [ %194, %193 ], [ %164, %163 ]
%197 = trunc i64 %196 to i32
%198 = call i32 @xfree_list(i8** %152, i32 %197)
%199 = load i64, i64* %7
%200 = trunc i64 %199 to i32
%201 = call i32 @xfree_list(i8** %153, i32 %200)
%202 = load i64, i64* %6
%203 = load i64, i64* %7
%204 = add i64 %203, %202
%205 = trunc i64 %204 to i32
%206 = icmp sgt i32 %205, 0
br i1 %206, label %207, label %253
207: ; preds = %195, %226
%208 = phi i32 [ %227, %226 ], [ 0, %195 ]
%209 = phi i32 [ %229, %226 ], [ 0, %195 ]
%210 = sext i32 %209 to i64
br label %211
211: ; preds = %207, %240
%212 = phi i64 [ %210, %207 ], [ %242, %240 ]
%213 = getelementptr inbounds i8*, i8** %157, i64 %212
%214 = load i8*, i8** %213
%215 = call i64 @xstrcmp(i8* %214, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.12, i64 0, i64 0))
%216 = icmp eq i64 %215, 0
br i1 %216, label %217, label %235
217: ; preds = %211
%218 = add nsw i32 %208, -1
%219 = call i32 @xmax(i32 %218, i32 0)
%220 = sext i32 %219 to i64
%221 = getelementptr inbounds i8*, i8** %157, i64 %220
%222 = load i8*, i8** %221
%223 = call i32 @xfree(i8* %222)
store i8* null, i8** %221
%224 = load i8*, i8** %213
%225 = call i32 @xfree(i8* %224)
store i8* null, i8** %213
br label %226
226: ; preds = %217, %249
%227 = phi i32 [ %252, %249 ], [ %219, %217 ]
%228 = trunc i64 %212 to i32
%229 = add nsw i32 %228, 1
%230 = load i64, i64* %6
%231 = load i64, i64* %7
%232 = add i64 %231, %230
%233 = trunc i64 %232 to i32
%234 = icmp slt i32 %229, %233
br i1 %234, label %207, label %253
235: ; preds = %211
%236 = load i8*, i8** %213
%237 = call i64 @xstrcmp(i8* %236, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0))
%238 = icmp eq i64 %237, 0
%239 = load i8*, i8** %213
br i1 %238, label %240, label %249
240: ; preds = %235
%241 = call i32 @xfree(i8* %239)
store i8* null, i8** %213
%242 = add nsw i64 %212, 1
%243 = load i64, i64* %6
%244 = load i64, i64* %7
%245 = add i64 %244, %243
%246 = shl i64 %245, 32
%247 = ashr exact i64 %246, 32
%248 = icmp slt i64 %242, %247
br i1 %248, label %211, label %253
249: ; preds = %235
%250 = sext i32 %208 to i64
%251 = getelementptr inbounds i8*, i8** %157, i64 %250
store i8* %239, i8** %251
%252 = add nsw i32 %208, 1
br label %226
253: ; preds = %226, %240, %195
%254 = phi i32 [ 0, %195 ], [ %208, %240 ], [ %227, %226 ]
%255 = call i8* @xstrjoin(i8** %157, i32 %254, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0))
%256 = call i64 @xstrcmp(i8* %255, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.13, i64 0, i64 0))
%257 = icmp eq i64 %256, 0
%258 = select i1 %257, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0), i8* %255
%259 = call i32 @setenv(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), i8* %258, i32 1)
%260 = call i32 @xfree_list(i8** %157, i32 %254)
%261 = call i32 @xfree(i8* %255)
br label %262
262: ; preds = %143, %253, %145
%263 = call i32 @xfree(i8* %97)
%264 = load i32, i32* @STDOUT_FILENO
%265 = icmp eq i32 %264, %3
br i1 %265, label %268, label %266
266: ; preds = %262
%267 = call i32 @fclose(i32* %18)
br label %268
268: ; preds = %266, %262
%269 = load i32, i32* @STDERR_FILENO
%270 = icmp eq i32 %269, %4
%271 = icmp eq i32 %4, %3
%272 = or i1 %271, %270
br i1 %272, label %275, label %273
273: ; preds = %268
%274 = call i32 @fclose(i32* %26)
br label %275
275: ; preds = %268, %273, %131, %136, %109, %114, %35, %40
%276 = phi i32 [ 1, %40 ], [ 1, %35 ], [ 2, %114 ], [ 2, %109 ], [ 0, %136 ], [ 0, %131 ], [ 0, %273 ], [ 0, %268 ]
ret i32 %276
}