#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 {
  int /*<<< orphan*/ st_mode;
};
struct dirent {
  char *d_name;
};
typedef int /*<<< orphan*/ DIR;

/* Variables and functions */
scalar_t__ ENOENT;
int O_DIRECTORY;
int O_RDONLY;
size_t PATH_MAX;
scalar_t__ S_ISDIR(int /*<<< orphan*/);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ closedir(int /*<<< orphan*/ *);
int dup(int);
scalar_t__ errno;
int /*<<< orphan*/ *fdopendir(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, ...);
int fstatat(int, char *, struct stat *, int /*<<< orphan*/);
int /*<<< orphan*/ memcpy(char *, char *, size_t);
scalar_t__ mkdirat(int, char *, int);
int openat(int, char *, int);
int /*<<< orphan*/ perror(char *);
struct dirent *readdir(int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
size_t strlen(char *);
scalar_t__ symlinkat(char *, int, char *);
int link_tree(int src_fd, char *src_path, size_t len, int dst_fd) {
  DIR *src_d;
  int ret = 0, fd, nsrc_fd, ndst_fd, x;
  struct dirent *de;
  struct stat st;
  size_t elen;
  if ((fd = dup(src_fd)) == -1) {
    perror("dup failed");
    fprintf(stderr, "link_tree: duplicating source fd failed on %s\n",
            src_path);
    return -1;
  }
  if ((src_d = fdopendir(fd)) == NULL) {
    close(fd);
    perror("fdopendir failed");
    fprintf(stderr, "fdopendir failed on %s\n", src_path);
    return -1;
  }
  errno = 0;
  while ((de = readdir(src_d)) != NULL) {
    if (de->d_name[0] == '.') {
      errno = 0;
      continue;
    }
    if (fstatat(src_fd, de->d_name, &st, 0) != 0) {
      perror("fstatat failed");
      fprintf(stderr, "link_tree: fstatat failed on entry %s/%s\n", src_path,
              de->d_name);
      ret = -1;
      goto exit;
    }
    elen = strlen(de->d_name);
    if (len + 1 + elen > PATH_MAX) {
      fprintf(stderr, "link_tree: path too long on entry %s/%s\n", src_path,
              de->d_name);
      ret = -1;
      goto exit;
    }
    src_path[len] = '/';
    memcpy(src_path + len + 1, de->d_name, elen + 1);
    if (S_ISDIR(st.st_mode)) {
      if ((x = fstatat(dst_fd, de->d_name, &st, 0)) != 0 && errno != ENOENT) {
        perror("fstatat failed");
        fprintf(stderr,
                "link_tree: fstatat failed on dst entry "
                "%s\n",
                src_path);
        ret = -1;
        goto exit;
      }
      if (x == 0 && !S_ISDIR(st.st_mode)) {
        fprintf(stderr,
                "link_tree: destination entry for dir %s exists"
                " but is not directory\n",
                src_path);
        ret = -1;
        goto exit;
      } else if (x != 0 && mkdirat(dst_fd, de->d_name, 0755) != 0) {
        perror("mkdirat failed");
        fprintf(stderr,
                "link_tree: creating destination dir for %s "
                "failed\n",
                src_path);
        ret = -1;
        goto exit;
      }
      if ((nsrc_fd = openat(src_fd, de->d_name, O_RDONLY | O_DIRECTORY)) ==
          -1) {
        perror("openat failed");
        fprintf(stderr, "link_tree: openat of src %s failed\n", src_path);
        ret = -1;
        goto exit;
      }
      if ((ndst_fd = openat(dst_fd, de->d_name, O_RDONLY | O_DIRECTORY)) ==
          -1) {
        perror("openat failed");
        close(nsrc_fd);
        fprintf(stderr, "link_tree: openat of dst for %s failed\n", src_path);
        ret = -1;
        goto exit;
      }
      x = link_tree(nsrc_fd, src_path, len + 1 + elen, ndst_fd);
      close(nsrc_fd);
      close(ndst_fd);
      if (x != 0) {
        fprintf(stderr, "link_tree: linking subtree at %s failed\n", src_path);
        ret = -1;
        goto exit;
      }
    } else {
      if (symlinkat(src_path, dst_fd, de->d_name) != 0) {
        perror("symlinkat failed");
        fprintf(stderr, "link_tree: linking entry %s failed\n", src_path);
        ret = -1;
        goto exit;
      }
    }
    errno = 0;
  }
  if (errno != 0) {
    perror("readdir failed");
    ret = -1;
  }
exit:
  closedir(src_d);
  src_path[len] = 0;
  return ret;
}


x86 assembly (clang, -O0):
<link_tree>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x8(%rbp),%edi
call   1060 <dup@plt>
mov    %eax,-0x30(%rbp)
cmp    $0xffffffff,%eax
jne    1254 <link_tree+0x64>
lea    0xdd8(%rip),%rdi
call   10e0 <perror@plt>
mov    0x2d94(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xdca(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    16c9 <link_tree+0x4d9>
mov    -0x30(%rbp),%edi
call   10f0 <fdopendir@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    12a5 <link_tree+0xb5>
mov    -0x30(%rbp),%edi
call   1070 <close@plt>
lea    0xdc1(%rip),%rdi
call   10e0 <perror@plt>
mov    0x2d43(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xdb9(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    16c9 <link_tree+0x4d9>
mov    0x2d14(%rip),%rax
movq   $0x0,(%rax)
mov    -0x28(%rbp),%rdi
call   10c0 <readdir@plt>
mov    %rax,-0x48(%rbp)
cmp    $0x0,%rax
je     1685 <link_tree+0x495>
mov    -0x48(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
jne    12f0 <link_tree+0x100>
mov    0x2cdc(%rip),%rax
movq   $0x0,(%rax)
jmp    12b3 <link_tree+0xc3>
mov    -0x8(%rbp),%edi
mov    -0x48(%rbp),%rax
mov    (%rax),%rsi
lea    -0x50(%rbp),%rdx
xor    %ecx,%ecx
call   1110 <fstatat@plt>
cmp    $0x0,%eax
je     1348 <link_tree+0x158>
lea    0xd4e(%rip),%rdi
call   10e0 <perror@plt>
mov    0x2ca7(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
mov    -0x48(%rbp),%rax
mov    (%rax),%rcx
lea    0xd3d(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
movl   $0xffffffff,-0x2c(%rbp)
jmp    16ae <link_tree+0x4be>
mov    -0x48(%rbp),%rax
mov    (%rax),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x58(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
add    -0x58(%rbp),%rax
mov    0x2c85(%rip),%rcx
cmp    (%rcx),%rax
jbe    13a2 <link_tree+0x1b2>
mov    0x2c4d(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
mov    -0x48(%rbp),%rax
mov    (%rax),%rcx
lea    0xd0d(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
movl   $0xffffffff,-0x2c(%rbp)
jmp    16ae <link_tree+0x4be>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
movb   $0x2f,(%rax,%rcx,1)
mov    -0x10(%rbp),%rdi
add    -0x18(%rbp),%rdi
add    $0x1,%rdi
mov    -0x48(%rbp),%rax
mov    (%rax),%rsi
mov    -0x58(%rbp),%rdx
add    $0x1,%rdx
call   10b0 <memcpy@plt>
mov    -0x50(%rbp),%edi
call   1050 <S_ISDIR@plt>
cmp    $0x0,%rax
je     161d <link_tree+0x42d>
mov    -0x1c(%rbp),%edi
mov    -0x48(%rbp),%rax
mov    (%rax),%rsi
lea    -0x50(%rbp),%rdx
xor    %ecx,%ecx
call   1110 <fstatat@plt>
mov    %eax,-0x3c(%rbp)
cmp    $0x0,%eax
je     144e <link_tree+0x25e>
mov    0x2bb8(%rip),%rax
mov    (%rax),%rax
mov    0x2b9e(%rip),%rcx
cmp    (%rcx),%rax
je     144e <link_tree+0x25e>
lea    0xc41(%rip),%rdi
call   10e0 <perror@plt>
mov    0x2b9a(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xc8a(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
movl   $0xffffffff,-0x2c(%rbp)
jmp    16ae <link_tree+0x4be>
cmpl   $0x0,-0x3c(%rbp)
jne    1491 <link_tree+0x2a1>
mov    -0x50(%rbp),%edi
call   1050 <S_ISDIR@plt>
cmp    $0x0,%rax
jne    1491 <link_tree+0x2a1>
mov    0x2b57(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xc72(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
movl   $0xffffffff,-0x2c(%rbp)
jmp    16ae <link_tree+0x4be>
cmpl   $0x0,-0x3c(%rbp)
je     14ec <link_tree+0x2fc>
mov    -0x1c(%rbp),%edi
mov    -0x48(%rbp),%rax
mov    (%rax),%rsi
mov    $0x1ed,%edx
call   10a0 <mkdirat@plt>
cmp    $0x0,%rax
je     14ec <link_tree+0x2fc>
lea    0xc75(%rip),%rdi
call   10e0 <perror@plt>
mov    0x2afc(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xc6b(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
movl   $0xffffffff,-0x2c(%rbp)
jmp    16ae <link_tree+0x4be>
jmp    14f1 <link_tree+0x301>
mov    -0x8(%rbp),%edi
mov    -0x48(%rbp),%rax
mov    (%rax),%rsi
mov    0x2ade(%rip),%rax
mov    (%rax),%edx
mov    0x2ac5(%rip),%rax
or     (%rax),%edx
call   1040 <openat@plt>
mov    %eax,-0x34(%rbp)
cmp    $0xffffffff,%eax
jne    1551 <link_tree+0x361>
lea    0xc52(%rip),%rdi
call   10e0 <perror@plt>
mov    0x2a97(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xc47(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
movl   $0xffffffff,-0x2c(%rbp)
jmp    16ae <link_tree+0x4be>
mov    -0x1c(%rbp),%edi
mov    -0x48(%rbp),%rax
mov    (%rax),%rsi
mov    0x2a7e(%rip),%rax
mov    (%rax),%edx
mov    0x2a65(%rip),%rax
or     (%rax),%edx
call   1040 <openat@plt>
mov    %eax,-0x38(%rbp)
cmp    $0xffffffff,%eax
jne    15b9 <link_tree+0x3c9>
lea    0xbf2(%rip),%rdi
call   10e0 <perror@plt>
mov    -0x34(%rbp),%edi
call   1070 <close@plt>
mov    0x2a2f(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xc03(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
movl   $0xffffffff,-0x2c(%rbp)
jmp    16ae <link_tree+0x4be>
mov    -0x34(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
add    $0x1,%rdx
add    -0x58(%rbp),%rdx
mov    -0x38(%rbp),%ecx
call   10d0 <link_tree@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x34(%rbp),%edi
call   1070 <close@plt>
mov    -0x38(%rbp),%edi
call   1070 <close@plt>
cmpl   $0x0,-0x3c(%rbp)
je     1618 <link_tree+0x428>
mov    0x29d0(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xbcc(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
movl   $0xffffffff,-0x2c(%rbp)
jmp    16ae <link_tree+0x4be>
jmp    1672 <link_tree+0x482>
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x48(%rbp),%rax
mov    (%rax),%rdx
call   1100 <symlinkat@plt>
cmp    $0x0,%rax
je     166d <link_tree+0x47d>
lea    0xbb9(%rip),%rdi
call   10e0 <perror@plt>
mov    0x297b(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xbb1(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
movl   $0xffffffff,-0x2c(%rbp)
jmp    16ae <link_tree+0x4be>
jmp    1672 <link_tree+0x482>
mov    0x2947(%rip),%rax
movq   $0x0,(%rax)
jmp    12b3 <link_tree+0xc3>
mov    0x2934(%rip),%rax
cmpq   $0x0,(%rax)
je     16a9 <link_tree+0x4b9>
lea    0xb92(%rip),%rdi
call   10e0 <perror@plt>
movl   $0xffffffff,-0x2c(%rbp)
jmp    16ae <link_tree+0x4be>
mov    -0x28(%rbp),%rdi
call   1080 <closedir@plt>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x2c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<link_tree>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %ecx,0xc(%rsp)
mov    %rdx,%r12
mov    %rsi,(%rsp)
mov    %edi,%r13d
call   1060 <dup@plt>
cmp    $0xffffffff,%eax
je     145f <link_tree+0x26f>
mov    %eax,%ebx
mov    %eax,%edi
call   10f0 <fdopendir@plt>
test   %rax,%rax
je     147d <link_tree+0x28d>
mov    %rax,%rbp
mov    0x2d8a(%rip),%rax
movq   $0x0,(%rax)
mov    %rbp,%rdi
call   10c0 <readdir@plt>
test   %rax,%rax
je     141b <link_tree+0x22b>
mov    %rax,%r15
mov    (%rsp),%rax
lea    (%rax,%r12,1),%rcx
mov    %rcx,0x30(%rsp)
add    %r12,%rax
add    $0x1,%rax
mov    %rax,0x28(%rsp)
mov    %rbp,0x20(%rsp)
mov    %r12,0x18(%rsp)
jmp    12b2 <link_tree+0xc2>
mov    (%rsp),%rdi
mov    0xc(%rsp),%esi
call   1100 <symlinkat@plt>
test   %rax,%rax
jne    157d <link_tree+0x38d>
nopl   0x0(%rax)
mov    0x2d29(%rip),%rax
movq   $0x0,(%rax)
mov    %rbp,%rdi
call   10c0 <readdir@plt>
mov    %rax,%r15
test   %rax,%rax
je     141b <link_tree+0x22b>
mov    (%r15),%rsi
cmpb   $0x2e,(%rsi)
je     1290 <link_tree+0xa0>
mov    %r13d,%edi
lea    0x10(%rsp),%rdx
xor    %ecx,%ecx
call   1110 <fstatat@plt>
test   %eax,%eax
jne    14f4 <link_tree+0x304>
mov    (%r15),%rbx
mov    %rbx,%rdi
call   1030 <strlen@plt>
lea    (%rax,%r12,1),%r14
add    $0x1,%r14
mov    0x2d05(%rip),%rcx
cmp    (%rcx),%r14
ja     143f <link_tree+0x24f>
add    $0x1,%rax
mov    0x30(%rsp),%rcx
movb   $0x2f,(%rcx)
mov    (%r15),%rsi
mov    0x28(%rsp),%rdi
mov    %rax,%rdx
call   10b0 <memcpy@plt>
mov    0x10(%rsp),%edi
call   1050 <S_ISDIR@plt>
mov    (%r15),%rdx
test   %rax,%rax
je     1276 <link_tree+0x86>
mov    0xc(%rsp),%edi
mov    %rdx,%rsi
lea    0x10(%rsp),%rdx
xor    %ecx,%ecx
call   1110 <fstatat@plt>
test   %eax,%eax
je     1371 <link_tree+0x181>
mov    0x2c7d(%rip),%rax
mov    (%rax),%rax
mov    0x2c63(%rip),%rcx
cmp    (%rcx),%rax
jne    159e <link_tree+0x3ae>
mov    (%r15),%rsi
mov    0xc(%rsp),%edi
mov    $0x1ed,%edx
call   10a0 <mkdirat@plt>
test   %rax,%rax
je     1383 <link_tree+0x193>
jmp    15bf <link_tree+0x3cf>
mov    0x10(%rsp),%edi
call   1050 <S_ISDIR@plt>
test   %rax,%rax
je     14b2 <link_tree+0x2c2>
mov    (%r15),%rsi
mov    0x2c43(%rip),%rbp
mov    0x0(%rbp),%edx
mov    0x2c49(%rip),%rbx
or     (%rbx),%edx
mov    %r13d,%r12d
mov    %r13d,%edi
call   1040 <openat@plt>
cmp    $0xffffffff,%eax
je     151c <link_tree+0x32c>
mov    %eax,%r13d
mov    (%r15),%rsi
mov    0x0(%rbp),%edx
or     (%rbx),%edx
mov    0xc(%rsp),%edi
call   1040 <openat@plt>
cmp    $0xffffffff,%eax
je     153a <link_tree+0x34a>
mov    %eax,%ebx
mov    %r13d,%edi
mov    (%rsp),%rsi
mov    %r14,%rdx
mov    %eax,%ecx
call   10d0 <link_tree@plt>
mov    %eax,%ebp
mov    %r13d,%edi
call   1070 <close@plt>
mov    %ebx,%edi
call   1070 <close@plt>
test   %ebp,%ebp
mov    0x18(%rsp),%rax
mov    0x20(%rsp),%rbp
mov    %r12d,%r13d
mov    %rax,%r12
je     1290 <link_tree+0xa0>
mov    0x2bbb(%rip),%rax
mov    (%rax),%edi
lea    0xdbb(%rip),%rsi
jmp    14c2 <link_tree+0x2d2>
xor    %ebx,%ebx
mov    0x2b9c(%rip),%rax
cmpq   $0x0,(%rax)
je     14d2 <link_tree+0x2e2>
lea    0xdfa(%rip),%rdi
call   10e0 <perror@plt>
jmp    14cd <link_tree+0x2dd>
mov    0x2b82(%rip),%rax
mov    (%rax),%edi
lea    0xc4d(%rip),%rsi
mov    (%rsp),%rdx
mov    %rbx,%rcx
xor    %eax,%eax
call   1090 <fprintf@plt>
jmp    14cd <link_tree+0x2dd>
lea    0xb9a(%rip),%rdi
call   10e0 <perror@plt>
mov    0x2b56(%rip),%rax
mov    (%rax),%edi
lea    0xb90(%rip),%rsi
jmp    14a0 <link_tree+0x2b0>
mov    %ebx,%edi
call   1070 <close@plt>
lea    0xbaf(%rip),%rdi
call   10e0 <perror@plt>
mov    0x2b31(%rip),%rax
mov    (%rax),%edi
lea    0xbab(%rip),%rsi
mov    (%rsp),%rdx
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    $0xffffffff,%ebx
jmp    14e3 <link_tree+0x2f3>
mov    0x2b0f(%rip),%rax
mov    (%rax),%edi
lea    0xc2e(%rip),%rsi
mov    (%rsp),%rdx
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    $0xffffffff,%ebx
mov    %rbp,%rdi
call   1080 <closedir@plt>
mov    (%rsp),%rax
movb   $0x0,(%rax,%r12,1)
mov    %ebx,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xb68(%rip),%rdi
call   10e0 <perror@plt>
mov    0x2ac1(%rip),%rax
mov    (%rax),%edi
mov    (%r15),%rcx
lea    0xb5f(%rip),%rsi
mov    (%rsp),%rdx
jmp    1456 <link_tree+0x266>
lea    0xc54(%rip),%rdi
call   10e0 <perror@plt>
mov    0x2a99(%rip),%rax
mov    (%rax),%edi
lea    0xc4d(%rip),%rsi
jmp    155e <link_tree+0x36e>
lea    0xc36(%rip),%rdi
call   10e0 <perror@plt>
mov    %r13d,%edi
call   1070 <close@plt>
mov    0x2a73(%rip),%rax
mov    (%rax),%edi
lea    0xc4b(%rip),%rsi
mov    (%rsp),%rdx
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    $0xffffffff,%ebx
mov    0x18(%rsp),%r12
mov    0x20(%rsp),%rbp
jmp    14d2 <link_tree+0x2e2>
lea    0xc76(%rip),%rdi
call   10e0 <perror@plt>
mov    0x2a38(%rip),%rax
mov    (%rax),%edi
lea    0xc72(%rip),%rsi
jmp    14c2 <link_tree+0x2d2>
lea    0xabe(%rip),%rdi
call   10e0 <perror@plt>
mov    0x2a17(%rip),%rax
mov    (%rax),%edi
lea    0xb0b(%rip),%rsi
jmp    14c2 <link_tree+0x2d2>
lea    0xb6f(%rip),%rdi
call   10e0 <perror@plt>
mov    0x29f6(%rip),%rax
mov    (%rax),%edi
lea    0xb69(%rip),%rsi
jmp    14c2 <link_tree+0x2d2>

LLVM IR (-O0):
%struct.dirent = type { i8* }
%struct.stat = type { i32 }
@.str = [11 x i8] c"dup failed\00"
@stderr = global i32 0
@.str.1 = [47 x i8] c"link_tree: duplicating source fd failed on %s\0A\00"
@.str.2 = [17 x i8] c"fdopendir failed\00"
@.str.3 = [24 x i8] c"fdopendir failed on %s\0A\00"
@errno = global i64 0
@.str.4 = [15 x i8] c"fstatat failed\00"
@.str.5 = [42 x i8] c"link_tree: fstatat failed on entry %s/%s\0A\00"
@PATH_MAX = global i64 0
@.str.6 = [41 x i8] c"link_tree: path too long on entry %s/%s\0A\00"
@ENOENT = global i64 0
@.str.7 = [43 x i8] c"link_tree: fstatat failed on dst entry %s\0A\00"
@.str.8 = [69 x i8] c"link_tree: destination entry for dir %s exists but is not directory\0A\00"
@.str.9 = [15 x i8] c"mkdirat failed\00"
@.str.10 = [51 x i8] c"link_tree: creating destination dir for %s failed\0A\00"
@O_RDONLY = global i32 0
@O_DIRECTORY = global i32 0
@.str.11 = [14 x i8] c"openat failed\00"
@.str.12 = [36 x i8] c"link_tree: openat of src %s failed\0A\00"
@.str.13 = [40 x i8] c"link_tree: openat of dst for %s failed\0A\00"
@.str.14 = [41 x i8] c"link_tree: linking subtree at %s failed\0A\00"
@.str.15 = [17 x i8] c"symlinkat failed\00"
@.str.16 = [36 x i8] c"link_tree: linking entry %s failed\0A\00"
@.str.17 = [15 x i8] c"readdir failed\00"
define i32 @link_tree(i32 %0, i8* %1, i64 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i32
%10 = alloca i32*
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca %struct.dirent*
%17 = alloca %struct.stat
%18 = alloca i64
store i32 %0, i32* %6
store i8* %1, i8** %7
store i64 %2, i64* %8
store i32 %3, i32* %9
store i32 0, i32* %11
%19 = load i32, i32* %6
%20 = call i32 @dup(i32 %19)
store i32 %20, i32* %12
%21 = icmp eq i32 %20, -1
br i1 %21, label %22, label %27
22: ; preds = %4
%23 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%24 = load i32, i32* @stderr
%25 = load i8*, i8** %7
%26 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %24, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.1, i64 0, i64 0), i8* %25)
store i32 -1, i32* %5
br label %227
27: ; preds = %4
%28 = load i32, i32* %12
%29 = call i32* @fdopendir(i32 %28)
store i32* %29, i32** %10
%30 = icmp eq i32* %29, null
br i1 %30, label %31, label %38
31: ; preds = %27
%32 = load i32, i32* %12
%33 = call i32 @close(i32 %32)
%34 = call i32 @perror(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%35 = load i32, i32* @stderr
%36 = load i8*, i8** %7
%37 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %35, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i8* %36)
store i32 -1, i32* %5
br label %227
38: ; preds = %27
store i64 0, i64* @errno
br label %39
39: ; preds = %213, %51, %38
%40 = load i32*, i32** %10
%41 = call %struct.dirent* @readdir(i32* %40)
store %struct.dirent* %41, %struct.dirent** %16
%42 = icmp ne %struct.dirent* %41, null
br i1 %42, label %43, label %214
43: ; preds = %39
%44 = load %struct.dirent*, %struct.dirent** %16
%45 = getelementptr inbounds %struct.dirent, %struct.dirent* %44, i32 0, i32 0
%46 = load i8*, i8** %45
%47 = getelementptr inbounds i8, i8* %46, i64 0
%48 = load i8, i8* %47
%49 = sext i8 %48 to i32
%50 = icmp eq i32 %49, 46
br i1 %50, label %51, label %52
51: ; preds = %43
store i64 0, i64* @errno
br label %39
52: ; preds = %43
%53 = load i32, i32* %6
%54 = load %struct.dirent*, %struct.dirent** %16
%55 = getelementptr inbounds %struct.dirent, %struct.dirent* %54, i32 0, i32 0
%56 = load i8*, i8** %55
%57 = call i32 @fstatat(i32 %53, i8* %56, %struct.stat* %17, i32 0)
%58 = icmp ne i32 %57, 0
br i1 %58, label %59, label %67
59: ; preds = %52
%60 = call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
%61 = load i32, i32* @stderr
%62 = load i8*, i8** %7
%63 = load %struct.dirent*, %struct.dirent** %16
%64 = getelementptr inbounds %struct.dirent, %struct.dirent* %63, i32 0, i32 0
%65 = load i8*, i8** %64
%66 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %61, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.5, i64 0, i64 0), i8* %62, i8* %65)
store i32 -1, i32* %11
br label %220
67: ; preds = %52
%68 = load %struct.dirent*, %struct.dirent** %16
%69 = getelementptr inbounds %struct.dirent, %struct.dirent* %68, i32 0, i32 0
%70 = load i8*, i8** %69
%71 = call i64 @strlen(i8* %70)
store i64 %71, i64* %18
%72 = load i64, i64* %8
%73 = add i64 %72, 1
%74 = load i64, i64* %18
%75 = add i64 %73, %74
%76 = load i64, i64* @PATH_MAX
%77 = icmp ugt i64 %75, %76
br i1 %77, label %78, label %85
78: ; preds = %67
%79 = load i32, i32* @stderr
%80 = load i8*, i8** %7
%81 = load %struct.dirent*, %struct.dirent** %16
%82 = getelementptr inbounds %struct.dirent, %struct.dirent* %81, i32 0, i32 0
%83 = load i8*, i8** %82
%84 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %79, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.6, i64 0, i64 0), i8* %80, i8* %83)
store i32 -1, i32* %11
br label %220
85: ; preds = %67
%86 = load i8*, i8** %7
%87 = load i64, i64* %8
%88 = getelementptr inbounds i8, i8* %86, i64 %87
store i8 47, i8* %88
%89 = load i8*, i8** %7
%90 = load i64, i64* %8
%91 = getelementptr inbounds i8, i8* %89, i64 %90
%92 = getelementptr inbounds i8, i8* %91, i64 1
%93 = load %struct.dirent*, %struct.dirent** %16
%94 = getelementptr inbounds %struct.dirent, %struct.dirent* %93, i32 0, i32 0
%95 = load i8*, i8** %94
%96 = load i64, i64* %18
%97 = add i64 %96, 1
%98 = call i32 @memcpy(i8* %92, i8* %95, i64 %97)
%99 = getelementptr inbounds %struct.stat, %struct.stat* %17, i32 0, i32 0
%100 = load i32, i32* %99
%101 = call i64 @S_ISDIR(i32 %100)
%102 = icmp ne i64 %101, 0
br i1 %102, label %103, label %199
103: ; preds = %85
%104 = load i32, i32* %9
%105 = load %struct.dirent*, %struct.dirent** %16
%106 = getelementptr inbounds %struct.dirent, %struct.dirent* %105, i32 0, i32 0
%107 = load i8*, i8** %106
%108 = call i32 @fstatat(i32 %104, i8* %107, %struct.stat* %17, i32 0)
store i32 %108, i32* %15
%109 = icmp ne i32 %108, 0
br i1 %109, label %110, label %119
110: ; preds = %103
%111 = load i64, i64* @errno
%112 = load i64, i64* @ENOENT
%113 = icmp ne i64 %111, %112
br i1 %113, label %114, label %119
114: ; preds = %110
%115 = call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
%116 = load i32, i32* @stderr
%117 = load i8*, i8** %7
%118 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %116, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.7, i64 0, i64 0), i8* %117)
store i32 -1, i32* %11
br label %220
119: ; preds = %110, %103
%120 = load i32, i32* %15
%121 = icmp eq i32 %120, 0
br i1 %121, label %122, label %131
122: ; preds = %119
%123 = getelementptr inbounds %struct.stat, %struct.stat* %17, i32 0, i32 0
%124 = load i32, i32* %123
%125 = call i64 @S_ISDIR(i32 %124)
%126 = icmp ne i64 %125, 0
br i1 %126, label %131, label %127
127: ; preds = %122
%128 = load i32, i32* @stderr
%129 = load i8*, i8** %7
%130 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %128, i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.8, i64 0, i64 0), i8* %129)
store i32 -1, i32* %11
br label %220
131: ; preds = %122, %119
%132 = load i32, i32* %15
%133 = icmp ne i32 %132, 0
br i1 %133, label %134, label %146
134: ; preds = %131
%135 = load i32, i32* %9
%136 = load %struct.dirent*, %struct.dirent** %16
%137 = getelementptr inbounds %struct.dirent, %struct.dirent* %136, i32 0, i32 0
%138 = load i8*, i8** %137
%139 = call i64 @mkdirat(i32 %135, i8* %138, i32 493)
%140 = icmp ne i64 %139, 0
br i1 %140, label %141, label %146
141: ; preds = %134
%142 = call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.9, i64 0, i64 0))
%143 = load i32, i32* @stderr
%144 = load i8*, i8** %7
%145 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %143, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.10, i64 0, i64 0), i8* %144)
store i32 -1, i32* %11
br label %220
146: ; preds = %134, %131
br label %147
147: ; preds = %146
%148 = load i32, i32* %6
%149 = load %struct.dirent*, %struct.dirent** %16
%150 = getelementptr inbounds %struct.dirent, %struct.dirent* %149, i32 0, i32 0
%151 = load i8*, i8** %150
%152 = load i32, i32* @O_RDONLY
%153 = load i32, i32* @O_DIRECTORY
%154 = or i32 %152, %153
%155 = call i32 @openat(i32 %148, i8* %151, i32 %154)
store i32 %155, i32* %13
%156 = icmp eq i32 %155, -1
br i1 %156, label %157, label %162
157: ; preds = %147
%158 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.11, i64 0, i64 0))
%159 = load i32, i32* @stderr
%160 = load i8*, i8** %7
%161 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %159, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.12, i64 0, i64 0), i8* %160)
store i32 -1, i32* %11
br label %220
162: ; preds = %147
%163 = load i32, i32* %9
%164 = load %struct.dirent*, %struct.dirent** %16
%165 = getelementptr inbounds %struct.dirent, %struct.dirent* %164, i32 0, i32 0
%166 = load i8*, i8** %165
%167 = load i32, i32* @O_RDONLY
%168 = load i32, i32* @O_DIRECTORY
%169 = or i32 %167, %168
%170 = call i32 @openat(i32 %163, i8* %166, i32 %169)
store i32 %170, i32* %14
%171 = icmp eq i32 %170, -1
br i1 %171, label %172, label %179
172: ; preds = %162
%173 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.11, i64 0, i64 0))
%174 = load i32, i32* %13
%175 = call i32 @close(i32 %174)
%176 = load i32, i32* @stderr
%177 = load i8*, i8** %7
%178 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %176, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.13, i64 0, i64 0), i8* %177)
store i32 -1, i32* %11
br label %220
179: ; preds = %162
%180 = load i32, i32* %13
%181 = load i8*, i8** %7
%182 = load i64, i64* %8
%183 = add i64 %182, 1
%184 = load i64, i64* %18
%185 = add i64 %183, %184
%186 = load i32, i32* %14
%187 = call i32 @link_tree(i32 %180, i8* %181, i64 %185, i32 %186)
store i32 %187, i32* %15
%188 = load i32, i32* %13
%189 = call i32 @close(i32 %188)
%190 = load i32, i32* %14
%191 = call i32 @close(i32 %190)
%192 = load i32, i32* %15
%193 = icmp ne i32 %192, 0
br i1 %193, label %194, label %198
194: ; preds = %179
%195 = load i32, i32* @stderr
%196 = load i8*, i8** %7
%197 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %195, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.14, i64 0, i64 0), i8* %196)
store i32 -1, i32* %11
br label %220
198: ; preds = %179
br label %213
199: ; preds = %85
%200 = load i8*, i8** %7
%201 = load i32, i32* %9
%202 = load %struct.dirent*, %struct.dirent** %16
%203 = getelementptr inbounds %struct.dirent, %struct.dirent* %202, i32 0, i32 0
%204 = load i8*, i8** %203
%205 = call i64 @symlinkat(i8* %200, i32 %201, i8* %204)
%206 = icmp ne i64 %205, 0
br i1 %206, label %207, label %212
207: ; preds = %199
%208 = call i32 @perror(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.15, i64 0, i64 0))
%209 = load i32, i32* @stderr
%210 = load i8*, i8** %7
%211 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %209, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.16, i64 0, i64 0), i8* %210)
store i32 -1, i32* %11
br label %220
212: ; preds = %199
br label %213
213: ; preds = %212, %198
store i64 0, i64* @errno
br label %39
214: ; preds = %39
%215 = load i64, i64* @errno
%216 = icmp ne i64 %215, 0
br i1 %216, label %217, label %219
217: ; preds = %214
%218 = call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.17, i64 0, i64 0))
store i32 -1, i32* %11
br label %219
219: ; preds = %217, %214
br label %220
220: ; preds = %219, %207, %194, %172, %157, %141, %127, %114, %78, %59
%221 = load i32*, i32** %10
%222 = call i32 @closedir(i32* %221)
%223 = load i8*, i8** %7
%224 = load i64, i64* %8
%225 = getelementptr inbounds i8, i8* %223, i64 %224
store i8 0, i8* %225
%226 = load i32, i32* %11
store i32 %226, i32* %5
br label %227
227: ; preds = %220, %31, %22
%228 = load i32, i32* %5
ret i32 %228
}

