#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 {
  scalar_t__ st_ino;
};
typedef int pid_t;
typedef int /*<<< orphan*/ namespaces;
typedef int /*<<< orphan*/ jmp_buf;
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
scalar_t__ ENOENT;
int O_DIRECTORY;
int O_RDONLY;
int O_RDWR;
int PATH_MAX;
int /*<<< orphan*/ SIGKILL;
scalar_t__ STDERR_FILENO;
scalar_t__ STDIN_FILENO;
scalar_t__ STDOUT_FILENO;
int /*<<< orphan*/ TIOCSCTTY;
int atoi(char *);
int clone_parent(int /*<<< orphan*/ *);
int /*<<< orphan*/ close(int);
scalar_t__ dup3(int, scalar_t__, int /*<<< orphan*/);
scalar_t__ errno;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int fstatat(int, char *, struct stat *, int /*<<< orphan*/);
char *getenv(char *);
int ioctl(int, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ kill(int, int /*<<< orphan*/);
int open(char *, int);
int openat(int, char *, int);
int setjmp(int /*<<< orphan*/);
int setns(int, int /*<<< orphan*/);
int setsid();
int snprintf(char *, int, char *, int);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, char *);
int write(int, char *, int);
void nsexec() {
  char *namespaces[] = {"ipc", "uts", "net", "pid", "mnt", "user"};
  const int num = sizeof(namespaces) / sizeof(char *);
  jmp_buf env;
  char buf[PATH_MAX], *val;
  int i, tfd, self_tfd, child, len, pipenum, consolefd = -1;
  pid_t pid;
  char *console;
  val = getenv("_LIBCONTAINER_INITPID");
  if (val == NULL)
    return;
  pid = atoi(val);
  snprintf(buf, sizeof(buf), "%d", pid);
  if (strcmp(val, buf)) {
    fprintf(stderr, "nsenter: "
                    "Unable to parse _LIBCONTAINER_INITPID"
                    ": %m\n");
    exit(1);
  }
  val = getenv("_LIBCONTAINER_INITPIPE");
  if (val == NULL) {
    fprintf(stderr, "nsenter: "
                    "Child pipe not found"
                    ": %m\n");
    exit(1);
  }
  pipenum = atoi(val);
  snprintf(buf, sizeof(buf), "%d", pipenum);
  if (strcmp(val, buf)) {
    fprintf(stderr, "nsenter: "
                    "Unable to parse _LIBCONTAINER_INITPIPE"
                    ": %m\n");
    exit(1);
  }
  console = getenv("_LIBCONTAINER_CONSOLE_PATH");
  if (console != NULL) {
    consolefd = open(console, O_RDWR);
    if (consolefd < 0) {
      fprintf(stderr,
              "nsenter: "
              "Failed to open console %s"
              ": %m\n",
              console);
      exit(1);
    }
  }
  snprintf(buf, PATH_MAX - 1, "/proc/%d/ns", pid);
  tfd = open(buf, O_DIRECTORY | O_RDONLY);
  if (tfd == -1) {
    fprintf(stderr,
            "nsenter: "
            "Failed to open \"%s\""
            ": %m\n",
            buf);
    exit(1);
  }
  self_tfd = open("/proc/self/ns", O_DIRECTORY | O_RDONLY);
  if (self_tfd == -1) {
    fprintf(stderr, "nsenter: "
                    "Failed to open /proc/self/ns"
                    ": %m\n");
    exit(1);
  }
  for (i = 0; i < num; i++) {
    struct stat st;
    struct stat self_st;
    int fd;
    if (fstatat(tfd, namespaces[i], &st, 0) == -1) {
      if (errno == ENOENT)
        continue;
    }
    if (fstatat(self_tfd, namespaces[i], &self_st, 0) != -1 &&
        st.st_ino == self_st.st_ino) {
      continue;
    }
    fd = openat(tfd, namespaces[i], O_RDONLY);
    if (fd == -1) {
      fprintf(stderr,
              "nsenter: "
              "Failed to open ns file %s for ns %s"
              ": %m\n",
              buf, namespaces[i]);
      exit(1);
    }
    if (setns(fd, 0) == -1) {
      fprintf(stderr,
              "nsenter: "
              "Failed to setns for %s"
              ": %m\n",
              namespaces[i]);
      exit(1);
    }
    close(fd);
  }
  close(self_tfd);
  close(tfd);
  if (setjmp(env) == 1) {
    if (setsid() == -1) {
      fprintf(stderr, "nsenter: "
                      "setsid failed"
                      ": %m\n");
      exit(1);
    }
    if (consolefd != -1) {
      if (ioctl(consolefd, TIOCSCTTY, 0) == -1) {
        fprintf(stderr, "nsenter: "
                        "ioctl TIOCSCTTY failed"
                        ": %m\n");
        exit(1);
      }
      if (dup3(consolefd, STDIN_FILENO, 0) != STDIN_FILENO) {
        fprintf(stderr, "nsenter: "
                        "Failed to dup 0"
                        ": %m\n");
        exit(1);
      }
      if (dup3(consolefd, STDOUT_FILENO, 0) != STDOUT_FILENO) {
        fprintf(stderr, "nsenter: "
                        "Failed to dup 1"
                        ": %m\n");
        exit(1);
      }
      if (dup3(consolefd, STDERR_FILENO, 0) != STDERR_FILENO) {
        fprintf(stderr, "nsenter: "
                        "Failed to dup 2"
                        ": %m\n");
        exit(1);
      }
    }
    return;
  }
  child = clone_parent(&env);
  if (child < 0) {
    fprintf(stderr, "nsenter: "
                    "Unable to fork"
                    ": %m\n");
    exit(1);
  }
  len = snprintf(buf, sizeof(buf), "{ \"pid\" : %d }\n", child);
  if (write(pipenum, buf, len) != len) {
    fprintf(stderr, "nsenter: "
                    "Unable to send a child pid"
                    ": %m\n");
    kill(child, SIGKILL);
    exit(1);
  }
  exit(0);
}


