#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 */
struct stat {
  scalar_t__ st_dev;
  scalar_t__ st_ino;
  int /*<<< orphan*/ st_mode;
};
struct dirent {
  char *d_name;
  scalar_t__ d_ino;
};
typedef scalar_t__ ino_t;
typedef scalar_t__ dev_t;
typedef int /*<<< orphan*/ DIR;

/* Variables and functions */
int AT_FDCWD;
int /*<<< orphan*/ AT_SYMLINK_NOFOLLOW;
int EINVAL;
int ENAMETOOLONG;
int ENOENT;
int ENOMEM;
int ERANGE;
int /*<<< orphan*/ O_RDONLY;
scalar_t__ S_ISDIR(int /*<<< orphan*/);
int /*<<< orphan*/ close(int);
scalar_t__ closedir(int /*<<< orphan*/ *);
int errno;
int /*<<< orphan*/ *fdopendir(int);
int /*<<< orphan*/ free(char *);
int fstat(int, struct stat *);
int fstatat(int, char *, struct stat *, int /*<<< orphan*/);
char *getcwd(char *, int);
scalar_t__ lstat(char *, struct stat *);
char *malloc(size_t);
char *memcpy(char *, char *, size_t);
int /*<<< orphan*/ memmove(char *, char *, size_t);
int openat(int, char *, int /*<<< orphan*/);
struct dirent *readdir(int /*<<< orphan*/ *);
char *realloc(char *, size_t);
int /*<<< orphan*/ rewinddir(int /*<<< orphan*/ *);
char *strdup(char *);
size_t strlen(char *);
char *rpl_getcwd(char *buf, size_t size) {
  enum {
    BIG_FILE_NAME_COMPONENT_LENGTH = 255,
    BIG_FILE_NAME_LENGTH = ((4095) < (8192 - 1) ? (4095) : (8192 - 1)),
    DEEP_NESTING = 100
  };
  int fd = AT_FDCWD;
  bool fd_needs_closing = false;
  DIR *dirstream = NULL;
  dev_t rootdev, thisdev;
  ino_t rootino, thisino;
  char *dir;
  register char *dirp;
  struct stat st;
  size_t allocated = size;
  size_t used;
  dir = getcwd(buf, size);
  if (dir || (size && errno == ERANGE))
    return dir;
  if (errno == EINVAL && buf == NULL && size == 0) {
    char big_buffer[BIG_FILE_NAME_LENGTH + 1];
    dir = getcwd(big_buffer, sizeof big_buffer);
    if (dir)
      return strdup(dir);
  }
  if (errno != ERANGE && errno != ENAMETOOLONG && errno != ENOENT)
    return NULL;
  if (size == 0) {
    if (buf != NULL) {
      (errno = (EINVAL));
      return NULL;
    }
    allocated = BIG_FILE_NAME_LENGTH + 1;
  }
  if (buf == NULL) {
    dir = malloc(allocated);
    if (dir == NULL)
      return NULL;
  } else
    dir = buf;
  dirp = dir + allocated;
  *--dirp = '\0';
  if (lstat(".", &st) < 0)
    goto lose;
  thisdev = st.st_dev;
  thisino = st.st_ino;
  if (lstat("/", &st) < 0)
    goto lose;
  rootdev = st.st_dev;
  rootino = st.st_ino;
  while (!(thisdev == rootdev && thisino == rootino)) {
    struct dirent *d;
    dev_t dotdev;
    ino_t dotino;
    bool mount_point;
    int parent_status;
    size_t dirroom;
    size_t namlen;
    bool use_d_ino = true;
    fd = openat(fd, "..", O_RDONLY);
    if (fd < 0)
      goto lose;
    fd_needs_closing = true;
    parent_status = fstat(fd, &st);
    if (parent_status != 0)
      goto lose;
    if (dirstream && closedir(dirstream) != 0) {
      dirstream = NULL;
      goto lose;
    }
    dotdev = st.st_dev;
    dotino = st.st_ino;
    mount_point = dotdev != thisdev;
    dirstream = fdopendir(fd);
    if (dirstream == NULL)
      goto lose;
    fd_needs_closing = false;
    for (;;) {
      (errno = (0));
      d = readdir(dirstream);
      if (d == NULL && errno == 0 && use_d_ino) {
        use_d_ino = false;
        rewinddir(dirstream);
        d = readdir(dirstream);
      }
      if (d == NULL) {
        if (errno == 0)
          (errno = (ENOENT));
        goto lose;
      }
      if (d->d_name[0] == '.' &&
          (d->d_name[1] == '\0' ||
           (d->d_name[1] == '.' && d->d_name[2] == '\0')))
        continue;
      if (use_d_ino) {
        bool match = (((d)->d_ino == (thisino)) || mount_point);
        if (!match)
          continue;
      }
      {
        int entry_status;
        entry_status = fstatat(fd, d->d_name, &st, AT_SYMLINK_NOFOLLOW);
        if (entry_status == 0 && S_ISDIR(st.st_mode) && st.st_dev == thisdev &&
            st.st_ino == thisino)
          break;
      }
    }
    dirroom = dirp - dir;
    namlen = strlen((d)->d_name);
    if (dirroom <= namlen) {
      if (size != 0) {
        (errno = (ERANGE));
        goto lose;
      } else {
        char *tmp;
        size_t oldsize = allocated;
        allocated += ((allocated) < (namlen) ? (namlen) : (allocated));
        if (allocated < oldsize || !(tmp = realloc(dir, allocated)))
          goto memory_exhausted;
        dirp = memcpy(tmp + allocated - (oldsize - dirroom), tmp + dirroom,
                      oldsize - dirroom);
        dir = tmp;
      }
    }
    dirp -= namlen;
    memcpy(dirp, d->d_name, namlen);
    *--dirp = '/';
    thisdev = dotdev;
    thisino = dotino;
  }
  if (dirstream && closedir(dirstream) != 0) {
    dirstream = NULL;
    goto lose;
  }
  if (dirp == &dir[allocated - 1])
    *--dirp = '/';
  used = dir + allocated - dirp;
  memmove(dir, dirp, used);
  if (size == 0)
    buf = realloc(dir, used);
  if (buf == NULL)
    buf = dir;
  return buf;
memory_exhausted:
  (errno = (ENOMEM));
lose : {
  int save = errno;
  if (dirstream)
    closedir(dirstream);
  if (fd_needs_closing)
    close(fd);
  if (buf == NULL)
    free(dir);
  (errno = (save));
}
  return NULL;
}


