#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*/ pid_t;

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ _exit(int /*<<< orphan*/);
scalar_t__ chdir(char *);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ execvp(char *, char **);
int fork();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ free(char *);
char **get_cmd_line_args(int /*<<< orphan*/);
char *getcwd(int /*<<< orphan*/ *, int /*<<< orphan*/);
int geteuid();
int /*<<< orphan*/ getpid();
int /*<<< orphan*/ setenv(char *, char *, int);
scalar_t__ setns(int, int /*<<< orphan*/);
int /*<<< orphan*/ sprintf(char *, char *, int);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
scalar_t__ syscall_setresgid(int /*<<< orphan*/, int /*<<< orphan*/,
                             int /*<<< orphan*/);
scalar_t__ syscall_setresuid(int /*<<< orphan*/, int /*<<< orphan*/,
                             int /*<<< orphan*/);
int reexec_userns_join(int userns, int mountns) {
  pid_t ppid = getpid();
  char uid[16];
  char **argv;
  int pid;
  char *cwd = getcwd(NULL, 0);
  if (cwd == NULL) {
    fprintf(stderr, "error getting current working directory: %s\n",
            strerror(errno));
    _exit(EXIT_FAILURE);
  }
  sprintf(uid, "%d", geteuid());
  argv = get_cmd_line_args(ppid);
  if (argv == NULL) {
    fprintf(stderr, "cannot read argv: %s\n", strerror(errno));
    _exit(EXIT_FAILURE);
  }
  pid = fork();
  if (pid < 0)
    fprintf(stderr, "cannot fork: %s\n", strerror(errno));
  if (pid)
    return pid;
  setenv("_CONTAINERS_USERNS_CONFIGURED", "init", 1);
  setenv("_CONTAINERS_ROOTLESS_UID", uid, 1);
  if (setns(userns, 0) < 0) {
    fprintf(stderr, "cannot setns: %s\n", strerror(errno));
    _exit(EXIT_FAILURE);
  }
  close(userns);
  if (mountns >= 0 && setns(mountns, 0) < 0) {
    fprintf(stderr, "cannot setns: %s\n", strerror(errno));
    _exit(EXIT_FAILURE);
  }
  close(userns);
  if (syscall_setresgid(0, 0, 0) < 0) {
    fprintf(stderr, "cannot setresgid: %s\n", strerror(errno));
    _exit(EXIT_FAILURE);
  }
  if (syscall_setresuid(0, 0, 0) < 0) {
    fprintf(stderr, "cannot setresuid: %s\n", strerror(errno));
    _exit(EXIT_FAILURE);
  }
  if (chdir(cwd) < 0) {
    fprintf(stderr, "cannot chdir: %s\n", strerror(errno));
    _exit(EXIT_FAILURE);
  }
  free(cwd);
  execvp(argv[0], argv);
  _exit(EXIT_FAILURE);
}


