#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 utimbuf {
  int /*<<< orphan*/ modtime;
  int /*<<< orphan*/ actime;
};
struct stat {
  int st_mode;
  int /*<<< orphan*/ st_gid;
  int /*<<< orphan*/ st_uid;
  int /*<<< orphan*/ st_mtime;
  int /*<<< orphan*/ st_atime;
  int /*<<< orphan*/ st_rdev;
};

/* Variables and functions */
int BUFSIZ;
scalar_t__ ENAMETOOLONG;
scalar_t__ ENOENT;
int O_CREAT;
int /*<<< orphan*/ O_RDONLY;
int O_TRUNC;
int O_WRONLY;
int PATH_MAX;
int S_IFBLK;
int S_IFCHR;
int S_IFIFO;
scalar_t__ S_ISBLK(int);
scalar_t__ S_ISCHR(int);
scalar_t__ S_ISDIR(int);
scalar_t__ S_ISFIFO(int);
scalar_t__ S_ISLNK(int);
scalar_t__ S_ISREG(int);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ debug(int, char *, char const *, char const *);
scalar_t__ errno;
int read(int, char *, int);
size_t strlen(char const *);
int /*<<< orphan*/ strncat(char *, char const *, int);
int /*<<< orphan*/ strncpy(char *, char const *, int);
int /*<<< orphan*/ true_chmod(char *, int);
int /*<<< orphan*/ true_chown(char *, int /*<<< orphan*/, int /*<<< orphan*/);
int true_lstat(char const *, struct stat *);
scalar_t__ true_mkdir(char *, int);
scalar_t__ true_mknod(char *, int, int /*<<< orphan*/);
int true_open(char const *, int, ...);
size_t true_readlink(char const *, char *, int);
scalar_t__ true_symlink(char *, char *);
int /*<<< orphan*/ true_utime(char *, struct utimbuf *);
int /*<<< orphan*/ write(int, char *, int);
int copy_path(const char *truepath, const char *translroot) {
  int rcod;
  char buffer[BUFSIZ];
  int bytes;
  char translpath[PATH_MAX + 1];
  struct stat trueinfo;
  struct stat translinfo;
  int truefd;
  int translfd;
  struct utimbuf timbuf;
  size_t truesz;
  char linkpath[PATH_MAX + 1];
  size_t linksz;
  debug(2, "copy_path(%s,%s)\n", truepath, translroot);
  rcod = true_lstat(truepath, &trueinfo);
  if (rcod < 0 && errno != ENOENT)
    return -1;
  if (!rcod) {
    if ((truesz = strlen(truepath) + strlen(translpath)) > PATH_MAX) {
      errno = ENAMETOOLONG;
      return -1;
    }
    strncpy(translpath, translroot, PATH_MAX);
    strncat(translpath, truepath, PATH_MAX - truesz);
    if (!true_lstat(translpath, &translinfo))
      return 0;
    if (S_ISLNK(trueinfo.st_mode)) {
      if ((linksz = true_readlink(truepath, linkpath, PATH_MAX)) < 0)
        return -1;
      linkpath[linksz] = '\0';
      if (true_symlink(linkpath, translpath) != 0)
        return -1;
    }
    if (S_ISREG(trueinfo.st_mode)) {
      if ((truefd = true_open(truepath, O_RDONLY)) < 0)
        return -1;
      if ((translfd = true_open(translpath, O_WRONLY | O_CREAT | O_TRUNC,
                                trueinfo.st_mode)) < 0) {
        close(truefd);
        return -1;
      }
      while ((bytes = read(truefd, buffer, BUFSIZ)) > 0)
        write(translfd, buffer, bytes);
      close(truefd);
      close(translfd);
    }
    if (S_ISDIR(trueinfo.st_mode)) {
      if (true_mkdir(translpath, trueinfo.st_mode))
        return -1;
    }
    if (S_ISBLK(trueinfo.st_mode)) {
      if (true_mknod(translpath, trueinfo.st_mode | S_IFBLK, trueinfo.st_rdev))
        return -1;
    }
    if (S_ISCHR(trueinfo.st_mode)) {
      if (true_mknod(translpath, trueinfo.st_mode | S_IFCHR, trueinfo.st_rdev))
        return -1;
    }
    if (S_ISFIFO(trueinfo.st_mode)) {
      if (true_mknod(translpath, trueinfo.st_mode | S_IFIFO, 0))
        return -1;
    }
    timbuf.actime = trueinfo.st_atime;
    timbuf.modtime = trueinfo.st_mtime;
    true_utime(translpath, &timbuf);
    if (!S_ISLNK(trueinfo.st_mode)) {
      true_chown(translpath, trueinfo.st_uid, trueinfo.st_gid);
      true_chmod(translpath, trueinfo.st_mode);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<copy_path>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    0x2d36(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x28(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0xb8(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x30(%rbp)
mov    0x2d37(%rip),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %rcx,%rsi
add    $0xf,%rsi
and    $0xfffffffffffffff0,%rsi
mov    %rsp,%rdx
sub    %rsi,%rdx
mov    %rdx,-0xb0(%rbp)
mov    %rdx,%rsp
mov    %rcx,-0x40(%rbp)
mov    (%rax),%eax
add    $0x1,%eax
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0xa8(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x90(%rbp)
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
mov    $0x2,%edi
lea    0xcf8(%rip),%rsi
call   10a0 <debug@plt>
mov    -0x10(%rbp),%rdi
lea    -0x58(%rbp),%rsi
call   1110 <true_lstat@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    1357 <copy_path+0xf7>
mov    0x2c7a(%rip),%rax
mov    (%rax),%rax
mov    0x2c50(%rip),%rcx
cmp    (%rcx),%rax
je     1357 <copy_path+0xf7>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x9c(%rbp)
jmp    175c <copy_path+0x4fc>
cmpl   $0x0,-0x1c(%rbp)
jne    174b <copy_path+0x4eb>
mov    -0x10(%rbp),%rdi
call   1080 <strlen@plt>
mov    -0xb0(%rbp),%rdi
mov    %rax,-0xc0(%rbp)
call   1080 <strlen@plt>
mov    %rax,%rcx
mov    -0xc0(%rbp),%rax
add    %rcx,%rax
mov    %rax,-0x88(%rbp)
mov    0x2c48(%rip),%rcx
movslq (%rcx),%rcx
cmp    %rcx,%rax
jbe    13ce <copy_path+0x16e>
mov    0x2bf5(%rip),%rax
mov    (%rax),%rcx
mov    0x2bf3(%rip),%rax
mov    %rcx,(%rax)
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x9c(%rbp)
jmp    175c <copy_path+0x4fc>
mov    -0xb0(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    0x2c00(%rip),%rax
mov    (%rax),%edx
call   1050 <strncpy@plt>
mov    -0xb0(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    0x2be7(%rip),%rax
movslq (%rax),%rax
sub    -0x88(%rbp),%rax
mov    %eax,%edx
call   10d0 <strncat@plt>
mov    -0xb0(%rbp),%rdi
lea    -0x70(%rbp),%rsi
call   1110 <true_lstat@plt>
cmp    $0x0,%eax
jne    1439 <copy_path+0x1d9>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x9c(%rbp)
jmp    175c <copy_path+0x4fc>
mov    -0x58(%rbp),%edi
call   1060 <S_ISLNK@plt>
cmp    $0x0,%rax
je     14ce <copy_path+0x26e>
mov    -0xa8(%rbp),%rsi
mov    -0x10(%rbp),%rdi
mov    0x2b83(%rip),%rax
mov    (%rax),%edx
call   1130 <true_readlink@plt>
mov    %rax,-0x98(%rbp)
cmp    $0x0,%rax
jae    148b <copy_path+0x22b>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x9c(%rbp)
jmp    175c <copy_path+0x4fc>
mov    -0xb0(%rbp),%rsi
mov    -0xa8(%rbp),%rdi
mov    -0x98(%rbp),%rax
movb   $0x0,(%rdi,%rax,1)
call   1160 <true_symlink@plt>
cmp    $0x0,%rax
je     14c9 <copy_path+0x269>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x9c(%rbp)
jmp    175c <copy_path+0x4fc>
jmp    14ce <copy_path+0x26e>
mov    -0x58(%rbp),%edi
call   1120 <S_ISREG@plt>
cmp    $0x0,%rax
je     15bc <copy_path+0x35c>
mov    -0x10(%rbp),%rdi
mov    0x2ae5(%rip),%rax
mov    (%rax),%esi
mov    $0x0,%al
call   1040 <true_open@plt>
mov    %eax,-0x74(%rbp)
cmp    $0x0,%eax
jge    1516 <copy_path+0x2b6>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x9c(%rbp)
jmp    175c <copy_path+0x4fc>
mov    -0xb0(%rbp),%rdi
mov    0x2a5c(%rip),%rax
mov    (%rax),%esi
mov    0x2acb(%rip),%rax
or     (%rax),%esi
mov    0x2aba(%rip),%rax
or     (%rax),%esi
mov    -0x58(%rbp),%edx
mov    $0x0,%al
call   1040 <true_open@plt>
mov    %eax,-0x78(%rbp)
cmp    $0x0,%eax
jge    156c <copy_path+0x30c>
mov    -0x74(%rbp),%edi
call   10e0 <close@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x9c(%rbp)
jmp    175c <copy_path+0x4fc>
jmp    1571 <copy_path+0x311>
mov    -0xb8(%rbp),%rsi
mov    -0x74(%rbp),%edi
mov    0x2a2e(%rip),%rax
mov    (%rax),%edx
call   10f0 <read@plt>
mov    %eax,-0x34(%rbp)
cmp    $0x0,%eax
jle    15ac <copy_path+0x34c>
mov    -0xb8(%rbp),%rsi
mov    -0x78(%rbp),%edi
mov    -0x34(%rbp),%edx
call   1070 <write@plt>
jmp    1571 <copy_path+0x311>
mov    -0x74(%rbp),%edi
call   10e0 <close@plt>
mov    -0x78(%rbp),%edi
call   10e0 <close@plt>
mov    -0x58(%rbp),%edi
call   10b0 <S_ISDIR@plt>
cmp    $0x0,%rax
je     1602 <copy_path+0x3a2>
mov    -0xb0(%rbp),%rdi
mov    -0x58(%rbp),%esi
call   1170 <true_mkdir@plt>
cmp    $0x0,%rax
je     15fd <copy_path+0x39d>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x9c(%rbp)
jmp    175c <copy_path+0x4fc>
jmp    1602 <copy_path+0x3a2>
mov    -0x58(%rbp),%edi
call   1150 <S_ISBLK@plt>
cmp    $0x0,%rax
je     1654 <copy_path+0x3f4>
mov    -0xb0(%rbp),%rdi
mov    -0x58(%rbp),%esi
mov    0x299b(%rip),%rax
or     (%rax),%esi
mov    -0x44(%rbp),%edx
call   1100 <true_mknod@plt>
cmp    $0x0,%rax
je     164f <copy_path+0x3ef>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x9c(%rbp)
jmp    175c <copy_path+0x4fc>
jmp    1654 <copy_path+0x3f4>
mov    -0x58(%rbp),%edi
call   1140 <S_ISCHR@plt>
cmp    $0x0,%rax
je     16a6 <copy_path+0x446>
mov    -0xb0(%rbp),%rdi
mov    -0x58(%rbp),%esi
mov    0x2941(%rip),%rax
or     (%rax),%esi
mov    -0x44(%rbp),%edx
call   1100 <true_mknod@plt>
cmp    $0x0,%rax
je     16a1 <copy_path+0x441>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x9c(%rbp)
jmp    175c <copy_path+0x4fc>
jmp    16a6 <copy_path+0x446>
mov    -0x58(%rbp),%edi
call   1090 <S_ISFIFO@plt>
cmp    $0x0,%rax
je     16f7 <copy_path+0x497>
mov    -0xb0(%rbp),%rdi
mov    -0x58(%rbp),%esi
mov    0x28cf(%rip),%rax
or     (%rax),%esi
xor    %edx,%edx
call   1100 <true_mknod@plt>
cmp    $0x0,%rax
je     16f2 <copy_path+0x492>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x9c(%rbp)
jmp    175c <copy_path+0x4fc>
jmp    16f7 <copy_path+0x497>
mov    -0xb0(%rbp),%rdi
mov    -0x48(%rbp),%eax
mov    %eax,-0x7c(%rbp)
mov    -0x4c(%rbp),%eax
mov    %eax,-0x80(%rbp)
lea    -0x80(%rbp),%rsi
call   10c0 <true_utime@plt>
mov    -0x58(%rbp),%edi
call   1060 <S_ISLNK@plt>
cmp    $0x0,%rax
jne    1746 <copy_path+0x4e6>
mov    -0xb0(%rbp),%rdi
mov    -0x50(%rbp),%esi
mov    -0x54(%rbp),%edx
call   1030 <true_chown@plt>
mov    -0xb0(%rbp),%rdi
mov    -0x58(%rbp),%esi
call   1180 <true_chmod@plt>
jmp    174b <copy_path+0x4eb>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x9c(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<copy_path>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %rsi,%r13
mov    %rdi,%r12
mov    0x2d32(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%r14
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r14
mov    %r14,%rsp
mov    0x2d48(%rip),%rax
mov    (%rax),%eax
add    $0x1,%eax
mov    %rsp,%rbx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
mov    %rsp,%r15
sub    %rax,%r15
mov    %r15,%rsp
lea    0xd42(%rip),%rsi
mov    $0x2,%edi
mov    %r12,%rdx
mov    %r13,%rcx
call   10a0 <debug@plt>
lea    -0x40(%rbp),%rsi
mov    %r12,%rdi
call   1110 <true_lstat@plt>
test   %eax,%eax
js     12e6 <copy_path+0x86>
test   %eax,%eax
je     1303 <copy_path+0xa3>
xor    %ebx,%ebx
jmp    134a <copy_path+0xea>
mov    0x2cbb(%rip),%rax
mov    (%rax),%rax
mov    0x2c91(%rip),%rcx
xor    %ebx,%ebx
cmp    (%rcx),%rax
setne  %bl
neg    %ebx
jmp    134a <copy_path+0xea>
mov    %r14,-0x48(%rbp)
mov    %r12,%rdi
call   1080 <strlen@plt>
mov    %rax,-0x50(%rbp)
mov    %rbx,%rdi
call   1080 <strlen@plt>
mov    %rax,%r14
add    -0x50(%rbp),%r14
mov    0x2cb7(%rip),%rax
movslq (%rax),%rdx
cmp    %rdx,%r14
jbe    135b <copy_path+0xfb>
mov    0x2c68(%rip),%rax
mov    (%rax),%rax
mov    0x2c66(%rip),%rcx
mov    %rax,(%rcx)
mov    $0xffffffff,%ebx
mov    %ebx,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rbx,%rdi
mov    %r13,%rsi
mov    %rax,%r13
call   1050 <strncpy@plt>
mov    0x0(%r13),%edx
sub    %r14d,%edx
mov    %rbx,%rdi
mov    %r12,%rsi
call   10d0 <strncat@plt>
lea    -0x70(%rbp),%rsi
mov    %rbx,%rdi
call   1110 <true_lstat@plt>
test   %eax,%eax
je     12e2 <copy_path+0x82>
mov    %rbx,%r14
mov    %r13,%rbx
mov    -0x40(%rbp),%edi
call   1060 <S_ISLNK@plt>
test   %rax,%rax
je     13c9 <copy_path+0x169>
mov    (%rbx),%edx
mov    %r12,%rdi
mov    %r15,%rsi
call   1130 <true_readlink@plt>
movb   $0x0,(%r15,%rax,1)
mov    %r15,%rdi
mov    %r14,%rsi
call   1160 <true_symlink@plt>
mov    $0xffffffff,%ebx
test   %rax,%rax
jne    134a <copy_path+0xea>
mov    -0x40(%rbp),%edi
call   1120 <S_ISREG@plt>
test   %rax,%rax
je     1481 <copy_path+0x221>
mov    0x2bef(%rip),%rax
mov    (%rax),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <true_open@plt>
mov    $0xffffffff,%ebx
test   %eax,%eax
js     134a <copy_path+0xea>
mov    %eax,%r12d
mov    0x2b7c(%rip),%rax
mov    0x2bed(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x2bda(%rip),%rax
or     (%rax),%esi
mov    -0x40(%rbp),%edx
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <true_open@plt>
test   %eax,%eax
js     157f <copy_path+0x31f>
mov    %eax,%r13d
mov    0x2b79(%rip),%r15
mov    (%r15),%edx
mov    %r12d,%edi
mov    -0x48(%rbp),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rsi
call   10f0 <read@plt>
test   %eax,%eax
jle    1471 <copy_path+0x211>
mov    %r13d,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1070 <write@plt>
mov    (%r15),%edx
mov    %r12d,%edi
jmp    1450 <copy_path+0x1f0>
mov    %r12d,%edi
call   10e0 <close@plt>
mov    %r13d,%edi
call   10e0 <close@plt>
mov    -0x40(%rbp),%edi
call   10b0 <S_ISDIR@plt>
test   %rax,%rax
je     14a7 <copy_path+0x247>
mov    -0x40(%rbp),%esi
mov    %r14,%rdi
call   1170 <true_mkdir@plt>
mov    $0xffffffff,%ebx
test   %rax,%rax
jne    134a <copy_path+0xea>
mov    -0x40(%rbp),%edi
call   1150 <S_ISBLK@plt>
test   %rax,%rax
je     14d9 <copy_path+0x279>
mov    0x2b05(%rip),%rax
mov    (%rax),%esi
or     -0x40(%rbp),%esi
mov    -0x2c(%rbp),%edx
mov    %r14,%rdi
call   1100 <true_mknod@plt>
mov    $0xffffffff,%ebx
test   %rax,%rax
jne    134a <copy_path+0xea>
mov    -0x40(%rbp),%edi
call   1140 <S_ISCHR@plt>
test   %rax,%rax
je     150b <copy_path+0x2ab>
mov    0x2acb(%rip),%rax
mov    (%rax),%esi
or     -0x40(%rbp),%esi
mov    -0x2c(%rbp),%edx
mov    %r14,%rdi
call   1100 <true_mknod@plt>
mov    $0xffffffff,%ebx
test   %rax,%rax
jne    134a <copy_path+0xea>
mov    -0x40(%rbp),%edi
call   1090 <S_ISFIFO@plt>
test   %rax,%rax
je     153c <copy_path+0x2dc>
mov    0x2a79(%rip),%rax
mov    (%rax),%esi
or     -0x40(%rbp),%esi
mov    %r14,%rdi
xor    %edx,%edx
call   1100 <true_mknod@plt>
mov    $0xffffffff,%ebx
test   %rax,%rax
jne    134a <copy_path+0xea>
mov    -0x34(%rbp),%rax
mov    %rax,-0x58(%rbp)
lea    -0x58(%rbp),%rsi
mov    %r14,%rdi
call   10c0 <true_utime@plt>
mov    -0x40(%rbp),%edi
call   1060 <S_ISLNK@plt>
test   %rax,%rax
jne    12e2 <copy_path+0x82>
mov    -0x3c(%rbp),%edx
mov    -0x38(%rbp),%esi
mov    %r14,%rdi
call   1030 <true_chown@plt>
mov    -0x40(%rbp),%esi
mov    %r14,%rdi
call   1180 <true_chmod@plt>
jmp    12e2 <copy_path+0x82>
mov    %r12d,%edi
call   10e0 <close@plt>
jmp    134a <copy_path+0xea>

LLVM IR (-O0):
%struct.stat = type { i32, i32, i32, i32, i32, i32 }
%struct.utimbuf = type { i32, i32 }
@BUFSIZ = global i32 0
@PATH_MAX = global i32 0
@.str = [18 x i8] c"copy_path(%s,%s)\0A\00"
@errno = global i64 0
@ENOENT = global i64 0
@ENAMETOOLONG = global i64 0
@O_RDONLY = global i32 0
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@O_TRUNC = global i32 0
@S_IFBLK = global i32 0
@S_IFCHR = global i32 0
@S_IFIFO = global i32 0
define i32 @copy_path(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i32
%10 = alloca i64
%11 = alloca %struct.stat
%12 = alloca %struct.stat
%13 = alloca i32
%14 = alloca i32
%15 = alloca %struct.utimbuf
%16 = alloca i64
%17 = alloca i64
%18 = alloca i64
%19 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
%20 = load i32, i32* @BUFSIZ
%21 = zext i32 %20 to i64
%22 = call i8* @llvm.stacksave()
store i8* %22, i8** %7
%23 = alloca i8, i64 %21
store i64 %21, i64* %8
%24 = load i32, i32* @PATH_MAX
%25 = add nsw i32 %24, 1
%26 = zext i32 %25 to i64
%27 = alloca i8, i64 %26
store i64 %26, i64* %10
%28 = load i32, i32* @PATH_MAX
%29 = add nsw i32 %28, 1
%30 = zext i32 %29 to i64
%31 = alloca i8, i64 %30
store i64 %30, i64* %17
%32 = load i8*, i8** %4
%33 = load i8*, i8** %5
%34 = call i32 @debug(i32 2, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %32, i8* %33)
%35 = load i8*, i8** %4
%36 = call i32 @true_lstat(i8* %35, %struct.stat* %11)
store i32 %36, i32* %6
%37 = load i32, i32* %6
%38 = icmp slt i32 %37, 0
br i1 %38, label %39, label %44
39: ; preds = %2
%40 = load i64, i64* @errno
%41 = load i64, i64* @ENOENT
%42 = icmp ne i64 %40, %41
br i1 %42, label %43, label %44
43: ; preds = %39
store i32 -1, i32* %3
store i32 1, i32* %19
br label %209
44: ; preds = %39, %2
%45 = load i32, i32* %6
%46 = icmp ne i32 %45, 0
br i1 %46, label %208, label %47
47: ; preds = %44
%48 = load i8*, i8** %4
%49 = call i64 @strlen(i8* %48)
%50 = call i64 @strlen(i8* %27)
%51 = add i64 %49, %50
store i64 %51, i64* %16
%52 = load i32, i32* @PATH_MAX
%53 = sext i32 %52 to i64
%54 = icmp ugt i64 %51, %53
br i1 %54, label %55, label %57
55: ; preds = %47
%56 = load i64, i64* @ENAMETOOLONG
store i64 %56, i64* @errno
store i32 -1, i32* %3
store i32 1, i32* %19
br label %209
57: ; preds = %47
%58 = load i8*, i8** %5
%59 = load i32, i32* @PATH_MAX
%60 = call i32 @strncpy(i8* %27, i8* %58, i32 %59)
%61 = load i8*, i8** %4
%62 = load i32, i32* @PATH_MAX
%63 = sext i32 %62 to i64
%64 = load i64, i64* %16
%65 = sub i64 %63, %64
%66 = trunc i64 %65 to i32
%67 = call i32 @strncat(i8* %27, i8* %61, i32 %66)
%68 = call i32 @true_lstat(i8* %27, %struct.stat* %12)
%69 = icmp ne i32 %68, 0
br i1 %69, label %71, label %70
70: ; preds = %57
store i32 0, i32* %3
store i32 1, i32* %19
br label %209
71: ; preds = %57
%72 = getelementptr inbounds %struct.stat, %struct.stat* %11, i32 0, i32 0
%73 = load i32, i32* %72
%74 = call i64 @S_ISLNK(i32 %73)
%75 = icmp ne i64 %74, 0
br i1 %75, label %76, label %89
76: ; preds = %71
%77 = load i8*, i8** %4
%78 = load i32, i32* @PATH_MAX
%79 = call i64 @true_readlink(i8* %77, i8* %31, i32 %78)
store i64 %79, i64* %18
%80 = icmp ult i64 %79, 0
br i1 %80, label %81, label %82
81: ; preds = %76
store i32 -1, i32* %3
store i32 1, i32* %19
br label %209
82: ; preds = %76
%83 = load i64, i64* %18
%84 = getelementptr inbounds i8, i8* %31, i64 %83
store i8 0, i8* %84
%85 = call i64 @true_symlink(i8* %31, i8* %27)
%86 = icmp ne i64 %85, 0
br i1 %86, label %87, label %88
87: ; preds = %82
store i32 -1, i32* %3
store i32 1, i32* %19
br label %209
88: ; preds = %82
br label %89
89: ; preds = %88, %71
%90 = getelementptr inbounds %struct.stat, %struct.stat* %11, i32 0, i32 0
%91 = load i32, i32* %90
%92 = call i64 @S_ISREG(i32 %91)
%93 = icmp ne i64 %92, 0
br i1 %93, label %94, label %128
94: ; preds = %89
%95 = load i8*, i8** %4
%96 = load i32, i32* @O_RDONLY
%97 = call i32 (i8*, i32, ...) @true_open(i8* %95, i32 %96)
store i32 %97, i32* %13
%98 = icmp slt i32 %97, 0
br i1 %98, label %99, label %100
99: ; preds = %94
store i32 -1, i32* %3
store i32 1, i32* %19
br label %209
100: ; preds = %94
%101 = load i32, i32* @O_WRONLY
%102 = load i32, i32* @O_CREAT
%103 = or i32 %101, %102
%104 = load i32, i32* @O_TRUNC
%105 = or i32 %103, %104
%106 = getelementptr inbounds %struct.stat, %struct.stat* %11, i32 0, i32 0
%107 = load i32, i32* %106
%108 = call i32 (i8*, i32, ...) @true_open(i8* %27, i32 %105, i32 %107)
store i32 %108, i32* %14
%109 = icmp slt i32 %108, 0
br i1 %109, label %110, label %113
110: ; preds = %100
%111 = load i32, i32* %13
%112 = call i32 @close(i32 %111)
store i32 -1, i32* %3
store i32 1, i32* %19
br label %209
113: ; preds = %100
br label %114
114: ; preds = %119, %113
%115 = load i32, i32* %13
%116 = load i32, i32* @BUFSIZ
%117 = call i32 @read(i32 %115, i8* %23, i32 %116)
store i32 %117, i32* %9
%118 = icmp sgt i32 %117, 0
br i1 %118, label %119, label %123
119: ; preds = %114
%120 = load i32, i32* %14
%121 = load i32, i32* %9
%122 = call i32 @write(i32 %120, i8* %23, i32 %121)
br label %114
123: ; preds = %114
%124 = load i32, i32* %13
%125 = call i32 @close(i32 %124)
%126 = load i32, i32* %14
%127 = call i32 @close(i32 %126)
br label %128
128: ; preds = %123, %89
%129 = getelementptr inbounds %struct.stat, %struct.stat* %11, i32 0, i32 0
%130 = load i32, i32* %129
%131 = call i64 @S_ISDIR(i32 %130)
%132 = icmp ne i64 %131, 0
br i1 %132, label %133, label %140
133: ; preds = %128
%134 = getelementptr inbounds %struct.stat, %struct.stat* %11, i32 0, i32 0
%135 = load i32, i32* %134
%136 = call i64 @true_mkdir(i8* %27, i32 %135)
%137 = icmp ne i64 %136, 0
br i1 %137, label %138, label %139
138: ; preds = %133
store i32 -1, i32* %3
store i32 1, i32* %19
br label %209
139: ; preds = %133
br label %140
140: ; preds = %139, %128
%141 = getelementptr inbounds %struct.stat, %struct.stat* %11, i32 0, i32 0
%142 = load i32, i32* %141
%143 = call i64 @S_ISBLK(i32 %142)
%144 = icmp ne i64 %143, 0
br i1 %144, label %145, label %156
145: ; preds = %140
%146 = getelementptr inbounds %struct.stat, %struct.stat* %11, i32 0, i32 0
%147 = load i32, i32* %146
%148 = load i32, i32* @S_IFBLK
%149 = or i32 %147, %148
%150 = getelementptr inbounds %struct.stat, %struct.stat* %11, i32 0, i32 5
%151 = load i32, i32* %150
%152 = call i64 @true_mknod(i8* %27, i32 %149, i32 %151)
%153 = icmp ne i64 %152, 0
br i1 %153, label %154, label %155
154: ; preds = %145
store i32 -1, i32* %3
store i32 1, i32* %19
br label %209
155: ; preds = %145
br label %156
156: ; preds = %155, %140
%157 = getelementptr inbounds %struct.stat, %struct.stat* %11, i32 0, i32 0
%158 = load i32, i32* %157
%159 = call i64 @S_ISCHR(i32 %158)
%160 = icmp ne i64 %159, 0
br i1 %160, label %161, label %172
161: ; preds = %156
%162 = getelementptr inbounds %struct.stat, %struct.stat* %11, i32 0, i32 0
%163 = load i32, i32* %162
%164 = load i32, i32* @S_IFCHR
%165 = or i32 %163, %164
%166 = getelementptr inbounds %struct.stat, %struct.stat* %11, i32 0, i32 5
%167 = load i32, i32* %166
%168 = call i64 @true_mknod(i8* %27, i32 %165, i32 %167)
%169 = icmp ne i64 %168, 0
br i1 %169, label %170, label %171
170: ; preds = %161
store i32 -1, i32* %3
store i32 1, i32* %19
br label %209
171: ; preds = %161
br label %172
172: ; preds = %171, %156
%173 = getelementptr inbounds %struct.stat, %struct.stat* %11, i32 0, i32 0
%174 = load i32, i32* %173
%175 = call i64 @S_ISFIFO(i32 %174)
%176 = icmp ne i64 %175, 0
br i1 %176, label %177, label %186
177: ; preds = %172
%178 = getelementptr inbounds %struct.stat, %struct.stat* %11, i32 0, i32 0
%179 = load i32, i32* %178
%180 = load i32, i32* @S_IFIFO
%181 = or i32 %179, %180
%182 = call i64 @true_mknod(i8* %27, i32 %181, i32 0)
%183 = icmp ne i64 %182, 0
br i1 %183, label %184, label %185
184: ; preds = %177
store i32 -1, i32* %3
store i32 1, i32* %19
br label %209
185: ; preds = %177
br label %186
186: ; preds = %185, %172
%187 = getelementptr inbounds %struct.stat, %struct.stat* %11, i32 0, i32 4
%188 = load i32, i32* %187
%189 = getelementptr inbounds %struct.utimbuf, %struct.utimbuf* %15, i32 0, i32 1
store i32 %188, i32* %189
%190 = getelementptr inbounds %struct.stat, %struct.stat* %11, i32 0, i32 3
%191 = load i32, i32* %190
%192 = getelementptr inbounds %struct.utimbuf, %struct.utimbuf* %15, i32 0, i32 0
store i32 %191, i32* %192
%193 = call i32 @true_utime(i8* %27, %struct.utimbuf* %15)
%194 = getelementptr inbounds %struct.stat, %struct.stat* %11, i32 0, i32 0
%195 = load i32, i32* %194
%196 = call i64 @S_ISLNK(i32 %195)
%197 = icmp ne i64 %196, 0
br i1 %197, label %207, label %198
198: ; preds = %186
%199 = getelementptr inbounds %struct.stat, %struct.stat* %11, i32 0, i32 2
%200 = load i32, i32* %199
%201 = getelementptr inbounds %struct.stat, %struct.stat* %11, i32 0, i32 1
%202 = load i32, i32* %201
%203 = call i32 @true_chown(i8* %27, i32 %200, i32 %202)
%204 = getelementptr inbounds %struct.stat, %struct.stat* %11, i32 0, i32 0
%205 = load i32, i32* %204
%206 = call i32 @true_chmod(i8* %27, i32 %205)
br label %207
207: ; preds = %198, %186
br label %208
208: ; preds = %207, %44
store i32 0, i32* %3
store i32 1, i32* %19
br label %209
209: ; preds = %208, %184, %170, %154, %138, %110, %99, %87, %81, %70, %55, %43
%210 = load i8*, i8** %7
%211 = load i32, i32* %3
ret i32 %211
}

LLVM IR (-O2):
%struct.stat = type { i32, i32, i32, i32, i32, i32 }
%struct.utimbuf = type { i32, i32 }
@BUFSIZ = global i32 0
@PATH_MAX = global i32 0
@.str = [18 x i8] c"copy_path(%s,%s)\0A\00"
@errno = global i64 0
@ENOENT = global i64 0
@ENAMETOOLONG = global i64 0
@O_RDONLY = global i32 0
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@O_TRUNC = global i32 0
@S_IFBLK = global i32 0
@S_IFCHR = global i32 0
@S_IFIFO = global i32 0
define i32 @copy_path(i8* %0, i8* %1) {
%3 = alloca %struct.stat
%4 = alloca %struct.stat
%5 = alloca %struct.utimbuf
%6 = load i32, i32* @BUFSIZ
%7 = zext i32 %6 to i64
%8 = alloca i8, i64 %7
%9 = load i32, i32* @PATH_MAX
%10 = add nsw i32 %9, 1
%11 = zext i32 %10 to i64
%12 = alloca i8, i64 %11
%13 = bitcast %struct.stat* %3 to i8*
%14 = bitcast %struct.stat* %4 to i8*
%15 = bitcast %struct.utimbuf* %5 to i8*
%16 = alloca i8, i64 %11
%17 = tail call i32 @debug(i32 2, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %1)
%18 = call i32 @true_lstat(i8* %0, %struct.stat* %3)
%19 = icmp slt i32 %18, 0
br i1 %19, label %20, label %25
20: ; preds = %2
%21 = load i64, i64* @errno
%22 = load i64, i64* @ENOENT
%23 = icmp ne i64 %21, %22
%24 = sext i1 %23 to i32
br label %148
25: ; preds = %2
%26 = icmp eq i32 %18, 0
br i1 %26, label %27, label %148
27: ; preds = %25
%28 = call i64 @strlen(i8* dereferenceable(1) %0)
%29 = call i64 @strlen(i8* %12)
%30 = add i64 %29, %28
%31 = load i32, i32* @PATH_MAX
%32 = sext i32 %31 to i64
%33 = icmp ugt i64 %30, %32
br i1 %33, label %34, label %36
34: ; preds = %27
%35 = load i64, i64* @ENAMETOOLONG
store i64 %35, i64* @errno
br label %148
36: ; preds = %27
%37 = call i32 @strncpy(i8* %12, i8* %1, i32 %31)
%38 = load i32, i32* @PATH_MAX
%39 = trunc i64 %30 to i32
%40 = sub i32 %38, %39
%41 = call i32 @strncat(i8* %12, i8* %0, i32 %40)
%42 = call i32 @true_lstat(i8* %12, %struct.stat* %4)
%43 = icmp eq i32 %42, 0
br i1 %43, label %148, label %44
44: ; preds = %36
%45 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0
%46 = load i32, i32* %45
%47 = call i64 @S_ISLNK(i32 %46)
%48 = icmp eq i64 %47, 0
br i1 %48, label %55, label %49
49: ; preds = %44
%50 = load i32, i32* @PATH_MAX
%51 = call i64 @true_readlink(i8* %0, i8* %16, i32 %50)
%52 = getelementptr inbounds i8, i8* %16, i64 %51
store i8 0, i8* %52
%53 = call i64 @true_symlink(i8* %16, i8* %12)
%54 = icmp eq i64 %53, 0
br i1 %54, label %55, label %148
55: ; preds = %49, %44
%56 = load i32, i32* %45
%57 = call i64 @S_ISREG(i32 %56)
%58 = icmp eq i64 %57, 0
br i1 %58, label %87, label %59
59: ; preds = %55
%60 = load i32, i32* @O_RDONLY
%61 = call i32 (i8*, i32, ...) @true_open(i8* %0, i32 %60)
%62 = icmp slt i32 %61, 0
br i1 %62, label %148, label %63
63: ; preds = %59
%64 = load i32, i32* @O_WRONLY
%65 = load i32, i32* @O_CREAT
%66 = or i32 %65, %64
%67 = load i32, i32* @O_TRUNC
%68 = or i32 %66, %67
%69 = load i32, i32* %45
%70 = call i32 (i8*, i32, ...) @true_open(i8* %12, i32 %68, i32 %69)
%71 = icmp slt i32 %70, 0
br i1 %71, label %76, label %72
72: ; preds = %63
%73 = load i32, i32* @BUFSIZ
%74 = call i32 @read(i32 %61, i8* %8, i32 %73)
%75 = icmp sgt i32 %74, 0
br i1 %75, label %78, label %84
76: ; preds = %63
%77 = call i32 @close(i32 %61)
br label %148
78: ; preds = %72, %78
%79 = phi i32 [ %82, %78 ], [ %74, %72 ]
%80 = call i32 @write(i32 %70, i8* %8, i32 %79)
%81 = load i32, i32* @BUFSIZ
%82 = call i32 @read(i32 %61, i8* %8, i32 %81)
%83 = icmp sgt i32 %82, 0
br i1 %83, label %78, label %84
84: ; preds = %78, %72
%85 = call i32 @close(i32 %61)
%86 = call i32 @close(i32 %70)
br label %87
87: ; preds = %84, %55
%88 = load i32, i32* %45
%89 = call i64 @S_ISDIR(i32 %88)
%90 = icmp eq i64 %89, 0
br i1 %90, label %95, label %91
91: ; preds = %87
%92 = load i32, i32* %45
%93 = call i64 @true_mkdir(i8* %12, i32 %92)
%94 = icmp eq i64 %93, 0
br i1 %94, label %95, label %148
95: ; preds = %91, %87
%96 = load i32, i32* %45
%97 = call i64 @S_ISBLK(i32 %96)
%98 = icmp eq i64 %97, 0
br i1 %98, label %107, label %99
99: ; preds = %95
%100 = load i32, i32* %45
%101 = load i32, i32* @S_IFBLK
%102 = or i32 %101, %100
%103 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 5
%104 = load i32, i32* %103
%105 = call i64 @true_mknod(i8* %12, i32 %102, i32 %104)
%106 = icmp eq i64 %105, 0
br i1 %106, label %107, label %148
107: ; preds = %99, %95
%108 = load i32, i32* %45
%109 = call i64 @S_ISCHR(i32 %108)
%110 = icmp eq i64 %109, 0
br i1 %110, label %119, label %111
111: ; preds = %107
%112 = load i32, i32* %45
%113 = load i32, i32* @S_IFCHR
%114 = or i32 %113, %112
%115 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 5
%116 = load i32, i32* %115
%117 = call i64 @true_mknod(i8* %12, i32 %114, i32 %116)
%118 = icmp eq i64 %117, 0
br i1 %118, label %119, label %148
119: ; preds = %111, %107
%120 = load i32, i32* %45
%121 = call i64 @S_ISFIFO(i32 %120)
%122 = icmp eq i64 %121, 0
br i1 %122, label %129, label %123
123: ; preds = %119
%124 = load i32, i32* %45
%125 = load i32, i32* @S_IFIFO
%126 = or i32 %125, %124
%127 = call i64 @true_mknod(i8* %12, i32 %126, i32 0)
%128 = icmp eq i64 %127, 0
br i1 %128, label %129, label %148
129: ; preds = %123, %119
%130 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 4
%131 = load i32, i32* %130
%132 = getelementptr inbounds %struct.utimbuf, %struct.utimbuf* %5, i64 0, i32 1
store i32 %131, i32* %132
%133 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 3
%134 = load i32, i32* %133
%135 = getelementptr inbounds %struct.utimbuf, %struct.utimbuf* %5, i64 0, i32 0
store i32 %134, i32* %135
%136 = call i32 @true_utime(i8* %12, %struct.utimbuf* %5)
%137 = load i32, i32* %45
%138 = call i64 @S_ISLNK(i32 %137)
%139 = icmp eq i64 %138, 0
br i1 %139, label %140, label %148
140: ; preds = %129
%141 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 2
%142 = load i32, i32* %141
%143 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 1
%144 = load i32, i32* %143
%145 = call i32 @true_chown(i8* %12, i32 %142, i32 %144)
%146 = load i32, i32* %45
%147 = call i32 @true_chmod(i8* %12, i32 %146)
br label %148
148: ; preds = %20, %25, %140, %129, %123, %111, %99, %91, %59, %49, %36, %76, %34
%149 = phi i32 [ -1, %34 ], [ -1, %76 ], [ 0, %36 ], [ -1, %49 ], [ -1, %59 ], [ -1, %91 ], [ -1, %99 ], [ -1, %111 ], [ -1, %123 ], [ 0, %129 ], [ 0, %140 ], [ 0, %25 ], [ %24, %20 ]
ret i32 %149
}