#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
typedef int /*<<< orphan*/ orig_workdir;
typedef int /*<<< orphan*/ binpath;

/* Variables and functions */
int /*<<< orphan*/ asprintf(char **, char *, char *);
scalar_t__ chdir(char *);
scalar_t__ chroot(char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ getcwd(char *, int);
int /*<<< orphan*/ link(char *, char *);
int /*<<< orphan*/ mkdir(char *, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ print_file(char *);
int /*<<< orphan*/ print_file_2(char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ snprintf(char *, int, char *, char *);
int /*<<< orphan*/ symlink(char *, char *);
int /*<<< orphan*/ write_file(char *, char *);
int main(int argc, char *argv[]) {
  char orig_workdir[4096];
  char *abs_path_to_d1;
  char binpath[4096];
  if (argc == 2) {
    print_file(argv[1]);
    exit(0);
  }
  mkdir("./Chroottest-dir", 0755);
  chdir("./Chroottest-dir");
  getcwd(orig_workdir, sizeof(orig_workdir));
  printf("orig_workdir='%s'\n", orig_workdir);
  mkdir("./d1", 0755);
  mkdir("./d1/d2", 0755);
  printf("argv[0]='%s'\n", argv[0]);
  snprintf(binpath, sizeof(binpath), "../%s", argv[0]);
  link(binpath, "./prf");
  link(binpath, "./d1/prf");
  link(binpath, "./d1/d2/prf");
  write_file("./a", "a in workdir");
  write_file("./d1/a", "a in d1");
  write_file("./d1/d2/a", "a in d2");
  symlink("./a", "a-rel");
  symlink("/a", "a-abs");
  chdir("d1");
  symlink("./a", "a-rel");
  symlink("/a", "a-abs");
  symlink("../a", "a-..");
  chdir("d2");
  symlink("./a", "a-rel");
  symlink("/a", "a-abs");
  symlink("../a", "a-..");
  chdir("../..");
  printf("Not yet chrooted:\n");
  printf("Here file 'a' should contain 'a in workdir':\n");
  print_file_2("./a", "./prf");
  printf("symlink 'a-rel' -> 'a', should contain 'a in workdir':\n");
  print_file("a-rel");
  printf("symlink 'a-abs' -> no such file:\n");
  print_file("a-abs");
  printf("\nchdir(/):\n");
  if (chdir("/") < 0) {
    printf("Error: chdir(/) failed");
  } else {
    printf("chdir OK\n");
  }
  asprintf(&abs_path_to_d1, "%s/d1", orig_workdir);
  printf("\nchroot(orig_workdir/d1) (%s):\n", abs_path_to_d1);
  if (chroot(abs_path_to_d1) < 0) {
    printf("Error: chroot(%s) failed", abs_path_to_d1);
  } else {
    printf("chroot OK\n");
  }
  printf("Here file '/a' should contain 'a in d1':\n");
  print_file_2("/a", "/prf");
  printf("And file 'd2/a' should contain 'a in d2':\n");
  print_file_2("/d2/a", "/prf");
  printf("symlink '/a-rel' -> 'a', should contain 'a in d1':\n");
  print_file("/a-rel");
  printf("symlink 'a-abs' -> '/a', should contain 'a in d1':\n");
  print_file("/a-abs");
  printf("\nSecond chroot, chroot(/d2):\n");
  if (chroot("/d2") < 0) {
    printf("Error: chroot(/d2) failed");
  } else {
    printf("chroot OK\n");
  }
  printf("Here file '/a' should contain 'a in d2':\n");
  print_file_2("/a", "/prf");
  printf("symlink 'a-rel' -> 'a', should contain 'a in d2':\n");
  print_file("/a-rel");
  printf("symlink 'a-abs' -> '/a', should contain 'a in d2':\n");
  print_file("/a-abs");
  printf("\nThird chroot, chroot(/d3) (which doesn't exist):\n");
  if (chroot("/d3") < 0) {
    printf("chroot failed, and that is OK\n");
    perror("errno=");
  } else {
    printf("Error: chroot(/d3) didn't fail!\n");
  }
  printf("\nYet another failing chroot, chroot(/a) ('a' is a file):\n");
  if (chroot("/a") < 0) {
    printf("chroot failed, and that is OK\n");
    perror("errno=");
  } else {
    printf("Error: chroot(/a) didn't fail!\n");
  }
  printf("\nchroot(.), should deactivate the effect:\n");
  if (chroot(".") < 0) {
    printf("Error: chroot(.) failed");
  } else {
    printf("chroot OK\n");
  }
  printf("\nchdir(orig_workdir)\n");
  if (chdir(orig_workdir) < 0) {
    printf("Error: chdir(orig_workdir) failed");
  } else {
    printf("chdir OK\n");
  }
  printf("\nfile 'a' should contain 'a in workdir':\n");
  print_file_2("a", "./prf");
  printf("\n2nd time: chroot(./d1):\n");
  if (chroot("./d1") < 0) {
    printf("Error: chroot(./d1) failed");
  } else {
    printf("chroot OK\n");
  }
  printf("\nHere file '/a' should contain 'a in d1':\n");
  print_file_2("/a", "/prf");
  printf("\nNow chroot(.) should take to orig_workdir\n");
  if (chroot(".") < 0) {
    printf("Error: chroot(.) failed");
  } else {
    printf("chroot OK\n");
  }
  printf("\nAgain, file '/a' should contain 'a in workdir':\n");
  print_file_2("/a", "./prf");
  printf("\nchdir(/d1/d2)\n");
  if (chdir("/d1/d2") < 0) {
    printf("Error: chdir(/d1/d2) failed");
  } else {
    printf("chdir OK\n");
  }
  printf("\nHere file 'a' should contain 'a in d2':\n");
  print_file_2("a", "./prf");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2020,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jne    1217 <main+0x37>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10b0 <print_file@plt>
xor    %edi,%edi
call   1100 <exit@plt>
lea    0xde2(%rip),%rdi
mov    $0x1ed,%esi
call   1040 <mkdir@plt>
lea    0xdd1(%rip),%rdi
call   1050 <chdir@plt>
lea    -0x1010(%rbp),%rdi
mov    $0x1000,%esi
call   10a0 <getcwd@plt>
lea    -0x1010(%rbp),%rsi
lea    0xdbe(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xdc3(%rip),%rdi
mov    $0x1ed,%esi
call   1040 <mkdir@plt>
lea    0xdb7(%rip),%rdi
mov    $0x1ed,%esi
call   1040 <mkdir@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xda7(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x2020(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rcx
mov    $0x1000,%esi
lea    0xd94(%rip),%rdx
call   1090 <snprintf@plt>
lea    -0x2020(%rbp),%rdi
lea    0xd87(%rip),%rsi
call   10f0 <link@plt>
lea    -0x2020(%rbp),%rdi
lea    0xd7a(%rip),%rsi
call   10f0 <link@plt>
lea    -0x2020(%rbp),%rdi
lea    0xd70(%rip),%rsi
call   10f0 <link@plt>
lea    0xd9f(%rip),%rdi
lea    0xd69(%rip),%rsi
call   1070 <write_file@plt>
lea    0xd6a(%rip),%rdi
lea    0xd6a(%rip),%rsi
call   1070 <write_file@plt>
lea    0xd66(%rip),%rdi
lea    0xd69(%rip),%rsi
call   1070 <write_file@plt>
lea    0xd66(%rip),%rdi
lea    0xee2(%rip),%rsi
call   1080 <symlink@plt>
lea    0xd54(%rip),%rdi
lea    0xf0a(%rip),%rsi
call   1080 <symlink@plt>
lea    0xd2a(%rip),%rdi
call   1050 <chdir@plt>
lea    0xd34(%rip),%rdi
lea    0xeb0(%rip),%rsi
call   1080 <symlink@plt>
lea    0xd22(%rip),%rdi
lea    0xed8(%rip),%rsi
call   1080 <symlink@plt>
lea    0xd0d(%rip),%rdi
lea    0xd0b(%rip),%rsi
call   1080 <symlink@plt>
lea    0xcf7(%rip),%rdi
call   1050 <chdir@plt>
lea    0xcef(%rip),%rdi
lea    0xe6b(%rip),%rsi
call   1080 <symlink@plt>
lea    0xcdd(%rip),%rdi
lea    0xe93(%rip),%rsi
call   1080 <symlink@plt>
lea    0xcc8(%rip),%rdi
lea    0xcc6(%rip),%rsi
call   1080 <symlink@plt>
lea    0xcbf(%rip),%rdi
call   1050 <chdir@plt>
lea    0xcb9(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xcbe(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xc8e(%rip),%rdi
lea    0xc3d(%rip),%rsi
call   10d0 <print_file_2@plt>
lea    0xccb(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xdf0(%rip),%rdi
call   10b0 <print_file@plt>
lea    0xce9(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xe11(%rip),%rdi
call   10b0 <print_file@plt>
lea    0xcf1(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xcef(%rip),%rdi
call   1050 <chdir@plt>
cmp    $0x0,%rax
jge    1478 <main+0x298>
lea    0xcdb(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1486 <main+0x2a6>
lea    0xcdf(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x1010(%rbp),%rdx
lea    -0x1018(%rbp),%rdi
lea    0xccd(%rip),%rsi
call   10c0 <asprintf@plt>
mov    -0x1018(%rbp),%rsi
lea    0xcc0(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x1018(%rbp),%rdi
call   1030 <chroot@plt>
cmp    $0x0,%rax
jge    14e5 <main+0x305>
mov    -0x1018(%rbp),%rsi
lea    0xcb5(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    14f3 <main+0x313>
lea    0xcbb(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xfd5(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xb88(%rip),%rdi
lea    0xb37(%rip),%rsi
call   10d0 <print_file_2@plt>
lea    0xc97(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xb57(%rip),%rdi
lea    0xb16(%rip),%rsi
call   10d0 <print_file_2@plt>
lea    0xca1(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xcc7(%rip),%rdi
call   10b0 <print_file@plt>
lea    0xcc2(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xce8(%rip),%rdi
call   10b0 <print_file@plt>
lea    0xce3(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xaaf(%rip),%rdi
call   1030 <chroot@plt>
cmp    $0x0,%rax
jge    15a0 <main+0x3c0>
lea    0xcdd(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    15ae <main+0x3ce>
lea    0xc00(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xcd6(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xacd(%rip),%rdi
lea    0xa7c(%rip),%rsi
call   10d0 <print_file_2@plt>
lea    0xcdf(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xc2d(%rip),%rdi
call   10b0 <print_file@plt>
lea    0xcf8(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xc4e(%rip),%rdi
call   10b0 <print_file@plt>
lea    0xd12(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xd37(%rip),%rdi
call   1030 <chroot@plt>
cmp    $0x0,%rax
jge    1646 <main+0x466>
lea    0xd25(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xd36(%rip),%rdi
call   10e0 <perror@plt>
jmp    1654 <main+0x474>
lea    0xd2c(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xd3f(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xa27(%rip),%rdi
call   1030 <chroot@plt>
cmp    $0x0,%rax
jge    1697 <main+0x4b7>
lea    0xcd4(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xce5(%rip),%rdi
call   10e0 <perror@plt>
jmp    16a5 <main+0x4c5>
lea    0xd36(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xd48(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0x9dc(%rip),%rdi
call   1030 <chroot@plt>
cmp    $0x0,%rax
jge    16dc <main+0x4fc>
lea    0xd4f(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    16ea <main+0x50a>
lea    0xac4(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xd46(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x1010(%rbp),%rdi
call   1050 <chdir@plt>
cmp    $0x0,%rax
jge    1721 <main+0x541>
lea    0xd38(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    172f <main+0x54f>
lea    0xa36(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xd39(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0x94d(%rip),%rdi
lea    0x8fa(%rip),%rsi
call   10d0 <print_file_2@plt>
lea    0xd42(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0x8bf(%rip),%rdi
call   1030 <chroot@plt>
cmp    $0x0,%rax
jge    1787 <main+0x5a7>
lea    0xd38(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1795 <main+0x5b5>
lea    0xa19(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xd32(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0x8e6(%rip),%rdi
lea    0x895(%rip),%rsi
call   10d0 <print_file_2@plt>
lea    0xd3c(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0x8cb(%rip),%rdi
call   1030 <chroot@plt>
cmp    $0x0,%rax
jge    17ed <main+0x60d>
lea    0xc3e(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    17fb <main+0x61b>
lea    0x9b3(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xd23(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0x880(%rip),%rdi
lea    0x82e(%rip),%rsi
call   10d0 <print_file_2@plt>
lea    0xd34(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0x7f9(%rip),%rdi
call   1050 <chdir@plt>
cmp    $0x0,%rax
jge    1853 <main+0x673>
lea    0xd20(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1861 <main+0x681>
lea    0x904(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xd1b(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0x81b(%rip),%rdi
lea    0x7c8(%rip),%rsi
call   10d0 <print_file_2@plt>
mov    -0x4(%rbp),%eax
add    $0x2020,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x2018,%rsp
mov    %rsi,%r14
cmp    $0x2,%edi
je     17bb <main+0x5cb>
lea    0xdec(%rip),%rbx
mov    %rbx,%rdi
mov    $0x1ed,%esi
call   1040 <mkdir@plt>
mov    %rbx,%rdi
call   1060 <chdir@plt>
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x1000,%esi
call   10b0 <getcwd@plt>
lea    0xdcf(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xdd1(%rip),%rdi
mov    $0x1ed,%esi
call   1040 <mkdir@plt>
lea    0xdc5(%rip),%rdi
mov    $0x1ed,%esi
call   1040 <mkdir@plt>
mov    (%r14),%rsi
lea    0xdb9(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    (%r14),%rcx
lea    0xdb6(%rip),%rdx
lea    0x1010(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x1000,%esi
call   10a0 <snprintf@plt>
lea    0xda0(%rip),%rsi
mov    %rbx,%rdi
call   1100 <link@plt>
lea    0xd97(%rip),%rsi
mov    %rbx,%rdi
call   1100 <link@plt>
lea    0xd91(%rip),%rsi
mov    %rbx,%rdi
call   1100 <link@plt>
lea    0xdbd(%rip),%r13
lea    0xd87(%rip),%rsi
mov    %r13,%rdi
call   1080 <write_file@plt>
lea    0xd85(%rip),%rdi
lea    0xd85(%rip),%rsi
call   1080 <write_file@plt>
lea    0xd81(%rip),%rdi
lea    0xd84(%rip),%rsi
call   1080 <write_file@plt>
lea    0xde9(%rip),%r12
mov    %r13,%rdi
mov    %r12,%rsi
call   1090 <symlink@plt>
lea    0xd70(%rip),%rbx
lea    0xdd7(%rip),%r15
mov    %rbx,%rdi
mov    %r15,%rsi
call   1090 <symlink@plt>
lea    0xd40(%rip),%rdi
call   1060 <chdir@plt>
mov    %r13,%rdi
mov    %r12,%rsi
call   1090 <symlink@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1090 <symlink@plt>
lea    0xd33(%rip),%rbp
lea    0xd31(%rip),%r14
mov    %rbp,%rdi
mov    %r14,%rsi
call   1090 <symlink@plt>
lea    0xd17(%rip),%rdi
call   1060 <chdir@plt>
mov    %r13,%rdi
mov    %r12,%rsi
call   1090 <symlink@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1090 <symlink@plt>
mov    %rbp,%rdi
mov    %r14,%rsi
call   1090 <symlink@plt>
lea    0xcf7(%rip),%rdi
call   1060 <chdir@plt>
lea    0xded(%rip),%rdi
call   1050 <puts@plt>
lea    0xdf3(%rip),%rdi
call   1050 <puts@plt>
mov    %r13,%rdi
lea    0xc7d(%rip),%rsi
call   10e0 <print_file_2@plt>
lea    0xe05(%rip),%rdi
call   1050 <puts@plt>
mov    %r12,%rdi
call   10c0 <print_file@plt>
lea    0xe28(%rip),%rdi
call   1050 <puts@plt>
mov    %r15,%rdi
call   10c0 <print_file@plt>
lea    0xe35(%rip),%rdi
call   1050 <puts@plt>
lea    0xc96(%rip),%rdi
call   1060 <chdir@plt>
test   %rax,%rax
js     1420 <main+0x230>
lea    0x1128(%rip),%rdi
call   1050 <puts@plt>
jmp    142e <main+0x23e>
lea    0xc79(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xc82(%rip),%rsi
lea    0x8(%rsp),%rdi
lea    0x10(%rsp),%rdx
call   10d0 <asprintf@plt>
mov    0x8(%rsp),%rsi
lea    0xc6d(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x8(%rsp),%rdi
call   1030 <chroot@plt>
test   %rax,%rax
js     1474 <main+0x284>
lea    0x108a(%rip),%rdi
call   1050 <puts@plt>
jmp    1487 <main+0x297>
mov    0x8(%rsp),%rsi
lea    0xc5d(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0x1015(%rip),%rdi
call   1050 <puts@plt>
lea    0xbf6(%rip),%rdi
lea    0xba5(%rip),%rbx
mov    %rbx,%rsi
call   10e0 <print_file_2@plt>
lea    0xd8c(%rip),%rdi
call   1050 <puts@plt>
lea    0xbc4(%rip),%rdi
mov    %rbx,%rsi
call   10e0 <print_file_2@plt>
lea    0xd9b(%rip),%rdi
call   1050 <puts@plt>
lea    0xc1f(%rip),%rdi
call   10c0 <print_file@plt>
lea    0xdb6(%rip),%rdi
call   1050 <puts@plt>
lea    0xc0e(%rip),%rdi
call   10c0 <print_file@plt>
lea    0xdd1(%rip),%rdi
call   1050 <puts@plt>
lea    0xb26(%rip),%rdi
call   1030 <chroot@plt>
test   %rax,%rax
js     151f <main+0x32f>
lea    0xfdf(%rip),%rdi
call   1050 <puts@plt>
jmp    152d <main+0x33d>
lea    0xbde(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xdb5(%rip),%rdi
call   1050 <puts@plt>
lea    0xb50(%rip),%rdi
lea    0xaff(%rip),%rsi
call   10e0 <print_file_2@plt>
lea    0xdbf(%rip),%rdi
call   1050 <puts@plt>
lea    0xb97(%rip),%rdi
call   10c0 <print_file@plt>
lea    0xdd9(%rip),%rdi
call   1050 <puts@plt>
lea    0xb86(%rip),%rdi
call   10c0 <print_file@plt>
lea    0xdf4(%rip),%rdi
call   1050 <puts@plt>
lea    0xb8f(%rip),%rdi
call   1030 <chroot@plt>
test   %rax,%rax
js     1781 <main+0x591>
lea    0xe05(%rip),%rdi
call   1050 <puts@plt>
lea    0xe19(%rip),%rdi
call   1050 <puts@plt>
lea    0xad4(%rip),%rdi
call   1030 <chroot@plt>
test   %rax,%rax
js     179e <main+0x5ae>
lea    0xe31(%rip),%rdi
call   1050 <puts@plt>
lea    0xe44(%rip),%rdi
call   1050 <puts@plt>
lea    0xaad(%rip),%rdi
call   1030 <chroot@plt>
test   %rax,%rax
js     1601 <main+0x411>
lea    0xefd(%rip),%rdi
call   1050 <puts@plt>
jmp    160f <main+0x41f>
lea    0xb21(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xe35(%rip),%rdi
call   1050 <puts@plt>
lea    0x10(%rsp),%rdi
call   1060 <chdir@plt>
test   %rax,%rax
js     1638 <main+0x448>
lea    0xf10(%rip),%rdi
call   1050 <puts@plt>
jmp    1646 <main+0x456>
lea    0xb02(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xe13(%rip),%rdi
call   1050 <puts@plt>
lea    0xa38(%rip),%rdi
lea    0x9e5(%rip),%rsi
call   10e0 <print_file_2@plt>
lea    0xe1d(%rip),%rdi
call   1050 <puts@plt>
lea    0x9ac(%rip),%rdi
call   1030 <chroot@plt>
test   %rax,%rax
js     1690 <main+0x4a0>
lea    0xe6e(%rip),%rdi
call   1050 <puts@plt>
jmp    169e <main+0x4ae>
lea    0xacc(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xdfd(%rip),%rdi
call   1050 <puts@plt>
lea    0x9df(%rip),%rdi
lea    0x98e(%rip),%rsi
call   10e0 <print_file_2@plt>
lea    0xe08(%rip),%rdi
call   1050 <puts@plt>
lea    0x9c6(%rip),%rdi
call   1030 <chroot@plt>
test   %rax,%rax
js     16e8 <main+0x4f8>
lea    0xe16(%rip),%rdi
call   1050 <puts@plt>
jmp    16f6 <main+0x506>
lea    0xa3a(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xe04(%rip),%rdi
call   1050 <puts@plt>
lea    0x987(%rip),%rdi
lea    0x935(%rip),%rsi
call   10e0 <print_file_2@plt>
lea    0xe16(%rip),%rdi
call   1050 <puts@plt>
lea    0x902(%rip),%rdi
call   1060 <chdir@plt>
test   %rax,%rax
js     1740 <main+0x550>
lea    0xe08(%rip),%rdi
call   1050 <puts@plt>
jmp    174e <main+0x55e>
lea    0xa37(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xdf5(%rip),%rdi
call   1050 <puts@plt>
lea    0x930(%rip),%rdi
lea    0x8dd(%rip),%rsi
call   10e0 <print_file_2@plt>
xor    %eax,%eax
add    $0x2018,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xdeb(%rip),%rdi
call   1050 <puts@plt>
lea    0x98e(%rip),%rdi
call   10f0 <perror@plt>
jmp    15a9 <main+0x3b9>
lea    0xdce(%rip),%rdi
call   1050 <puts@plt>
lea    0x971(%rip),%rdi
call   10f0 <perror@plt>
jmp    15d6 <main+0x3e6>
mov    0x8(%r14),%rdi
call   10c0 <print_file@plt>
xor    %edi,%edi
call   1110 <exit@plt>

LLVM IR (-O0):
@.str = [17 x i8] c"./Chroottest-dir\00"
@.str.1 = [19 x i8] c"orig_workdir='%s'\0A\00"
@.str.2 = [5 x i8] c"./d1\00"
@.str.3 = [8 x i8] c"./d1/d2\00"
@.str.4 = [14 x i8] c"argv[0]='%s'\0A\00"
@.str.5 = [6 x i8] c"../%s\00"
@.str.6 = [6 x i8] c"./prf\00"
@.str.7 = [9 x i8] c"./d1/prf\00"
@.str.8 = [12 x i8] c"./d1/d2/prf\00"
@.str.9 = [4 x i8] c"./a\00"
@.str.10 = [13 x i8] c"a in workdir\00"
@.str.11 = [7 x i8] c"./d1/a\00"
@.str.12 = [8 x i8] c"a in d1\00"
@.str.13 = [10 x i8] c"./d1/d2/a\00"
@.str.14 = [8 x i8] c"a in d2\00"
@.str.15 = [6 x i8] c"a-rel\00"
@.str.16 = [3 x i8] c"/a\00"
@.str.17 = [6 x i8] c"a-abs\00"
@.str.18 = [3 x i8] c"d1\00"
@.str.19 = [5 x i8] c"../a\00"
@.str.20 = [5 x i8] c"a-..\00"
@.str.21 = [3 x i8] c"d2\00"
@.str.22 = [6 x i8] c"../..\00"
@.str.23 = [19 x i8] c"Not yet chrooted:\0A\00"
@.str.24 = [46 x i8] c"Here file 'a' should contain 'a in workdir':\0A\00"
@.str.25 = [56 x i8] c"symlink 'a-rel' -> 'a', should contain 'a in workdir':\0A\00"
@.str.26 = [34 x i8] c"symlink 'a-abs' -> no such file:\0A\00"
@.str.27 = [12 x i8] c"\0Achdir(/):\0A\00"
@.str.28 = [2 x i8] c"/\00"
@.str.29 = [23 x i8] c"Error: chdir(/) failed\00"
@.str.30 = [10 x i8] c"chdir OK\0A\00"
@.str.31 = [6 x i8] c"%s/d1\00"
@.str.32 = [32 x i8] c"\0Achroot(orig_workdir/d1) (%s):\0A\00"
@.str.33 = [25 x i8] c"Error: chroot(%s) failed\00"
@.str.34 = [11 x i8] c"chroot OK\0A\00"
@.str.35 = [42 x i8] c"Here file '/a' should contain 'a in d1':\0A\00"
@.str.36 = [5 x i8] c"/prf\00"
@.str.37 = [43 x i8] c"And file 'd2/a' should contain 'a in d2':\0A\00"
@.str.38 = [6 x i8] c"/d2/a\00"
@.str.39 = [52 x i8] c"symlink '/a-rel' -> 'a', should contain 'a in d1':\0A\00"
@.str.40 = [7 x i8] c"/a-rel\00"
@.str.41 = [52 x i8] c"symlink 'a-abs' -> '/a', should contain 'a in d1':\0A\00"
@.str.42 = [7 x i8] c"/a-abs\00"
@.str.43 = [30 x i8] c"\0ASecond chroot, chroot(/d2):\0A\00"
@.str.44 = [4 x i8] c"/d2\00"
@.str.45 = [26 x i8] c"Error: chroot(/d2) failed\00"
@.str.46 = [42 x i8] c"Here file '/a' should contain 'a in d2':\0A\00"
@.str.47 = [51 x i8] c"symlink 'a-rel' -> 'a', should contain 'a in d2':\0A\00"
@.str.48 = [52 x i8] c"symlink 'a-abs' -> '/a', should contain 'a in d2':\0A\00"
@.str.49 = [51 x i8] c"\0AThird chroot, chroot(/d3) (which doesn't exist):\0A\00"
@.str.50 = [4 x i8] c"/d3\00"
@.str.51 = [31 x i8] c"chroot failed, and that is OK\0A\00"
@.str.52 = [7 x i8] c"errno=\00"
@.str.53 = [33 x i8] c"Error: chroot(/d3) didn't fail!\0A\00"
@.str.54 = [58 x i8] c"\0AYet another failing chroot, chroot(/a) ('a' is a file):\0A\00"
@.str.55 = [32 x i8] c"Error: chroot(/a) didn't fail!\0A\00"
@.str.56 = [43 x i8] c"\0Achroot(.), should deactivate the effect:\0A\00"
@.str.57 = [2 x i8] c".\00"
@.str.58 = [24 x i8] c"Error: chroot(.) failed\00"
@.str.59 = [22 x i8] c"\0Achdir(orig_workdir)\0A\00"
@.str.60 = [34 x i8] c"Error: chdir(orig_workdir) failed\00"
@.str.61 = [42 x i8] c"\0Afile 'a' should contain 'a in workdir':\0A\00"
@.str.62 = [2 x i8] c"a\00"
@.str.63 = [26 x i8] c"\0A2nd time: chroot(./d1):\0A\00"
@.str.64 = [27 x i8] c"Error: chroot(./d1) failed\00"
@.str.65 = [43 x i8] c"\0AHere file '/a' should contain 'a in d1':\0A\00"
@.str.66 = [44 x i8] c"\0ANow chroot(.) should take to orig_workdir\0A\00"
@.str.67 = [50 x i8] c"\0AAgain, file '/a' should contain 'a in workdir':\0A\00"
@.str.68 = [16 x i8] c"\0Achdir(/d1/d2)\0A\00"
@.str.69 = [7 x i8] c"/d1/d2\00"
@.str.70 = [28 x i8] c"Error: chdir(/d1/d2) failed\00"
@.str.71 = [42 x i8] c"\0AHere file 'a' should contain 'a in d2':\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [4096 x i8]
%7 = alloca i8*
%8 = alloca [4096 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp eq i32 %9, 2
br i1 %10, label %11, label %17
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
%15 = call i32 @print_file(i8* %14)
%16 = call i32 @exit(i32 0)
unreachable
17: ; preds = %2
%18 = call i32 @mkdir(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 493)
%19 = call i64 @chdir(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%20 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%21 = call i32 @getcwd(i8* %20, i32 4096)
%22 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* %22)
%24 = call i32 @mkdir(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 493)
%25 = call i32 @mkdir(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 493)
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 0
%28 = load i8*, i8** %27
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i8* %28)
%30 = getelementptr inbounds [4096 x i8], [4096 x i8]* %8, i64 0, i64 0
%31 = load i8**, i8*** %5
%32 = getelementptr inbounds i8*, i8** %31, i64 0
%33 = load i8*, i8** %32
%34 = call i32 @snprintf(i8* %30, i32 4096, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i8* %33)
%35 = getelementptr inbounds [4096 x i8], [4096 x i8]* %8, i64 0, i64 0
%36 = call i32 @link(i8* %35, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
%37 = getelementptr inbounds [4096 x i8], [4096 x i8]* %8, i64 0, i64 0
%38 = call i32 @link(i8* %37, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0))
%39 = getelementptr inbounds [4096 x i8], [4096 x i8]* %8, i64 0, i64 0
%40 = call i32 @link(i8* %39, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.8, i64 0, i64 0))
%41 = call i32 @write_file(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.10, i64 0, i64 0))
%42 = call i32 @write_file(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.12, i64 0, i64 0))
%43 = call i32 @write_file(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.13, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.14, i64 0, i64 0))
%44 = call i32 @symlink(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.15, i64 0, i64 0))
%45 = call i32 @symlink(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.16, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.17, i64 0, i64 0))
%46 = call i64 @chdir(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.18, i64 0, i64 0))
%47 = call i32 @symlink(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.15, i64 0, i64 0))
%48 = call i32 @symlink(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.16, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.17, i64 0, i64 0))
%49 = call i32 @symlink(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.19, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.20, i64 0, i64 0))
%50 = call i64 @chdir(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.21, i64 0, i64 0))
%51 = call i32 @symlink(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.15, i64 0, i64 0))
%52 = call i32 @symlink(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.16, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.17, i64 0, i64 0))
%53 = call i32 @symlink(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.19, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.20, i64 0, i64 0))
%54 = call i64 @chdir(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.22, i64 0, i64 0))
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.23, i64 0, i64 0))
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.24, i64 0, i64 0))
%57 = call i32 @print_file_2(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.25, i64 0, i64 0))
%59 = call i32 @print_file(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.15, i64 0, i64 0))
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.26, i64 0, i64 0))
%61 = call i32 @print_file(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.17, i64 0, i64 0))
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.27, i64 0, i64 0))
%63 = call i64 @chdir(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.28, i64 0, i64 0))
%64 = icmp slt i64 %63, 0
br i1 %64, label %65, label %67
65: ; preds = %17
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.29, i64 0, i64 0))
br label %69
67: ; preds = %17
%68 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.30, i64 0, i64 0))
br label %69
69: ; preds = %67, %65
%70 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%71 = call i32 @asprintf(i8** %7, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.31, i64 0, i64 0), i8* %70)
%72 = load i8*, i8** %7
%73 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.32, i64 0, i64 0), i8* %72)
%74 = load i8*, i8** %7
%75 = call i64 @chroot(i8* %74)
%76 = icmp slt i64 %75, 0
br i1 %76, label %77, label %80
77: ; preds = %69
%78 = load i8*, i8** %7
%79 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.33, i64 0, i64 0), i8* %78)
br label %82
80: ; preds = %69
%81 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.34, i64 0, i64 0))
br label %82
82: ; preds = %80, %77
%83 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.35, i64 0, i64 0))
%84 = call i32 @print_file_2(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.16, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.36, i64 0, i64 0))
%85 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.37, i64 0, i64 0))
%86 = call i32 @print_file_2(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.38, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.36, i64 0, i64 0))
%87 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.39, i64 0, i64 0))
%88 = call i32 @print_file(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.40, i64 0, i64 0))
%89 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.41, i64 0, i64 0))
%90 = call i32 @print_file(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.42, i64 0, i64 0))
%91 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.43, i64 0, i64 0))
%92 = call i64 @chroot(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.44, i64 0, i64 0))
%93 = icmp slt i64 %92, 0
br i1 %93, label %94, label %96
94: ; preds = %82
%95 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.45, i64 0, i64 0))
br label %98
96: ; preds = %82
%97 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.34, i64 0, i64 0))
br label %98
98: ; preds = %96, %94
%99 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.46, i64 0, i64 0))
%100 = call i32 @print_file_2(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.16, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.36, i64 0, i64 0))
%101 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.47, i64 0, i64 0))
%102 = call i32 @print_file(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.40, i64 0, i64 0))
%103 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.48, i64 0, i64 0))
%104 = call i32 @print_file(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.42, i64 0, i64 0))
%105 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.49, i64 0, i64 0))
%106 = call i64 @chroot(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.50, i64 0, i64 0))
%107 = icmp slt i64 %106, 0
br i1 %107, label %108, label %111
108: ; preds = %98
%109 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.51, i64 0, i64 0))
%110 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.52, i64 0, i64 0))
br label %113
111: ; preds = %98
%112 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.53, i64 0, i64 0))
br label %113
113: ; preds = %111, %108
%114 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.54, i64 0, i64 0))
%115 = call i64 @chroot(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.16, i64 0, i64 0))
%116 = icmp slt i64 %115, 0
br i1 %116, label %117, label %120
117: ; preds = %113
%118 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.51, i64 0, i64 0))
%119 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.52, i64 0, i64 0))
br label %122
120: ; preds = %113
%121 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.55, i64 0, i64 0))
br label %122
122: ; preds = %120, %117
%123 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.56, i64 0, i64 0))
%124 = call i64 @chroot(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.57, i64 0, i64 0))
%125 = icmp slt i64 %124, 0
br i1 %125, label %126, label %128
126: ; preds = %122
%127 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.58, i64 0, i64 0))
br label %130
128: ; preds = %122
%129 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.34, i64 0, i64 0))
br label %130
130: ; preds = %128, %126
%131 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.59, i64 0, i64 0))
%132 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%133 = call i64 @chdir(i8* %132)
%134 = icmp slt i64 %133, 0
br i1 %134, label %135, label %137
135: ; preds = %130
%136 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.60, i64 0, i64 0))
br label %139
137: ; preds = %130
%138 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.30, i64 0, i64 0))
br label %139
139: ; preds = %137, %135
%140 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.61, i64 0, i64 0))
%141 = call i32 @print_file_2(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.62, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
%142 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.63, i64 0, i64 0))
%143 = call i64 @chroot(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%144 = icmp slt i64 %143, 0
br i1 %144, label %145, label %147
145: ; preds = %139
%146 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.64, i64 0, i64 0))
br label %149
147: ; preds = %139
%148 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.34, i64 0, i64 0))
br label %149
149: ; preds = %147, %145
%150 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.65, i64 0, i64 0))
%151 = call i32 @print_file_2(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.16, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.36, i64 0, i64 0))
%152 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.66, i64 0, i64 0))
%153 = call i64 @chroot(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.57, i64 0, i64 0))
%154 = icmp slt i64 %153, 0
br i1 %154, label %155, label %157
155: ; preds = %149
%156 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.58, i64 0, i64 0))
br label %159
157: ; preds = %149
%158 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.34, i64 0, i64 0))
br label %159
159: ; preds = %157, %155
%160 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.67, i64 0, i64 0))
%161 = call i32 @print_file_2(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.16, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
%162 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.68, i64 0, i64 0))
%163 = call i64 @chdir(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.69, i64 0, i64 0))
%164 = icmp slt i64 %163, 0
br i1 %164, label %165, label %167
165: ; preds = %159
%166 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.70, i64 0, i64 0))
br label %169
167: ; preds = %159
%168 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.30, i64 0, i64 0))
br label %169
169: ; preds = %167, %165
%170 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.71, i64 0, i64 0))
%171 = call i32 @print_file_2(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.62, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
%172 = load i32, i32* %3
ret i32 %172
}

