#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*/ buf;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
scalar_t__ EEXIST;
int /*<<< orphan*/ MS_MGC_VAL;
int /*<<< orphan*/ O_RDONLY;
int S_IFCHR;
scalar_t__ chdir(char *);
int /*<<< orphan*/ close(int);
scalar_t__ errno;
scalar_t__ fchdir(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
char *getenv(char *);
int /*<<< orphan*/ makedev(int, int);
scalar_t__ mkdir(char *, int);
int /*<<< orphan*/ mknod(char *, int, int /*<<< orphan*/);
scalar_t__ mount(char *, char *, char *, int /*<<< orphan*/,
                 int /*<<< orphan*/ *);
int open(char *, int /*<<< orphan*/);
scalar_t__ pivot_root(char *, char *);
int /*<<< orphan*/ stderr;
char *strchr(char *, char);
int /*<<< orphan*/ strcmp(char *, char *);
scalar_t__ umount(char *);
int prepare_mntns() {
  FILE *f;
  unsigned fs_cnt, fs_cnt_last = 0;
  char buf[1024];
  char *root;
  root = getenv("ZDTM_ROOT");
  fprintf(stderr, "'%s'\n", root);
again:
  fs_cnt = 0;
  f = fopen("/proc/self/mountinfo", "r");
  if (!f) {
    fprintf(stderr, "Can't open mountinfo");
    return -1;
  }
  while (fgets(buf, sizeof(buf), f) != NULL) {
    char *mp = buf, *end;
    mp = strchr(mp, ' ') + 1;
    mp = strchr(mp, ' ') + 1;
    mp = strchr(mp, ' ') + 1;
    mp = strchr(mp, ' ') + 1;
    end = strchr(mp, ' ');
    *end = '\0';
    if (!strcmp(mp, "/"))
      continue;
    if (!strcmp(mp, "/proc"))
      continue;
    if (root && !strcmp(mp, root))
      continue;
    fprintf(stderr, "%s\n", mp);
    if (umount(mp))
      fprintf(stderr, "%s - %m\n", mp);
    fs_cnt++;
  }
  fclose(f);
  if (fs_cnt == 0)
    goto done;
  if (fs_cnt != fs_cnt_last) {
    fs_cnt_last = fs_cnt;
    goto again;
  }
  fprintf(stderr, "Can't umount all the filesystems");
  return -1;
done:
  if (root) {
    int dfd;
    dfd = open(".", O_RDONLY);
    if (dfd == -1) {
      fprintf(stderr, "open(.) failed: %m\n");
      return -1;
    }
    if (umount("/proc")) {
      fprintf(stderr, "umount(/proc) failed: %m\n");
      return -1;
    }
    if (chdir(root)) {
      fprintf(stderr, "chdir(%s) failed: %m\n", root);
      return -1;
    }
    if (mkdir("old", 0777) && errno != EEXIST) {
      fprintf(stderr, "mkdir(old) failed: %m\n");
      return -1;
    }
    if (pivot_root(".", "./old")) {
      fprintf(stderr, "pivot_root(., ./old) failed: %m\n");
      return -1;
    }
    if (umount("./old")) {
      fprintf(stderr, "umount(./old) failed: %m\n");
      return -1;
    }
    if (mkdir("proc", 0777) && errno != EEXIST) {
      fprintf(stderr, "mkdir(proc) failed: %m\n");
      return -1;
    }
    if (mount("proc", "/proc", "proc", MS_MGC_VAL, NULL)) {
      fprintf(stderr, "mount(/proc) failed: %m\n");
      return -1;
    }
    if (fchdir(dfd)) {
      fprintf(stderr, "fchdir() failed: %m\n");
      return -1;
    }
    close(dfd);
  }
  mkdir("/dev", 0777);
  mknod("/dev/null", 0777 | S_IFCHR, makedev(1, 3));
  return 0;
}


x86 assembly (clang, -O0):
<prepare_mntns>:
push   %rbp
mov    %rsp,%rbp
sub    $0x440,%rsp
movl   $0x0,-0x18(%rbp)
lea    0xdd7(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x428(%rbp)
mov    0x2d94(%rip),%rax
mov    (%rax),%edi
mov    -0x428(%rbp),%rdx
lea    0xdbe(%rip),%rsi
mov    $0x0,%al
call   10d0 <fprintf@plt>
movl   $0x0,-0x14(%rbp)
lea    0xdaf(%rip),%rdi
lea    0xdbd(%rip),%rsi
call   1110 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    129f <prepare_mntns+0x8f>
mov    0x2d4d(%rip),%rax
mov    (%rax),%edi
lea    0xd9b(%rip),%rsi
mov    $0x0,%al
call   10d0 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1764 <prepare_mntns+0x554>
jmp    12a4 <prepare_mntns+0x94>
lea    -0x420(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x400,%esi
call   10b0 <fgets@plt>
cmp    $0x0,%rax
je     1434 <prepare_mntns+0x224>
lea    -0x420(%rbp),%rax
mov    %rax,-0x430(%rbp)
mov    -0x430(%rbp),%rdi
mov    $0x20,%esi
call   1090 <strchr@plt>
add    $0x1,%rax
mov    %rax,-0x430(%rbp)
mov    -0x430(%rbp),%rdi
mov    $0x20,%esi
call   1090 <strchr@plt>
add    $0x1,%rax
mov    %rax,-0x430(%rbp)
mov    -0x430(%rbp),%rdi
mov    $0x20,%esi
call   1090 <strchr@plt>
add    $0x1,%rax
mov    %rax,-0x430(%rbp)
mov    -0x430(%rbp),%rdi
mov    $0x20,%esi
call   1090 <strchr@plt>
add    $0x1,%rax
mov    %rax,-0x430(%rbp)
mov    -0x430(%rbp),%rdi
mov    $0x20,%esi
call   1090 <strchr@plt>
mov    %rax,-0x438(%rbp)
mov    -0x438(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x430(%rbp),%rdi
lea    0xccb(%rip),%rsi
call   10c0 <strcmp@plt>
cmp    $0x0,%eax
jne    1384 <prepare_mntns+0x174>
jmp    12a4 <prepare_mntns+0x94>
mov    -0x430(%rbp),%rdi
lea    0xcac(%rip),%rsi
call   10c0 <strcmp@plt>
cmp    $0x0,%eax
jne    13a5 <prepare_mntns+0x195>
jmp    12a4 <prepare_mntns+0x94>
cmpq   $0x0,-0x428(%rbp)
je     13d4 <prepare_mntns+0x1c4>
mov    -0x430(%rbp),%rdi
mov    -0x428(%rbp),%rsi
call   10c0 <strcmp@plt>
cmp    $0x0,%eax
jne    13d4 <prepare_mntns+0x1c4>
jmp    12a4 <prepare_mntns+0x94>
mov    0x2bf5(%rip),%rax
mov    (%rax),%edi
mov    -0x430(%rbp),%rdx
lea    0xc59(%rip),%rsi
mov    $0x0,%al
call   10d0 <fprintf@plt>
mov    -0x430(%rbp),%rdi
call   1050 <umount@plt>
cmp    $0x0,%rax
je     1426 <prepare_mntns+0x216>
mov    0x2bc1(%rip),%rax
mov    (%rax),%edi
mov    -0x430(%rbp),%rdx
lea    0xc29(%rip),%rsi
mov    $0x0,%al
call   10d0 <fprintf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    12a4 <prepare_mntns+0x94>
mov    -0x10(%rbp),%rdi
call   1060 <fclose@plt>
cmpl   $0x0,-0x14(%rbp)
jne    144c <prepare_mntns+0x23c>
jmp    1486 <prepare_mntns+0x276>
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
je     1463 <prepare_mntns+0x253>
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    1253 <prepare_mntns+0x43>
mov    0x2b66(%rip),%rax
mov    (%rax),%edi
lea    0xbde(%rip),%rsi
mov    $0x0,%al
call   10d0 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1764 <prepare_mntns+0x554>
cmpq   $0x0,-0x428(%rbp)
je     1715 <prepare_mntns+0x505>
mov    0x2b4d(%rip),%rax
mov    (%rax),%esi
lea    0xbce(%rip),%rdi
call   1100 <open@plt>
mov    %eax,-0x43c(%rbp)
cmpl   $0xffffffff,-0x43c(%rbp)
jne    14df <prepare_mntns+0x2cf>
mov    0x2b0d(%rip),%rax
mov    (%rax),%edi
lea    0xba8(%rip),%rsi
mov    $0x0,%al
call   10d0 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1764 <prepare_mntns+0x554>
lea    0xb58(%rip),%rdi
call   1050 <umount@plt>
cmp    $0x0,%rax
je     1518 <prepare_mntns+0x308>
mov    0x2ad4(%rip),%rax
mov    (%rax),%edi
lea    0xb83(%rip),%rsi
mov    $0x0,%al
call   10d0 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1764 <prepare_mntns+0x554>
mov    -0x428(%rbp),%rdi
call   1080 <chdir@plt>
cmp    $0x0,%rax
je     1558 <prepare_mntns+0x348>
mov    0x2a9b(%rip),%rax
mov    (%rax),%edi
mov    -0x428(%rbp),%rdx
lea    0xb5d(%rip),%rsi
mov    $0x0,%al
call   10d0 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1764 <prepare_mntns+0x554>
lea    0xb72(%rip),%rdi
mov    $0x1ff,%esi
call   1040 <mkdir@plt>
cmp    $0x0,%rax
je     15b0 <prepare_mntns+0x3a0>
mov    0x2a46(%rip),%rax
mov    (%rax),%rax
mov    0x2a54(%rip),%rcx
cmp    (%rcx),%rax
je     15b0 <prepare_mntns+0x3a0>
mov    0x2a3c(%rip),%rax
mov    (%rax),%edi
lea    0xb1b(%rip),%rsi
mov    $0x0,%al
call   10d0 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1764 <prepare_mntns+0x554>
lea    0xabb(%rip),%rdi
lea    0xb11(%rip),%rsi
call   1130 <pivot_root@plt>
cmp    $0x0,%rax
je     15f0 <prepare_mntns+0x3e0>
mov    0x29fc(%rip),%rax
mov    (%rax),%edi
lea    0xaf8(%rip),%rsi
mov    $0x0,%al
call   10d0 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1764 <prepare_mntns+0x554>
lea    0xad8(%rip),%rdi
call   1050 <umount@plt>
cmp    $0x0,%rax
je     1629 <prepare_mntns+0x419>
mov    0x29c3(%rip),%rax
mov    (%rax),%edi
lea    0xae0(%rip),%rsi
mov    $0x0,%al
call   10d0 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1764 <prepare_mntns+0x554>
lea    0xa0f(%rip),%rdi
mov    $0x1ff,%esi
call   1040 <mkdir@plt>
cmp    $0x0,%rax
je     1681 <prepare_mntns+0x471>
mov    0x2975(%rip),%rax
mov    (%rax),%rax
mov    0x2983(%rip),%rcx
cmp    (%rcx),%rax
je     1681 <prepare_mntns+0x471>
mov    0x296b(%rip),%rax
mov    (%rax),%edi
lea    0xaa2(%rip),%rsi
mov    $0x0,%al
call   10d0 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1764 <prepare_mntns+0x554>
mov    0x2930(%rip),%rax
mov    (%rax),%ecx
lea    0x9ae(%rip),%rdx
lea    0x9a6(%rip),%rsi
xor    %eax,%eax
mov    %eax,%r8d
mov    %rdx,%rdi
call   1070 <mount@plt>
cmp    $0x0,%rax
je     16d2 <prepare_mntns+0x4c2>
mov    0x291a(%rip),%rax
mov    (%rax),%edi
lea    0x9ca(%rip),%rsi
mov    $0x0,%al
call   10d0 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1764 <prepare_mntns+0x554>
mov    -0x43c(%rbp),%edi
call   10f0 <fchdir@plt>
cmp    $0x0,%rax
je     170a <prepare_mntns+0x4fa>
mov    0x28e2(%rip),%rax
mov    (%rax),%edi
lea    0xa31(%rip),%rsi
mov    $0x0,%al
call   10d0 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1764 <prepare_mntns+0x554>
mov    -0x43c(%rbp),%edi
call   10a0 <close@plt>
lea    0xa21(%rip),%rdi
mov    $0x1ff,%esi
call   1040 <mkdir@plt>
mov    0x289b(%rip),%rax
mov    (%rax),%eax
or     $0x1ff,%eax
mov    %eax,-0x440(%rbp)
mov    $0x1,%edi
mov    $0x3,%esi
call   1120 <makedev@plt>
mov    -0x440(%rbp),%esi
mov    %eax,%edx
lea    0x9ea(%rip),%rdi
call   10e0 <mknod@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x440,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<prepare_mntns>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x418,%rsp
lea    0xdd8(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,%r15
mov    0x2d99(%rip),%rax
mov    (%rax),%edi
lea    0xdca(%rip),%rsi
mov    %r15,%rdx
xor    %eax,%eax
call   10d0 <fprintf@plt>
lea    0x10(%rsp),%rbp
lea    0xde6(%rip),%r12
lea    0xde1(%rip),%r13
xor    %r14d,%r14d
lea    0xda9(%rip),%rdi
lea    0xdb7(%rip),%rsi
call   1110 <fopen@plt>
test   %rax,%rax
je     13ee <prepare_mntns+0x1de>
mov    %rax,%rbx
mov    %rbp,%rdi
mov    $0x400,%esi
mov    %rax,%rdx
call   10b0 <fgets@plt>
test   %rax,%rax
je     1400 <prepare_mntns+0x1f0>
mov    %r14d,0x4(%rsp)
movl   $0x0,(%rsp)
mov    %rbx,0x8(%rsp)
jmp    12de <prepare_mntns+0xce>
nopl   0x0(%rax,%rax,1)
addl   $0x1,(%rsp)
mov    %rbp,%rax
mov    %rbx,%r12
mov    %r15,%rbp
mov    %rax,%r15
mov    0x8(%rsp),%rbx
mov    %rbp,%rdi
mov    $0x400,%esi
mov    %rbx,%rdx
call   10b0 <fgets@plt>
test   %rax,%rax
je     13c0 <prepare_mntns+0x1b0>
mov    %rbp,%rdi
mov    $0x20,%esi
call   1090 <strchr@plt>
lea    0x1(%rax),%rdi
mov    $0x20,%esi
call   1090 <strchr@plt>
lea    0x1(%rax),%rdi
mov    $0x20,%esi
call   1090 <strchr@plt>
lea    0x1(%rax),%rdi
mov    $0x20,%esi
call   1090 <strchr@plt>
mov    %rax,%r14
add    $0x1,%r14
mov    %r14,%rdi
mov    $0x20,%esi
call   1090 <strchr@plt>
movb   $0x0,(%rax)
mov    %r14,%rdi
mov    %r12,%rsi
call   10c0 <strcmp@plt>
test   %eax,%eax
je     12c5 <prepare_mntns+0xb5>
mov    %r14,%rdi
mov    %r13,%rsi
call   10c0 <strcmp@plt>
test   %eax,%eax
je     12c5 <prepare_mntns+0xb5>
test   %r15,%r15
je     1366 <prepare_mntns+0x156>
mov    %r14,%rdi
mov    %r15,%rsi
call   10c0 <strcmp@plt>
test   %eax,%eax
je     12c5 <prepare_mntns+0xb5>
mov    %r15,%rax
mov    %rbp,%r15
mov    %r12,%rbx
mov    %rax,%rbp
mov    0x2c57(%rip),%r12
mov    (%r12),%edi
lea    0xcc0(%rip),%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   10d0 <fprintf@plt>
mov    %r14,%rdi
call   1050 <umount@plt>
test   %rax,%rax
je     12b0 <prepare_mntns+0xa0>
mov    (%r12),%edi
lea    0xc9e(%rip),%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   10d0 <fprintf@plt>
jmp    12b0 <prepare_mntns+0xa0>
nopl   0x0(%rax)
mov    %rbx,%rdi
call   1060 <fclose@plt>
mov    (%rsp),%r14d
test   %r14d,%r14d
je     1408 <prepare_mntns+0x1f8>
cmp    0x4(%rsp),%r14d
jne    1260 <prepare_mntns+0x50>
mov    0x2bed(%rip),%rax
mov    (%rax),%edi
lea    0xc65(%rip),%rsi
jmp    1460 <prepare_mntns+0x250>
mov    0x2bdb(%rip),%rax
mov    (%rax),%edi
lea    0xc29(%rip),%rsi
jmp    1460 <prepare_mntns+0x250>
mov    %rbx,%rdi
call   1060 <fclose@plt>
test   %r15,%r15
je     15c9 <prepare_mntns+0x3b9>
mov    0x2bd0(%rip),%rax
mov    (%rax),%esi
lea    0xc51(%rip),%rdi
call   1100 <open@plt>
cmp    $0xffffffff,%eax
je     1450 <prepare_mntns+0x240>
mov    %eax,%ebx
lea    0xc0a(%rip),%rdi
call   1050 <umount@plt>
test   %rax,%rax
je     147e <prepare_mntns+0x26e>
mov    0x2b8b(%rip),%rax
mov    (%rax),%edi
lea    0xc3a(%rip),%rsi
jmp    1460 <prepare_mntns+0x250>
mov    0x2b79(%rip),%rax
mov    (%rax),%edi
lea    0xc14(%rip),%rsi
xor    %eax,%eax
call   10d0 <fprintf@plt>
mov    $0xffffffff,%eax
add    $0x418,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %r15,%rdi
call   1080 <chdir@plt>
test   %rax,%rax
je     14a7 <prepare_mntns+0x297>
mov    0x2b3e(%rip),%rax
mov    (%rax),%edi
lea    0xc07(%rip),%rsi
mov    %r15,%rdx
xor    %eax,%eax
call   10d0 <fprintf@plt>
jmp    1467 <prepare_mntns+0x257>
lea    0xc23(%rip),%rdi
mov    $0x1ff,%esi
call   1040 <mkdir@plt>
test   %rax,%rax
je     14d3 <prepare_mntns+0x2c3>
mov    0x2afc(%rip),%rax
mov    (%rax),%rax
mov    0x2b0a(%rip),%rcx
cmp    (%rcx),%rax
jne    1501 <prepare_mntns+0x2f1>
lea    0xb98(%rip),%rdi
lea    0xbee(%rip),%rsi
call   1130 <pivot_root@plt>
test   %rax,%rax
mov    0x2ae0(%rip),%rbp
je     1516 <prepare_mntns+0x306>
mov    0x0(%rbp),%edi
lea    0xbd9(%rip),%rsi
jmp    1460 <prepare_mntns+0x250>
mov    0x2ac8(%rip),%rax
mov    (%rax),%edi
lea    0xba7(%rip),%rsi
jmp    1460 <prepare_mntns+0x250>
lea    0xbb2(%rip),%rdi
call   1050 <umount@plt>
test   %rax,%rax
je     1536 <prepare_mntns+0x326>
mov    0x0(%rbp),%edi
lea    0xbc5(%rip),%rsi
jmp    1460 <prepare_mntns+0x250>
lea    0xb02(%rip),%rdi
mov    $0x1ff,%esi
call   1040 <mkdir@plt>
test   %rax,%rax
je     1562 <prepare_mntns+0x352>
mov    0x2a6d(%rip),%rax
mov    (%rax),%rax
mov    0x2a7b(%rip),%rcx
cmp    (%rcx),%rax
jne    1598 <prepare_mntns+0x388>
mov    0x2a4f(%rip),%rax
mov    (%rax),%ecx
lea    0xacc(%rip),%rsi
lea    0xac6(%rip),%rdi
mov    %rdi,%rdx
xor    %r8d,%r8d
call   1070 <mount@plt>
test   %rax,%rax
je     15a7 <prepare_mntns+0x397>
mov    0x0(%rbp),%edi
lea    0xaf6(%rip),%rsi
jmp    1460 <prepare_mntns+0x250>
mov    0x0(%rbp),%edi
lea    0xb6e(%rip),%rsi
jmp    1460 <prepare_mntns+0x250>
mov    %ebx,%edi
call   10f0 <fchdir@plt>
test   %rax,%rax
je     15c2 <prepare_mntns+0x3b2>
mov    0x0(%rbp),%edi
lea    0xb6b(%rip),%rsi
jmp    1460 <prepare_mntns+0x250>
mov    %ebx,%edi
call   10a0 <close@plt>
lea    0xb6d(%rip),%rdi
mov    $0x1ff,%ebx
mov    $0x1ff,%esi
call   1040 <mkdir@plt>
mov    0x29e2(%rip),%rax
or     (%rax),%ebx
mov    $0x1,%edi
mov    $0x3,%esi
call   1120 <makedev@plt>
lea    0xb44(%rip),%rdi
mov    %ebx,%esi
mov    %eax,%edx
call   10e0 <mknod@plt>
xor    %eax,%eax
jmp    146c <prepare_mntns+0x25c>

LLVM IR (-O0):
@.str = [10 x i8] c"ZDTM_ROOT\00"
@stderr = global i32 0
@.str.1 = [6 x i8] c"'%s'\0A\00"
@.str.2 = [21 x i8] c"/proc/self/mountinfo\00"
@.str.3 = [2 x i8] c"r\00"
@.str.4 = [21 x i8] c"Can't open mountinfo\00"
@.str.5 = [2 x i8] c"/\00"
@.str.6 = [6 x i8] c"/proc\00"
@.str.7 = [4 x i8] c"%s\0A\00"
@.str.8 = [9 x i8] c"%s - %m\0A\00"
@.str.9 = [33 x i8] c"Can't umount all the filesystems\00"
@.str.10 = [2 x i8] c".\00"
@O_RDONLY = global i32 0
@.str.11 = [20 x i8] c"open(.) failed: %m\0A\00"
@.str.12 = [26 x i8] c"umount(/proc) failed: %m\0A\00"
@.str.13 = [22 x i8] c"chdir(%s) failed: %m\0A\00"
@.str.14 = [4 x i8] c"old\00"
@errno = global i64 0
@EEXIST = global i64 0
@.str.15 = [23 x i8] c"mkdir(old) failed: %m\0A\00"
@.str.16 = [6 x i8] c"./old\00"
@.str.17 = [33 x i8] c"pivot_root(., ./old) failed: %m\0A\00"
@.str.18 = [26 x i8] c"umount(./old) failed: %m\0A\00"
@.str.19 = [5 x i8] c"proc\00"
@.str.20 = [24 x i8] c"mkdir(proc) failed: %m\0A\00"
@MS_MGC_VAL = global i32 0
@.str.21 = [25 x i8] c"mount(/proc) failed: %m\0A\00"
@.str.22 = [21 x i8] c"fchdir() failed: %m\0A\00"
@.str.23 = [5 x i8] c"/dev\00"
@.str.24 = [10 x i8] c"/dev/null\00"
@S_IFCHR = global i32 0
define i32 @prepare_mntns() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
%5 = alloca [1024 x i8]
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
store i32 0, i32* %4
%10 = call i8* @getenv(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
store i8* %10, i8** %6
%11 = load i32, i32* @stderr
%12 = load i8*, i8** %6
%13 = call i32 (i32, i8*, ...) @fprintf(i32 %11, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %12)
br label %14
14: ; preds = %86, %0
store i32 0, i32* %3
%15 = call i32* @fopen(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %15, i32** %2
%16 = load i32*, i32** %2
%17 = icmp ne i32* %16, null
br i1 %17, label %21, label %18
18: ; preds = %14
%19 = load i32, i32* @stderr
%20 = call i32 (i32, i8*, ...) @fprintf(i32 %19, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0))
store i32 -1, i32* %1
br label %171
21: ; preds = %14
br label %22
22: ; preds = %73, %61, %52, %47, %21
%23 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%24 = load i32*, i32** %2
%25 = call i32* @fgets(i8* %23, i32 1024, i32* %24)
%26 = icmp ne i32* %25, null
br i1 %26, label %27, label %76
27: ; preds = %22
%28 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
store i8* %28, i8** %7
%29 = load i8*, i8** %7
%30 = call i8* @strchr(i8* %29, i8 signext 32)
%31 = getelementptr inbounds i8, i8* %30, i64 1
store i8* %31, i8** %7
%32 = load i8*, i8** %7
%33 = call i8* @strchr(i8* %32, i8 signext 32)
%34 = getelementptr inbounds i8, i8* %33, i64 1
store i8* %34, i8** %7
%35 = load i8*, i8** %7
%36 = call i8* @strchr(i8* %35, i8 signext 32)
%37 = getelementptr inbounds i8, i8* %36, i64 1
store i8* %37, i8** %7
%38 = load i8*, i8** %7
%39 = call i8* @strchr(i8* %38, i8 signext 32)
%40 = getelementptr inbounds i8, i8* %39, i64 1
store i8* %40, i8** %7
%41 = load i8*, i8** %7
%42 = call i8* @strchr(i8* %41, i8 signext 32)
store i8* %42, i8** %8
%43 = load i8*, i8** %8
store i8 0, i8* %43
%44 = load i8*, i8** %7
%45 = call i32 @strcmp(i8* %44, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%46 = icmp ne i32 %45, 0
br i1 %46, label %48, label %47
47: ; preds = %27
br label %22
48: ; preds = %27
%49 = load i8*, i8** %7
%50 = call i32 @strcmp(i8* %49, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
%51 = icmp ne i32 %50, 0
br i1 %51, label %53, label %52
52: ; preds = %48
br label %22
53: ; preds = %48
%54 = load i8*, i8** %6
%55 = icmp ne i8* %54, null
br i1 %55, label %56, label %62
56: ; preds = %53
%57 = load i8*, i8** %7
%58 = load i8*, i8** %6
%59 = call i32 @strcmp(i8* %57, i8* %58)
%60 = icmp ne i32 %59, 0
br i1 %60, label %62, label %61
61: ; preds = %56
br label %22
62: ; preds = %56, %53
%63 = load i32, i32* @stderr
%64 = load i8*, i8** %7
%65 = call i32 (i32, i8*, ...) @fprintf(i32 %63, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i8* %64)
%66 = load i8*, i8** %7
%67 = call i64 @umount(i8* %66)
%68 = icmp ne i64 %67, 0
br i1 %68, label %69, label %73
69: ; preds = %62
%70 = load i32, i32* @stderr
%71 = load i8*, i8** %7
%72 = call i32 (i32, i8*, ...) @fprintf(i32 %70, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.8, i64 0, i64 0), i8* %71)
br label %73
73: ; preds = %69, %62
%74 = load i32, i32* %3
%75 = add i32 %74, 1
store i32 %75, i32* %3
br label %22
76: ; preds = %22
%77 = load i32*, i32** %2
%78 = call i32 @fclose(i32* %77)
%79 = load i32, i32* %3
%80 = icmp eq i32 %79, 0
br i1 %80, label %81, label %82
81: ; preds = %76
br label %91
82: ; preds = %76
%83 = load i32, i32* %3
%84 = load i32, i32* %4
%85 = icmp ne i32 %83, %84
br i1 %85, label %86, label %88
86: ; preds = %82
%87 = load i32, i32* %3
store i32 %87, i32* %4
br label %14
88: ; preds = %82
%89 = load i32, i32* @stderr
%90 = call i32 (i32, i8*, ...) @fprintf(i32 %89, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.9, i64 0, i64 0))
store i32 -1, i32* %1
br label %171
91: ; preds = %81
%92 = load i8*, i8** %6
%93 = icmp ne i8* %92, null
br i1 %93, label %94, label %165
94: ; preds = %91
%95 = load i32, i32* @O_RDONLY
%96 = call i32 @open(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0), i32 %95)
store i32 %96, i32* %9
%97 = load i32, i32* %9
%98 = icmp eq i32 %97, -1
br i1 %98, label %99, label %102
99: ; preds = %94
%100 = load i32, i32* @stderr
%101 = call i32 (i32, i8*, ...) @fprintf(i32 %100, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.11, i64 0, i64 0))
store i32 -1, i32* %1
br label %171
102: ; preds = %94
%103 = call i64 @umount(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
%104 = icmp ne i64 %103, 0
br i1 %104, label %105, label %108
105: ; preds = %102
%106 = load i32, i32* @stderr
%107 = call i32 (i32, i8*, ...) @fprintf(i32 %106, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.12, i64 0, i64 0))
store i32 -1, i32* %1
br label %171
108: ; preds = %102
%109 = load i8*, i8** %6
%110 = call i64 @chdir(i8* %109)
%111 = icmp ne i64 %110, 0
br i1 %111, label %112, label %116
112: ; preds = %108
%113 = load i32, i32* @stderr
%114 = load i8*, i8** %6
%115 = call i32 (i32, i8*, ...) @fprintf(i32 %113, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.13, i64 0, i64 0), i8* %114)
store i32 -1, i32* %1
br label %171
116: ; preds = %108
%117 = call i64 @mkdir(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.14, i64 0, i64 0), i32 511)
%118 = icmp ne i64 %117, 0
br i1 %118, label %119, label %126
119: ; preds = %116
%120 = load i64, i64* @errno
%121 = load i64, i64* @EEXIST
%122 = icmp ne i64 %120, %121
br i1 %122, label %123, label %126
123: ; preds = %119
%124 = load i32, i32* @stderr
%125 = call i32 (i32, i8*, ...) @fprintf(i32 %124, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.15, i64 0, i64 0))
store i32 -1, i32* %1
br label %171
126: ; preds = %119, %116
%127 = call i64 @pivot_root(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.16, i64 0, i64 0))
%128 = icmp ne i64 %127, 0
br i1 %128, label %129, label %132
129: ; preds = %126
%130 = load i32, i32* @stderr
%131 = call i32 (i32, i8*, ...) @fprintf(i32 %130, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.17, i64 0, i64 0))
store i32 -1, i32* %1
br label %171
132: ; preds = %126
%133 = call i64 @umount(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.16, i64 0, i64 0))
%134 = icmp ne i64 %133, 0
br i1 %134, label %135, label %138
135: ; preds = %132
%136 = load i32, i32* @stderr
%137 = call i32 (i32, i8*, ...) @fprintf(i32 %136, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.18, i64 0, i64 0))
store i32 -1, i32* %1
br label %171
138: ; preds = %132
%139 = call i64 @mkdir(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.19, i64 0, i64 0), i32 511)
%140 = icmp ne i64 %139, 0
br i1 %140, label %141, label %148
141: ; preds = %138
%142 = load i64, i64* @errno
%143 = load i64, i64* @EEXIST
%144 = icmp ne i64 %142, %143
br i1 %144, label %145, label %148
145: ; preds = %141
%146 = load i32, i32* @stderr
%147 = call i32 (i32, i8*, ...) @fprintf(i32 %146, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.20, i64 0, i64 0))
store i32 -1, i32* %1
br label %171
148: ; preds = %141, %138
%149 = load i32, i32* @MS_MGC_VAL
%150 = call i64 @mount(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.19, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.19, i64 0, i64 0), i32 %149, i32* null)
%151 = icmp ne i64 %150, 0
br i1 %151, label %152, label %155
152: ; preds = %148
%153 = load i32, i32* @stderr
%154 = call i32 (i32, i8*, ...) @fprintf(i32 %153, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.21, i64 0, i64 0))
store i32 -1, i32* %1
br label %171
155: ; preds = %148
%156 = load i32, i32* %9
%157 = call i64 @fchdir(i32 %156)
%158 = icmp ne i64 %157, 0
br i1 %158, label %159, label %162
159: ; preds = %155
%160 = load i32, i32* @stderr
%161 = call i32 (i32, i8*, ...) @fprintf(i32 %160, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.22, i64 0, i64 0))
store i32 -1, i32* %1
br label %171
162: ; preds = %155
%163 = load i32, i32* %9
%164 = call i32 @close(i32 %163)
br label %165
165: ; preds = %162, %91
%166 = call i64 @mkdir(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.23, i64 0, i64 0), i32 511)
%167 = load i32, i32* @S_IFCHR
%168 = or i32 511, %167
%169 = call i32 @makedev(i32 1, i32 3)
%170 = call i32 @mknod(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.24, i64 0, i64 0), i32 %168, i32 %169)
store i32 0, i32* %1
br label %171
171: ; preds = %165, %159, %152, %145, %135, %129, %123, %112, %105, %99, %88, %18
%172 = load i32, i32* %1
ret i32 %172
}

