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

/* Variables and functions */
int /*<<< orphan*/ AT_SYMLINK_NOFOLLOW;
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__ dup2(int, scalar_t__);
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"};
  const int num = sizeof(namespaces) / sizeof(char *);
  jmp_buf env;
  char buf[PATH_MAX], *val;
  int i, 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);
  }
  for (i = 0; i < num; i++) {
    struct stat st;
    int fd;
    if (fstatat(tfd, namespaces[i], &st, AT_SYMLINK_NOFOLLOW) == -1) {
      if (errno == ENOENT)
        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);
  }
  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 (dup2(consolefd, STDIN_FILENO) != STDIN_FILENO) {
        fprintf(stderr, "nsenter: "
                        "Failed to dup 0"
                        ": %m\n");
        exit(1);
      }
      if (dup2(consolefd, STDOUT_FILENO) != STDOUT_FILENO) {
        fprintf(stderr, "nsenter: "
                        "Failed to dup 1"
                        ": %m\n");
        exit(1);
      }
      if (dup2(consolefd, STDERR_FILENO) != 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    $0xa0,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,-0x20(%rbp)
movaps %xmm0,-0x30(%rbp)
movq   $0x0,-0x10(%rbp)
lea    0xdbb(%rip),%rax
mov    %rax,-0x30(%rbp)
lea    0xdb4(%rip),%rax
mov    %rax,-0x28(%rbp)
lea    0xdad(%rip),%rax
mov    %rax,-0x20(%rbp)
lea    0xda6(%rip),%rax
mov    %rax,-0x18(%rbp)
lea    0xd9f(%rip),%rax
mov    %rax,-0x10(%rbp)
movl   $0x5,-0x34(%rbp)
mov    0x2d6d(%rip),%rax
mov    (%rax),%eax
mov    %rax,-0x98(%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,-0x90(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x48(%rbp)
movl   $0xffffffff,-0x68(%rbp)
lea    0xd54(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x50(%rbp)
cmpq   $0x0,-0x50(%rbp)
jne    12e0 <nsexec+0xc0>
movl   $0x1,-0x7c(%rbp)
jmp    17e8 <nsexec+0x5c8>
mov    -0x50(%rbp),%rdi
call   1120 <atoi@plt>
mov    -0x90(%rbp),%rdi
mov    %eax,%ecx
mov    -0x98(%rbp),%rax
mov    %ecx,-0x6c(%rbp)
mov    %eax,%esi
mov    -0x6c(%rbp),%ecx
lea    0xd22(%rip),%rdx
call   1080 <snprintf@plt>
mov    -0x90(%rbp),%rsi
mov    -0x50(%rbp),%rdi
call   10d0 <strcmp@plt>
cmp    $0x0,%rax
je     1348 <nsexec+0x128>
mov    0x2c8a(%rip),%rax
mov    (%rax),%edi
lea    0xcf6(%rip),%rsi
mov    $0x0,%al
call   10e0 <fprintf@plt>
mov    $0x1,%edi
call   1130 <exit@plt>
lea    0xd12(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x50(%rbp)
cmpq   $0x0,-0x50(%rbp)
jne    1384 <nsexec+0x164>
mov    0x2c4e(%rip),%rax
mov    (%rax),%edi
lea    0xd05(%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    -0x90(%rbp),%rdi
mov    %eax,%ecx
mov    -0x98(%rbp),%rax
mov    %ecx,-0x64(%rbp)
mov    %eax,%esi
mov    -0x64(%rbp),%ecx
lea    0xc7e(%rip),%rdx
call   1080 <snprintf@plt>
mov    -0x90(%rbp),%rsi
mov    -0x50(%rbp),%rdi
call   10d0 <strcmp@plt>
cmp    $0x0,%rax
je     13ec <nsexec+0x1cc>
mov    0x2be6(%rip),%rax
mov    (%rax),%edi
lea    0xcc0(%rip),%rsi
mov    $0x0,%al
call   10e0 <fprintf@plt>
mov    $0x1,%edi
call   1130 <exit@plt>
lea    0xcdd(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x78(%rbp)
cmpq   $0x0,-0x78(%rbp)
je     1450 <nsexec+0x230>
mov    -0x78(%rbp),%rdi
mov    0x2bc6(%rip),%rax
mov    (%rax),%esi
call   1110 <open@plt>
mov    %eax,-0x68(%rbp)
cmpl   $0x0,-0x68(%rbp)
jge    144b <nsexec+0x22b>
mov    0x2b8b(%rip),%rax
mov    (%rax),%edi
mov    -0x78(%rbp),%rdx
lea    0xcb1(%rip),%rsi
mov    $0x0,%al
call   10e0 <fprintf@plt>
mov    $0x1,%edi
call   1130 <exit@plt>
jmp    1450 <nsexec+0x230>
mov    -0x90(%rbp),%rdi
mov    0x2b92(%rip),%rax
mov    (%rax),%esi
sub    $0x1,%esi
mov    -0x6c(%rbp),%ecx
lea    0xca6(%rip),%rdx
call   1080 <snprintf@plt>
mov    -0x90(%rbp),%rdi
mov    0x2b40(%rip),%rax
mov    (%rax),%esi
mov    0x2b47(%rip),%rax
or     (%rax),%esi
call   1110 <open@plt>
mov    %eax,-0x58(%rbp)
cmpl   $0xffffffff,-0x58(%rbp)
jne    14c5 <nsexec+0x2a5>
mov    -0x90(%rbp),%rdx
mov    0x2b0d(%rip),%rax
mov    (%rax),%edi
lea    0xc6b(%rip),%rsi
mov    $0x0,%al
call   10e0 <fprintf@plt>
mov    $0x1,%edi
call   1130 <exit@plt>
movl   $0x0,-0x54(%rbp)
cmpl   $0x5,-0x54(%rbp)
jge    15d8 <nsexec+0x3b8>
mov    -0x58(%rbp),%edi
movslq -0x54(%rbp),%rax
mov    -0x30(%rbp,%rax,8),%rsi
mov    0x2aa7(%rip),%rax
mov    (%rax),%ecx
lea    -0x80(%rbp),%rdx
call   1140 <fstatat@plt>
cmp    $0xffffffff,%eax
jne    1521 <nsexec+0x301>
mov    0x2aac(%rip),%rax
mov    (%rax),%rax
mov    0x2a6a(%rip),%rcx
cmp    (%rcx),%rax
jne    151c <nsexec+0x2fc>
jmp    15ca <nsexec+0x3aa>
jmp    1521 <nsexec+0x301>
mov    -0x58(%rbp),%edi
movslq -0x54(%rbp),%rax
mov    -0x30(%rbp,%rax,8),%rsi
mov    0x2a9c(%rip),%rax
mov    (%rax),%edx
call   1060 <openat@plt>
mov    %eax,-0x84(%rbp)
cmpl   $0xffffffff,-0x84(%rbp)
jne    157f <nsexec+0x35f>
mov    -0x90(%rbp),%rdx
mov    0x2a5c(%rip),%rax
mov    (%rax),%edi
movslq -0x54(%rbp),%rax
mov    -0x30(%rbp,%rax,8),%rcx
lea    0xbd3(%rip),%rsi
mov    $0x0,%al
call   10e0 <fprintf@plt>
mov    $0x1,%edi
call   1130 <exit@plt>
mov    -0x84(%rbp),%edi
xor    %esi,%esi
call   1090 <setns@plt>
cmp    $0xffffffff,%eax
jne    15bf <nsexec+0x39f>
mov    0x2a1c(%rip),%rax
mov    (%rax),%edi
movslq -0x54(%rbp),%rax
mov    -0x30(%rbp,%rax,8),%rdx
lea    0xbc5(%rip),%rsi
mov    $0x0,%al
call   10e0 <fprintf@plt>
mov    $0x1,%edi
call   1130 <exit@plt>
mov    -0x84(%rbp),%edi
call   10b0 <close@plt>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    14cc <nsexec+0x2ac>
mov    -0x38(%rbp),%edi
call   1100 <setjmp@plt>
cmp    $0x1,%eax
jne    173b <nsexec+0x51b>
mov    $0x0,%al
call   10c0 <setsid@plt>
cmp    $0xffffffff,%eax
jne    161a <nsexec+0x3fa>
mov    0x29b8(%rip),%rax
mov    (%rax),%edi
lea    0xb8f(%rip),%rsi
mov    $0x0,%al
call   10e0 <fprintf@plt>
mov    $0x1,%edi
call   1130 <exit@plt>
cmpl   $0xffffffff,-0x68(%rbp)
je     172f <nsexec+0x50f>
mov    -0x68(%rbp),%edi
mov    0x296a(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10a0 <ioctl@plt>
cmp    $0xffffffff,%eax
jne    1661 <nsexec+0x441>
mov    0x2971(%rip),%rax
mov    (%rax),%edi
lea    0xb64(%rip),%rsi
mov    $0x0,%al
call   10e0 <fprintf@plt>
mov    $0x1,%edi
call   1130 <exit@plt>
mov    -0x68(%rbp),%edi
mov    0x291d(%rip),%rax
mov    (%rax),%rsi
call   1070 <dup2@plt>
mov    0x290e(%rip),%rcx
cmp    (%rcx),%rax
je     16a4 <nsexec+0x484>
mov    0x292e(%rip),%rax
mov    (%rax),%edi
lea    0xb46(%rip),%rsi
mov    $0x0,%al
call   10e0 <fprintf@plt>
mov    $0x1,%edi
call   1130 <exit@plt>
mov    -0x68(%rbp),%edi
mov    0x293a(%rip),%rax
mov    (%rax),%rsi
call   1070 <dup2@plt>
mov    0x292b(%rip),%rcx
cmp    (%rcx),%rax
je     16e7 <nsexec+0x4c7>
mov    0x28eb(%rip),%rax
mov    (%rax),%edi
lea    0xb21(%rip),%rsi
mov    $0x0,%al
call   10e0 <fprintf@plt>
mov    $0x1,%edi
call   1130 <exit@plt>
mov    -0x68(%rbp),%edi
mov    0x28b7(%rip),%rax
mov    (%rax),%rsi
call   1070 <dup2@plt>
mov    0x28a8(%rip),%rcx
cmp    (%rcx),%rax
je     172a <nsexec+0x50a>
mov    0x28a8(%rip),%rax
mov    (%rax),%edi
lea    0xafc(%rip),%rsi
mov    $0x0,%al
call   10e0 <fprintf@plt>
mov    $0x1,%edi
call   1130 <exit@plt>
jmp    172f <nsexec+0x50f>
movl   $0x1,-0x7c(%rbp)
jmp    17e8 <nsexec+0x5c8>
lea    -0x38(%rbp),%rdi
call   1040 <clone_parent@plt>
mov    %eax,-0x5c(%rbp)
cmpl   $0x0,-0x5c(%rbp)
jge    1772 <nsexec+0x552>
mov    0x2860(%rip),%rax
mov    (%rax),%edi
lea    0xad2(%rip),%rsi
mov    $0x0,%al
call   10e0 <fprintf@plt>
mov    $0x1,%edi
call   1130 <exit@plt>
mov    -0x90(%rbp),%rdi
mov    -0x98(%rbp),%rax
mov    %eax,%esi
mov    -0x5c(%rbp),%ecx
lea    0xac4(%rip),%rdx
call   1080 <snprintf@plt>
mov    -0x90(%rbp),%rsi
mov    %eax,-0x60(%rbp)
mov    -0x64(%rbp),%edi
mov    -0x60(%rbp),%edx
call   1050 <write@plt>
cmp    -0x60(%rbp),%eax
je     17e1 <nsexec+0x5c1>
mov    0x2802(%rip),%rax
mov    (%rax),%edi
lea    0xaa1(%rip),%rsi
mov    $0x0,%al
call   10e0 <fprintf@plt>
mov    -0x5c(%rbp),%edi
mov    0x27d0(%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    $0x28,%rsp
mov    %rsp,%r15
mov    0x2db5(%rip),%rax
mov    (%rax),%eax
mov    %eax,%ebx
mov    %rsp,%r13
lea    0xf(%rbx),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r13
mov    %r13,%rsp
lea    0xdbd(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     1640 <nsexec+0x420>
mov    %ebx,%r12d
mov    %rax,%rbx
mov    %rax,%rdi
call   1120 <atoi@plt>
mov    %eax,%r14d
lea    0xdad(%rip),%rdx
mov    %r13,%rdi
mov    %r12d,-0x34(%rbp)
mov    %r12d,%esi
mov    %eax,%ecx
call   1080 <snprintf@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   10d0 <strcmp@plt>
test   %rax,%rax
jne    1679 <nsexec+0x459>
lea    0xdb8(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     168e <nsexec+0x46e>
mov    %rax,%rbx
mov    %rax,%rdi
call   1120 <atoi@plt>
mov    %eax,%r12d
lea    0xd5e(%rip),%rdx
mov    %r13,%rdi
mov    -0x34(%rbp),%esi
mov    %eax,%ecx
call   1080 <snprintf@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   10d0 <strcmp@plt>
test   %rax,%rax
jne    16a3 <nsexec+0x483>
mov    %r15,-0x48(%rbp)
lea    0xdd8(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     1336 <nsexec+0x116>
mov    %rax,%r15
mov    0x2ccc(%rip),%rax
mov    (%rax),%esi
mov    %r15,%rdi
call   1110 <open@plt>
mov    %eax,%ecx
test   %eax,%eax
jns    133b <nsexec+0x11b>
mov    0x2c95(%rip),%rax
mov    (%rax),%edi
lea    0xdbf(%rip),%rsi
xor    %eax,%eax
mov    %r15,%rdx
jmp    1747 <nsexec+0x527>
mov    $0xffffffff,%ecx
mov    %r12d,-0x3c(%rbp)
mov    %ecx,-0x38(%rbp)
mov    0x2ca7(%rip),%rax
mov    (%rax),%esi
add    $0xffffffff,%esi
lea    0xdbe(%rip),%rdx
mov    %r13,%rdi
mov    %r14d,%ecx
call   1080 <snprintf@plt>
mov    0x2c59(%rip),%rax
mov    0x2c62(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    %r13,%rdi
call   1110 <open@plt>
cmp    $0xffffffff,%eax
je     16b8 <nsexec+0x498>
mov    %eax,%r14d
mov    0x2c03(%rip),%r12
mov    (%r12),%ecx
lea    0xc68(%rip),%r15
lea    -0x30(%rbp),%rdx
mov    %eax,%edi
mov    %r15,%rsi
call   1140 <fstatat@plt>
cmp    $0xffffffff,%eax
jne    13c1 <nsexec+0x1a1>
mov    0x2bfe(%rip),%rax
mov    (%rax),%rax
mov    0x2bbc(%rip),%rcx
cmp    (%rcx),%rax
je     13f9 <nsexec+0x1d9>
mov    0x2c08(%rip),%rax
mov    (%rax),%edx
mov    %r14d,%edi
mov    %r15,%rsi
call   1060 <openat@plt>
cmp    $0xffffffff,%eax
je     1652 <nsexec+0x432>
mov    %eax,%ebx
xor    %esi,%esi
mov    %eax,%edi
call   1090 <setns@plt>
cmp    $0xffffffff,%eax
je     170a <nsexec+0x4ea>
mov    %ebx,%edi
call   10b0 <close@plt>
mov    (%r12),%ecx
lea    0xc00(%rip),%r15
lea    -0x30(%rbp),%rdx
mov    %r14d,%edi
mov    %r15,%rsi
call   1140 <fstatat@plt>
cmp    $0xffffffff,%eax
jne    142e <nsexec+0x20e>
mov    0x2b91(%rip),%rax
mov    (%rax),%rax
mov    0x2b4f(%rip),%rcx
cmp    (%rcx),%rax
je     1466 <nsexec+0x246>
mov    0x2b9b(%rip),%rax
mov    (%rax),%edx
mov    %r14d,%edi
mov    %r15,%rsi
call   1060 <openat@plt>
cmp    $0xffffffff,%eax
je     1652 <nsexec+0x432>
mov    %eax,%ebx
xor    %esi,%esi
mov    %eax,%edi
call   1090 <setns@plt>
cmp    $0xffffffff,%eax
je     1713 <nsexec+0x4f3>
mov    %ebx,%edi
call   10b0 <close@plt>
mov    (%r12),%ecx
lea    0xb97(%rip),%r15
lea    -0x30(%rbp),%rdx
mov    %r14d,%edi
mov    %r15,%rsi
call   1140 <fstatat@plt>
cmp    $0xffffffff,%eax
jne    149b <nsexec+0x27b>
mov    0x2b24(%rip),%rax
mov    (%rax),%rax
mov    0x2ae2(%rip),%rcx
cmp    (%rcx),%rax
je     14d3 <nsexec+0x2b3>
mov    0x2b2e(%rip),%rax
mov    (%rax),%edx
mov    %r14d,%edi
mov    %r15,%rsi
call   1060 <openat@plt>
cmp    $0xffffffff,%eax
je     1652 <nsexec+0x432>
mov    %eax,%ebx
xor    %esi,%esi
mov    %eax,%edi
call   1090 <setns@plt>
cmp    $0xffffffff,%eax
je     171c <nsexec+0x4fc>
mov    %ebx,%edi
call   10b0 <close@plt>
mov    (%r12),%ecx
lea    0xb2e(%rip),%r15
lea    -0x30(%rbp),%rdx
mov    %r14d,%edi
mov    %r15,%rsi
call   1140 <fstatat@plt>
cmp    $0xffffffff,%eax
jne    1508 <nsexec+0x2e8>
mov    0x2ab7(%rip),%rax
mov    (%rax),%rax
mov    0x2a75(%rip),%rcx
cmp    (%rcx),%rax
je     1540 <nsexec+0x320>
mov    0x2ac1(%rip),%rax
mov    (%rax),%edx
mov    %r14d,%edi
mov    %r15,%rsi
call   1060 <openat@plt>
cmp    $0xffffffff,%eax
je     1652 <nsexec+0x432>
mov    %eax,%ebx
xor    %esi,%esi
mov    %eax,%edi
call   1090 <setns@plt>
cmp    $0xffffffff,%eax
je     1725 <nsexec+0x505>
mov    %ebx,%edi
call   10b0 <close@plt>
mov    (%r12),%ecx
lea    0xac5(%rip),%r15
lea    -0x30(%rbp),%rdx
mov    %r14d,%edi
mov    %r15,%rsi
call   1140 <fstatat@plt>
cmp    $0xffffffff,%eax
jne    1575 <nsexec+0x355>
mov    0x2a4a(%rip),%rax
mov    (%rax),%rax
mov    0x2a08(%rip),%rcx
cmp    (%rcx),%rax
je     15ad <nsexec+0x38d>
mov    0x2a54(%rip),%rax
mov    (%rax),%edx
mov    %r14d,%edi
mov    %r15,%rsi
call   1060 <openat@plt>
cmp    $0xffffffff,%eax
je     1652 <nsexec+0x432>
mov    %eax,%ebx
xor    %esi,%esi
mov    %eax,%edi
call   1090 <setns@plt>
cmp    $0xffffffff,%eax
je     172e <nsexec+0x50e>
mov    %ebx,%edi
call   10b0 <close@plt>
call   1100 <setjmp@plt>
cmp    $0x1,%eax
jne    16cf <nsexec+0x4af>
xor    %eax,%eax
call   10c0 <setsid@plt>
cmp    $0xffffffff,%eax
mov    -0x48(%rbp),%r15
je     16f5 <nsexec+0x4d5>
mov    -0x38(%rbp),%ebx
cmp    $0xffffffff,%ebx
je     1640 <nsexec+0x420>
mov    0x29ba(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
mov    %ebx,%edi
call   10a0 <ioctl@plt>
cmp    $0xffffffff,%eax
je     1756 <nsexec+0x536>
mov    0x298f(%rip),%r14
mov    (%r14),%rsi
mov    %ebx,%edi
call   1070 <dup2@plt>
cmp    (%r14),%rax
jne    1768 <nsexec+0x548>
mov    0x29d5(%rip),%r14
mov    (%r14),%rsi
mov    %ebx,%edi
call   1070 <dup2@plt>
cmp    (%r14),%rax
jne    177a <nsexec+0x55a>
mov    0x297b(%rip),%r14
mov    (%r14),%rsi
mov    %ebx,%edi
call   1070 <dup2@plt>
cmp    (%r14),%rax
jne    178c <nsexec+0x56c>
mov    %r15,%rsp
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x295f(%rip),%rax
mov    (%rax),%edi
lea    0xadf(%rip),%rsi
xor    %eax,%eax
mov    %r13,%rdx
mov    %r15,%rcx
call   10e0 <fprintf@plt>
mov    $0x1,%edi
call   1130 <exit@plt>
mov    0x2938(%rip),%rax
mov    (%rax),%edi
lea    0x9a4(%rip),%rsi
jmp    179c <nsexec+0x57c>
mov    0x2923(%rip),%rax
mov    (%rax),%edi
lea    0x9da(%rip),%rsi
jmp    179c <nsexec+0x57c>
mov    0x290e(%rip),%rax
mov    (%rax),%edi
lea    0x9e8(%rip),%rsi
jmp    179c <nsexec+0x57c>
mov    0x28f9(%rip),%rax
mov    (%rax),%edi
lea    0xa57(%rip),%rsi
xor    %eax,%eax
mov    %r13,%rdx
jmp    1747 <nsexec+0x527>
lea    -0x4c(%rbp),%rdi
call   1040 <clone_parent@plt>
test   %eax,%eax
jns    17ad <nsexec+0x58d>
mov    0x28d1(%rip),%rax
mov    (%rax),%edi
lea    0xb43(%rip),%rsi
jmp    179c <nsexec+0x57c>
mov    0x28bc(%rip),%rax
mov    (%rax),%edi
lea    0xa93(%rip),%rsi
jmp    179c <nsexec+0x57c>
lea    0x8ef(%rip),%rdx
jmp    1735 <nsexec+0x515>
lea    0x8ea(%rip),%rdx
jmp    1735 <nsexec+0x515>
lea    0x8e5(%rip),%rdx
jmp    1735 <nsexec+0x515>
lea    0x8e0(%rip),%rdx
jmp    1735 <nsexec+0x515>
lea    0x8db(%rip),%rdx
mov    0x287c(%rip),%rax
mov    (%rax),%edi
lea    0xa2e(%rip),%rsi
xor    %eax,%eax
call   10e0 <fprintf@plt>
mov    $0x1,%edi
call   1130 <exit@plt>
mov    0x285b(%rip),%rax
mov    (%rax),%edi
lea    0xa4e(%rip),%rsi
jmp    179c <nsexec+0x57c>
mov    0x2849(%rip),%rax
mov    (%rax),%edi
lea    0xa61(%rip),%rsi
jmp    179c <nsexec+0x57c>
mov    0x2837(%rip),%rax
mov    (%rax),%edi
lea    0xa6d(%rip),%rsi
jmp    179c <nsexec+0x57c>
mov    0x2825(%rip),%rax
mov    (%rax),%edi
lea    0xa79(%rip),%rsi
xor    %eax,%eax
call   10e0 <fprintf@plt>
mov    $0x1,%edi
call   1130 <exit@plt>
mov    -0x3c(%rbp),%r15d
mov    %eax,%r14d
lea    0xa95(%rip),%rdx
mov    %r13,%rdi
mov    -0x34(%rbp),%esi
mov    %eax,%ecx
call   1080 <snprintf@plt>
mov    %eax,%ebx
mov    %r15d,%edi
mov    %r13,%rsi
mov    %eax,%edx
call   1050 <write@plt>
cmp    %ebx,%eax
jne    17e2 <nsexec+0x5c2>
xor    %edi,%edi
call   1130 <exit@plt>
mov    0x27cf(%rip),%rax
mov    (%rax),%edi
lea    0xa6e(%rip),%rsi
xor    %eax,%eax
call   10e0 <fprintf@plt>
mov    0x27a0(%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 { i32 }
@.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"
@PATH_MAX = global i32 0
@.str.5 = [22 x i8] c"_LIBCONTAINER_INITPID\00"
@.str.6 = [3 x i8] c"%d\00"
@stderr = global i32 0
@.str.7 = [52 x i8] c"nsenter: Unable to parse _LIBCONTAINER_INITPID: %m\0A\00"
@.str.8 = [23 x i8] c"_LIBCONTAINER_INITPIPE\00"
@.str.9 = [35 x i8] c"nsenter: Child pipe not found: %m\0A\00"
@.str.10 = [53 x i8] c"nsenter: Unable to parse _LIBCONTAINER_INITPIPE: %m\0A\00"
@.str.11 = [27 x i8] c"_LIBCONTAINER_CONSOLE_PATH\00"
@O_RDWR = global i32 0
@.str.12 = [40 x i8] c"nsenter: Failed to open console %s: %m\0A\00"
@.str.13 = [12 x i8] c"/proc/%d/ns\00"
@O_DIRECTORY = global i32 0
@O_RDONLY = global i32 0
@.str.14 = [34 x i8] c"nsenter: Failed to open \22%s\22: %m\0A\00"
@AT_SYMLINK_NOFOLLOW = global i32 0
@errno = global i64 0
@ENOENT = global i64 0
@.str.15 = [50 x i8] c"nsenter: Failed to open ns file %s for ns %s: %m\0A\00"
@.str.16 = [37 x i8] c"nsenter: Failed to setns for %s: %m\0A\00"
@.str.17 = [28 x i8] c"nsenter: setsid failed: %m\0A\00"
@TIOCSCTTY = global i32 0
@.str.18 = [37 x i8] c"nsenter: ioctl TIOCSCTTY failed: %m\0A\00"
@STDIN_FILENO = global i64 0
@.str.19 = [30 x i8] c"nsenter: Failed to dup 0: %m\0A\00"
@STDOUT_FILENO = global i64 0
@.str.20 = [30 x i8] c"nsenter: Failed to dup 1: %m\0A\00"
@STDERR_FILENO = global i64 0
@.str.21 = [30 x i8] c"nsenter: Failed to dup 2: %m\0A\00"
@.str.22 = [29 x i8] c"nsenter: Unable to fork: %m\0A\00"
@.str.23 = [16 x i8] c"{ \22pid\22 : %d }\0A\00"
@.str.24 = [41 x i8] c"nsenter: Unable to send a child pid: %m\0A\00"
@SIGKILL = global i32 0
define void @nsexec() {
%1 = alloca [5 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 i8*
%15 = alloca i32
%16 = alloca %struct.stat
%17 = alloca i32
%18 = bitcast [5 x i8*]* %1 to i8*
%19 = bitcast i8* %18 to [5 x i8*]*
%20 = getelementptr inbounds [5 x i8*], [5 x i8*]* %19, i32 0, i32 0
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i8** %20
%21 = getelementptr inbounds [5 x i8*], [5 x i8*]* %19, i32 0, i32 1
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i32 0, i32 0), i8** %21
%22 = getelementptr inbounds [5 x i8*], [5 x i8*]* %19, i32 0, i32 2
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i32 0, i32 0), i8** %22
%23 = getelementptr inbounds [5 x i8*], [5 x i8*]* %19, i32 0, i32 3
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i32 0, i32 0), i8** %23
%24 = getelementptr inbounds [5 x i8*], [5 x i8*]* %19, i32 0, i32 4
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i32 0, i32 0), i8** %24
store i32 5, i32* %2
%25 = load i32, i32* @PATH_MAX
%26 = zext i32 %25 to i64
%27 = call i8* @llvm.stacksave()
store i8* %27, i8** %4
%28 = alloca i8, i64 %26
store i64 %26, i64* %5
store i32 -1, i32* %12
%29 = call i8* @getenv(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0))
store i8* %29, i8** %6
%30 = load i8*, i8** %6
%31 = icmp eq i8* %30, null
br i1 %31, label %32, label %33
32: ; preds = %0
store i32 1, i32* %15
br label %234
33: ; preds = %0
%34 = load i8*, i8** %6
%35 = call i32 @atoi(i8* %34)
store i32 %35, i32* %13
%36 = trunc i64 %26 to i32
%37 = load i32, i32* %13
%38 = call i32 @snprintf(i8* %28, i32 %36, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32 %37)
%39 = load i8*, i8** %6
%40 = call i64 @strcmp(i8* %39, i8* %28)
%41 = icmp ne i64 %40, 0
br i1 %41, label %42, label %46
42: ; preds = %33
%43 = load i32, i32* @stderr
%44 = call i32 (i32, i8*, ...) @fprintf(i32 %43, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.7, i64 0, i64 0))
%45 = call i32 @exit(i32 1)
unreachable
46: ; preds = %33
%47 = call i8* @getenv(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.8, i64 0, i64 0))
store i8* %47, i8** %6
%48 = load i8*, i8** %6
%49 = icmp eq i8* %48, null
br i1 %49, label %50, label %54
50: ; preds = %46
%51 = load i32, i32* @stderr
%52 = call i32 (i32, i8*, ...) @fprintf(i32 %51, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.9, i64 0, i64 0))
%53 = call i32 @exit(i32 1)
unreachable
54: ; preds = %46
%55 = load i8*, i8** %6
%56 = call i32 @atoi(i8* %55)
store i32 %56, i32* %11
%57 = trunc i64 %26 to i32
%58 = load i32, i32* %11
%59 = call i32 @snprintf(i8* %28, i32 %57, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32 %58)
%60 = load i8*, i8** %6
%61 = call i64 @strcmp(i8* %60, i8* %28)
%62 = icmp ne i64 %61, 0
br i1 %62, label %63, label %67
63: ; preds = %54
%64 = load i32, i32* @stderr
%65 = call i32 (i32, i8*, ...) @fprintf(i32 %64, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.10, i64 0, i64 0))
%66 = call i32 @exit(i32 1)
unreachable
67: ; preds = %54
%68 = call i8* @getenv(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.11, i64 0, i64 0))
store i8* %68, i8** %14
%69 = load i8*, i8** %14
%70 = icmp ne i8* %69, null
br i1 %70, label %71, label %83
71: ; preds = %67
%72 = load i8*, i8** %14
%73 = load i32, i32* @O_RDWR
%74 = call i32 @open(i8* %72, i32 %73)
store i32 %74, i32* %12
%75 = load i32, i32* %12
%76 = icmp slt i32 %75, 0
br i1 %76, label %77, label %82
77: ; preds = %71
%78 = load i32, i32* @stderr
%79 = load i8*, i8** %14
%80 = call i32 (i32, i8*, ...) @fprintf(i32 %78, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.12, i64 0, i64 0), i8* %79)
%81 = call i32 @exit(i32 1)
unreachable
82: ; preds = %71
br label %83
83: ; preds = %82, %67
%84 = load i32, i32* @PATH_MAX
%85 = sub nsw i32 %84, 1
%86 = load i32, i32* %13
%87 = call i32 @snprintf(i8* %28, i32 %85, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.13, i64 0, i64 0), i32 %86)
%88 = load i32, i32* @O_DIRECTORY
%89 = load i32, i32* @O_RDONLY
%90 = or i32 %88, %89
%91 = call i32 @open(i8* %28, i32 %90)
store i32 %91, i32* %8
%92 = load i32, i32* %8
%93 = icmp eq i32 %92, -1
br i1 %93, label %94, label %98
94: ; preds = %83
%95 = load i32, i32* @stderr
%96 = call i32 (i32, i8*, ...) @fprintf(i32 %95, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.14, i64 0, i64 0), i8* %28)
%97 = call i32 @exit(i32 1)
unreachable
98: ; preds = %83
store i32 0, i32* %7
br label %99
99: ; preds = %150, %98
%100 = load i32, i32* %7
%101 = icmp slt i32 %100, 5
br i1 %101, label %102, label %153
102: ; preds = %99
%103 = load i32, i32* %8
%104 = load i32, i32* %7
%105 = sext i32 %104 to i64
%106 = getelementptr inbounds [5 x i8*], [5 x i8*]* %1, i64 0, i64 %105
%107 = load i8*, i8** %106
%108 = load i32, i32* @AT_SYMLINK_NOFOLLOW
%109 = call i32 @fstatat(i32 %103, i8* %107, %struct.stat* %16, i32 %108)
%110 = icmp eq i32 %109, -1
br i1 %110, label %111, label %117
111: ; preds = %102
%112 = load i64, i64* @errno
%113 = load i64, i64* @ENOENT
%114 = icmp eq i64 %112, %113
br i1 %114, label %115, label %116
115: ; preds = %111
br label %150
116: ; preds = %111
br label %117
117: ; preds = %116, %102
%118 = load i32, i32* %8
%119 = load i32, i32* %7
%120 = sext i32 %119 to i64
%121 = getelementptr inbounds [5 x i8*], [5 x i8*]* %1, i64 0, i64 %120
%122 = load i8*, i8** %121
%123 = load i32, i32* @O_RDONLY
%124 = call i32 @openat(i32 %118, i8* %122, i32 %123)
store i32 %124, i32* %17
%125 = load i32, i32* %17
%126 = icmp eq i32 %125, -1
br i1 %126, label %127, label %135
127: ; preds = %117
%128 = load i32, i32* @stderr
%129 = load i32, i32* %7
%130 = sext i32 %129 to i64
%131 = getelementptr inbounds [5 x i8*], [5 x i8*]* %1, i64 0, i64 %130
%132 = load i8*, i8** %131
%133 = call i32 (i32, i8*, ...) @fprintf(i32 %128, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.15, i64 0, i64 0), i8* %28, i8* %132)
%134 = call i32 @exit(i32 1)
unreachable
135: ; preds = %117
%136 = load i32, i32* %17
%137 = call i32 @setns(i32 %136, i32 0)
%138 = icmp eq i32 %137, -1
br i1 %138, label %139, label %147
139: ; preds = %135
%140 = load i32, i32* @stderr
%141 = load i32, i32* %7
%142 = sext i32 %141 to i64
%143 = getelementptr inbounds [5 x i8*], [5 x i8*]* %1, i64 0, i64 %142
%144 = load i8*, i8** %143
%145 = call i32 (i32, i8*, ...) @fprintf(i32 %140, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.16, i64 0, i64 0), i8* %144)
%146 = call i32 @exit(i32 1)
unreachable
147: ; preds = %135
%148 = load i32, i32* %17
%149 = call i32 @close(i32 %148)
br label %150
150: ; preds = %147, %115
%151 = load i32, i32* %7
%152 = add nsw i32 %151, 1
store i32 %152, i32* %7
br label %99
153: ; preds = %99
%154 = load i32, i32* %3
%155 = call i32 @setjmp(i32 %154)
%156 = icmp eq i32 %155, 1
br i1 %156, label %157, label %208
157: ; preds = %153
%158 = call i32 (...) @setsid()
%159 = icmp eq i32 %158, -1
br i1 %159, label %160, label %164
160: ; preds = %157
%161 = load i32, i32* @stderr
%162 = call i32 (i32, i8*, ...) @fprintf(i32 %161, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.17, i64 0, i64 0))
%163 = call i32 @exit(i32 1)
unreachable
164: ; preds = %157
%165 = load i32, i32* %12
%166 = icmp ne i32 %165, -1
br i1 %166, label %167, label %207
167: ; preds = %164
%168 = load i32, i32* %12
%169 = load i32, i32* @TIOCSCTTY
%170 = call i32 @ioctl(i32 %168, i32 %169, i32 0)
%171 = icmp eq i32 %170, -1
br i1 %171, label %172, label %176
172: ; preds = %167
%173 = load i32, i32* @stderr
%174 = call i32 (i32, i8*, ...) @fprintf(i32 %173, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.18, i64 0, i64 0))
%175 = call i32 @exit(i32 1)
unreachable
176: ; preds = %167
%177 = load i32, i32* %12
%178 = load i64, i64* @STDIN_FILENO
%179 = call i64 @dup2(i32 %177, i64 %178)
%180 = load i64, i64* @STDIN_FILENO
%181 = icmp ne i64 %179, %180
br i1 %181, label %182, label %186
182: ; preds = %176
%183 = load i32, i32* @stderr
%184 = call i32 (i32, i8*, ...) @fprintf(i32 %183, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.19, i64 0, i64 0))
%185 = call i32 @exit(i32 1)
unreachable
186: ; preds = %176
%187 = load i32, i32* %12
%188 = load i64, i64* @STDOUT_FILENO
%189 = call i64 @dup2(i32 %187, i64 %188)
%190 = load i64, i64* @STDOUT_FILENO
%191 = icmp ne i64 %189, %190
br i1 %191, label %192, label %196
192: ; preds = %186
%193 = load i32, i32* @stderr
%194 = call i32 (i32, i8*, ...) @fprintf(i32 %193, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.20, i64 0, i64 0))
%195 = call i32 @exit(i32 1)
unreachable
196: ; preds = %186
%197 = load i32, i32* %12
%198 = load i64, i64* @STDERR_FILENO
%199 = call i64 @dup2(i32 %197, i64 %198)
%200 = load i64, i64* @STDERR_FILENO
%201 = icmp ne i64 %199, %200
br i1 %201, label %202, label %206
202: ; preds = %196
%203 = load i32, i32* @stderr
%204 = call i32 (i32, i8*, ...) @fprintf(i32 %203, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.21, i64 0, i64 0))
%205 = call i32 @exit(i32 1)
unreachable
206: ; preds = %196
br label %207
207: ; preds = %206, %164
store i32 1, i32* %15
br label %234
208: ; preds = %153
%209 = call i32 @clone_parent(i32* %3)
store i32 %209, i32* %9
%210 = load i32, i32* %9
%211 = icmp slt i32 %210, 0
br i1 %211, label %212, label %216
212: ; preds = %208
%213 = load i32, i32* @stderr
%214 = call i32 (i32, i8*, ...) @fprintf(i32 %213, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.22, i64 0, i64 0))
%215 = call i32 @exit(i32 1)
unreachable
216: ; preds = %208
%217 = trunc i64 %26 to i32
%218 = load i32, i32* %9
%219 = call i32 @snprintf(i8* %28, i32 %217, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.23, i64 0, i64 0), i32 %218)
store i32 %219, i32* %10
%220 = load i32, i32* %11
%221 = load i32, i32* %10
%222 = call i32 @write(i32 %220, i8* %28, i32 %221)
%223 = load i32, i32* %10
%224 = icmp ne i32 %222, %223
br i1 %224, label %225, label %232
225: ; preds = %216
%226 = load i32, i32* @stderr
%227 = call i32 (i32, i8*, ...) @fprintf(i32 %226, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.24, i64 0, i64 0))
%228 = load i32, i32* %9
%229 = load i32, i32* @SIGKILL
%230 = call i32 @kill(i32 %228, i32 %229)
%231 = call i32 @exit(i32 1)
unreachable
232: ; preds = %216
%233 = call i32 @exit(i32 0)
unreachable
234: ; preds = %207, %32
%235 = load i8*, i8** %4
ret void
}

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