x86 assembly (clang, -O0):
<reexec_userns_join>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    $0x0,%al
call   1060 <getpid@plt>
mov    %eax,-0xc(%rbp)
xor    %eax,%eax
mov    %eax,%edi
xor    %esi,%esi
call   10a0 <getcwd@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    127c <reexec_userns_join+0x6c>
mov    0x2d97(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x3c(%rbp)
mov    0x2d83(%rip),%rax
mov    (%rax),%edi
call   1110 <strerror@plt>
mov    -0x3c(%rbp),%edi
mov    %rax,%rdx
lea    0xd97(%rip),%rsi
call   10d0 <fprintf@plt>
mov    0x2d5b(%rip),%rax
mov    (%rax),%edi
call   1040 <_exit@plt>
lea    -0x20(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    $0x0,%al
call   1090 <geteuid@plt>
mov    -0x48(%rbp),%rdi
mov    %eax,%edx
lea    0xd95(%rip),%rsi
call   1100 <sprintf@plt>
mov    -0xc(%rbp),%edi
call   1130 <get_cmd_line_args@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    12ee <reexec_userns_join+0xde>
mov    0x2d25(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4c(%rbp)
mov    0x2d11(%rip),%rax
mov    (%rax),%edi
call   1110 <strerror@plt>
mov    -0x4c(%rbp),%edi
mov    %rax,%rdx
lea    0xd55(%rip),%rsi
call   10d0 <fprintf@plt>
mov    0x2ce9(%rip),%rax
mov    (%rax),%edi
call   1040 <_exit@plt>
mov    $0x0,%al
call   1120 <fork@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jge    132e <reexec_userns_join+0x11e>
mov    0x2cd7(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x50(%rbp)
mov    0x2cc3(%rip),%rax
mov    (%rax),%edi
call   1110 <strerror@plt>
mov    -0x50(%rbp),%edi
mov    %rax,%rdx
lea    0xd1d(%rip),%rsi
call   10d0 <fprintf@plt>
cmpl   $0x0,-0x2c(%rbp)
je     1341 <reexec_userns_join+0x131>
mov    -0x2c(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret
lea    0xd0f(%rip),%rdi
lea    0xd26(%rip),%rsi
mov    $0x1,%edx
call   1050 <setenv@plt>
lea    -0x20(%rbp),%rsi
lea    0xd16(%rip),%rdi
mov    $0x1,%edx
call   1050 <setenv@plt>
mov    -0x4(%rbp),%edi
xor    %esi,%esi
call   1080 <setns@plt>
cmp    $0x0,%rax
jge    13bc <reexec_userns_join+0x1ac>
mov    0x2c57(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x54(%rbp)
mov    0x2c43(%rip),%rax
mov    (%rax),%edi
call   1110 <strerror@plt>
mov    -0x54(%rbp),%edi
mov    %rax,%rdx
lea    0xcea(%rip),%rsi
call   10d0 <fprintf@plt>
mov    0x2c1b(%rip),%rax
mov    (%rax),%edi
call   1040 <_exit@plt>
mov    -0x4(%rbp),%edi
call   10b0 <close@plt>
cmpl   $0x0,-0x8(%rbp)
jl     141c <reexec_userns_join+0x20c>
mov    -0x8(%rbp),%edi
xor    %esi,%esi
call   1080 <setns@plt>
cmp    $0x0,%rax
jge    141c <reexec_userns_join+0x20c>
mov    0x2bf7(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x58(%rbp)
mov    0x2be3(%rip),%rax
mov    (%rax),%edi
call   1110 <strerror@plt>
mov    -0x58(%rbp),%edi
mov    %rax,%rdx
lea    0xc8a(%rip),%rsi
call   10d0 <fprintf@plt>
mov    0x2bbb(%rip),%rax
mov    (%rax),%edi
call   1040 <_exit@plt>
mov    -0x4(%rbp),%edi
call   10b0 <close@plt>
xor    %edx,%edx
mov    %edx,%edi
mov    %edx,%esi
call   10e0 <syscall_setresgid@plt>
cmp    $0x0,%rax
jge    1473 <reexec_userns_join+0x263>
mov    0x2ba0(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x5c(%rbp)
mov    0x2b8c(%rip),%rax
mov    (%rax),%edi
call   1110 <strerror@plt>
mov    -0x5c(%rbp),%edi
mov    %rax,%rdx
lea    0xc45(%rip),%rsi
call   10d0 <fprintf@plt>
mov    0x2b64(%rip),%rax
mov    (%rax),%edi
call   1040 <_exit@plt>
xor    %edx,%edx
mov    %edx,%edi
mov    %edx,%esi
call   10c0 <syscall_setresuid@plt>
cmp    $0x0,%rax
jge    14c2 <reexec_userns_join+0x2b2>
mov    0x2b51(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x60(%rbp)
mov    0x2b3d(%rip),%rax
mov    (%rax),%edi
call   1110 <strerror@plt>
mov    -0x60(%rbp),%edi
mov    %rax,%rdx
lea    0xc0c(%rip),%rsi
call   10d0 <fprintf@plt>
mov    0x2b15(%rip),%rax
mov    (%rax),%edi
call   1040 <_exit@plt>
mov    -0x38(%rbp),%rdi
call   1070 <chdir@plt>
cmp    $0x0,%rax
jge    150f <reexec_userns_join+0x2ff>
mov    0x2b04(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x64(%rbp)
mov    0x2af0(%rip),%rax
mov    (%rax),%edi
call   1110 <strerror@plt>
mov    -0x64(%rbp),%edi
mov    %rax,%rdx
lea    0xbd5(%rip),%rsi
call   10d0 <fprintf@plt>
mov    0x2ac8(%rip),%rax
mov    (%rax),%edi
call   1040 <_exit@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rax
mov    (%rax),%rdi
mov    -0x28(%rbp),%rsi
call   10f0 <execvp@plt>
mov    0x2aa1(%rip),%rax
mov    (%rax),%edi
call   1040 <_exit@plt>

x86 assembly (clang, -O2):
<reexec_userns_join>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %esi,%r12d
mov    %edi,%r15d
xor    %eax,%eax
call   1060 <getpid@plt>
mov    %eax,%ebx
xor    %edi,%edi
xor    %esi,%esi
call   10a0 <getcwd@plt>
test   %rax,%rax
je     1314 <reexec_userns_join+0x104>
mov    %rax,%r14
xor    %eax,%eax
call   1090 <geteuid@plt>
lea    0xddf(%rip),%rsi
mov    %rsp,%rdi
mov    %eax,%edx
call   1100 <sprintf@plt>
mov    %ebx,%edi
call   1130 <get_cmd_line_args@plt>
test   %rax,%rax
je     1334 <reexec_userns_join+0x124>
mov    %rax,%rbx
xor    %eax,%eax
call   1120 <fork@plt>
mov    %eax,%ebp
test   %eax,%eax
js     12dd <reexec_userns_join+0xcd>
jne    1305 <reexec_userns_join+0xf5>
lea    0xdd2(%rip),%rdi
lea    0xde9(%rip),%rsi
mov    $0x1,%edx
call   1050 <setenv@plt>
lea    0xddd(%rip),%rdi
mov    %rsp,%rsi
mov    $0x1,%edx
call   1050 <setenv@plt>
mov    %r15d,%edi
xor    %esi,%esi
call   1080 <setns@plt>
test   %rax,%rax
jns    136a <reexec_userns_join+0x15a>
mov    0x2d1c(%rip),%rax
mov    (%rax),%ebx
mov    0x2d0b(%rip),%rax
mov    (%rax),%edi
call   1110 <strerror@plt>
lea    0xdb8(%rip),%rsi
jmp    1352 <reexec_userns_join+0x142>
mov    0x2cfc(%rip),%rax
mov    (%rax),%ebx
mov    0x2ceb(%rip),%rax
mov    (%rax),%edi
call   1110 <strerror@plt>
lea    0xd4b(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
call   10d0 <fprintf@plt>
mov    %ebp,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2cc5(%rip),%rax
mov    (%rax),%ebx
mov    0x2cb4(%rip),%rax
mov    (%rax),%edi
call   1110 <strerror@plt>
lea    0xcce(%rip),%rsi
jmp    1352 <reexec_userns_join+0x142>
mov    0x2ca5(%rip),%rax
mov    (%rax),%ebx
mov    0x2c94(%rip),%rax
mov    (%rax),%edi
call   1110 <strerror@plt>
lea    0xcde(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
call   10d0 <fprintf@plt>
mov    0x2c6d(%rip),%rax
mov    (%rax),%edi
call   1040 <_exit@plt>
mov    %r15d,%edi
call   10b0 <close@plt>
test   %r12d,%r12d
js     138a <reexec_userns_join+0x17a>
mov    %r12d,%edi
xor    %esi,%esi
call   1080 <setns@plt>
test   %rax,%rax
js     12bd <reexec_userns_join+0xad>
mov    %r15d,%edi
call   10b0 <close@plt>
xor    %edi,%edi
xor    %esi,%esi
xor    %edx,%edx
call   10e0 <syscall_setresgid@plt>
test   %rax,%rax
jns    13c2 <reexec_userns_join+0x1b2>
mov    0x2c37(%rip),%rax
mov    (%rax),%ebx
mov    0x2c26(%rip),%rax
mov    (%rax),%edi
call   1110 <strerror@plt>
lea    0xce5(%rip),%rsi
jmp    1352 <reexec_userns_join+0x142>
xor    %edi,%edi
xor    %esi,%esi
xor    %edx,%edx
call   10c0 <syscall_setresuid@plt>
test   %rax,%rax
jns    13f5 <reexec_userns_join+0x1e5>
mov    0x2c07(%rip),%rax
mov    (%rax),%ebx
mov    0x2bf6(%rip),%rax
mov    (%rax),%edi
call   1110 <strerror@plt>
lea    0xccb(%rip),%rsi
jmp    1352 <reexec_userns_join+0x142>
mov    %r14,%rdi
call   1070 <chdir@plt>
test   %rax,%rax
jns    1425 <reexec_userns_join+0x215>
mov    0x2bd7(%rip),%rax
mov    (%rax),%ebx
mov    0x2bc6(%rip),%rax
mov    (%rax),%edi
call   1110 <strerror@plt>
lea    0xcb1(%rip),%rsi
jmp    1352 <reexec_userns_join+0x142>
mov    %r14,%rdi
call   1030 <free@plt>
mov    (%rbx),%rdi
mov    %rbx,%rsi
call   10f0 <execvp@plt>
jmp    135c <reexec_userns_join+0x14c>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [45 x i8] c"error getting current working directory: %s\0A\00"
@errno = global i32 0
@EXIT_FAILURE = global i32 0
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [22 x i8] c"cannot read argv: %s\0A\00"
@.str.3 = [17 x i8] c"cannot fork: %s\0A\00"
@.str.4 = [30 x i8] c"_CONTAINERS_USERNS_CONFIGURED\00"
@.str.5 = [5 x i8] c"init\00"
@.str.6 = [25 x i8] c"_CONTAINERS_ROOTLESS_UID\00"
@.str.7 = [18 x i8] c"cannot setns: %s\0A\00"
@.str.8 = [22 x i8] c"cannot setresgid: %s\0A\00"
@.str.9 = [22 x i8] c"cannot setresuid: %s\0A\00"
@.str.10 = [18 x i8] c"cannot chdir: %s\0A\00"
define i32 @reexec_userns_join(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca [16 x i8]
%7 = alloca i8**
%8 = alloca i32
%9 = alloca i8*
store i32 %0, i32* %3
store i32 %1, i32* %4
%10 = call i32 (...) @getpid()
store i32 %10, i32* %5
%11 = call i8* @getcwd(i32* null, i32 0)
store i8* %11, i8** %9
%12 = load i8*, i8** %9
%13 = icmp eq i8* %12, null
br i1 %13, label %14, label %21
14: ; preds = %2
%15 = load i32, i32* @stderr
%16 = load i32, i32* @errno
%17 = call i8* @strerror(i32 %16)
%18 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0), i8* %17)
%19 = load i32, i32* @EXIT_FAILURE
%20 = call i32 @_exit(i32 %19)
unreachable
21: ; preds = %2
%22 = getelementptr inbounds [16 x i8], [16 x i8]* %6, i64 0, i64 0
%23 = call i32 (...) @geteuid()
%24 = call i32 @sprintf(i8* %22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %23)
%25 = load i32, i32* %5
%26 = call i8** @get_cmd_line_args(i32 %25)
store i8** %26, i8*** %7
%27 = load i8**, i8*** %7
%28 = icmp eq i8** %27, null
br i1 %28, label %29, label %36
29: ; preds = %21
%30 = load i32, i32* @stderr
%31 = load i32, i32* @errno
%32 = call i8* @strerror(i32 %31)
%33 = call i32 @fprintf(i32 %30, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8* %32)
%34 = load i32, i32* @EXIT_FAILURE
%35 = call i32 @_exit(i32 %34)
unreachable
36: ; preds = %21
%37 = call i32 (...) @fork()
store i32 %37, i32* %8
%38 = load i32, i32* %8
%39 = icmp slt i32 %38, 0
br i1 %39, label %40, label %45
40: ; preds = %36
%41 = load i32, i32* @stderr
%42 = load i32, i32* @errno
%43 = call i8* @strerror(i32 %42)
%44 = call i32 @fprintf(i32 %41, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i8* %43)
br label %45
45: ; preds = %40, %36
%46 = load i32, i32* %8
%47 = icmp ne i32 %46, 0
br i1 %47, label %48, label %50
48: ; preds = %45
%49 = load i32, i32* %8
ret i32 %49
50: ; preds = %45
%51 = call i32 @setenv(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i32 1)
%52 = getelementptr inbounds [16 x i8], [16 x i8]* %6, i64 0, i64 0
%53 = call i32 @setenv(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0), i8* %52, i32 1)
%54 = load i32, i32* %3
%55 = call i64 @setns(i32 %54, i32 0)
%56 = icmp slt i64 %55, 0
br i1 %56, label %57, label %64
57: ; preds = %50
%58 = load i32, i32* @stderr
%59 = load i32, i32* @errno
%60 = call i8* @strerror(i32 %59)
%61 = call i32 @fprintf(i32 %58, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0), i8* %60)
%62 = load i32, i32* @EXIT_FAILURE
%63 = call i32 @_exit(i32 %62)
unreachable
64: ; preds = %50
%65 = load i32, i32* %3
%66 = call i32 @close(i32 %65)
%67 = load i32, i32* %4
%68 = icmp sge i32 %67, 0
br i1 %68, label %69, label %80
69: ; preds = %64
%70 = load i32, i32* %4
%71 = call i64 @setns(i32 %70, i32 0)
%72 = icmp slt i64 %71, 0
br i1 %72, label %73, label %80
73: ; preds = %69
%74 = load i32, i32* @stderr
%75 = load i32, i32* @errno
%76 = call i8* @strerror(i32 %75)
%77 = call i32 @fprintf(i32 %74, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0), i8* %76)
%78 = load i32, i32* @EXIT_FAILURE
%79 = call i32 @_exit(i32 %78)
unreachable
80: ; preds = %69, %64
%81 = load i32, i32* %3
%82 = call i32 @close(i32 %81)
%83 = call i64 @syscall_setresgid(i32 0, i32 0, i32 0)
%84 = icmp slt i64 %83, 0
br i1 %84, label %85, label %92
85: ; preds = %80
%86 = load i32, i32* @stderr
%87 = load i32, i32* @errno
%88 = call i8* @strerror(i32 %87)
%89 = call i32 @fprintf(i32 %86, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.8, i64 0, i64 0), i8* %88)
%90 = load i32, i32* @EXIT_FAILURE
%91 = call i32 @_exit(i32 %90)
unreachable
92: ; preds = %80
%93 = call i64 @syscall_setresuid(i32 0, i32 0, i32 0)
%94 = icmp slt i64 %93, 0
br i1 %94, label %95, label %102
95: ; preds = %92
%96 = load i32, i32* @stderr
%97 = load i32, i32* @errno
%98 = call i8* @strerror(i32 %97)
%99 = call i32 @fprintf(i32 %96, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.9, i64 0, i64 0), i8* %98)
%100 = load i32, i32* @EXIT_FAILURE
%101 = call i32 @_exit(i32 %100)
unreachable
102: ; preds = %92
%103 = load i8*, i8** %9
%104 = call i64 @chdir(i8* %103)
%105 = icmp slt i64 %104, 0
br i1 %105, label %106, label %113
106: ; preds = %102
%107 = load i32, i32* @stderr
%108 = load i32, i32* @errno
%109 = call i8* @strerror(i32 %108)
%110 = call i32 @fprintf(i32 %107, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.10, i64 0, i64 0), i8* %109)
%111 = load i32, i32* @EXIT_FAILURE
%112 = call i32 @_exit(i32 %111)
unreachable
113: ; preds = %102
%114 = load i8*, i8** %9
%115 = call i32 @free(i8* %114)
%116 = load i8**, i8*** %7
%117 = getelementptr inbounds i8*, i8** %116, i64 0
%118 = load i8*, i8** %117
%119 = load i8**, i8*** %7
%120 = call i32 @execvp(i8* %118, i8** %119)
%121 = load i32, i32* @EXIT_FAILURE
%122 = call i32 @_exit(i32 %121)
unreachable
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [45 x i8] c"error getting current working directory: %s\0A\00"
@errno = global i32 0
@EXIT_FAILURE = global i32 0
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [22 x i8] c"cannot read argv: %s\0A\00"
@.str.3 = [17 x i8] c"cannot fork: %s\0A\00"
@.str.4 = [30 x i8] c"_CONTAINERS_USERNS_CONFIGURED\00"
@.str.5 = [5 x i8] c"init\00"
@.str.6 = [25 x i8] c"_CONTAINERS_ROOTLESS_UID\00"
@.str.7 = [18 x i8] c"cannot setns: %s\0A\00"
@.str.8 = [22 x i8] c"cannot setresgid: %s\0A\00"
@.str.9 = [22 x i8] c"cannot setresuid: %s\0A\00"
@.str.10 = [18 x i8] c"cannot chdir: %s\0A\00"
define i32 @reexec_userns_join(i32 %0, i32 %1) {
%3 = alloca [16 x i8]
%4 = tail call i32 (...) @getpid()
%5 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 0
%6 = tail call i8* @getcwd(i32* null, i32 0)
%7 = icmp eq i8* %6, null
br i1 %7, label %8, label %15
8: ; preds = %2
%9 = load i32, i32* @stderr
%10 = load i32, i32* @errno
%11 = tail call i8* @strerror(i32 %10)
%12 = tail call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0), i8* %11)
%13 = load i32, i32* @EXIT_FAILURE
%14 = tail call i32 @_exit(i32 %13)
unreachable
15: ; preds = %2
%16 = tail call i32 (...) @geteuid()
%17 = call i32 @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %16)
%18 = tail call i8** @get_cmd_line_args(i32 %4)
%19 = icmp eq i8** %18, null
br i1 %19, label %20, label %27
20: ; preds = %15
%21 = load i32, i32* @stderr
%22 = load i32, i32* @errno
%23 = tail call i8* @strerror(i32 %22)
%24 = tail call i32 @fprintf(i32 %21, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8* %23)
%25 = load i32, i32* @EXIT_FAILURE
%26 = tail call i32 @_exit(i32 %25)
unreachable
27: ; preds = %15
%28 = tail call i32 (...) @fork()
%29 = icmp slt i32 %28, 0
br i1 %29, label %30, label %35
30: ; preds = %27
%31 = load i32, i32* @stderr
%32 = load i32, i32* @errno
%33 = tail call i8* @strerror(i32 %32)
%34 = tail call i32 @fprintf(i32 %31, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i8* %33)
br label %37
35: ; preds = %27
%36 = icmp eq i32 %28, 0
br i1 %36, label %38, label %37
37: ; preds = %30, %35
ret i32 %28
38: ; preds = %35
%39 = tail call i32 @setenv(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i32 1)
%40 = call i32 @setenv(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0), i8* %5, i32 1)
%41 = call i64 @setns(i32 %0, i32 0)
%42 = icmp slt i64 %41, 0
br i1 %42, label %43, label %50
43: ; preds = %38
%44 = load i32, i32* @stderr
%45 = load i32, i32* @errno
%46 = call i8* @strerror(i32 %45)
%47 = call i32 @fprintf(i32 %44, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0), i8* %46)
%48 = load i32, i32* @EXIT_FAILURE
%49 = call i32 @_exit(i32 %48)
unreachable
50: ; preds = %38
%51 = call i32 @close(i32 %0)
%52 = icmp sgt i32 %1, -1
br i1 %52, label %53, label %63
53: ; preds = %50
%54 = call i64 @setns(i32 %1, i32 0)
%55 = icmp slt i64 %54, 0
br i1 %55, label %56, label %63
56: ; preds = %53
%57 = load i32, i32* @stderr
%58 = load i32, i32* @errno
%59 = call i8* @strerror(i32 %58)
%60 = call i32 @fprintf(i32 %57, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0), i8* %59)
%61 = load i32, i32* @EXIT_FAILURE
%62 = call i32 @_exit(i32 %61)
unreachable
63: ; preds = %53, %50
%64 = call i32 @close(i32 %0)
%65 = call i64 @syscall_setresgid(i32 0, i32 0, i32 0)
%66 = icmp slt i64 %65, 0
br i1 %66, label %67, label %74
67: ; preds = %63
%68 = load i32, i32* @stderr
%69 = load i32, i32* @errno
%70 = call i8* @strerror(i32 %69)
%71 = call i32 @fprintf(i32 %68, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.8, i64 0, i64 0), i8* %70)
%72 = load i32, i32* @EXIT_FAILURE
%73 = call i32 @_exit(i32 %72)
unreachable
74: ; preds = %63
%75 = call i64 @syscall_setresuid(i32 0, i32 0, i32 0)
%76 = icmp slt i64 %75, 0
br i1 %76, label %77, label %84
77: ; preds = %74
%78 = load i32, i32* @stderr
%79 = load i32, i32* @errno
%80 = call i8* @strerror(i32 %79)
%81 = call i32 @fprintf(i32 %78, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.9, i64 0, i64 0), i8* %80)
%82 = load i32, i32* @EXIT_FAILURE
%83 = call i32 @_exit(i32 %82)
unreachable
84: ; preds = %74
%85 = call i64 @chdir(i8* %6)
%86 = icmp slt i64 %85, 0
br i1 %86, label %87, label %94
87: ; preds = %84
%88 = load i32, i32* @stderr
%89 = load i32, i32* @errno
%90 = call i8* @strerror(i32 %89)
%91 = call i32 @fprintf(i32 %88, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.10, i64 0, i64 0), i8* %90)
%92 = load i32, i32* @EXIT_FAILURE
%93 = call i32 @_exit(i32 %92)
unreachable
94: ; preds = %84
%95 = call i32 @free(i8* %6)
%96 = load i8*, i8** %18
%97 = call i32 @execvp(i8* %96, i8** %18)
%98 = load i32, i32* @EXIT_FAILURE
%99 = call i32 @_exit(i32 %98)
unreachable
}