x86 assembly (clang, -O0):
<rpl_getcwd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10e0,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    0x2d5e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x78(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    %eax,%esi
call   1070 <getcwd@plt>
mov    %rax,-0x50(%rbp)
cmpq   $0x0,-0x50(%rbp)
jne    1297 <rpl_getcwd+0x77>
cmpq   $0x0,-0x18(%rbp)
je     12a4 <rpl_getcwd+0x84>
mov    0x2d42(%rip),%rax
mov    (%rax),%eax
mov    0x2d51(%rip),%rcx
cmp    (%rcx),%eax
jne    12a4 <rpl_getcwd+0x84>
mov    -0x50(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    19f5 <rpl_getcwd+0x7d5>
mov    0x2d1d(%rip),%rax
mov    (%rax),%eax
mov    0x2d0c(%rip),%rcx
cmp    (%rcx),%eax
jne    1309 <rpl_getcwd+0xe9>
cmpq   $0x0,-0x10(%rbp)
jne    1309 <rpl_getcwd+0xe9>
cmpq   $0x0,-0x18(%rbp)
jne    1309 <rpl_getcwd+0xe9>
lea    -0x1080(%rbp),%rdi
mov    $0x1000,%esi
call   1070 <getcwd@plt>
mov    %rax,-0x50(%rbp)
cmpq   $0x0,-0x50(%rbp)
je     1304 <rpl_getcwd+0xe4>
mov    -0x50(%rbp),%rdi
call   1120 <strdup@plt>
mov    %rax,-0x8(%rbp)
jmp    19f5 <rpl_getcwd+0x7d5>
jmp    1309 <rpl_getcwd+0xe9>
mov    0x2cb8(%rip),%rax
mov    (%rax),%eax
mov    0x2cc7(%rip),%rcx
cmp    (%rcx),%eax
je     135e <rpl_getcwd+0x13e>
mov    0x2ca0(%rip),%rax
mov    (%rax),%eax
mov    0x2c87(%rip),%rcx
cmp    (%rcx),%eax
je     135e <rpl_getcwd+0x13e>
mov    0x2c88(%rip),%rax
mov    (%rax),%eax
mov    0x2c57(%rip),%rcx
cmp    (%rcx),%eax
je     135e <rpl_getcwd+0x13e>
movq   $0x0,-0x8(%rbp)
jmp    19f5 <rpl_getcwd+0x7d5>
cmpq   $0x0,-0x18(%rbp)
jne    139b <rpl_getcwd+0x17b>
cmpq   $0x0,-0x10(%rbp)
je     1393 <rpl_getcwd+0x173>
mov    0x2c45(%rip),%rax
mov    (%rax),%ecx
mov    0x2c44(%rip),%rax
mov    %ecx,(%rax)
movq   $0x0,-0x8(%rbp)
jmp    19f5 <rpl_getcwd+0x7d5>
movq   $0x1000,-0x78(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    13d0 <rpl_getcwd+0x1b0>
mov    -0x78(%rbp),%rdi
call   10e0 <malloc@plt>
mov    %rax,-0x50(%rbp)
cmpq   $0x0,-0x50(%rbp)
jne    13cb <rpl_getcwd+0x1ab>
movq   $0x0,-0x8(%rbp)
jmp    19f5 <rpl_getcwd+0x7d5>
jmp    13d8 <rpl_getcwd+0x1b8>
mov    -0x10(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x50(%rbp),%rax
add    -0x78(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x58(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x58(%rbp)
movb   $0x0,-0x1(%rax)
lea    0xc05(%rip),%rdi
lea    -0x70(%rbp),%rsi
call   10b0 <lstat@plt>
cmp    $0x0,%rax
jge    1416 <rpl_getcwd+0x1f6>
jmp    1995 <rpl_getcwd+0x775>
mov    -0x70(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x68(%rbp),%rax
mov    %rax,-0x48(%rbp)
lea    0xbd3(%rip),%rdi
lea    -0x70(%rbp),%rsi
call   10b0 <lstat@plt>
cmp    $0x0,%rax
jge    1445 <rpl_getcwd+0x225>
jmp    1995 <rpl_getcwd+0x775>
mov    -0x70(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x68(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x38(%rbp),%rcx
xor    %eax,%eax
cmp    -0x30(%rbp),%rcx
mov    %al,-0x10d5(%rbp)
jne    147c <rpl_getcwd+0x25c>
mov    -0x48(%rbp),%rax
cmp    -0x40(%rbp),%rax
sete   %al
mov    %al,-0x10d5(%rbp)
mov    -0x10d5(%rbp),%al
xor    $0xff,%al
test   $0x1,%al
jne    1491 <rpl_getcwd+0x271>
jmp    18c9 <rpl_getcwd+0x6a9>
movl   $0x1,-0x10b4(%rbp)
mov    -0x1c(%rbp),%edi
mov    0x2b43(%rip),%rax
mov    (%rax),%edx
lea    0xb54(%rip),%rsi
call   1050 <openat@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    14c5 <rpl_getcwd+0x2a5>
jmp    1995 <rpl_getcwd+0x775>
movl   $0x1,-0x20(%rbp)
mov    -0x1c(%rbp),%edi
lea    -0x70(%rbp),%rsi
call   1130 <fstat@plt>
mov    %eax,-0x10a0(%rbp)
cmpl   $0x0,-0x10a0(%rbp)
je     14f0 <rpl_getcwd+0x2d0>
jmp    1995 <rpl_getcwd+0x775>
cmpq   $0x0,-0x28(%rbp)
je     151b <rpl_getcwd+0x2fb>
mov    -0x28(%rbp),%rdi
call   10a0 <closedir@plt>
cmp    $0x0,%rax
je     151b <rpl_getcwd+0x2fb>
movq   $0x0,-0x28(%rbp)
jmp    1995 <rpl_getcwd+0x775>
mov    -0x70(%rbp),%rax
mov    %rax,-0x1090(%rbp)
mov    -0x68(%rbp),%rax
mov    %rax,-0x1098(%rbp)
mov    -0x1090(%rbp),%rax
cmp    -0x38(%rbp),%rax
setne  %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x109c(%rbp)
mov    -0x1c(%rbp),%edi
call   1110 <fdopendir@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1566 <rpl_getcwd+0x346>
jmp    1995 <rpl_getcwd+0x775>
movl   $0x0,-0x20(%rbp)
mov    0x2a54(%rip),%rax
movl   $0x0,(%rax)
mov    -0x28(%rbp),%rdi
call   10d0 <readdir@plt>
mov    %rax,-0x1088(%rbp)
cmpq   $0x0,-0x1088(%rbp)
jne    15d8 <rpl_getcwd+0x3b8>
mov    0x2a29(%rip),%rax
cmpl   $0x0,(%rax)
jne    15d8 <rpl_getcwd+0x3b8>
cmpl   $0x0,-0x10b4(%rbp)
je     15d8 <rpl_getcwd+0x3b8>
movl   $0x0,-0x10b4(%rbp)
mov    -0x28(%rbp),%rdi
call   1090 <rewinddir@plt>
mov    -0x28(%rbp),%rdi
call   10d0 <readdir@plt>
mov    %rax,-0x1088(%rbp)
cmpq   $0x0,-0x1088(%rbp)
jne    160d <rpl_getcwd+0x3ed>
mov    0x29db(%rip),%rax
cmpl   $0x0,(%rax)
jne    1608 <rpl_getcwd+0x3e8>
mov    0x29a3(%rip),%rax
mov    (%rax),%ecx
mov    0x29c2(%rip),%rax
mov    %ecx,(%rax)
jmp    1995 <rpl_getcwd+0x775>
mov    -0x1088(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
jne    166d <rpl_getcwd+0x44d>
mov    -0x1088(%rbp),%rax
mov    (%rax),%rax
movsbl 0x1(%rax),%eax
cmp    $0x0,%eax
je     1668 <rpl_getcwd+0x448>
mov    -0x1088(%rbp),%rax
mov    (%rax),%rax
movsbl 0x1(%rax),%eax
cmp    $0x2e,%eax
jne    166d <rpl_getcwd+0x44d>
mov    -0x1088(%rbp),%rax
mov    (%rax),%rax
movsbl 0x2(%rax),%eax
cmp    $0x0,%eax
jne    166d <rpl_getcwd+0x44d>
jmp    156d <rpl_getcwd+0x34d>
cmpl   $0x0,-0x10b4(%rbp)
je     16cf <rpl_getcwd+0x4af>
mov    -0x1088(%rbp),%rax
mov    0x8(%rax),%rcx
mov    $0x1,%al
cmp    -0x48(%rbp),%rcx
mov    %al,-0x10d6(%rbp)
je     16a7 <rpl_getcwd+0x487>
cmpl   $0x0,-0x109c(%rbp)
setne  %al
mov    %al,-0x10d6(%rbp)
mov    -0x10d6(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x10b8(%rbp)
cmpl   $0x0,-0x10b8(%rbp)
jne    16ca <rpl_getcwd+0x4aa>
jmp    156d <rpl_getcwd+0x34d>
jmp    16cf <rpl_getcwd+0x4af>
mov    -0x1c(%rbp),%edi
mov    -0x1088(%rbp),%rax
mov    (%rax),%rsi
mov    0x28cd(%rip),%rax
mov    (%rax),%ecx
lea    -0x70(%rbp),%rdx
call   1140 <fstatat@plt>
mov    %eax,-0x10bc(%rbp)
cmpl   $0x0,-0x10bc(%rbp)
jne    1734 <rpl_getcwd+0x514>
mov    -0x60(%rbp),%edi
call   1060 <S_ISDIR@plt>
cmp    $0x0,%rax
je     1734 <rpl_getcwd+0x514>
mov    -0x70(%rbp),%rax
cmp    -0x38(%rbp),%rax
jne    1734 <rpl_getcwd+0x514>
mov    -0x68(%rbp),%rax
cmp    -0x48(%rbp),%rax
jne    1734 <rpl_getcwd+0x514>
jmp    1739 <rpl_getcwd+0x519>
jmp    156d <rpl_getcwd+0x34d>
mov    -0x58(%rbp),%rax
mov    -0x50(%rbp),%rcx
sub    %rcx,%rax
mov    %rax,-0x10a8(%rbp)
mov    -0x1088(%rbp),%rax
mov    (%rax),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x10b0(%rbp)
mov    -0x10a8(%rbp),%rax
cmp    -0x10b0(%rbp),%rax
ja     186a <rpl_getcwd+0x64a>
cmpq   $0x0,-0x18(%rbp)
je     1797 <rpl_getcwd+0x577>
mov    0x2859(%rip),%rax
mov    (%rax),%ecx
mov    0x2838(%rip),%rax
mov    %ecx,(%rax)
jmp    1995 <rpl_getcwd+0x775>
mov    -0x78(%rbp),%rax
mov    %rax,-0x10d0(%rbp)
mov    -0x78(%rbp),%rax
cmp    -0x10b0(%rbp),%rax
jae    17c6 <rpl_getcwd+0x5a6>
mov    -0x10b0(%rbp),%rax
mov    %rax,-0x10e0(%rbp)
jmp    17d1 <rpl_getcwd+0x5b1>
mov    -0x78(%rbp),%rax
mov    %rax,-0x10e0(%rbp)
mov    -0x10e0(%rbp),%rax
add    -0x78(%rbp),%rax
mov    %rax,-0x78(%rbp)
mov    -0x78(%rbp),%rax
cmp    -0x10d0(%rbp),%rax
jb     180f <rpl_getcwd+0x5ef>
mov    -0x50(%rbp),%rdi
mov    -0x78(%rbp),%rsi
call   10f0 <realloc@plt>
mov    %rax,-0x10c8(%rbp)
cmp    $0x0,%rax
jne    1814 <rpl_getcwd+0x5f4>
jmp    1983 <rpl_getcwd+0x763>
mov    -0x10c8(%rbp),%rdi
add    -0x78(%rbp),%rdi
mov    -0x10d0(%rbp),%rcx
sub    -0x10a8(%rbp),%rcx
xor    %eax,%eax
sub    %rcx,%rax
add    %rax,%rdi
mov    -0x10c8(%rbp),%rsi
add    -0x10a8(%rbp),%rsi
mov    -0x10d0(%rbp),%rdx
sub    -0x10a8(%rbp),%rdx
call   10c0 <memcpy@plt>
mov    %rax,-0x58(%rbp)
mov    -0x10c8(%rbp),%rax
mov    %rax,-0x50(%rbp)
jmp    186a <rpl_getcwd+0x64a>
mov    -0x10b0(%rbp),%rdx
mov    -0x58(%rbp),%rax
xor    %ecx,%ecx
sub    %rdx,%rcx
add    %rcx,%rax
mov    %rax,-0x58(%rbp)
mov    -0x58(%rbp),%rdi
mov    -0x1088(%rbp),%rax
mov    (%rax),%rsi
mov    -0x10b0(%rbp),%rdx
call   10c0 <memcpy@plt>
mov    -0x58(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x58(%rbp)
movb   $0x2f,-0x1(%rax)
mov    -0x1090(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x1098(%rbp),%rax
mov    %rax,-0x48(%rbp)
jmp    1455 <rpl_getcwd+0x235>
cmpq   $0x0,-0x28(%rbp)
je     18f4 <rpl_getcwd+0x6d4>
mov    -0x28(%rbp),%rdi
call   10a0 <closedir@plt>
cmp    $0x0,%rax
je     18f4 <rpl_getcwd+0x6d4>
movq   $0x0,-0x28(%rbp)
jmp    1995 <rpl_getcwd+0x775>
mov    -0x58(%rbp),%rax
mov    -0x50(%rbp),%rcx
mov    -0x78(%rbp),%rdx
sub    $0x1,%rdx
add    %rdx,%rcx
cmp    %rcx,%rax
jne    1923 <rpl_getcwd+0x703>
mov    -0x58(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x58(%rbp)
movb   $0x2f,-0x1(%rax)
mov    -0x50(%rbp),%rax
add    -0x78(%rbp),%rax
mov    -0x58(%rbp),%rcx
sub    %rcx,%rax
mov    %rax,-0x80(%rbp)
mov    -0x50(%rbp),%rdi
mov    -0x58(%rbp),%rsi
mov    -0x80(%rbp),%rdx
call   1100 <memmove@plt>
cmpq   $0x0,-0x18(%rbp)
jne    1963 <rpl_getcwd+0x743>
mov    -0x50(%rbp),%rdi
mov    -0x80(%rbp),%rsi
call   10f0 <realloc@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1976 <rpl_getcwd+0x756>
mov    -0x50(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    19f5 <rpl_getcwd+0x7d5>
mov    0x2646(%rip),%rax
mov    (%rax),%ecx
mov    0x2635(%rip),%rax
mov    %ecx,(%rax)
mov    0x262c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x10d4(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     19b8 <rpl_getcwd+0x798>
mov    -0x28(%rbp),%rdi
call   10a0 <closedir@plt>
cmpl   $0x0,-0x20(%rbp)
je     19ca <rpl_getcwd+0x7aa>
mov    -0x1c(%rbp),%edi
call   1080 <close@plt>
cmpq   $0x0,-0x10(%rbp)
jne    19de <rpl_getcwd+0x7be>
mov    -0x50(%rbp),%rdi
call   1030 <free@plt>
mov    -0x10d4(%rbp),%ecx
mov    0x25dd(%rip),%rax
mov    %ecx,(%rax)
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x10e0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rpl_getcwd>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1068,%rsp
mov    %rsi,%rbp
mov    %rdi,%rbx
mov    0x2d5a(%rip),%rax
mov    (%rax),%r12d
call   1070 <getcwd@plt>
mov    %rax,%r15
test   %rax,%rax
jne    1402 <rpl_getcwd+0x1e2>
mov    0x2d6f(%rip),%r14
mov    (%r14),%eax
test   %rbp,%rbp
je     1279 <rpl_getcwd+0x59>
mov    0x2d78(%rip),%rcx
cmp    (%rcx),%eax
je     13ff <rpl_getcwd+0x1df>
test   %rbx,%rbx
sete   %r13b
jmp    12b7 <rpl_getcwd+0x97>
test   %rbx,%rbx
sete   %r13b
jne    12b7 <rpl_getcwd+0x97>
mov    0x2d37(%rip),%rcx
cmp    (%rcx),%eax
jne    12b7 <rpl_getcwd+0x97>
lea    0x60(%rsp),%rdi
mov    $0x1000,%esi
call   1070 <getcwd@plt>
test   %rax,%rax
je     12b1 <rpl_getcwd+0x91>
mov    %rax,%rdi
call   1120 <strdup@plt>
mov    %rax,%r15
jmp    1402 <rpl_getcwd+0x1e2>
mov    (%r14),%eax
mov    $0x1,%r13b
mov    0x2d22(%rip),%rcx
mov    0x2cdb(%rip),%rdx
cmp    (%rcx),%eax
je     12dc <rpl_getcwd+0xbc>
mov    0x2ce8(%rip),%rcx
cmp    (%rcx),%eax
je     12dc <rpl_getcwd+0xbc>
cmp    (%rdx),%eax
jne    13ff <rpl_getcwd+0x1df>
test   %rbp,%rbp
je     12ee <rpl_getcwd+0xce>
mov    %rbp,%rdi
mov    %rbx,%r15
test   %r13b,%r13b
jne    12fc <rpl_getcwd+0xdc>
jmp    1313 <rpl_getcwd+0xf3>
mov    $0x1000,%edi
test   %r13b,%r13b
je     13d9 <rpl_getcwd+0x1b9>
mov    %rdi,%r15
call   10e0 <malloc@plt>
mov    %r15,%rdi
mov    %rax,%r15
test   %rax,%rax
je     13ff <rpl_getcwd+0x1df>
mov    %rdi,0x18(%rsp)
movb   $0x0,-0x1(%r15,%rdi,1)
lea    0xcde(%rip),%rdi
lea    0x60(%rsp),%rsi
call   10b0 <lstat@plt>
test   %rax,%rax
js     13ec <rpl_getcwd+0x1cc>
mov    %r13b,0x3(%rsp)
mov    0x60(%rsp),%r13
mov    0x68(%rsp),%rax
mov    %rax,0x8(%rsp)
lea    0xcad(%rip),%rdi
lea    0x60(%rsp),%rsi
call   10b0 <lstat@plt>
test   %rax,%rax
js     13e7 <rpl_getcwd+0x1c7>
mov    0x18(%rsp),%rcx
lea    (%r15,%rcx,1),%rsi
add    $0xffffffffffffffff,%rsi
mov    0x60(%rsp),%rax
mov    0x68(%rsp),%rdx
cmp    %rax,%r13
mov    %r13,%rdi
jne    1417 <rpl_getcwd+0x1f7>
cmp    %rdx,0x8(%rsp)
jne    1417 <rpl_getcwd+0x1f7>
lea    (%rcx,%r15,1),%rax
add    $0xffffffffffffffff,%rax
cmp    %rax,%rsi
jne    13a9 <rpl_getcwd+0x189>
movb   $0x2f,-0x1(%rsi)
add    $0xffffffffffffffff,%rsi
add    %r15,%rcx
sub    %rsi,%rcx
mov    %r15,%rdi
mov    %rcx,%r14
mov    %rcx,%rdx
call   1100 <memmove@plt>
test   %rbp,%rbp
jne    13d0 <rpl_getcwd+0x1b0>
mov    %r15,%rdi
mov    %r14,%rsi
call   10f0 <realloc@plt>
mov    %rax,%rbx
test   %rbx,%rbx
cmovne %rbx,%r15
jmp    1402 <rpl_getcwd+0x1e2>
mov    0x2be0(%rip),%rax
mov    (%rax),%eax
mov    %eax,(%r14)
jmp    13ff <rpl_getcwd+0x1df>
mov    0x3(%rsp),%r13b
mov    (%r14),%ebp
test   %r13b,%r13b
je     13fc <rpl_getcwd+0x1dc>
mov    %r15,%rdi
call   1030 <free@plt>
mov    %ebp,(%r14)
xor    %r15d,%r15d
mov    %r15,%rax
add    $0x1068,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rdx,0x48(%rsp)
mov    %rax,0x50(%rsp)
mov    %rsi,0x20(%rsp)
mov    %rbp,0x28(%rsp)
mov    %rbx,0x40(%rsp)
xor    %eax,%eax
mov    %rax,0x10(%rsp)
mov    0x2baa(%rip),%rax
lea    0xbbd(%rip),%rsi
mov    0x3(%rsp),%r13b
mov    %rdi,0x38(%rsp)
mov    (%rax),%edx
mov    %r12d,%edi
call   1050 <openat@plt>
mov    %eax,%r12d
test   %eax,%eax
js     1761 <rpl_getcwd+0x541>
mov    %r12d,%edi
lea    0x60(%rsp),%rsi
call   1130 <fstat@plt>
test   %eax,%eax
jne    1761 <rpl_getcwd+0x541>
mov    0x10(%rsp),%rdi
test   %rdi,%rdi
je     1491 <rpl_getcwd+0x271>
call   10a0 <closedir@plt>
test   %rax,%rax
jne    176c <rpl_getcwd+0x54c>
mov    0x60(%rsp),%rax
mov    %rax,0x30(%rsp)
mov    0x68(%rsp),%rax
mov    %rax,0x58(%rsp)
mov    %r12d,%edi
call   1110 <fdopendir@plt>
test   %rax,%rax
je     176c <rpl_getcwd+0x54c>
mov    %rax,0x10(%rsp)
mov    %r12d,0x4(%rsp)
mov    $0x1,%r13d
jmp    14ea <rpl_getcwd+0x2ca>
mov    0x2ae1(%rip),%rax
mov    (%rax),%ecx
mov    0x4(%rsp),%edi
lea    0x60(%rsp),%rdx
call   1140 <fstatat@plt>
mov    %r14d,%r13d
test   %eax,%eax
je     15b1 <rpl_getcwd+0x391>
mov    0x2ad7(%rip),%rbp
movl   $0x0,0x0(%rbp)
mov    0x10(%rsp),%rdi
call   10d0 <readdir@plt>
mov    %rax,%r12
test   %rax,%rax
jne    15a4 <rpl_getcwd+0x384>
cmpl   $0x0,0x0(%rbp)
jne    15a4 <rpl_getcwd+0x384>
mov    %r13d,%r14d
test   %r13d,%r13d
je     153b <rpl_getcwd+0x31b>
mov    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   1090 <rewinddir@plt>
mov    %rbx,%rdi
call   10d0 <readdir@plt>
mov    %rax,%r12
xor    %r14d,%r14d
test   %r12,%r12
je     1717 <rpl_getcwd+0x4f7>
mov    (%r12),%rsi
cmpb   $0x2e,(%rsi)
jne    1570 <rpl_getcwd+0x350>
movzbl 0x1(%rsi),%eax
mov    %r14d,%r13d
test   %al,%al
je     14ea <rpl_getcwd+0x2ca>
cmp    $0x2e,%al
jne    1570 <rpl_getcwd+0x350>
cmpb   $0x0,0x2(%rsi)
mov    %r14d,%r13d
je     14ea <rpl_getcwd+0x2ca>
cs nopw 0x0(%rax,%rax,1)
nop
test   %r14d,%r14d
je     14c8 <rpl_getcwd+0x2a8>
mov    0x8(%rsp),%rax
cmp    %rax,0x8(%r12)
je     14c8 <rpl_getcwd+0x2a8>
mov    $0x1,%r13d
mov    0x30(%rsp),%rax
cmp    0x38(%rsp),%rax
je     14ea <rpl_getcwd+0x2ca>
jmp    14c8 <rpl_getcwd+0x2a8>
mov    %r13d,%r14d
test   %r12,%r12
jne    1544 <rpl_getcwd+0x324>
jmp    1717 <rpl_getcwd+0x4f7>
mov    0x70(%rsp),%edi
call   1060 <S_ISDIR@plt>
mov    %r14d,%r13d
test   %rax,%rax
je     14ea <rpl_getcwd+0x2ca>
mov    %r14d,%r13d
mov    0x38(%rsp),%rax
cmp    %rax,0x60(%rsp)
jne    14ea <rpl_getcwd+0x2ca>
mov    %r14d,%r13d
mov    0x8(%rsp),%rax
cmp    %rax,0x68(%rsp)
jne    14ea <rpl_getcwd+0x2ca>
mov    0x20(%rsp),%r14
sub    %r15,%r14
mov    (%r12),%rdi
mov    %rdi,0x8(%rsp)
call   1040 <strlen@plt>
mov    %rax,%rbp
cmp    %rax,%r14
jbe    161b <rpl_getcwd+0x3fb>
mov    0x3(%rsp),%r13b
mov    0x20(%rsp),%rbx
mov    0x8(%rsp),%rsi
jmp    1686 <rpl_getcwd+0x466>
cmpq   $0x0,0x28(%rsp)
mov    0x3(%rsp),%r13b
jne    177a <rpl_getcwd+0x55a>
mov    0x18(%rsp),%rax
cmp    %rbp,%rax
mov    %rax,%rbx
cmovb  %rbp,%rbx
add    %rax,%rbx
jb     1771 <rpl_getcwd+0x551>
mov    %r15,%rdi
mov    %rbx,%rsi
call   10f0 <realloc@plt>
test   %rax,%rax
je     1771 <rpl_getcwd+0x551>
mov    %rbx,%r15
add    %rax,%rbx
mov    0x18(%rsp),%rdx
sub    %r14,%rdx
sub    %rdx,%rbx
mov    %rax,%rsi
add    %r14,%rsi
mov    %rbx,%rdi
mov    %rax,%r14
call   10c0 <memcpy@plt>
mov    (%r12),%rsi
mov    %r15,0x18(%rsp)
mov    %r14,%r15
sub    %rbp,%rbx
mov    %rbx,%rdi
mov    %rbp,%rdx
call   10c0 <memcpy@plt>
movb   $0x2f,-0x1(%rbx)
add    $0xffffffffffffffff,%rbx
mov    %rbx,0x20(%rsp)
mov    0x30(%rsp),%rdx
mov    %rdx,%rdi
mov    0x58(%rsp),%rcx
mov    %rcx,0x8(%rsp)
cmp    0x50(%rsp),%rdx
mov    0x2909(%rip),%r14
mov    0x4(%rsp),%r12d
mov    0x291d(%rip),%rax
lea    0x930(%rip),%rsi
jne    144a <rpl_getcwd+0x22a>
mov    %rdx,%rdi
mov    %rcx,0x8(%rsp)
cmp    0x48(%rsp),%rcx
jne    144a <rpl_getcwd+0x22a>
mov    0x10(%rsp),%rdi
call   10a0 <closedir@plt>
test   %rax,%rax
mov    0x40(%rsp),%rbx
mov    0x28(%rsp),%rbp
mov    0x18(%rsp),%rcx
mov    0x20(%rsp),%rsi
jne    13ec <rpl_getcwd+0x1cc>
jmp    1394 <rpl_getcwd+0x174>
mov    0x28aa(%rip),%r14
mov    (%r14),%ebp
mov    $0x1,%bl
test   %ebp,%ebp
jne    1733 <rpl_getcwd+0x513>
mov    0x2872(%rip),%rax
mov    (%rax),%ebp
mov    %ebp,(%r14)
mov    0x3(%rsp),%r13b
mov    0x4(%rsp),%r12d
mov    0x10(%rsp),%rdi
test   %rdi,%rdi
je     174c <rpl_getcwd+0x52c>
call   10a0 <closedir@plt>
test   %bl,%bl
jne    13ef <rpl_getcwd+0x1cf>
mov    %r12d,%edi
call   1080 <close@plt>
jmp    13ef <rpl_getcwd+0x1cf>
mov    %r12d,%ebx
shr    $0x1f,%ebx
mov    (%r14),%ebp
jmp    173d <rpl_getcwd+0x51d>
mov    (%r14),%ebp
jmp    1754 <rpl_getcwd+0x534>
mov    0x2858(%rip),%rax
jmp    1781 <rpl_getcwd+0x561>
mov    0x285f(%rip),%rax
mov    (%rax),%ebp
mov    0x283e(%rip),%r14
mov    %ebp,(%r14)
mov    $0x1,%bl
jmp    1738 <rpl_getcwd+0x518>

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

LLVM IR (-O2):
%struct.stat = type { i64, i64, i32 }
%struct.dirent = type { i8*, i64 }
@AT_FDCWD = global i32 0
@errno = global i32 0
@ERANGE = global i32 0
@EINVAL = global i32 0
@ENAMETOOLONG = global i32 0
@ENOENT = global i32 0
@.str = [2 x i8] c".\00"
@.str.1 = [2 x i8] c"/\00"
@.str.2 = [3 x i8] c"..\00"
@O_RDONLY = global i32 0
@AT_SYMLINK_NOFOLLOW = global i32 0
@ENOMEM = global i32 0
define i8* @rpl_getcwd(i8* %0, i64 %1) {
%3 = alloca %struct.stat
%4 = alloca [4096 x i8]
%5 = load i32, i32* @AT_FDCWD
%6 = bitcast %struct.stat* %3 to i8*
%7 = trunc i64 %1 to i32
%8 = tail call i8* @getcwd(i8* %0, i32 %7)
%9 = icmp eq i8* %8, null
br i1 %9, label %10, label %242
10: ; preds = %2
%11 = icmp eq i64 %1, 0
%12 = load i32, i32* @errno
br i1 %11, label %18, label %13
13: ; preds = %10
%14 = load i32, i32* @ERANGE
%15 = icmp eq i32 %12, %14
br i1 %15, label %242, label %16
16: ; preds = %13
%17 = icmp eq i8* %0, null
br label %31
18: ; preds = %10
%19 = load i32, i32* @EINVAL
%20 = icmp eq i32 %12, %19
%21 = icmp eq i8* %0, null
%22 = and i1 %21, %20
br i1 %22, label %23, label %31
23: ; preds = %18
%24 = getelementptr inbounds [4096 x i8], [4096 x i8]* %4, i64 0, i64 0
%25 = call i8* @getcwd(i8* %24, i32 4096)
%26 = icmp eq i8* %25, null
br i1 %26, label %27, label %29
27: ; preds = %23
%28 = load i32, i32* @errno
br label %31
29: ; preds = %23
%30 = call i8* @strdup(i8* %25)
br label %242
31: ; preds = %27, %16, %18
%32 = phi i32 [ %12, %18 ], [ %12, %16 ], [ %28, %27 ]
%33 = phi i1 [ %21, %18 ], [ %17, %16 ], [ true, %27 ]
%34 = load i32, i32* @ERANGE
%35 = icmp eq i32 %32, %34
%36 = load i32, i32* @ENAMETOOLONG
%37 = icmp eq i32 %32, %36
%38 = select i1 %35, i1 true, i1 %37
%39 = load i32, i32* @ENOENT
%40 = icmp eq i32 %32, %39
%41 = select i1 %38, i1 true, i1 %40
br i1 %41, label %42, label %242
42: ; preds = %31
br i1 %11, label %43, label %46
43: ; preds = %42
br i1 %33, label %47, label %44
44: ; preds = %43
%45 = load i32, i32* @EINVAL
store i32 %45, i32* @errno
br label %242
46: ; preds = %42
br i1 %33, label %47, label %51
47: ; preds = %43, %46
%48 = phi i64 [ %1, %46 ], [ 4096, %43 ]
%49 = call i8* @malloc(i64 %48)
%50 = icmp eq i8* %49, null
br i1 %50, label %242, label %51
51: ; preds = %46, %47
%52 = phi i64 [ %48, %47 ], [ %1, %46 ]
%53 = phi i8* [ %49, %47 ], [ %0, %46 ]
%54 = getelementptr inbounds i8, i8* %53, i64 %52
%55 = getelementptr inbounds i8, i8* %54, i64 -1
store i8 0, i8* %55
%56 = call i64 @lstat(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), %struct.stat* %3)
%57 = icmp slt i64 %56, 0
br i1 %57, label %218, label %58
58: ; preds = %51
%59 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0
%60 = load i64, i64* %59
%61 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 1
%62 = load i64, i64* %61
%63 = call i64 @lstat(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), %struct.stat* %3)
%64 = icmp slt i64 %63, 0
br i1 %64, label %218, label %65
65: ; preds = %58
%66 = load i64, i64* %59
%67 = load i64, i64* %61
%68 = icmp ne i64 %60, %66
%69 = icmp ne i64 %62, %67
%70 = select i1 %68, i1 true, i1 %69
br i1 %70, label %71, label %194
71: ; preds = %65
%72 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 2
br label %73
73: ; preds = %71, %180
%74 = phi i32 [ %5, %71 ], [ %82, %180 ]
%75 = phi i32* [ null, %71 ], [ %96, %180 ]
%76 = phi i64 [ %60, %71 ], [ %93, %180 ]
%77 = phi i64 [ %62, %71 ], [ %94, %180 ]
%78 = phi i8* [ %53, %71 ], [ %184, %180 ]
%79 = phi i8* [ %55, %71 ], [ %187, %180 ]
%80 = phi i64 [ %52, %71 ], [ %182, %180 ]
%81 = load i32, i32* @O_RDONLY
%82 = call i32 @openat(i32 %74, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %81)
%83 = icmp slt i32 %82, 0
br i1 %83, label %223, label %84
84: ; preds = %73
%85 = call i32 @fstat(i32 %82, %struct.stat* %3)
%86 = icmp eq i32 %85, 0
br i1 %86, label %87, label %223
87: ; preds = %84
%88 = icmp eq i32* %75, null
br i1 %88, label %92, label %89
89: ; preds = %87
%90 = call i64 @closedir(i32* %75)
%91 = icmp eq i64 %90, 0
br i1 %91, label %92, label %221
92: ; preds = %89, %87
%93 = load i64, i64* %59
%94 = load i64, i64* %61
%95 = icmp ne i64 %93, %76
%96 = call i32* @fdopendir(i32 %82)
%97 = icmp eq i32* %96, null
br i1 %97, label %221, label %98
98: ; preds = %92, %152
%99 = phi i32 [ %153, %152 ], [ 1, %92 ]
store i32 0, i32* @errno
%100 = call %struct.dirent* @readdir(i32* %96)
%101 = icmp eq %struct.dirent* %100, null
%102 = load i32, i32* @errno
%103 = icmp eq i32 %102, 0
%104 = select i1 %101, i1 %103, i1 false
%105 = icmp ne i32 %99, 0
%106 = select i1 %104, i1 %105, i1 false
br i1 %106, label %107, label %110
107: ; preds = %98
%108 = call i32 @rewinddir(i32* %96)
%109 = call %struct.dirent* @readdir(i32* %96)
br label %110
110: ; preds = %107, %98
%111 = phi %struct.dirent* [ %109, %107 ], [ %100, %98 ]
%112 = phi i32 [ 0, %107 ], [ %99, %98 ]
%113 = icmp eq %struct.dirent* %111, null
br i1 %113, label %114, label %119
114: ; preds = %110
%115 = load i32, i32* @errno
%116 = icmp eq i32 %115, 0
br i1 %116, label %117, label %225
117: ; preds = %114
%118 = load i32, i32* @ENOENT
store i32 %118, i32* @errno
br label %225
119: ; preds = %110
%120 = getelementptr inbounds %struct.dirent, %struct.dirent* %111, i64 0, i32 0
%121 = load i8*, i8** %120
%122 = load i8, i8* %121
%123 = icmp eq i8 %122, 46
br i1 %123, label %124, label %131
124: ; preds = %119
%125 = getelementptr inbounds i8, i8* %121, i64 1
%126 = load i8, i8* %125
switch i8 %126, label %131 [
i8 0, label %152
i8 46, label %127
]
127: ; preds = %124
%128 = getelementptr inbounds i8, i8* %121, i64 2
%129 = load i8, i8* %128
%130 = icmp eq i8 %129, 0
br i1 %130, label %152, label %131
131: ; preds = %124, %127, %119
%132 = icmp eq i32 %112, 0
br i1 %132, label %138, label %133
133: ; preds = %131
%134 = getelementptr inbounds %struct.dirent, %struct.dirent* %111, i64 0, i32 1
%135 = load i64, i64* %134
%136 = icmp eq i64 %135, %77
%137 = select i1 %136, i1 true, i1 %95
br i1 %137, label %138, label %152
138: ; preds = %133, %131
%139 = load i32, i32* @AT_SYMLINK_NOFOLLOW
%140 = call i32 @fstatat(i32 %82, i8* %121, %struct.stat* %3, i32 %139)
%141 = icmp eq i32 %140, 0
br i1 %141, label %142, label %152
142: ; preds = %138
%143 = load i32, i32* %72
%144 = call i64 @S_ISDIR(i32 %143)
%145 = icmp ne i64 %144, 0
%146 = load i64, i64* %59
%147 = icmp eq i64 %146, %76
%148 = select i1 %145, i1 %147, i1 false
%149 = load i64, i64* %61
%150 = icmp eq i64 %149, %77
%151 = select i1 %148, i1 %150, i1 false
br i1 %151, label %154, label %152
152: ; preds = %142, %138, %127, %124, %133
%153 = phi i32 [ 1, %133 ], [ %112, %124 ], [ %112, %127 ], [ %112, %138 ], [ %112, %142 ]
br label %98
154: ; preds = %142
%155 = getelementptr inbounds %struct.dirent, %struct.dirent* %111, i64 0, i32 0
%156 = ptrtoint i8* %79 to i64
%157 = ptrtoint i8* %78 to i64
%158 = sub i64 %156, %157
%159 = load i8*, i8** %155
%160 = call i64 @strlen(i8* dereferenceable(1) %159)
%161 = icmp ugt i64 %158, %160
br i1 %161, label %180, label %162
162: ; preds = %154
br i1 %11, label %165, label %163
163: ; preds = %162
%164 = load i32, i32* @ERANGE
store i32 %164, i32* @errno
br label %225
165: ; preds = %162
%166 = icmp ult i64 %80, %160
%167 = select i1 %166, i64 %160, i64 %80
%168 = add i64 %167, %80
%169 = icmp ult i64 %168, %80
br i1 %169, label %216, label %170
170: ; preds = %165
%171 = call i8* @realloc(i8* %78, i64 %168)
%172 = icmp eq i8* %171, null
br i1 %172, label %216, label %173
173: ; preds = %170
%174 = getelementptr inbounds i8, i8* %171, i64 %168
%175 = sub i64 %80, %158
%176 = sub i64 0, %175
%177 = getelementptr inbounds i8, i8* %174, i64 %176
%178 = getelementptr inbounds i8, i8* %171, i64 %158
%179 = load i8*, i8** %155
br label %180
180: ; preds = %154, %173
%181 = phi i8* [ %179, %173 ], [ %159, %154 ]
%182 = phi i64 [ %168, %173 ], [ %80, %154 ]
%183 = phi i8* [ %177, %173 ], [ %79, %154 ]
%184 = phi i8* [ %171, %173 ], [ %78, %154 ]
%185 = sub i64 0, %160
%186 = getelementptr inbounds i8, i8* %183, i64 %185
%187 = getelementptr inbounds i8, i8* %186, i64 -1
store i8 47, i8* %187
%188 = icmp ne i64 %93, %66
%189 = icmp ne i64 %94, %67
%190 = select i1 %188, i1 true, i1 %189
br i1 %190, label %73, label %191
191: ; preds = %180
%192 = call i64 @closedir(i32* %96)
%193 = icmp eq i64 %192, 0
br i1 %193, label %194, label %218
194: ; preds = %65, %191
%195 = phi i8* [ %184, %191 ], [ %53, %65 ]
%196 = phi i8* [ %187, %191 ], [ %55, %65 ]
%197 = phi i64 [ %182, %191 ], [ %52, %65 ]
%198 = add i64 %197, -1
%199 = getelementptr inbounds i8, i8* %195, i64 %198
%200 = icmp eq i8* %196, %199
br i1 %200, label %201, label %203
201: ; preds = %194
%202 = getelementptr inbounds i8, i8* %196, i64 -1
store i8 47, i8* %202
br label %203
203: ; preds = %201, %194
%204 = phi i8* [ %202, %201 ], [ %196, %194 ]
%205 = getelementptr inbounds i8, i8* %195, i64 %197
%206 = ptrtoint i8* %205 to i64
%207 = ptrtoint i8* %204 to i64
%208 = sub i64 %206, %207
%209 = call i32 @memmove(i8* %195, i8* %204, i64 %208)
br i1 %11, label %210, label %212
210: ; preds = %203
%211 = call i8* @realloc(i8* %195, i64 %208)
br label %212
212: ; preds = %210, %203
%213 = phi i8* [ %211, %210 ], [ %0, %203 ]
%214 = icmp eq i8* %213, null
%215 = select i1 %214, i8* %195, i8* %213
br label %242
216: ; preds = %170, %165
%217 = load i32, i32* @ENOMEM
store i32 %217, i32* @errno
br label %225
218: ; preds = %191, %58, %51
%219 = phi i8* [ %184, %191 ], [ %53, %58 ], [ %53, %51 ]
%220 = load i32, i32* @errno
br label %236
221: ; preds = %89, %92
%222 = load i32, i32* @errno
br label %233
223: ; preds = %73, %84
%224 = load i32, i32* @errno
br label %225
225: ; preds = %223, %114, %117, %163, %216
%226 = phi i32 [ %217, %216 ], [ %115, %114 ], [ %118, %117 ], [ %164, %163 ], [ %224, %223 ]
%227 = phi i32* [ %96, %216 ], [ %96, %114 ], [ %96, %117 ], [ %96, %163 ], [ %75, %223 ]
%228 = phi i1 [ true, %216 ], [ true, %114 ], [ true, %117 ], [ true, %163 ], [ %83, %223 ]
%229 = icmp eq i32* %227, null
br i1 %229, label %232, label %230
230: ; preds = %225
%231 = call i64 @closedir(i32* %227)
br label %232
232: ; preds = %230, %225
br i1 %228, label %236, label %233
233: ; preds = %221, %232
%234 = phi i32 [ %222, %221 ], [ %226, %232 ]
%235 = call i32 @close(i32 %82)
br label %236
236: ; preds = %218, %233, %232
%237 = phi i8* [ %219, %218 ], [ %78, %233 ], [ %78, %232 ]
%238 = phi i32 [ %220, %218 ], [ %234, %233 ], [ %226, %232 ]
br i1 %33, label %239, label %241
239: ; preds = %236
%240 = call i32 @free(i8* %237)
br label %241
241: ; preds = %239, %236
store i32 %238, i32* @errno
br label %242
242: ; preds = %29, %47, %31, %2, %13, %241, %212, %44
%243 = phi i8* [ null, %44 ], [ null, %241 ], [ %215, %212 ], [ %30, %29 ], [ null, %13 ], [ %8, %2 ], [ null, %31 ], [ null, %47 ]
ret i8* %243
}