x86 assembly (clang, -O0):
<nsexec>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,-0x10(%rbp)
movaps %xmm0,-0x20(%rbp)
movaps %xmm0,-0x30(%rbp)
lea    0xdbf(%rip),%rax
mov    %rax,-0x30(%rbp)
lea    0xdb8(%rip),%rax
mov    %rax,-0x28(%rbp)
lea    0xdb1(%rip),%rax
mov    %rax,-0x20(%rbp)
lea    0xdaa(%rip),%rax
mov    %rax,-0x18(%rbp)
lea    0xda3(%rip),%rax
mov    %rax,-0x10(%rbp)
lea    0xd9c(%rip),%rax
mov    %rax,-0x8(%rbp)
movl   $0x6,-0x34(%rbp)
mov    0x2d66(%rip),%rax
mov    (%rax),%eax
mov    %rax,-0xa8(%rbp)
mov    %rsp,%rcx
mov    %rcx,-0x40(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0xa0(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x48(%rbp)
movl   $0xffffffff,-0x6c(%rbp)
lea    0xd52(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x50(%rbp)
cmpq   $0x0,-0x50(%rbp)
jne    12e7 <nsexec+0xc7>
movl   $0x1,-0x7c(%rbp)
jmp    1889 <nsexec+0x669>
mov    -0x50(%rbp),%rdi
call   1120 <atoi@plt>
mov    -0xa0(%rbp),%rdi
mov    %eax,%ecx
mov    -0xa8(%rbp),%rax
mov    %ecx,-0x70(%rbp)
mov    %eax,%esi
mov    -0x70(%rbp),%ecx
lea    0xd20(%rip),%rdx
call   1080 <snprintf@plt>
mov    -0xa0(%rbp),%rsi
mov    -0x50(%rbp),%rdi
call   10d0 <strcmp@plt>
cmp    $0x0,%rax
je     134f <nsexec+0x12f>
mov    0x2c83(%rip),%rax
mov    (%rax),%edi
lea    0xcf4(%rip),%rsi
mov    $0x0,%al
call   10e0 <fprintf@plt>
mov    $0x1,%edi
call   1130 <exit@plt>
lea    0xd10(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x50(%rbp)
cmpq   $0x0,-0x50(%rbp)
jne    138b <nsexec+0x16b>
mov    0x2c47(%rip),%rax
mov    (%rax),%edi
lea    0xd03(%rip),%rsi
mov    $0x0,%al
call   10e0 <fprintf@plt>
mov    $0x1,%edi
call   1130 <exit@plt>
mov    -0x50(%rbp),%rdi
call   1120 <atoi@plt>
mov    -0xa0(%rbp),%rdi
mov    %eax,%ecx
mov    -0xa8(%rbp),%rax
mov    %ecx,-0x68(%rbp)
mov    %eax,%esi
mov    -0x68(%rbp),%ecx
lea    0xc7c(%rip),%rdx
call   1080 <snprintf@plt>
mov    -0xa0(%rbp),%rsi
mov    -0x50(%rbp),%rdi
call   10d0 <strcmp@plt>
cmp    $0x0,%rax
je     13f3 <nsexec+0x1d3>
mov    0x2bdf(%rip),%rax
mov    (%rax),%edi
lea    0xcbe(%rip),%rsi
mov    $0x0,%al
call   10e0 <fprintf@plt>
mov    $0x1,%edi
call   1130 <exit@plt>
lea    0xcdb(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x78(%rbp)
cmpq   $0x0,-0x78(%rbp)
je     1457 <nsexec+0x237>
mov    -0x78(%rbp),%rdi
mov    0x2bbf(%rip),%rax
mov    (%rax),%esi
call   1110 <open@plt>
mov    %eax,-0x6c(%rbp)
cmpl   $0x0,-0x6c(%rbp)
jge    1452 <nsexec+0x232>
mov    0x2b84(%rip),%rax
mov    (%rax),%edi
mov    -0x78(%rbp),%rdx
lea    0xcaf(%rip),%rsi
mov    $0x0,%al
call   10e0 <fprintf@plt>
mov    $0x1,%edi
call   1130 <exit@plt>
jmp    1457 <nsexec+0x237>
mov    -0xa0(%rbp),%rdi
mov    0x2b8b(%rip),%rax
mov    (%rax),%esi
sub    $0x1,%esi
mov    -0x70(%rbp),%ecx
lea    0xca4(%rip),%rdx
call   1080 <snprintf@plt>
mov    -0xa0(%rbp),%rdi
mov    0x2b39(%rip),%rax
mov    (%rax),%esi
mov    0x2b40(%rip),%rax
or     (%rax),%esi
call   1110 <open@plt>
mov    %eax,-0x58(%rbp)
cmpl   $0xffffffff,-0x58(%rbp)
jne    14cc <nsexec+0x2ac>
mov    -0xa0(%rbp),%rdx
mov    0x2b06(%rip),%rax
mov    (%rax),%edi
lea    0xc69(%rip),%rsi
mov    $0x0,%al
call   10e0 <fprintf@plt>
mov    $0x1,%edi
call   1130 <exit@plt>
mov    0x2aed(%rip),%rax
mov    (%rax),%esi
mov    0x2af4(%rip),%rax
or     (%rax),%esi
lea    0xc61(%rip),%rdi
call   1110 <open@plt>
mov    %eax,-0x5c(%rbp)
cmpl   $0xffffffff,-0x5c(%rbp)
jne    1518 <nsexec+0x2f8>
mov    0x2aba(%rip),%rax
mov    (%rax),%edi
lea    0xc4d(%rip),%rsi
mov    $0x0,%al
call   10e0 <fprintf@plt>
mov    $0x1,%edi
call   1130 <exit@plt>
movl   $0x0,-0x54(%rbp)
cmpl   $0x6,-0x54(%rbp)
jge    1663 <nsexec+0x443>
mov    -0x58(%rbp),%edi
movslq -0x54(%rbp),%rax
mov    -0x30(%rbp,%rax,8),%rsi
lea    -0x88(%rbp),%rdx
xor    %ecx,%ecx
call   1140 <fstatat@plt>
cmp    $0xffffffff,%eax
jne    1570 <nsexec+0x350>
mov    0x2a5d(%rip),%rax
mov    (%rax),%rax
mov    0x2a23(%rip),%rcx
cmp    (%rcx),%rax
jne    156b <nsexec+0x34b>
jmp    1655 <nsexec+0x435>
jmp    1570 <nsexec+0x350>
mov    -0x5c(%rbp),%edi
movslq -0x54(%rbp),%rax
mov    -0x30(%rbp,%rax,8),%rsi
lea    -0x90(%rbp),%rdx
xor    %ecx,%ecx
call   1140 <fstatat@plt>
cmp    $0xffffffff,%eax
je     15ac <nsexec+0x38c>
mov    -0x88(%rbp),%rax
cmp    -0x90(%rbp),%rax
jne    15ac <nsexec+0x38c>
jmp    1655 <nsexec+0x435>
mov    -0x58(%rbp),%edi
movslq -0x54(%rbp),%rax
mov    -0x30(%rbp,%rax,8),%rsi
mov    0x2a11(%rip),%rax
mov    (%rax),%edx
call   1070 <openat@plt>
mov    %eax,-0x94(%rbp)
cmpl   $0xffffffff,-0x94(%rbp)
jne    160a <nsexec+0x3ea>
mov    -0xa0(%rbp),%rdx
mov    0x29d1(%rip),%rax
mov    (%rax),%edi
movslq -0x54(%rbp),%rax
mov    -0x30(%rbp,%rax,8),%rcx
lea    0xb86(%rip),%rsi
mov    $0x0,%al
call   10e0 <fprintf@plt>
mov    $0x1,%edi
call   1130 <exit@plt>
mov    -0x94(%rbp),%edi
xor    %esi,%esi
call   1090 <setns@plt>
cmp    $0xffffffff,%eax
jne    164a <nsexec+0x42a>
mov    0x2991(%rip),%rax
mov    (%rax),%edi
movslq -0x54(%rbp),%rax
mov    -0x30(%rbp,%rax,8),%rdx
lea    0xb78(%rip),%rsi
mov    $0x0,%al
call   10e0 <fprintf@plt>
mov    $0x1,%edi
call   1130 <exit@plt>
mov    -0x94(%rbp),%edi
call   10b0 <close@plt>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    151f <nsexec+0x2ff>
mov    -0x5c(%rbp),%edi
call   10b0 <close@plt>
mov    -0x58(%rbp),%edi
call   10b0 <close@plt>
mov    -0x38(%rbp),%edi
call   1100 <setjmp@plt>
cmp    $0x1,%eax
jne    17dc <nsexec+0x5bc>
mov    $0x0,%al
call   10c0 <setsid@plt>
cmp    $0xffffffff,%eax
jne    16b5 <nsexec+0x495>
mov    0x291d(%rip),%rax
mov    (%rax),%edi
lea    0xb32(%rip),%rsi
mov    $0x0,%al
call   10e0 <fprintf@plt>
mov    $0x1,%edi
call   1130 <exit@plt>
cmpl   $0xffffffff,-0x6c(%rbp)
je     17d0 <nsexec+0x5b0>
mov    -0x6c(%rbp),%edi
mov    0x28cf(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10a0 <ioctl@plt>
cmp    $0xffffffff,%eax
jne    16fc <nsexec+0x4dc>
mov    0x28d6(%rip),%rax
mov    (%rax),%edi
lea    0xb07(%rip),%rsi
mov    $0x0,%al
call   10e0 <fprintf@plt>
mov    $0x1,%edi
call   1130 <exit@plt>
mov    -0x6c(%rbp),%edi
mov    0x288a(%rip),%rax
mov    (%rax),%rsi
xor    %edx,%edx
call   1060 <dup3@plt>
mov    0x2879(%rip),%rcx
cmp    (%rcx),%rax
je     1741 <nsexec+0x521>
mov    0x2891(%rip),%rax
mov    (%rax),%edi
lea    0xae7(%rip),%rsi
mov    $0x0,%al
call   10e0 <fprintf@plt>
mov    $0x1,%edi
call   1130 <exit@plt>
mov    -0x6c(%rbp),%edi
mov    0x289d(%rip),%rax
mov    (%rax),%rsi
xor    %edx,%edx
call   1060 <dup3@plt>
mov    0x288c(%rip),%rcx
cmp    (%rcx),%rax
je     1786 <nsexec+0x566>
mov    0x284c(%rip),%rax
mov    (%rax),%edi
lea    0xac0(%rip),%rsi
mov    $0x0,%al
call   10e0 <fprintf@plt>
mov    $0x1,%edi
call   1130 <exit@plt>
mov    -0x6c(%rbp),%edi
mov    0x2818(%rip),%rax
mov    (%rax),%rsi
xor    %edx,%edx
call   1060 <dup3@plt>
mov    0x2807(%rip),%rcx
cmp    (%rcx),%rax
je     17cb <nsexec+0x5ab>
mov    0x2807(%rip),%rax
mov    (%rax),%edi
lea    0xa99(%rip),%rsi
mov    $0x0,%al
call   10e0 <fprintf@plt>
mov    $0x1,%edi
call   1130 <exit@plt>
jmp    17d0 <nsexec+0x5b0>
movl   $0x1,-0x7c(%rbp)
jmp    1889 <nsexec+0x669>
lea    -0x38(%rbp),%rdi
call   1040 <clone_parent@plt>
mov    %eax,-0x60(%rbp)
cmpl   $0x0,-0x60(%rbp)
jge    1813 <nsexec+0x5f3>
mov    0x27bf(%rip),%rax
mov    (%rax),%edi
lea    0xa6f(%rip),%rsi
mov    $0x0,%al
call   10e0 <fprintf@plt>
mov    $0x1,%edi
call   1130 <exit@plt>
mov    -0xa0(%rbp),%rdi
mov    -0xa8(%rbp),%rax
mov    %eax,%esi
mov    -0x60(%rbp),%ecx
lea    0xa61(%rip),%rdx
call   1080 <snprintf@plt>
mov    -0xa0(%rbp),%rsi
mov    %eax,-0x64(%rbp)
mov    -0x68(%rbp),%edi
mov    -0x64(%rbp),%edx
call   1050 <write@plt>
cmp    -0x64(%rbp),%eax
je     1882 <nsexec+0x662>
mov    0x2761(%rip),%rax
mov    (%rax),%edi
lea    0xa3e(%rip),%rsi
mov    $0x0,%al
call   10e0 <fprintf@plt>
mov    -0x60(%rbp),%edi
mov    0x272f(%rip),%rax
mov    (%rax),%esi
call   10f0 <kill@plt>
mov    $0x1,%edi
call   1130 <exit@plt>
xor    %edi,%edi
call   1130 <exit@plt>
mov    -0x40(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nsexec>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
mov    %rsp,%r14
lea    0xdc5(%rip),%rax
mov    %rax,-0x90(%rbp)
lea    0xdbb(%rip),%rax
mov    %rax,-0x88(%rbp)
lea    0xdb1(%rip),%rax
mov    %rax,-0x80(%rbp)
lea    0xdaa(%rip),%rax
mov    %rax,-0x78(%rbp)
lea    0xda3(%rip),%rax
mov    %rax,-0x70(%rbp)
lea    0xd9c(%rip),%rax
mov    %rax,-0x68(%rbp)
mov    0x2d6d(%rip),%rax
mov    (%rax),%eax
mov    %eax,%r15d
mov    %rsp,%rbx
lea    0xf(%r15),%rcx
and    $0xfffffffffffffff0,%rcx
sub    %rcx,%rbx
mov    %rbx,%rsp
lea    0xd79(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     1556 <nsexec+0x336>
mov    %r15d,%r13d
mov    %rax,%r12
mov    %rax,%rdi
call   1120 <atoi@plt>
mov    %eax,%r15d
lea    0xd69(%rip),%rdx
mov    %rbx,%rdi
mov    %r13d,-0x38(%rbp)
mov    %r13d,%esi
mov    %eax,%ecx
call   1080 <snprintf@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   10d0 <strcmp@plt>
test   %rax,%rax
jne    15b4 <nsexec+0x394>
mov    %rbx,-0x30(%rbp)
mov    %r14,-0x50(%rbp)
lea    0xd6c(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     15c9 <nsexec+0x3a9>
mov    %rax,%r14
mov    %rax,%rdi
call   1120 <atoi@plt>
mov    %eax,%r12d
lea    0xd12(%rip),%rdx
mov    -0x30(%rbp),%rbx
mov    %rbx,%rdi
mov    -0x38(%rbp),%esi
mov    %eax,%ecx
call   1080 <snprintf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   10d0 <strcmp@plt>
test   %rax,%rax
jne    15de <nsexec+0x3be>
lea    0xd8c(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     1387 <nsexec+0x167>
mov    %rax,%r14
mov    0x2c7b(%rip),%rax
mov    (%rax),%esi
mov    %r14,%rdi
call   1110 <open@plt>
mov    %eax,%ecx
test   %eax,%eax
jns    138c <nsexec+0x16c>
mov    0x2c44(%rip),%rax
mov    (%rax),%edi
lea    0xd73(%rip),%rsi
xor    %eax,%eax
mov    %r14,%rdx
jmp    157d <nsexec+0x35d>
mov    $0xffffffff,%ecx
mov    %ecx,%r13d
mov    0x2c5a(%rip),%rax
mov    (%rax),%esi
add    $0xffffffff,%esi
lea    0xd76(%rip),%rdx
mov    -0x30(%rbp),%rbx
mov    %rbx,%rdi
mov    %r15d,%ecx
call   1080 <snprintf@plt>
mov    0x2c08(%rip),%r14
mov    0x2c11(%rip),%r15
mov    (%r15),%esi
or     (%r14),%esi
mov    %rbx,%rdi
call   1110 <open@plt>
cmp    $0xffffffff,%eax
je     15f3 <nsexec+0x3d3>
mov    %eax,%ebx
mov    %r13d,-0x40(%rbp)
mov    (%r15),%esi
or     (%r14),%esi
lea    0xd5d(%rip),%rdi
call   1110 <open@plt>
cmp    $0xffffffff,%eax
je     160e <nsexec+0x3ee>
mov    %r12d,-0x3c(%rbp)
mov    %eax,-0x34(%rbp)
mov    $0x1,%r12d
xor    %r15d,%r15d
lea    0xbf2(%rip),%r13
xchg   %ax,%ax
mov    %ebx,%edi
mov    %r13,%rsi
lea    -0x48(%rbp),%rdx
mov    %r15d,%ecx
call   1140 <fstatat@plt>
cmp    $0xffffffff,%eax
jne    143c <nsexec+0x21c>
mov    0x2b83(%rip),%rax
mov    (%rax),%rax
mov    0x2b49(%rip),%rcx
cmp    (%rcx),%rax
je     1497 <nsexec+0x277>
mov    -0x34(%rbp),%edi
mov    %r13,%rsi
lea    -0x58(%rbp),%rdx
mov    %r15d,%ecx
call   1140 <fstatat@plt>
cmp    $0xffffffff,%eax
je     145d <nsexec+0x23d>
mov    -0x48(%rbp),%rax
cmp    -0x58(%rbp),%rax
je     1497 <nsexec+0x277>
mov    0x2b6c(%rip),%rax
mov    (%rax),%edx
mov    %ebx,%edi
mov    %r13,%rsi
call   1070 <openat@plt>
cmp    $0xffffffff,%eax
je     158c <nsexec+0x36c>
mov    %eax,%r14d
mov    %eax,%edi
mov    %r15d,%esi
call   1090 <setns@plt>
cmp    $0xffffffff,%eax
je     1568 <nsexec+0x348>
mov    %r14d,%edi
call   10b0 <close@plt>
cmp    $0x6,%r12
je     14ae <nsexec+0x28e>
mov    -0x90(%rbp,%r12,8),%r13
ff
add    $0x1,%r12
jmp    1410 <nsexec+0x1f0>
mov    -0x34(%rbp),%edi
call   10b0 <close@plt>
mov    %ebx,%edi
call   10b0 <close@plt>
call   1100 <setjmp@plt>
cmp    $0x1,%eax
jne    1620 <nsexec+0x400>
xor    %eax,%eax
call   10c0 <setsid@plt>
cmp    $0xffffffff,%eax
mov    -0x50(%rbp),%r14
mov    -0x40(%rbp),%ebx
je     163f <nsexec+0x41f>
cmp    $0xffffffff,%ebx
je     1556 <nsexec+0x336>
mov    0x2aaa(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
mov    %ebx,%edi
call   10a0 <ioctl@plt>
cmp    $0xffffffff,%eax
je     1651 <nsexec+0x431>
mov    0x2a87(%rip),%r15
mov    (%r15),%rsi
xor    %edx,%edx
mov    %ebx,%edi
call   1060 <dup3@plt>
cmp    (%r15),%rax
jne    1663 <nsexec+0x443>
mov    0x2ac3(%rip),%r15
mov    (%r15),%rsi
xor    %edx,%edx
mov    %ebx,%edi
call   1060 <dup3@plt>
cmp    (%r15),%rax
jne    1675 <nsexec+0x455>
mov    0x2a67(%rip),%r15
mov    (%r15),%rsi
xor    %edx,%edx
mov    %ebx,%edi
call   1060 <dup3@plt>
cmp    (%r15),%rax
jne    1687 <nsexec+0x467>
mov    %r14,%rsp
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2a49(%rip),%rax
mov    (%rax),%edi
lea    0xc39(%rip),%rsi
xor    %eax,%eax
mov    %r13,%rdx
call   10e0 <fprintf@plt>
mov    $0x1,%edi
call   1130 <exit@plt>
mov    0x2a25(%rip),%rax
mov    (%rax),%edi
lea    0xbe3(%rip),%rsi
xor    %eax,%eax
mov    -0x30(%rbp),%rdx
mov    %r13,%rcx
call   10e0 <fprintf@plt>
mov    $0x1,%edi
call   1130 <exit@plt>
mov    0x29fd(%rip),%rax
mov    (%rax),%edi
lea    0xa6e(%rip),%rsi
jmp    1697 <nsexec+0x477>
mov    0x29e8(%rip),%rax
mov    (%rax),%edi
lea    0xaa4(%rip),%rsi
jmp    1697 <nsexec+0x477>
mov    0x29d3(%rip),%rax
mov    (%rax),%edi
lea    0xab2(%rip),%rsi
jmp    1697 <nsexec+0x477>
mov    0x29be(%rip),%rax
mov    (%rax),%edi
lea    0xb21(%rip),%rsi
xor    %eax,%eax
mov    -0x30(%rbp),%rdx
jmp    157d <nsexec+0x35d>
mov    0x29a3(%rip),%rax
mov    (%rax),%edi
lea    0xb36(%rip),%rsi
jmp    1697 <nsexec+0x477>
lea    -0x48(%rbp),%rdi
call   1040 <clone_parent@plt>
test   %eax,%eax
jns    16a8 <nsexec+0x488>
mov    0x2984(%rip),%rax
mov    (%rax),%edi
lea    0xc34(%rip),%rsi
jmp    1697 <nsexec+0x477>
mov    0x2972(%rip),%rax
mov    (%rax),%edi
lea    0xb87(%rip),%rsi
jmp    1697 <nsexec+0x477>
mov    0x2960(%rip),%rax
mov    (%rax),%edi
lea    0xb91(%rip),%rsi
jmp    1697 <nsexec+0x477>
mov    0x294e(%rip),%rax
mov    (%rax),%edi
lea    0xba4(%rip),%rsi
jmp    1697 <nsexec+0x477>
mov    0x293c(%rip),%rax
mov    (%rax),%edi
lea    0xbb0(%rip),%rsi
jmp    1697 <nsexec+0x477>
mov    0x292a(%rip),%rax
mov    (%rax),%edi
lea    0xbbc(%rip),%rsi
xor    %eax,%eax
call   10e0 <fprintf@plt>
mov    $0x1,%edi
call   1130 <exit@plt>
mov    %eax,%r14d
lea    0xbdc(%rip),%rdx
mov    -0x30(%rbp),%r15
mov    %r15,%rdi
mov    -0x38(%rbp),%esi
mov    %eax,%ecx
call   1080 <snprintf@plt>
mov    %eax,%ebx
mov    -0x3c(%rbp),%edi
mov    %r15,%rsi
mov    %eax,%edx
call   1050 <write@plt>
cmp    %ebx,%eax
jne    16dd <nsexec+0x4bd>
xor    %edi,%edi
call   1130 <exit@plt>
mov    0x28d4(%rip),%rax
mov    (%rax),%edi
lea    0xbb1(%rip),%rsi
xor    %eax,%eax
call   10e0 <fprintf@plt>
mov    0x28a5(%rip),%rax
mov    (%rax),%esi
mov    %r14d,%edi
call   10f0 <kill@plt>
mov    $0x1,%edi
call   1130 <exit@plt>

LLVM IR (-O0):
%struct.stat = type { i64 }
@.str = [4 x i8] c"ipc\00"
@.str.1 = [4 x i8] c"uts\00"
@.str.2 = [4 x i8] c"net\00"
@.str.3 = [4 x i8] c"pid\00"
@.str.4 = [4 x i8] c"mnt\00"
@.str.5 = [5 x i8] c"user\00"
@PATH_MAX = global i32 0
@.str.6 = [22 x i8] c"_LIBCONTAINER_INITPID\00"
@.str.7 = [3 x i8] c"%d\00"
@stderr = global i32 0
@.str.8 = [52 x i8] c"nsenter: Unable to parse _LIBCONTAINER_INITPID: %m\0A\00"
@.str.9 = [23 x i8] c"_LIBCONTAINER_INITPIPE\00"
@.str.10 = [35 x i8] c"nsenter: Child pipe not found: %m\0A\00"
@.str.11 = [53 x i8] c"nsenter: Unable to parse _LIBCONTAINER_INITPIPE: %m\0A\00"
@.str.12 = [27 x i8] c"_LIBCONTAINER_CONSOLE_PATH\00"
@O_RDWR = global i32 0
@.str.13 = [40 x i8] c"nsenter: Failed to open console %s: %m\0A\00"
@.str.14 = [12 x i8] c"/proc/%d/ns\00"
@O_DIRECTORY = global i32 0
@O_RDONLY = global i32 0
@.str.15 = [34 x i8] c"nsenter: Failed to open \22%s\22: %m\0A\00"
@.str.16 = [14 x i8] c"/proc/self/ns\00"
@.str.17 = [43 x i8] c"nsenter: Failed to open /proc/self/ns: %m\0A\00"
@errno = global i64 0
@ENOENT = global i64 0
@.str.18 = [50 x i8] c"nsenter: Failed to open ns file %s for ns %s: %m\0A\00"
@.str.19 = [37 x i8] c"nsenter: Failed to setns for %s: %m\0A\00"
@.str.20 = [28 x i8] c"nsenter: setsid failed: %m\0A\00"
@TIOCSCTTY = global i32 0
@.str.21 = [37 x i8] c"nsenter: ioctl TIOCSCTTY failed: %m\0A\00"
@STDIN_FILENO = global i64 0
@.str.22 = [30 x i8] c"nsenter: Failed to dup 0: %m\0A\00"
@STDOUT_FILENO = global i64 0
@.str.23 = [30 x i8] c"nsenter: Failed to dup 1: %m\0A\00"
@STDERR_FILENO = global i64 0
@.str.24 = [30 x i8] c"nsenter: Failed to dup 2: %m\0A\00"
@.str.25 = [29 x i8] c"nsenter: Unable to fork: %m\0A\00"
@.str.26 = [16 x i8] c"{ \22pid\22 : %d }\0A\00"
@.str.27 = [41 x i8] c"nsenter: Unable to send a child pid: %m\0A\00"
@SIGKILL = global i32 0
define void @nsexec() {
%1 = alloca [6 x i8*]
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i8*
%16 = alloca i32
%17 = alloca %struct.stat
%18 = alloca %struct.stat
%19 = alloca i32
%20 = bitcast [6 x i8*]* %1 to i8*
%21 = bitcast i8* %20 to [6 x i8*]*
%22 = getelementptr inbounds [6 x i8*], [6 x i8*]* %21, i32 0, i32 0
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i8** %22
%23 = getelementptr inbounds [6 x i8*], [6 x i8*]* %21, i32 0, i32 1
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i32 0, i32 0), i8** %23
%24 = getelementptr inbounds [6 x i8*], [6 x i8*]* %21, i32 0, i32 2
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i32 0, i32 0), i8** %24
%25 = getelementptr inbounds [6 x i8*], [6 x i8*]* %21, i32 0, i32 3
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i32 0, i32 0), i8** %25
%26 = getelementptr inbounds [6 x i8*], [6 x i8*]* %21, i32 0, i32 4
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i32 0, i32 0), i8** %26
%27 = getelementptr inbounds [6 x i8*], [6 x i8*]* %21, i32 0, i32 5
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i32 0, i32 0), i8** %27
store i32 6, i32* %2
%28 = load i32, i32* @PATH_MAX
%29 = zext i32 %28 to i64
%30 = call i8* @llvm.stacksave()
store i8* %30, i8** %4
%31 = alloca i8, i64 %29
store i64 %29, i64* %5
store i32 -1, i32* %13
%32 = call i8* @getenv(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0))
store i8* %32, i8** %6
%33 = load i8*, i8** %6
%34 = icmp eq i8* %33, null
br i1 %34, label %35, label %36
35: ; preds = %0
store i32 1, i32* %16
br label %266
36: ; preds = %0
%37 = load i8*, i8** %6
%38 = call i32 @atoi(i8* %37)
store i32 %38, i32* %14
%39 = trunc i64 %29 to i32
%40 = load i32, i32* %14
%41 = call i32 @snprintf(i8* %31, i32 %39, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32 %40)
%42 = load i8*, i8** %6
%43 = call i64 @strcmp(i8* %42, i8* %31)
%44 = icmp ne i64 %43, 0
br i1 %44, label %45, label %49
45: ; preds = %36
%46 = load i32, i32* @stderr
%47 = call i32 (i32, i8*, ...) @fprintf(i32 %46, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.8, i64 0, i64 0))
%48 = call i32 @exit(i32 1)
unreachable
49: ; preds = %36
%50 = call i8* @getenv(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.9, i64 0, i64 0))
store i8* %50, i8** %6
%51 = load i8*, i8** %6
%52 = icmp eq i8* %51, null
br i1 %52, label %53, label %57
53: ; preds = %49
%54 = load i32, i32* @stderr
%55 = call i32 (i32, i8*, ...) @fprintf(i32 %54, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.10, i64 0, i64 0))
%56 = call i32 @exit(i32 1)
unreachable
57: ; preds = %49
%58 = load i8*, i8** %6
%59 = call i32 @atoi(i8* %58)
store i32 %59, i32* %12
%60 = trunc i64 %29 to i32
%61 = load i32, i32* %12
%62 = call i32 @snprintf(i8* %31, i32 %60, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32 %61)
%63 = load i8*, i8** %6
%64 = call i64 @strcmp(i8* %63, i8* %31)
%65 = icmp ne i64 %64, 0
br i1 %65, label %66, label %70
66: ; preds = %57
%67 = load i32, i32* @stderr
%68 = call i32 (i32, i8*, ...) @fprintf(i32 %67, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.11, i64 0, i64 0))
%69 = call i32 @exit(i32 1)
unreachable
70: ; preds = %57
%71 = call i8* @getenv(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.12, i64 0, i64 0))
store i8* %71, i8** %15
%72 = load i8*, i8** %15
%73 = icmp ne i8* %72, null
br i1 %73, label %74, label %86
74: ; preds = %70
%75 = load i8*, i8** %15
%76 = load i32, i32* @O_RDWR
%77 = call i32 @open(i8* %75, i32 %76)
store i32 %77, i32* %13
%78 = load i32, i32* %13
%79 = icmp slt i32 %78, 0
br i1 %79, label %80, label %85
80: ; preds = %74
%81 = load i32, i32* @stderr
%82 = load i8*, i8** %15
%83 = call i32 (i32, i8*, ...) @fprintf(i32 %81, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.13, i64 0, i64 0), i8* %82)
%84 = call i32 @exit(i32 1)
unreachable
85: ; preds = %74
br label %86
86: ; preds = %85, %70
%87 = load i32, i32* @PATH_MAX
%88 = sub nsw i32 %87, 1
%89 = load i32, i32* %14
%90 = call i32 @snprintf(i8* %31, i32 %88, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.14, i64 0, i64 0), i32 %89)
%91 = load i32, i32* @O_DIRECTORY
%92 = load i32, i32* @O_RDONLY
%93 = or i32 %91, %92
%94 = call i32 @open(i8* %31, i32 %93)
store i32 %94, i32* %8
%95 = load i32, i32* %8
%96 = icmp eq i32 %95, -1
br i1 %96, label %97, label %101
97: ; preds = %86
%98 = load i32, i32* @stderr
%99 = call i32 (i32, i8*, ...) @fprintf(i32 %98, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.15, i64 0, i64 0), i8* %31)
%100 = call i32 @exit(i32 1)
unreachable
101: ; preds = %86
%102 = load i32, i32* @O_DIRECTORY
%103 = load i32, i32* @O_RDONLY
%104 = or i32 %102, %103
%105 = call i32 @open(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.16, i64 0, i64 0), i32 %104)
store i32 %105, i32* %9
%106 = load i32, i32* %9
%107 = icmp eq i32 %106, -1
br i1 %107, label %108, label %112
108: ; preds = %101
%109 = load i32, i32* @stderr
%110 = call i32 (i32, i8*, ...) @fprintf(i32 %109, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.17, i64 0, i64 0))
%111 = call i32 @exit(i32 1)
unreachable
112: ; preds = %101
store i32 0, i32* %7
br label %113
113: ; preds = %178, %112
%114 = load i32, i32* %7
%115 = icmp slt i32 %114, 6
br i1 %115, label %116, label %181
116: ; preds = %113
%117 = load i32, i32* %8
%118 = load i32, i32* %7
%119 = sext i32 %118 to i64
%120 = getelementptr inbounds [6 x i8*], [6 x i8*]* %1, i64 0, i64 %119
%121 = load i8*, i8** %120
%122 = call i32 @fstatat(i32 %117, i8* %121, %struct.stat* %17, i32 0)
%123 = icmp eq i32 %122, -1
br i1 %123, label %124, label %130
124: ; preds = %116
%125 = load i64, i64* @errno
%126 = load i64, i64* @ENOENT
%127 = icmp eq i64 %125, %126
br i1 %127, label %128, label %129
128: ; preds = %124
br label %178
129: ; preds = %124
br label %130
130: ; preds = %129, %116
%131 = load i32, i32* %9
%132 = load i32, i32* %7
%133 = sext i32 %132 to i64
%134 = getelementptr inbounds [6 x i8*], [6 x i8*]* %1, i64 0, i64 %133
%135 = load i8*, i8** %134
%136 = call i32 @fstatat(i32 %131, i8* %135, %struct.stat* %18, i32 0)
%137 = icmp ne i32 %136, -1
br i1 %137, label %138, label %145
138: ; preds = %130
%139 = getelementptr inbounds %struct.stat, %struct.stat* %17, i32 0, i32 0
%140 = load i64, i64* %139
%141 = getelementptr inbounds %struct.stat, %struct.stat* %18, i32 0, i32 0
%142 = load i64, i64* %141
%143 = icmp eq i64 %140, %142
br i1 %143, label %144, label %145
144: ; preds = %138
br label %178
145: ; preds = %138, %130
%146 = load i32, i32* %8
%147 = load i32, i32* %7
%148 = sext i32 %147 to i64
%149 = getelementptr inbounds [6 x i8*], [6 x i8*]* %1, i64 0, i64 %148
%150 = load i8*, i8** %149
%151 = load i32, i32* @O_RDONLY
%152 = call i32 @openat(i32 %146, i8* %150, i32 %151)
store i32 %152, i32* %19
%153 = load i32, i32* %19
%154 = icmp eq i32 %153, -1
br i1 %154, label %155, label %163
155: ; preds = %145
%156 = load i32, i32* @stderr
%157 = load i32, i32* %7
%158 = sext i32 %157 to i64
%159 = getelementptr inbounds [6 x i8*], [6 x i8*]* %1, i64 0, i64 %158
%160 = load i8*, i8** %159
%161 = call i32 (i32, i8*, ...) @fprintf(i32 %156, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.18, i64 0, i64 0), i8* %31, i8* %160)
%162 = call i32 @exit(i32 1)
unreachable
163: ; preds = %145
%164 = load i32, i32* %19
%165 = call i32 @setns(i32 %164, i32 0)
%166 = icmp eq i32 %165, -1
br i1 %166, label %167, label %175
167: ; preds = %163
%168 = load i32, i32* @stderr
%169 = load i32, i32* %7
%170 = sext i32 %169 to i64
%171 = getelementptr inbounds [6 x i8*], [6 x i8*]* %1, i64 0, i64 %170
%172 = load i8*, i8** %171
%173 = call i32 (i32, i8*, ...) @fprintf(i32 %168, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.19, i64 0, i64 0), i8* %172)
%174 = call i32 @exit(i32 1)
unreachable
175: ; preds = %163
%176 = load i32, i32* %19
%177 = call i32 @close(i32 %176)
br label %178
178: ; preds = %175, %144, %128
%179 = load i32, i32* %7
%180 = add nsw i32 %179, 1
store i32 %180, i32* %7
br label %113
181: ; preds = %113
%182 = load i32, i32* %9
%183 = call i32 @close(i32 %182)
%184 = load i32, i32* %8
%185 = call i32 @close(i32 %184)
%186 = load i32, i32* %3
%187 = call i32 @setjmp(i32 %186)
%188 = icmp eq i32 %187, 1
br i1 %188, label %189, label %240
189: ; preds = %181
%190 = call i32 (...) @setsid()
%191 = icmp eq i32 %190, -1
br i1 %191, label %192, label %196
192: ; preds = %189
%193 = load i32, i32* @stderr
%194 = call i32 (i32, i8*, ...) @fprintf(i32 %193, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.20, i64 0, i64 0))
%195 = call i32 @exit(i32 1)
unreachable
196: ; preds = %189
%197 = load i32, i32* %13
%198 = icmp ne i32 %197, -1
br i1 %198, label %199, label %239
199: ; preds = %196
%200 = load i32, i32* %13
%201 = load i32, i32* @TIOCSCTTY
%202 = call i32 @ioctl(i32 %200, i32 %201, i32 0)
%203 = icmp eq i32 %202, -1
br i1 %203, label %204, label %208
204: ; preds = %199
%205 = load i32, i32* @stderr
%206 = call i32 (i32, i8*, ...) @fprintf(i32 %205, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.21, i64 0, i64 0))
%207 = call i32 @exit(i32 1)
unreachable
208: ; preds = %199
%209 = load i32, i32* %13
%210 = load i64, i64* @STDIN_FILENO
%211 = call i64 @dup3(i32 %209, i64 %210, i32 0)
%212 = load i64, i64* @STDIN_FILENO
%213 = icmp ne i64 %211, %212
br i1 %213, label %214, label %218
214: ; preds = %208
%215 = load i32, i32* @stderr
%216 = call i32 (i32, i8*, ...) @fprintf(i32 %215, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.22, i64 0, i64 0))
%217 = call i32 @exit(i32 1)
unreachable
218: ; preds = %208
%219 = load i32, i32* %13
%220 = load i64, i64* @STDOUT_FILENO
%221 = call i64 @dup3(i32 %219, i64 %220, i32 0)
%222 = load i64, i64* @STDOUT_FILENO
%223 = icmp ne i64 %221, %222
br i1 %223, label %224, label %228
224: ; preds = %218
%225 = load i32, i32* @stderr
%226 = call i32 (i32, i8*, ...) @fprintf(i32 %225, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.23, i64 0, i64 0))
%227 = call i32 @exit(i32 1)
unreachable
228: ; preds = %218
%229 = load i32, i32* %13
%230 = load i64, i64* @STDERR_FILENO
%231 = call i64 @dup3(i32 %229, i64 %230, i32 0)
%232 = load i64, i64* @STDERR_FILENO
%233 = icmp ne i64 %231, %232
br i1 %233, label %234, label %238
234: ; preds = %228
%235 = load i32, i32* @stderr
%236 = call i32 (i32, i8*, ...) @fprintf(i32 %235, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.24, i64 0, i64 0))
%237 = call i32 @exit(i32 1)
unreachable
238: ; preds = %228
br label %239
239: ; preds = %238, %196
store i32 1, i32* %16
br label %266
240: ; preds = %181
%241 = call i32 @clone_parent(i32* %3)
store i32 %241, i32* %10
%242 = load i32, i32* %10
%243 = icmp slt i32 %242, 0
br i1 %243, label %244, label %248
244: ; preds = %240
%245 = load i32, i32* @stderr
%246 = call i32 (i32, i8*, ...) @fprintf(i32 %245, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.25, i64 0, i64 0))
%247 = call i32 @exit(i32 1)
unreachable
248: ; preds = %240
%249 = trunc i64 %29 to i32
%250 = load i32, i32* %10
%251 = call i32 @snprintf(i8* %31, i32 %249, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.26, i64 0, i64 0), i32 %250)
store i32 %251, i32* %11
%252 = load i32, i32* %12
%253 = load i32, i32* %11
%254 = call i32 @write(i32 %252, i8* %31, i32 %253)
%255 = load i32, i32* %11
%256 = icmp ne i32 %254, %255
br i1 %256, label %257, label %264
257: ; preds = %248
%258 = load i32, i32* @stderr
%259 = call i32 (i32, i8*, ...) @fprintf(i32 %258, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.27, i64 0, i64 0))
%260 = load i32, i32* %10
%261 = load i32, i32* @SIGKILL
%262 = call i32 @kill(i32 %260, i32 %261)
%263 = call i32 @exit(i32 1)
unreachable
264: ; preds = %248
%265 = call i32 @exit(i32 0)
unreachable
266: ; preds = %239, %35
%267 = load i8*, i8** %4
ret void
}