LLVM IR (-O2):
%struct.stat = type { i32 }
%struct.dirent = type { i8* }
@.str = [11 x i8] c"dup failed\00"
@stderr = global i32 0
@.str.1 = [47 x i8] c"link_tree: duplicating source fd failed on %s\0A\00"
@.str.2 = [17 x i8] c"fdopendir failed\00"
@.str.3 = [24 x i8] c"fdopendir failed on %s\0A\00"
@errno = global i64 0
@.str.4 = [15 x i8] c"fstatat failed\00"
@.str.5 = [42 x i8] c"link_tree: fstatat failed on entry %s/%s\0A\00"
@PATH_MAX = global i64 0
@.str.6 = [41 x i8] c"link_tree: path too long on entry %s/%s\0A\00"
@ENOENT = global i64 0
@.str.7 = [43 x i8] c"link_tree: fstatat failed on dst entry %s\0A\00"
@.str.8 = [69 x i8] c"link_tree: destination entry for dir %s exists but is not directory\0A\00"
@.str.9 = [15 x i8] c"mkdirat failed\00"
@.str.10 = [51 x i8] c"link_tree: creating destination dir for %s failed\0A\00"
@O_RDONLY = global i32 0
@O_DIRECTORY = global i32 0
@.str.11 = [14 x i8] c"openat failed\00"
@.str.12 = [36 x i8] c"link_tree: openat of src %s failed\0A\00"
@.str.13 = [40 x i8] c"link_tree: openat of dst for %s failed\0A\00"
@.str.14 = [41 x i8] c"link_tree: linking subtree at %s failed\0A\00"
@.str.15 = [17 x i8] c"symlinkat failed\00"
@.str.16 = [36 x i8] c"link_tree: linking entry %s failed\0A\00"
@.str.17 = [15 x i8] c"readdir failed\00"
define i32 @link_tree(i32 %0, i8* %1, i64 %2, i32 %3) {
%5 = alloca %struct.stat
%6 = bitcast %struct.stat* %5 to i8*
%7 = tail call i32 @dup(i32 %0)
%8 = icmp eq i32 %7, -1
br i1 %8, label %9, label %13
9: ; preds = %4
%10 = tail call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%11 = load i32, i32* @stderr
%12 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %11, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.1, i64 0, i64 0), i8* %1)
br label %135
13: ; preds = %4
%14 = tail call i32* @fdopendir(i32 %7)
%15 = icmp eq i32* %14, null
br i1 %15, label %16, label %21
16: ; preds = %13
%17 = tail call i32 @close(i32 %7)
%18 = tail call i32 @perror(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%19 = load i32, i32* @stderr
%20 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %19, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i8* %1)
br label %135
21: ; preds = %13
store i64 0, i64* @errno
%22 = call %struct.dirent* @readdir(i32* %14)
%23 = icmp eq %struct.dirent* %22, null
br i1 %23, label %126, label %24
24: ; preds = %21
%25 = getelementptr inbounds i8, i8* %1, i64 %2
%26 = getelementptr inbounds i8, i8* %25, i64 1
%27 = getelementptr inbounds %struct.stat, %struct.stat* %5, i64 0, i32 0
br label %28
28: ; preds = %24, %34
%29 = phi %struct.dirent* [ %22, %24 ], [ %35, %34 ]
%30 = getelementptr inbounds %struct.dirent, %struct.dirent* %29, i64 0, i32 0
%31 = load i8*, i8** %30
%32 = load i8, i8* %31
%33 = icmp eq i8 %32, 46
br i1 %33, label %34, label %37
34: ; preds = %111, %119, %28
store i64 0, i64* @errno
%35 = call %struct.dirent* @readdir(i32* %14)
%36 = icmp eq %struct.dirent* %35, null
br i1 %36, label %126, label %28
37: ; preds = %28
%38 = call i32 @fstatat(i32 %0, i8* %31, %struct.stat* %5, i32 0)
%39 = icmp eq i32 %38, 0
br i1 %39, label %45, label %40
40: ; preds = %37
%41 = call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
%42 = load i32, i32* @stderr
%43 = load i8*, i8** %30
%44 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %42, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.5, i64 0, i64 0), i8* %1, i8* %43)
br label %131
45: ; preds = %37
%46 = load i8*, i8** %30
%47 = call i64 @strlen(i8* dereferenceable(1) %46)
%48 = add i64 %47, 1
%49 = add i64 %48, %2
%50 = load i64, i64* @PATH_MAX
%51 = icmp ugt i64 %49, %50
br i1 %51, label %52, label %55
52: ; preds = %45
%53 = load i32, i32* @stderr
%54 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %53, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.6, i64 0, i64 0), i8* %1, i8* %46)
br label %131
55: ; preds = %45
store i8 47, i8* %25
%56 = load i8*, i8** %30
%57 = call i32 @memcpy(i8* %26, i8* %56, i64 %48)
%58 = load i32, i32* %27
%59 = call i64 @S_ISDIR(i32 %58)
%60 = icmp eq i64 %59, 0
%61 = load i8*, i8** %30
br i1 %60, label %119, label %62
62: ; preds = %55
%63 = call i32 @fstatat(i32 %3, i8* %61, %struct.stat* %5, i32 0)
%64 = icmp eq i32 %63, 0
br i1 %64, label %73, label %65
65: ; preds = %62
%66 = load i64, i64* @errno
%67 = load i64, i64* @ENOENT
%68 = icmp eq i64 %66, %67
br i1 %68, label %80, label %69
69: ; preds = %65
%70 = call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
%71 = load i32, i32* @stderr
%72 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %71, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.7, i64 0, i64 0), i8* %1)
br label %131
73: ; preds = %62
%74 = load i32, i32* %27
%75 = call i64 @S_ISDIR(i32 %74)
%76 = icmp eq i64 %75, 0
br i1 %76, label %77, label %88
77: ; preds = %73
%78 = load i32, i32* @stderr
%79 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %78, i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.8, i64 0, i64 0), i8* %1)
br label %131
80: ; preds = %65
%81 = load i8*, i8** %30
%82 = call i64 @mkdirat(i32 %3, i8* %81, i32 493)
%83 = icmp eq i64 %82, 0
br i1 %83, label %88, label %84
84: ; preds = %80
%85 = call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.9, i64 0, i64 0))
%86 = load i32, i32* @stderr
%87 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %86, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.10, i64 0, i64 0), i8* %1)
br label %131
88: ; preds = %73, %80
%89 = load i8*, i8** %30
%90 = load i32, i32* @O_RDONLY
%91 = load i32, i32* @O_DIRECTORY
%92 = or i32 %91, %90
%93 = call i32 @openat(i32 %0, i8* %89, i32 %92)
%94 = icmp eq i32 %93, -1
br i1 %94, label %95, label %99
95: ; preds = %88
%96 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.11, i64 0, i64 0))
%97 = load i32, i32* @stderr
%98 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %97, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.12, i64 0, i64 0), i8* %1)
br label %131
99: ; preds = %88
%100 = load i8*, i8** %30
%101 = load i32, i32* @O_RDONLY
%102 = load i32, i32* @O_DIRECTORY
%103 = or i32 %102, %101
%104 = call i32 @openat(i32 %3, i8* %100, i32 %103)
%105 = icmp eq i32 %104, -1
br i1 %105, label %106, label %111
106: ; preds = %99
%107 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.11, i64 0, i64 0))
%108 = call i32 @close(i32 %93)
%109 = load i32, i32* @stderr
%110 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %109, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.13, i64 0, i64 0), i8* %1)
br label %131
111: ; preds = %99
%112 = call i32 @link_tree(i32 %93, i8* %1, i64 %49, i32 %104)
%113 = call i32 @close(i32 %93)
%114 = call i32 @close(i32 %104)
%115 = icmp eq i32 %112, 0
br i1 %115, label %34, label %116
116: ; preds = %111
%117 = load i32, i32* @stderr
%118 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %117, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.14, i64 0, i64 0), i8* %1)
br label %131
119: ; preds = %55
%120 = call i64 @symlinkat(i8* %1, i32 %3, i8* %61)
%121 = icmp eq i64 %120, 0
br i1 %121, label %34, label %122
122: ; preds = %119
%123 = call i32 @perror(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.15, i64 0, i64 0))
%124 = load i32, i32* @stderr
%125 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %124, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.16, i64 0, i64 0), i8* %1)
br label %131
126: ; preds = %34, %21
%127 = load i64, i64* @errno
%128 = icmp eq i64 %127, 0
br i1 %128, label %131, label %129
129: ; preds = %126
%130 = call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.17, i64 0, i64 0))
br label %131
131: ; preds = %126, %129, %122, %116, %106, %95, %84, %77, %69, %52, %40
%132 = phi i32 [ -1, %40 ], [ -1, %52 ], [ -1, %69 ], [ -1, %84 ], [ -1, %95 ], [ -1, %106 ], [ -1, %116 ], [ -1, %77 ], [ -1, %122 ], [ -1, %129 ], [ 0, %126 ]
%133 = call i32 @closedir(i32* %14)
%134 = getelementptr inbounds i8, i8* %1, i64 %2
store i8 0, i8* %134
br label %135
135: ; preds = %131, %16, %9
%136 = phi i32 [ -1, %9 ], [ -1, %16 ], [ %132, %131 ]
ret i32 %136
}