#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;
};
typedef int /*<<< orphan*/ pid_t;

/* Variables and functions */
int EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ PATH_MAX;
int S_IRUSR;
scalar_t__ S_ISDIR(int /*<<< orphan*/);
int S_IWUSR;
int S_IXUSR;
int chdir(char *);
scalar_t__ chroot(char *);
int errno;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fork();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
char *getcwd(char *, int /*<<< orphan*/);
int mkdir(char *, int);
int /*<<< orphan*/ printf(char *, char *);
scalar_t__ stat(char *, struct stat *);
int /*<<< orphan*/ stderr;
char *strerror(int);
int /*<<< orphan*/ waitpid(int /*<<< orphan*/, int /*<<< orphan*/ *,
                           int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  struct stat statbuf;
  pid_t pid;
  char *buf;
  if (argc < 2) {
    fprintf(stderr, "Uso: %s <dirname>\n", argv[0]);
    exit(EXIT_FAILURE);
  }
  if (stat(argv[1], &statbuf) < 0) {
    if (mkdir(argv[1], (S_IRUSR | S_IWUSR | S_IXUSR)) == -1) {
      fprintf(stderr, "Err.(%s) mkdir() failed\n", strerror(errno));
      exit(EXIT_FAILURE);
    }
  } else if (S_ISDIR(statbuf.st_mode)) {
    printf("New dir: %s\n", argv[1]);
  }
  if (chdir(argv[1]) == -1) {
    fprintf(stderr, "Err.(%s) chdir() failed\n", strerror(errno));
    exit(EXIT_FAILURE);
  }
  if (chroot(argv[1]) != 0) {
    fprintf(stderr, "Err.(%s) chroot() failed\n", strerror(errno));
    return (EXIT_FAILURE);
  }
  switch (pid = fork()) {
  case -1:
    fprintf(stderr, "Err.(%s) fork() failed\n", strerror(errno));
    exit(EXIT_FAILURE);
  case 0:
    printf("Current working dir: %s\n", getcwd(buf, PATH_MAX));
    if (chdir("/etc") == -1) {
      fprintf(stderr, "Err: %d chdir(); %s\n", errno, strerror(errno));
      return (EXIT_FAILURE);
    }
  default:
    waitpid(pid, NULL, 0);
  }
  return (EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    120c <main+0x4c>
mov    0x2de1(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe09(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    0x2db3(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x18(%rbp),%rsi
call   10a0 <stat@plt>
cmp    $0x0,%rax
jge    1299 <main+0xd9>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2d7a(%rip),%rax
mov    (%rax),%esi
mov    0x2d99(%rip),%rax
or     (%rax),%esi
mov    0x2d98(%rip),%rax
or     (%rax),%esi
call   1040 <mkdir@plt>
cmp    $0xffffffff,%eax
jne    1294 <main+0xd4>
mov    0x2d69(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
mov    0x2d55(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
mov    -0x2c(%rbp),%edi
mov    %rax,%rdx
lea    0xd94(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    0x2d2b(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
jmp    12c4 <main+0x104>
mov    -0x18(%rbp),%edi
call   1070 <S_ISDIR@plt>
cmp    $0x0,%rax
je     12bf <main+0xff>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xd72(%rip),%rdi
call   1060 <printf@plt>
jmp    12c4 <main+0x104>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <chdir@plt>
cmp    $0xffffffff,%eax
jne    1316 <main+0x156>
mov    0x2ce7(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x30(%rbp)
mov    0x2cd3(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
mov    -0x30(%rbp),%edi
mov    %rax,%rdx
lea    0xd38(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    0x2ca9(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1030 <chroot@plt>
cmp    $0x0,%rax
je     136c <main+0x1ac>
mov    0x2c94(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
mov    0x2c80(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
mov    -0x34(%rbp),%edi
mov    %rax,%rdx
lea    0xcfe(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    0x2c56(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1478 <main+0x2b8>
xor    %eax,%eax
call   10e0 <fork@plt>
mov    %eax,-0x1c(%rbp)
mov    %eax,%ecx
mov    %ecx,-0x38(%rbp)
sub    $0xffffffff,%eax
je     1399 <main+0x1d9>
jmp    1389 <main+0x1c9>
mov    -0x38(%rbp),%eax
test   %eax,%eax
je     13d5 <main+0x215>
jmp    145e <main+0x29e>
mov    0x2c28(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x3c(%rbp)
mov    0x2c14(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
mov    -0x3c(%rbp),%edi
mov    %rax,%rdx
lea    0xcac(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    0x2bea(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
mov    -0x28(%rbp),%rdi
mov    0x2c10(%rip),%rax
mov    (%rax),%esi
call   1080 <getcwd@plt>
mov    %rax,%rsi
lea    0xc93(%rip),%rdi
call   1060 <printf@plt>
lea    0xca0(%rip),%rdi
call   1050 <chdir@plt>
cmp    $0xffffffff,%eax
jne    1459 <main+0x299>
mov    0x2bb6(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x44(%rbp)
mov    0x2ba2(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x40(%rbp)
mov    0x2b96(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
mov    -0x44(%rbp),%edi
mov    -0x40(%rbp),%edx
mov    %rax,%rcx
lea    0xc61(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    0x2b69(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1478 <main+0x2b8>
jmp    145e <main+0x29e>
mov    -0x1c(%rbp),%edi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   10b0 <waitpid@plt>
mov    0x2b35(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
cmp    $0x1,%edi
jle    1334 <main+0x174>
mov    0x8(%rbx),%rdi
mov    %rsp,%rsi
call   10a0 <stat@plt>
test   %rax,%rax
js     11ff <main+0x3f>
mov    (%rsp),%edi
call   1070 <S_ISDIR@plt>
test   %rax,%rax
je     122c <main+0x6c>
mov    0x8(%rbx),%rsi
lea    0xe34(%rip),%rdi
call   1060 <printf@plt>
jmp    122c <main+0x6c>
mov    0x2daa(%rip),%rax
mov    0x2dcb(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x8(%rbx),%rdi
mov    0x2dc4(%rip),%rax
or     (%rax),%esi
call   1040 <mkdir@plt>
cmp    $0xffffffff,%eax
je     1369 <main+0x1a9>
mov    0x8(%rbx),%rdi
call   1050 <chdir@plt>
cmp    $0xffffffff,%eax
je     1349 <main+0x189>
mov    0x8(%rbx),%rdi
call   1030 <chroot@plt>
test   %rax,%rax
je     127f <main+0xbf>
mov    0x2d75(%rip),%rax
mov    (%rax),%ebx
mov    0x2d64(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
lea    0xde8(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    0x2d3b(%rip),%rax
jmp    12f4 <main+0x134>
xor    %eax,%eax
call   10e0 <fork@plt>
mov    %eax,%ebx
test   %eax,%eax
je     12b4 <main+0xf4>
cmp    $0xffffffff,%ebx
jne    12e2 <main+0x122>
mov    0x2d30(%rip),%rax
mov    (%rax),%ebx
mov    0x2d1f(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
lea    0xdbd(%rip),%rsi
jmp    1387 <main+0x1c7>
mov    0x2d35(%rip),%rax
mov    (%rax),%esi
call   1080 <getcwd@plt>
lea    0xdbb(%rip),%rdi
mov    %rax,%rsi
call   1060 <printf@plt>
lea    0xdc5(%rip),%rdi
call   1050 <chdir@plt>
cmp    $0xffffffff,%eax
je     12fd <main+0x13d>
mov    %ebx,%edi
xor    %esi,%esi
xor    %edx,%edx
call   10b0 <waitpid@plt>
mov    0x2cb4(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
mov    0x2cc4(%rip),%rax
mov    (%rax),%ebx
mov    0x2cb3(%rip),%rax
mov    (%rax),%ebp
mov    %ebp,%edi
call   10d0 <strerror@plt>
lea    0xd85(%rip),%rsi
mov    %ebx,%edi
mov    %ebp,%edx
mov    %rax,%rcx
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    0x2c86(%rip),%rax
jmp    12f4 <main+0x134>
mov    0x2c8d(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xcb9(%rip),%rsi
jmp    138c <main+0x1cc>
mov    0x2c78(%rip),%rax
mov    (%rax),%ebx
mov    0x2c67(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
lea    0xcd2(%rip),%rsi
jmp    1387 <main+0x1c7>
mov    0x2c58(%rip),%rax
mov    (%rax),%ebx
mov    0x2c47(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
lea    0xc8c(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    0x2c1e(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
%struct.stat = type { i32 }
@stderr = global i32 0
@.str = [19 x i8] c"Uso: %s <dirname>\0A\00"
@EXIT_FAILURE = global i32 0
@S_IRUSR = global i32 0
@S_IWUSR = global i32 0
@S_IXUSR = global i32 0
@.str.1 = [25 x i8] c"Err.(%s) mkdir() failed\0A\00"
@errno = global i32 0
@.str.2 = [13 x i8] c"New dir: %s\0A\00"
@.str.3 = [25 x i8] c"Err.(%s) chdir() failed\0A\00"
@.str.4 = [26 x i8] c"Err.(%s) chroot() failed\0A\00"
@.str.5 = [24 x i8] c"Err.(%s) fork() failed\0A\00"
@.str.6 = [25 x i8] c"Current working dir: %s\0A\00"
@PATH_MAX = global i32 0
@.str.7 = [5 x i8] c"/etc\00"
@.str.8 = [21 x i8] c"Err: %d chdir(); %s\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.stat
%7 = alloca i32
%8 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 2
br i1 %10, label %11, label %19
11: ; preds = %2
%12 = load i32, i32* @stderr
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 0
%15 = load i8*, i8** %14
%16 = call i32 (i32, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %15)
%17 = load i32, i32* @EXIT_FAILURE
%18 = call i32 @exit(i32 %17)
unreachable
19: ; preds = %2
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = load i8*, i8** %21
%23 = call i64 @stat(i8* %22, %struct.stat* %6)
%24 = icmp slt i64 %23, 0
br i1 %24, label %25, label %44
25: ; preds = %19
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 1
%28 = load i8*, i8** %27
%29 = load i32, i32* @S_IRUSR
%30 = load i32, i32* @S_IWUSR
%31 = or i32 %29, %30
%32 = load i32, i32* @S_IXUSR
%33 = or i32 %31, %32
%34 = call i32 @mkdir(i8* %28, i32 %33)
%35 = icmp eq i32 %34, -1
br i1 %35, label %36, label %43
36: ; preds = %25
%37 = load i32, i32* @stderr
%38 = load i32, i32* @errno
%39 = call i8* @strerror(i32 %38)
%40 = call i32 (i32, i8*, ...) @fprintf(i32 %37, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* %39)
%41 = load i32, i32* @EXIT_FAILURE
%42 = call i32 @exit(i32 %41)
unreachable
43: ; preds = %25
br label %55
44: ; preds = %19
%45 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 0
%46 = load i32, i32* %45
%47 = call i64 @S_ISDIR(i32 %46)
%48 = icmp ne i64 %47, 0
br i1 %48, label %49, label %54
49: ; preds = %44
%50 = load i8**, i8*** %5
%51 = getelementptr inbounds i8*, i8** %50, i64 1
%52 = load i8*, i8** %51
%53 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* %52)
br label %54
54: ; preds = %49, %44
br label %55
55: ; preds = %54, %43
%56 = load i8**, i8*** %5
%57 = getelementptr inbounds i8*, i8** %56, i64 1
%58 = load i8*, i8** %57
%59 = call i32 @chdir(i8* %58)
%60 = icmp eq i32 %59, -1
br i1 %60, label %61, label %68
61: ; preds = %55
%62 = load i32, i32* @stderr
%63 = load i32, i32* @errno
%64 = call i8* @strerror(i32 %63)
%65 = call i32 (i32, i8*, ...) @fprintf(i32 %62, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i8* %64)
%66 = load i32, i32* @EXIT_FAILURE
%67 = call i32 @exit(i32 %66)
unreachable
68: ; preds = %55
%69 = load i8**, i8*** %5
%70 = getelementptr inbounds i8*, i8** %69, i64 1
%71 = load i8*, i8** %70
%72 = call i64 @chroot(i8* %71)
%73 = icmp ne i64 %72, 0
br i1 %73, label %74, label %80
74: ; preds = %68
%75 = load i32, i32* @stderr
%76 = load i32, i32* @errno
%77 = call i8* @strerror(i32 %76)
%78 = call i32 (i32, i8*, ...) @fprintf(i32 %75, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i8* %77)
%79 = load i32, i32* @EXIT_FAILURE
store i32 %79, i32* %3
br label %109
80: ; preds = %68
%81 = call i32 (...) @fork()
store i32 %81, i32* %7
switch i32 %81, label %104 [
i32 -1, label %82
i32 0, label %89
]
82: ; preds = %80
%83 = load i32, i32* @stderr
%84 = load i32, i32* @errno
%85 = call i8* @strerror(i32 %84)
%86 = call i32 (i32, i8*, ...) @fprintf(i32 %83, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0), i8* %85)
%87 = load i32, i32* @EXIT_FAILURE
%88 = call i32 @exit(i32 %87)
unreachable
89: ; preds = %80
%90 = load i8*, i8** %8
%91 = load i32, i32* @PATH_MAX
%92 = call i8* @getcwd(i8* %90, i32 %91)
%93 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0), i8* %92)
%94 = call i32 @chdir(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
%95 = icmp eq i32 %94, -1
br i1 %95, label %96, label %103
96: ; preds = %89
%97 = load i32, i32* @stderr
%98 = load i32, i32* @errno
%99 = load i32, i32* @errno
%100 = call i8* @strerror(i32 %99)
%101 = call i32 (i32, i8*, ...) @fprintf(i32 %97, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.8, i64 0, i64 0), i32 %98, i8* %100)
%102 = load i32, i32* @EXIT_FAILURE
store i32 %102, i32* %3
br label %109
103: ; preds = %89
br label %104
104: ; preds = %80, %103
%105 = load i32, i32* %7
%106 = call i32 @waitpid(i32 %105, i32* null, i32 0)
br label %107
107: ; preds = %104
%108 = load i32, i32* @EXIT_SUCCESS
store i32 %108, i32* %3
br label %109
109: ; preds = %107, %96, %74
%110 = load i32, i32* %3
ret i32 %110
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@stderr = global i32 0
@.str = [19 x i8] c"Uso: %s <dirname>\0A\00"
@EXIT_FAILURE = global i32 0
@S_IRUSR = global i32 0
@S_IWUSR = global i32 0
@S_IXUSR = global i32 0
@.str.1 = [25 x i8] c"Err.(%s) mkdir() failed\0A\00"
@errno = global i32 0
@.str.2 = [13 x i8] c"New dir: %s\0A\00"
@.str.3 = [25 x i8] c"Err.(%s) chdir() failed\0A\00"
@.str.4 = [26 x i8] c"Err.(%s) chroot() failed\0A\00"
@.str.5 = [24 x i8] c"Err.(%s) fork() failed\0A\00"
@.str.6 = [25 x i8] c"Current working dir: %s\0A\00"
@PATH_MAX = global i32 0
@.str.7 = [5 x i8] c"/etc\00"
@.str.8 = [21 x i8] c"Err: %d chdir(); %s\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.stat
%4 = bitcast %struct.stat* %3 to i8*
%5 = icmp slt i32 %0, 2
br i1 %5, label %6, label %12
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = load i8*, i8** %1
%9 = tail call i32 (i32, i8*, ...) @fprintf(i32 %7, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = load i32, i32* @EXIT_FAILURE
%11 = tail call i32 @exit(i32 %10)
unreachable
12: ; preds = %2
%13 = getelementptr inbounds i8*, i8** %1, i64 1
%14 = load i8*, i8** %13
%15 = call i64 @stat(i8* %14, %struct.stat* %3)
%16 = icmp slt i64 %15, 0
br i1 %16, label %17, label %33
17: ; preds = %12
%18 = load i8*, i8** %13
%19 = load i32, i32* @S_IRUSR
%20 = load i32, i32* @S_IWUSR
%21 = or i32 %20, %19
%22 = load i32, i32* @S_IXUSR
%23 = or i32 %21, %22
%24 = call i32 @mkdir(i8* %18, i32 %23)
%25 = icmp eq i32 %24, -1
br i1 %25, label %26, label %41
26: ; preds = %17
%27 = load i32, i32* @stderr
%28 = load i32, i32* @errno
%29 = call i8* @strerror(i32 %28)
%30 = call i32 (i32, i8*, ...) @fprintf(i32 %27, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* %29)
%31 = load i32, i32* @EXIT_FAILURE
%32 = call i32 @exit(i32 %31)
unreachable
33: ; preds = %12
%34 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0
%35 = load i32, i32* %34
%36 = call i64 @S_ISDIR(i32 %35)
%37 = icmp eq i64 %36, 0
br i1 %37, label %41, label %38
38: ; preds = %33
%39 = load i8*, i8** %13
%40 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* %39)
br label %41
41: ; preds = %33, %38, %17
%42 = load i8*, i8** %13
%43 = call i32 @chdir(i8* %42)
%44 = icmp eq i32 %43, -1
br i1 %44, label %45, label %52
45: ; preds = %41
%46 = load i32, i32* @stderr
%47 = load i32, i32* @errno
%48 = call i8* @strerror(i32 %47)
%49 = call i32 (i32, i8*, ...) @fprintf(i32 %46, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i8* %48)
%50 = load i32, i32* @EXIT_FAILURE
%51 = call i32 @exit(i32 %50)
unreachable
52: ; preds = %41
%53 = load i8*, i8** %13
%54 = call i64 @chroot(i8* %53)
%55 = icmp eq i64 %54, 0
br i1 %55, label %61, label %56
56: ; preds = %52
%57 = load i32, i32* @stderr
%58 = load i32, i32* @errno
%59 = call i8* @strerror(i32 %58)
%60 = call i32 (i32, i8*, ...) @fprintf(i32 %57, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i8* %59)
br label %83
61: ; preds = %52
%62 = call i32 (...) @fork()
switch i32 %62, label %81 [
i32 -1, label %63
i32 0, label %70
]
63: ; preds = %61
%64 = load i32, i32* @stderr
%65 = load i32, i32* @errno
%66 = call i8* @strerror(i32 %65)
%67 = call i32 (i32, i8*, ...) @fprintf(i32 %64, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0), i8* %66)
%68 = load i32, i32* @EXIT_FAILURE
%69 = call i32 @exit(i32 %68)
unreachable
70: ; preds = %61
%71 = load i32, i32* @PATH_MAX
%72 = call i8* @getcwd(i8* undef, i32 %71)
%73 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0), i8* %72)
%74 = call i32 @chdir(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
%75 = icmp eq i32 %74, -1
br i1 %75, label %76, label %81
76: ; preds = %70
%77 = load i32, i32* @stderr
%78 = load i32, i32* @errno
%79 = call i8* @strerror(i32 %78)
%80 = call i32 (i32, i8*, ...) @fprintf(i32 %77, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.8, i64 0, i64 0), i32 %78, i8* %79)
br label %83
81: ; preds = %70, %61
%82 = call i32 @waitpid(i32 %62, i32* null, i32 0)
br label %83
83: ; preds = %81, %76, %56
%84 = phi i32* [ @EXIT_FAILURE, %56 ], [ @EXIT_SUCCESS, %81 ], [ @EXIT_FAILURE, %76 ]
%85 = load i32, i32* %84
ret i32 %85
}