LLVM IR (-O2):
@.str = [10 x i8] c"ZDTM_ROOT\00"
@stderr = global i32 0
@.str.1 = [6 x i8] c"'%s'\0A\00"
@.str.2 = [21 x i8] c"/proc/self/mountinfo\00"
@.str.3 = [2 x i8] c"r\00"
@.str.4 = [21 x i8] c"Can't open mountinfo\00"
@.str.5 = [2 x i8] c"/\00"
@.str.6 = [6 x i8] c"/proc\00"
@.str.7 = [4 x i8] c"%s\0A\00"
@.str.8 = [9 x i8] c"%s - %m\0A\00"
@.str.9 = [33 x i8] c"Can't umount all the filesystems\00"
@.str.10 = [2 x i8] c".\00"
@O_RDONLY = global i32 0
@.str.11 = [20 x i8] c"open(.) failed: %m\0A\00"
@.str.12 = [26 x i8] c"umount(/proc) failed: %m\0A\00"
@.str.13 = [22 x i8] c"chdir(%s) failed: %m\0A\00"
@.str.14 = [4 x i8] c"old\00"
@errno = global i64 0
@EEXIST = global i64 0
@.str.15 = [23 x i8] c"mkdir(old) failed: %m\0A\00"
@.str.16 = [6 x i8] c"./old\00"
@.str.17 = [33 x i8] c"pivot_root(., ./old) failed: %m\0A\00"
@.str.18 = [26 x i8] c"umount(./old) failed: %m\0A\00"
@.str.19 = [5 x i8] c"proc\00"
@.str.20 = [24 x i8] c"mkdir(proc) failed: %m\0A\00"
@MS_MGC_VAL = global i32 0
@.str.21 = [25 x i8] c"mount(/proc) failed: %m\0A\00"
@.str.22 = [21 x i8] c"fchdir() failed: %m\0A\00"
@.str.23 = [5 x i8] c"/dev\00"
@.str.24 = [10 x i8] c"/dev/null\00"
@S_IFCHR = global i32 0
define i32 @prepare_mntns() {
%1 = alloca [1024 x i8]
%2 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%3 = tail call i8* @getenv(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%4 = load i32, i32* @stderr
%5 = tail call i32 (i32, i8*, ...) @fprintf(i32 %4, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%6 = icmp eq i8* %3, null
br label %7
7: ; preds = %56, %0
%8 = phi i32 [ 0, %0 ], [ %50, %56 ]
%9 = call i32* @fopen(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%10 = icmp eq i32* %9, null
br i1 %10, label %16, label %11
11: ; preds = %7
%12 = call i32* @fgets(i8* %2, i32 1024, i32* %9)
%13 = icmp eq i32* %12, null
br i1 %13, label %14, label %19
14: ; preds = %11
%15 = call i32 @fclose(i32* %9)
br label %61
16: ; preds = %7
%17 = load i32, i32* @stderr
%18 = call i32 (i32, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0))
br label %134
19: ; preds = %11, %49
%20 = phi i32 [ %50, %49 ], [ 0, %11 ]
%21 = call i8* @strchr(i8* %2, i8 signext 32)
%22 = getelementptr inbounds i8, i8* %21, i64 1
%23 = call i8* @strchr(i8* %22, i8 signext 32)
%24 = getelementptr inbounds i8, i8* %23, i64 1
%25 = call i8* @strchr(i8* %24, i8 signext 32)
%26 = getelementptr inbounds i8, i8* %25, i64 1
%27 = call i8* @strchr(i8* %26, i8 signext 32)
%28 = getelementptr inbounds i8, i8* %27, i64 1
%29 = call i8* @strchr(i8* %28, i8 signext 32)
store i8 0, i8* %29
%30 = call i32 @strcmp(i8* %28, i8* dereferenceable(2) getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%31 = icmp eq i32 %30, 0
br i1 %31, label %49, label %32
32: ; preds = %19
%33 = call i32 @strcmp(i8* %28, i8* dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
%34 = icmp eq i32 %33, 0
br i1 %34, label %49, label %35
35: ; preds = %32
br i1 %6, label %39, label %36
36: ; preds = %35
%37 = call i32 @strcmp(i8* %28, i8* %3)
%38 = icmp eq i32 %37, 0
br i1 %38, label %49, label %39
39: ; preds = %36, %35
%40 = load i32, i32* @stderr
%41 = call i32 (i32, i8*, ...) @fprintf(i32 %40, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i8* %28)
%42 = call i64 @umount(i8* %28)
%43 = icmp eq i64 %42, 0
br i1 %43, label %47, label %44
44: ; preds = %39
%45 = load i32, i32* @stderr
%46 = call i32 (i32, i8*, ...) @fprintf(i32 %45, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.8, i64 0, i64 0), i8* %28)
br label %47
47: ; preds = %44, %39
%48 = add i32 %20, 1
br label %49
49: ; preds = %36, %32, %19, %47
%50 = phi i32 [ %48, %47 ], [ %20, %19 ], [ %20, %32 ], [ %20, %36 ]
%51 = call i32* @fgets(i8* %2, i32 1024, i32* %9)
%52 = icmp eq i32* %51, null
br i1 %52, label %53, label %19
53: ; preds = %49
%54 = call i32 @fclose(i32* %9)
%55 = icmp eq i32 %50, 0
br i1 %55, label %61, label %56
56: ; preds = %53
%57 = icmp eq i32 %50, %8
br i1 %57, label %58, label %7
58: ; preds = %56
%59 = load i32, i32* @stderr
%60 = call i32 (i32, i8*, ...) @fprintf(i32 %59, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.9, i64 0, i64 0))
br label %134
61: ; preds = %53, %14
br i1 %6, label %128, label %62
62: ; preds = %61
%63 = load i32, i32* @O_RDONLY
%64 = call i32 @open(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0), i32 %63)
%65 = icmp eq i32 %64, -1
br i1 %65, label %66, label %69
66: ; preds = %62
%67 = load i32, i32* @stderr
%68 = call i32 (i32, i8*, ...) @fprintf(i32 %67, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.11, i64 0, i64 0))
br label %134
69: ; preds = %62
%70 = call i64 @umount(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
%71 = icmp eq i64 %70, 0
br i1 %71, label %75, label %72
72: ; preds = %69
%73 = load i32, i32* @stderr
%74 = call i32 (i32, i8*, ...) @fprintf(i32 %73, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.12, i64 0, i64 0))
br label %134
75: ; preds = %69
%76 = call i64 @chdir(i8* %3)
%77 = icmp eq i64 %76, 0
br i1 %77, label %81, label %78
78: ; preds = %75
%79 = load i32, i32* @stderr
%80 = call i32 (i32, i8*, ...) @fprintf(i32 %79, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.13, i64 0, i64 0), i8* %3)
br label %134
81: ; preds = %75
%82 = call i64 @mkdir(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.14, i64 0, i64 0), i32 511)
%83 = icmp eq i64 %82, 0
br i1 %83, label %91, label %84
84: ; preds = %81
%85 = load i64, i64* @errno
%86 = load i64, i64* @EEXIST
%87 = icmp eq i64 %85, %86
br i1 %87, label %91, label %88
88: ; preds = %84
%89 = load i32, i32* @stderr
%90 = call i32 (i32, i8*, ...) @fprintf(i32 %89, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.15, i64 0, i64 0))
br label %134
91: ; preds = %84, %81
%92 = call i64 @pivot_root(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.16, i64 0, i64 0))
%93 = icmp eq i64 %92, 0
br i1 %93, label %97, label %94
94: ; preds = %91
%95 = load i32, i32* @stderr
%96 = call i32 (i32, i8*, ...) @fprintf(i32 %95, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.17, i64 0, i64 0))
br label %134
97: ; preds = %91
%98 = call i64 @umount(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.16, i64 0, i64 0))
%99 = icmp eq i64 %98, 0
br i1 %99, label %103, label %100
100: ; preds = %97
%101 = load i32, i32* @stderr
%102 = call i32 (i32, i8*, ...) @fprintf(i32 %101, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.18, i64 0, i64 0))
br label %134
103: ; preds = %97
%104 = call i64 @mkdir(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.19, i64 0, i64 0), i32 511)
%105 = icmp eq i64 %104, 0
br i1 %105, label %113, label %106
106: ; preds = %103
%107 = load i64, i64* @errno
%108 = load i64, i64* @EEXIST
%109 = icmp eq i64 %107, %108
br i1 %109, label %113, label %110
110: ; preds = %106
%111 = load i32, i32* @stderr
%112 = call i32 (i32, i8*, ...) @fprintf(i32 %111, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.20, i64 0, i64 0))
br label %134
113: ; preds = %106, %103
%114 = load i32, i32* @MS_MGC_VAL
%115 = call i64 @mount(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.19, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.19, i64 0, i64 0), i32 %114, i32* null)
%116 = icmp eq i64 %115, 0
br i1 %116, label %120, label %117
117: ; preds = %113
%118 = load i32, i32* @stderr
%119 = call i32 (i32, i8*, ...) @fprintf(i32 %118, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.21, i64 0, i64 0))
br label %134
120: ; preds = %113
%121 = call i64 @fchdir(i32 %64)
%122 = icmp eq i64 %121, 0
br i1 %122, label %126, label %123
123: ; preds = %120
%124 = load i32, i32* @stderr
%125 = call i32 (i32, i8*, ...) @fprintf(i32 %124, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.22, i64 0, i64 0))
br label %134
126: ; preds = %120
%127 = call i32 @close(i32 %64)
br label %128
128: ; preds = %126, %61
%129 = call i64 @mkdir(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.23, i64 0, i64 0), i32 511)
%130 = load i32, i32* @S_IFCHR
%131 = or i32 %130, 511
%132 = call i32 @makedev(i32 1, i32 3)
%133 = call i32 @mknod(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.24, i64 0, i64 0), i32 %131, i32 %132)
br label %134
134: ; preds = %66, %72, %78, %88, %94, %100, %110, %117, %123, %128, %58, %16
%135 = phi i32 [ 0, %128 ], [ -1, %58 ], [ -1, %16 ], [ -1, %123 ], [ -1, %117 ], [ -1, %110 ], [ -1, %100 ], [ -1, %94 ], [ -1, %88 ], [ -1, %78 ], [ -1, %72 ], [ -1, %66 ]
ret i32 %135
}