LLVM IR (-O2):
%struct.stat = type { i64 }
@.str = [4 x i8] c"ipc\00"
@.str.1 = [4 x i8] c"uts\00"
@.str.2 = [4 x i8] c"net\00"
@.str.3 = [4 x i8] c"pid\00"
@.str.4 = [4 x i8] c"mnt\00"
@.str.5 = [5 x i8] c"user\00"
@PATH_MAX = global i32 0
@.str.6 = [22 x i8] c"_LIBCONTAINER_INITPID\00"
@.str.7 = [3 x i8] c"%d\00"
@stderr = global i32 0
@.str.8 = [52 x i8] c"nsenter: Unable to parse _LIBCONTAINER_INITPID: %m\0A\00"
@.str.9 = [23 x i8] c"_LIBCONTAINER_INITPIPE\00"
@.str.10 = [35 x i8] c"nsenter: Child pipe not found: %m\0A\00"
@.str.11 = [53 x i8] c"nsenter: Unable to parse _LIBCONTAINER_INITPIPE: %m\0A\00"
@.str.12 = [27 x i8] c"_LIBCONTAINER_CONSOLE_PATH\00"
@O_RDWR = global i32 0
@.str.13 = [40 x i8] c"nsenter: Failed to open console %s: %m\0A\00"
@.str.14 = [12 x i8] c"/proc/%d/ns\00"
@O_DIRECTORY = global i32 0
@O_RDONLY = global i32 0
@.str.15 = [34 x i8] c"nsenter: Failed to open \22%s\22: %m\0A\00"
@.str.16 = [14 x i8] c"/proc/self/ns\00"
@.str.17 = [43 x i8] c"nsenter: Failed to open /proc/self/ns: %m\0A\00"
@errno = global i64 0
@ENOENT = global i64 0
@.str.18 = [50 x i8] c"nsenter: Failed to open ns file %s for ns %s: %m\0A\00"
@.str.19 = [37 x i8] c"nsenter: Failed to setns for %s: %m\0A\00"
@.str.20 = [28 x i8] c"nsenter: setsid failed: %m\0A\00"
@TIOCSCTTY = global i32 0
@.str.21 = [37 x i8] c"nsenter: ioctl TIOCSCTTY failed: %m\0A\00"
@STDIN_FILENO = global i64 0
@.str.22 = [30 x i8] c"nsenter: Failed to dup 0: %m\0A\00"
@STDOUT_FILENO = global i64 0
@.str.23 = [30 x i8] c"nsenter: Failed to dup 1: %m\0A\00"
@STDERR_FILENO = global i64 0
@.str.24 = [30 x i8] c"nsenter: Failed to dup 2: %m\0A\00"
@.str.25 = [29 x i8] c"nsenter: Unable to fork: %m\0A\00"
@.str.26 = [16 x i8] c"{ \22pid\22 : %d }\0A\00"
@.str.27 = [41 x i8] c"nsenter: Unable to send a child pid: %m\0A\00"
@SIGKILL = global i32 0
define void @nsexec() {
%1 = alloca [6 x i8*]
%2 = alloca i32
%3 = alloca %struct.stat
%4 = alloca %struct.stat
%5 = bitcast [6 x i8*]* %1 to i8*
%6 = getelementptr inbounds [6 x i8*], [6 x i8*]* %1, i64 0, i64 0
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8** %6
%7 = getelementptr inbounds [6 x i8*], [6 x i8*]* %1, i64 0, i64 1
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8** %7
%8 = getelementptr inbounds [6 x i8*], [6 x i8*]* %1, i64 0, i64 2
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8** %8
%9 = getelementptr inbounds [6 x i8*], [6 x i8*]* %1, i64 0, i64 3
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8** %9
%10 = getelementptr inbounds [6 x i8*], [6 x i8*]* %1, i64 0, i64 4
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8** %10
%11 = getelementptr inbounds [6 x i8*], [6 x i8*]* %1, i64 0, i64 5
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i8** %11
%12 = bitcast i32* %2 to i8*
%13 = load i32, i32* @PATH_MAX
%14 = zext i32 %13 to i64
%15 = call i8* @llvm.stacksave()
%16 = alloca i8, i64 %14
%17 = call i8* @getenv(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0))
%18 = icmp eq i8* %17, null
br i1 %18, label %191, label %19
19: ; preds = %0
%20 = call i32 @atoi(i8* %17)
%21 = call i32 @snprintf(i8* %16, i32 %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32 %20)
%22 = call i64 @strcmp(i8* %17, i8* %16)
%23 = icmp eq i64 %22, 0
br i1 %23, label %28, label %24
24: ; preds = %19
%25 = load i32, i32* @stderr
%26 = call i32 (i32, i8*, ...) @fprintf(i32 %25, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.8, i64 0, i64 0))
%27 = call i32 @exit(i32 1)
unreachable
28: ; preds = %19
%29 = call i8* @getenv(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.9, i64 0, i64 0))
%30 = icmp eq i8* %29, null
br i1 %30, label %31, label %35
31: ; preds = %28
%32 = load i32, i32* @stderr
%33 = call i32 (i32, i8*, ...) @fprintf(i32 %32, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.10, i64 0, i64 0))
%34 = call i32 @exit(i32 1)
unreachable
35: ; preds = %28
%36 = call i32 @atoi(i8* %29)
%37 = call i32 @snprintf(i8* %16, i32 %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32 %36)
%38 = call i64 @strcmp(i8* %29, i8* %16)
%39 = icmp eq i64 %38, 0
br i1 %39, label %44, label %40
40: ; preds = %35
%41 = load i32, i32* @stderr
%42 = call i32 (i32, i8*, ...) @fprintf(i32 %41, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.11, i64 0, i64 0))
%43 = call i32 @exit(i32 1)
unreachable
44: ; preds = %35
%45 = call i8* @getenv(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.12, i64 0, i64 0))
%46 = icmp eq i8* %45, null
br i1 %46, label %55, label %47
47: ; preds = %44
%48 = load i32, i32* @O_RDWR
%49 = call i32 @open(i8* %45, i32 %48)
%50 = icmp slt i32 %49, 0
br i1 %50, label %51, label %55
51: ; preds = %47
%52 = load i32, i32* @stderr
%53 = call i32 (i32, i8*, ...) @fprintf(i32 %52, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.13, i64 0, i64 0), i8* %45)
%54 = call i32 @exit(i32 1)
unreachable
55: ; preds = %47, %44
%56 = phi i32 [ %49, %47 ], [ -1, %44 ]
%57 = load i32, i32* @PATH_MAX
%58 = add nsw i32 %57, -1
%59 = call i32 @snprintf(i8* %16, i32 %58, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.14, i64 0, i64 0), i32 %20)
%60 = load i32, i32* @O_DIRECTORY
%61 = load i32, i32* @O_RDONLY
%62 = or i32 %61, %60
%63 = call i32 @open(i8* %16, i32 %62)
%64 = icmp eq i32 %63, -1
br i1 %64, label %65, label %69
65: ; preds = %55
%66 = load i32, i32* @stderr
%67 = call i32 (i32, i8*, ...) @fprintf(i32 %66, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.15, i64 0, i64 0), i8* %16)
%68 = call i32 @exit(i32 1)
unreachable
69: ; preds = %55
%70 = load i32, i32* @O_DIRECTORY
%71 = load i32, i32* @O_RDONLY
%72 = or i32 %71, %70
%73 = call i32 @open(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.16, i64 0, i64 0), i32 %72)
%74 = icmp eq i32 %73, -1
br i1 %74, label %80, label %75
75: ; preds = %69
%76 = bitcast %struct.stat* %3 to i8*
%77 = bitcast %struct.stat* %4 to i8*
%78 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0
%79 = getelementptr inbounds %struct.stat, %struct.stat* %4, i64 0, i32 0
br label %84
80: ; preds = %69
%81 = load i32, i32* @stderr
%82 = call i32 (i32, i8*, ...) @fprintf(i32 %81, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.17, i64 0, i64 0))
%83 = call i32 @exit(i32 1)
unreachable
84: ; preds = %120, %75
%85 = phi i8* [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), %75 ], [ %122, %120 ]
%86 = phi i64 [ 0, %75 ], [ %118, %120 ]
%87 = call i32 @fstatat(i32 %63, i8* %85, %struct.stat* %3, i32 0)
%88 = icmp eq i32 %87, -1
br i1 %88, label %89, label %93
89: ; preds = %84
%90 = load i64, i64* @errno
%91 = load i64, i64* @ENOENT
%92 = icmp eq i64 %90, %91
br i1 %92, label %117, label %93
93: ; preds = %89, %84
%94 = call i32 @fstatat(i32 %73, i8* %85, %struct.stat* %4, i32 0)
%95 = icmp eq i32 %94, -1
br i1 %95, label %100, label %96
96: ; preds = %93
%97 = load i64, i64* %78
%98 = load i64, i64* %79
%99 = icmp eq i64 %97, %98
br i1 %99, label %117, label %100
100: ; preds = %96, %93
%101 = load i32, i32* @O_RDONLY
%102 = call i32 @openat(i32 %63, i8* %85, i32 %101)
%103 = icmp eq i32 %102, -1
br i1 %103, label %104, label %108
104: ; preds = %100
%105 = load i32, i32* @stderr
%106 = call i32 (i32, i8*, ...) @fprintf(i32 %105, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.18, i64 0, i64 0), i8* %16, i8* %85)
%107 = call i32 @exit(i32 1)
unreachable
108: ; preds = %100
%109 = call i32 @setns(i32 %102, i32 0)
%110 = icmp eq i32 %109, -1
br i1 %110, label %111, label %115
111: ; preds = %108
%112 = load i32, i32* @stderr
%113 = call i32 (i32, i8*, ...) @fprintf(i32 %112, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.19, i64 0, i64 0), i8* %85)
%114 = call i32 @exit(i32 1)
unreachable
115: ; preds = %108
%116 = call i32 @close(i32 %102)
br label %117
117: ; preds = %96, %89, %115
%118 = add nuw nsw i64 %86, 1
%119 = icmp eq i64 %118, 6
br i1 %119, label %123, label %120
120: ; preds = %117
%121 = getelementptr inbounds [6 x i8*], [6 x i8*]* %1, i64 0, i64 %118
%122 = load i8*, i8** %121
br label %84
123: ; preds = %117
%124 = call i32 @close(i32 %73)
%125 = call i32 @close(i32 %63)
%126 = call i32 @setjmp(i32 undef)
%127 = icmp eq i32 %126, 1
br i1 %127, label %128, label %172
128: ; preds = %123
%129 = call i32 (...) @setsid()
%130 = icmp eq i32 %129, -1
br i1 %130, label %131, label %135
131: ; preds = %128
%132 = load i32, i32* @stderr
%133 = call i32 (i32, i8*, ...) @fprintf(i32 %132, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.20, i64 0, i64 0))
%134 = call i32 @exit(i32 1)
unreachable
135: ; preds = %128
%136 = icmp eq i32 %56, -1
br i1 %136, label %191, label %137
137: ; preds = %135
%138 = load i32, i32* @TIOCSCTTY
%139 = call i32 @ioctl(i32 %56, i32 %138, i32 0)
%140 = icmp eq i32 %139, -1
br i1 %140, label %141, label %145
141: ; preds = %137
%142 = load i32, i32* @stderr
%143 = call i32 (i32, i8*, ...) @fprintf(i32 %142, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.21, i64 0, i64 0))
%144 = call i32 @exit(i32 1)
unreachable
145: ; preds = %137
%146 = load i64, i64* @STDIN_FILENO
%147 = call i64 @dup3(i32 %56, i64 %146, i32 0)
%148 = load i64, i64* @STDIN_FILENO
%149 = icmp eq i64 %147, %148
br i1 %149, label %154, label %150
150: ; preds = %145
%151 = load i32, i32* @stderr
%152 = call i32 (i32, i8*, ...) @fprintf(i32 %151, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.22, i64 0, i64 0))
%153 = call i32 @exit(i32 1)
unreachable
154: ; preds = %145
%155 = load i64, i64* @STDOUT_FILENO
%156 = call i64 @dup3(i32 %56, i64 %155, i32 0)
%157 = load i64, i64* @STDOUT_FILENO
%158 = icmp eq i64 %156, %157
br i1 %158, label %163, label %159
159: ; preds = %154
%160 = load i32, i32* @stderr
%161 = call i32 (i32, i8*, ...) @fprintf(i32 %160, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.23, i64 0, i64 0))
%162 = call i32 @exit(i32 1)
unreachable
163: ; preds = %154
%164 = load i64, i64* @STDERR_FILENO
%165 = call i64 @dup3(i32 %56, i64 %164, i32 0)
%166 = load i64, i64* @STDERR_FILENO
%167 = icmp eq i64 %165, %166
br i1 %167, label %191, label %168
168: ; preds = %163
%169 = load i32, i32* @stderr
%170 = call i32 (i32, i8*, ...) @fprintf(i32 %169, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.24, i64 0, i64 0))
%171 = call i32 @exit(i32 1)
unreachable
172: ; preds = %123
%173 = call i32 @clone_parent(i32* %2)
%174 = icmp slt i32 %173, 0
br i1 %174, label %175, label %179
175: ; preds = %172
%176 = load i32, i32* @stderr
%177 = call i32 (i32, i8*, ...) @fprintf(i32 %176, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.25, i64 0, i64 0))
%178 = call i32 @exit(i32 1)
unreachable
179: ; preds = %172
%180 = call i32 @snprintf(i8* %16, i32 %13, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.26, i64 0, i64 0), i32 %173)
%181 = call i32 @write(i32 %36, i8* %16, i32 %180)
%182 = icmp eq i32 %181, %180
br i1 %182, label %189, label %183
183: ; preds = %179
%184 = load i32, i32* @stderr
%185 = call i32 (i32, i8*, ...) @fprintf(i32 %184, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.27, i64 0, i64 0))
%186 = load i32, i32* @SIGKILL
%187 = call i32 @kill(i32 %173, i32 %186)
%188 = call i32 @exit(i32 1)
unreachable
189: ; preds = %179
%190 = call i32 @exit(i32 0)
unreachable
191: ; preds = %135, %163, %0
ret void
}