LLVM IR (-O2):
@.str = [17 x i8] c"./Chroottest-dir\00"
@.str.1 = [19 x i8] c"orig_workdir='%s'\0A\00"
@.str.2 = [5 x i8] c"./d1\00"
@.str.3 = [8 x i8] c"./d1/d2\00"
@.str.4 = [14 x i8] c"argv[0]='%s'\0A\00"
@.str.5 = [6 x i8] c"../%s\00"
@.str.6 = [6 x i8] c"./prf\00"
@.str.7 = [9 x i8] c"./d1/prf\00"
@.str.8 = [12 x i8] c"./d1/d2/prf\00"
@.str.9 = [4 x i8] c"./a\00"
@.str.10 = [13 x i8] c"a in workdir\00"
@.str.11 = [7 x i8] c"./d1/a\00"
@.str.12 = [8 x i8] c"a in d1\00"
@.str.13 = [10 x i8] c"./d1/d2/a\00"
@.str.14 = [8 x i8] c"a in d2\00"
@.str.15 = [6 x i8] c"a-rel\00"
@.str.16 = [3 x i8] c"/a\00"
@.str.17 = [6 x i8] c"a-abs\00"
@.str.18 = [3 x i8] c"d1\00"
@.str.19 = [5 x i8] c"../a\00"
@.str.20 = [5 x i8] c"a-..\00"
@.str.21 = [3 x i8] c"d2\00"
@.str.22 = [6 x i8] c"../..\00"
@.str.28 = [2 x i8] c"/\00"
@.str.29 = [23 x i8] c"Error: chdir(/) failed\00"
@.str.31 = [6 x i8] c"%s/d1\00"
@.str.32 = [32 x i8] c"\0Achroot(orig_workdir/d1) (%s):\0A\00"
@.str.33 = [25 x i8] c"Error: chroot(%s) failed\00"
@.str.36 = [5 x i8] c"/prf\00"
@.str.38 = [6 x i8] c"/d2/a\00"
@.str.40 = [7 x i8] c"/a-rel\00"
@.str.42 = [7 x i8] c"/a-abs\00"
@.str.44 = [4 x i8] c"/d2\00"
@.str.45 = [26 x i8] c"Error: chroot(/d2) failed\00"
@.str.50 = [4 x i8] c"/d3\00"
@.str.52 = [7 x i8] c"errno=\00"
@.str.57 = [2 x i8] c".\00"
@.str.58 = [24 x i8] c"Error: chroot(.) failed\00"
@.str.60 = [34 x i8] c"Error: chdir(orig_workdir) failed\00"
@.str.62 = [2 x i8] c"a\00"
@.str.64 = [27 x i8] c"Error: chroot(./d1) failed\00"
@.str.69 = [7 x i8] c"/d1/d2\00"
@.str.70 = [28 x i8] c"Error: chdir(/d1/d2) failed\00"
@str = [18 x i8] c"Not yet chrooted:\00"
@str.72 = [45 x i8] c"Here file 'a' should contain 'a in workdir':\00"
@str.73 = [55 x i8] c"symlink 'a-rel' -> 'a', should contain 'a in workdir':\00"
@str.74 = [33 x i8] c"symlink 'a-abs' -> no such file:\00"
@str.75 = [11 x i8] c"\0Achdir(/):\00"
@str.78 = [41 x i8] c"Here file '/a' should contain 'a in d1':\00"
@str.79 = [42 x i8] c"And file 'd2/a' should contain 'a in d2':\00"
@str.80 = [51 x i8] c"symlink '/a-rel' -> 'a', should contain 'a in d1':\00"
@str.81 = [51 x i8] c"symlink 'a-abs' -> '/a', should contain 'a in d1':\00"
@str.82 = [29 x i8] c"\0ASecond chroot, chroot(/d2):\00"
@str.84 = [41 x i8] c"Here file '/a' should contain 'a in d2':\00"
@str.85 = [50 x i8] c"symlink 'a-rel' -> 'a', should contain 'a in d2':\00"
@str.86 = [51 x i8] c"symlink 'a-abs' -> '/a', should contain 'a in d2':\00"
@str.87 = [50 x i8] c"\0AThird chroot, chroot(/d3) (which doesn't exist):\00"
@str.88 = [32 x i8] c"Error: chroot(/d3) didn't fail!\00"
@str.89 = [57 x i8] c"\0AYet another failing chroot, chroot(/a) ('a' is a file):\00"
@str.90 = [31 x i8] c"Error: chroot(/a) didn't fail!\00"
@str.91 = [42 x i8] c"\0Achroot(.), should deactivate the effect:\00"
@str.93 = [21 x i8] c"\0Achdir(orig_workdir)\00"
@str.95 = [41 x i8] c"\0Afile 'a' should contain 'a in workdir':\00"
@str.96 = [25 x i8] c"\0A2nd time: chroot(./d1):\00"
@str.98 = [42 x i8] c"\0AHere file '/a' should contain 'a in d1':\00"
@str.99 = [43 x i8] c"\0ANow chroot(.) should take to orig_workdir\00"
@str.100 = [10 x i8] c"chroot OK\00"
@str.101 = [49 x i8] c"\0AAgain, file '/a' should contain 'a in workdir':\00"
@str.102 = [15 x i8] c"\0Achdir(/d1/d2)\00"
@str.103 = [9 x i8] c"chdir OK\00"
@str.104 = [41 x i8] c"\0AHere file 'a' should contain 'a in d2':\00"
@str.106 = [30 x i8] c"chroot failed, and that is OK\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [4096 x i8]
%4 = alloca i8*
%5 = alloca [4096 x i8]
%6 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 0
%7 = bitcast i8** %4 to i8*
%8 = getelementptr inbounds [4096 x i8], [4096 x i8]* %5, i64 0, i64 0
%9 = icmp eq i32 %0, 2
br i1 %9, label %10, label %15
10: ; preds = %2
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = tail call i32 @print_file(i8* %12)
%14 = tail call i32 @exit(i32 0)
unreachable
15: ; preds = %2
%16 = tail call i32 @mkdir(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 493)
%17 = tail call i64 @chdir(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%18 = call i32 @getcwd(i8* %6, i32 4096)
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* %6)
%20 = call i32 @mkdir(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 493)
%21 = call i32 @mkdir(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 493)
%22 = load i8*, i8** %1
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i8* %22)
%24 = load i8*, i8** %1
%25 = call i32 @snprintf(i8* %8, i32 4096, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i8* %24)
%26 = call i32 @link(i8* %8, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
%27 = call i32 @link(i8* %8, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0))
%28 = call i32 @link(i8* %8, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.8, i64 0, i64 0))
%29 = call i32 @write_file(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.10, i64 0, i64 0))
%30 = call i32 @write_file(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.12, i64 0, i64 0))
%31 = call i32 @write_file(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.13, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.14, i64 0, i64 0))
%32 = call i32 @symlink(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.15, i64 0, i64 0))
%33 = call i32 @symlink(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.16, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.17, i64 0, i64 0))
%34 = call i64 @chdir(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.18, i64 0, i64 0))
%35 = call i32 @symlink(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.15, i64 0, i64 0))
%36 = call i32 @symlink(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.16, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.17, i64 0, i64 0))
%37 = call i32 @symlink(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.19, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.20, i64 0, i64 0))
%38 = call i64 @chdir(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.21, i64 0, i64 0))
%39 = call i32 @symlink(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.15, i64 0, i64 0))
%40 = call i32 @symlink(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.16, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.17, i64 0, i64 0))
%41 = call i32 @symlink(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.19, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.20, i64 0, i64 0))
%42 = call i64 @chdir(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.22, i64 0, i64 0))
%43 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0))
%44 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @str.72, i64 0, i64 0))
%45 = call i32 @print_file_2(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
%46 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @str.73, i64 0, i64 0))
%47 = call i32 @print_file(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.15, i64 0, i64 0))
%48 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str.74, i64 0, i64 0))
%49 = call i32 @print_file(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.17, i64 0, i64 0))
%50 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.75, i64 0, i64 0))
%51 = call i64 @chdir(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.28, i64 0, i64 0))
%52 = icmp slt i64 %51, 0
br i1 %52, label %53, label %55
53: ; preds = %15
%54 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.29, i64 0, i64 0))
br label %57
55: ; preds = %15
%56 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.103, i64 0, i64 0))
br label %57
57: ; preds = %55, %53
%58 = call i32 @asprintf(i8** %4, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.31, i64 0, i64 0), i8* %6)
%59 = load i8*, i8** %4
%60 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.32, i64 0, i64 0), i8* %59)
%61 = load i8*, i8** %4
%62 = call i64 @chroot(i8* %61)
%63 = icmp slt i64 %62, 0
br i1 %63, label %64, label %67
64: ; preds = %57
%65 = load i8*, i8** %4
%66 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.33, i64 0, i64 0), i8* %65)
br label %69
67: ; preds = %57
%68 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str.100, i64 0, i64 0))
br label %69
69: ; preds = %67, %64
%70 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str.78, i64 0, i64 0))
%71 = call i32 @print_file_2(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.16, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.36, i64 0, i64 0))
%72 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str.79, i64 0, i64 0))
%73 = call i32 @print_file_2(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.38, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.36, i64 0, i64 0))
%74 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @str.80, i64 0, i64 0))
%75 = call i32 @print_file(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.40, i64 0, i64 0))
%76 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @str.81, i64 0, i64 0))
%77 = call i32 @print_file(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.42, i64 0, i64 0))
%78 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.82, i64 0, i64 0))
%79 = call i64 @chroot(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.44, i64 0, i64 0))
%80 = icmp slt i64 %79, 0
br i1 %80, label %81, label %83
81: ; preds = %69
%82 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.45, i64 0, i64 0))
br label %85
83: ; preds = %69
%84 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str.100, i64 0, i64 0))
br label %85
85: ; preds = %83, %81
%86 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str.84, i64 0, i64 0))
%87 = call i32 @print_file_2(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.16, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.36, i64 0, i64 0))
%88 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @str.85, i64 0, i64 0))
%89 = call i32 @print_file(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.40, i64 0, i64 0))
%90 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @str.86, i64 0, i64 0))
%91 = call i32 @print_file(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.42, i64 0, i64 0))
%92 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @str.87, i64 0, i64 0))
%93 = call i64 @chroot(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.50, i64 0, i64 0))
%94 = icmp slt i64 %93, 0
br i1 %94, label %95, label %98
95: ; preds = %85
%96 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str.106, i64 0, i64 0))
%97 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.52, i64 0, i64 0))
br label %100
98: ; preds = %85
%99 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.88, i64 0, i64 0))
br label %100
100: ; preds = %98, %95
%101 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 x i8]* @str.89, i64 0, i64 0))
%102 = call i64 @chroot(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.16, i64 0, i64 0))
%103 = icmp slt i64 %102, 0
br i1 %103, label %104, label %107
104: ; preds = %100
%105 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str.106, i64 0, i64 0))
%106 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.52, i64 0, i64 0))
br label %109
107: ; preds = %100
%108 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.90, i64 0, i64 0))
br label %109
109: ; preds = %107, %104
%110 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str.91, i64 0, i64 0))
%111 = call i64 @chroot(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.57, i64 0, i64 0))
%112 = icmp slt i64 %111, 0
br i1 %112, label %113, label %115
113: ; preds = %109
%114 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.58, i64 0, i64 0))
br label %117
115: ; preds = %109
%116 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str.100, i64 0, i64 0))
br label %117
117: ; preds = %115, %113
%118 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.93, i64 0, i64 0))
%119 = call i64 @chdir(i8* %6)
%120 = icmp slt i64 %119, 0
br i1 %120, label %121, label %123
121: ; preds = %117
%122 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.60, i64 0, i64 0))
br label %125
123: ; preds = %117
%124 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.103, i64 0, i64 0))
br label %125
125: ; preds = %123, %121
%126 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str.95, i64 0, i64 0))
%127 = call i32 @print_file_2(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.62, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
%128 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.96, i64 0, i64 0))
%129 = call i64 @chroot(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%130 = icmp slt i64 %129, 0
br i1 %130, label %131, label %133
131: ; preds = %125
%132 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.64, i64 0, i64 0))
br label %135
133: ; preds = %125
%134 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str.100, i64 0, i64 0))
br label %135
135: ; preds = %133, %131
%136 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str.98, i64 0, i64 0))
%137 = call i32 @print_file_2(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.16, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.36, i64 0, i64 0))
%138 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @str.99, i64 0, i64 0))
%139 = call i64 @chroot(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.57, i64 0, i64 0))
%140 = icmp slt i64 %139, 0
br i1 %140, label %141, label %143
141: ; preds = %135
%142 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.58, i64 0, i64 0))
br label %145
143: ; preds = %135
%144 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str.100, i64 0, i64 0))
br label %145
145: ; preds = %143, %141
%146 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @str.101, i64 0, i64 0))
%147 = call i32 @print_file_2(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.16, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
%148 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.102, i64 0, i64 0))
%149 = call i64 @chdir(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.69, i64 0, i64 0))
%150 = icmp slt i64 %149, 0
br i1 %150, label %151, label %153
151: ; preds = %145
%152 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.70, i64 0, i64 0))
br label %155
153: ; preds = %145
%154 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.103, i64 0, i64 0))
br label %155
155: ; preds = %153, %151
%156 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str.104, i64 0, i64 0))
%157 = call i32 @print_file_2(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.62, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
ret i32 0
}