#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 scalar_t__ pid_t;

/* Variables and functions */
int WEXITSTATUS(int);
scalar_t__ WIFEXITED(int);
scalar_t__ _ensure(int, int /*<<< orphan*/);
int /*<<< orphan*/ _ensure_argc(int, int, int);
int /*<<< orphan*/ chain_command(int, int, char **);
int /*<<< orphan*/ fork();
int /*<<< orphan*/ nsenter(char *, char *);
scalar_t__ strchr(char *, char);
int /*<<< orphan*/ waitpid(scalar_t__, int *, int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  _ensure_argc(19, 4, argc);
  int flags = 0;
  if (strchr(argv[1], 'u'))
    nsenter(argv[2], "uts");
  if (strchr(argv[1], 'i'))
    nsenter(argv[2], "ipc");
  if (strchr(argv[1], 'p'))
    nsenter(argv[2], "pid");
  if (strchr(argv[1], 'n'))
    nsenter(argv[2], "net");
  if (strchr(argv[1], 'm'))
    nsenter(argv[2], "mnt");
  pid_t cpid = _ensure(30, fork());
  if (cpid == 0)
    _ensure(31, chain_command(3, argc, argv));
  int status;
  _ensure(34, waitpid(cpid, &status, 0));
  return WIFEXITED(status) ? WEXITSTATUS(status) : 1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%edx
mov    $0x13,%edi
mov    $0x4,%esi
call   1030 <_ensure_argc@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    $0x75,%esi
call   1040 <strchr@plt>
cmp    $0x0,%rax
je     11ef <main+0x5f>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe16(%rip),%rsi
call   1080 <nsenter@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    $0x69,%esi
call   1040 <strchr@plt>
cmp    $0x0,%rax
je     121f <main+0x8f>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xdea(%rip),%rsi
call   1080 <nsenter@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    $0x70,%esi
call   1040 <strchr@plt>
cmp    $0x0,%rax
je     124f <main+0xbf>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xdbe(%rip),%rsi
call   1080 <nsenter@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    $0x6e,%esi
call   1040 <strchr@plt>
cmp    $0x0,%rax
je     127f <main+0xef>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xd92(%rip),%rsi
call   1080 <nsenter@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    $0x6d,%esi
call   1040 <strchr@plt>
cmp    $0x0,%rax
je     12af <main+0x11f>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xd66(%rip),%rsi
call   1080 <nsenter@plt>
mov    $0x0,%al
call   10b0 <fork@plt>
mov    %eax,%esi
mov    $0x1e,%edi
call   10a0 <_ensure@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    12ee <main+0x15e>
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%rdx
mov    $0x3,%edi
call   1070 <chain_command@plt>
mov    %eax,%esi
mov    $0x1f,%edi
call   10a0 <_ensure@plt>
mov    -0x20(%rbp),%rdi
lea    -0x24(%rbp),%rsi
xor    %edx,%edx
call   1060 <waitpid@plt>
mov    %eax,%esi
mov    $0x22,%edi
call   10a0 <_ensure@plt>
mov    -0x24(%rbp),%edi
call   1090 <WIFEXITED@plt>
cmp    $0x0,%rax
je     132b <main+0x19b>
mov    -0x24(%rbp),%edi
call   1050 <WEXITSTATUS@plt>
mov    %eax,-0x28(%rbp)
jmp    1338 <main+0x1a8>
mov    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1338 <main+0x1a8>
mov    -0x28(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
mov    %edi,%r14d
mov    $0x13,%edi
mov    $0x4,%esi
mov    %r14d,%edx
call   1030 <_ensure_argc@plt>
mov    0x8(%rbx),%rdi
mov    $0x75,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     11d3 <main+0x43>
mov    0x10(%rbx),%rdi
lea    0xe32(%rip),%rsi
call   1080 <nsenter@plt>
mov    0x8(%rbx),%rdi
mov    $0x69,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     11f6 <main+0x66>
mov    0x10(%rbx),%rdi
lea    0xe13(%rip),%rsi
call   1080 <nsenter@plt>
mov    0x8(%rbx),%rdi
mov    $0x70,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     1219 <main+0x89>
mov    0x10(%rbx),%rdi
lea    0xdf4(%rip),%rsi
call   1080 <nsenter@plt>
mov    0x8(%rbx),%rdi
mov    $0x6e,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     123c <main+0xac>
mov    0x10(%rbx),%rdi
lea    0xdd5(%rip),%rsi
call   1080 <nsenter@plt>
mov    0x8(%rbx),%rdi
mov    $0x6d,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     125f <main+0xcf>
mov    0x10(%rbx),%rdi
lea    0xdb6(%rip),%rsi
call   1080 <nsenter@plt>
xor    %eax,%eax
call   10b0 <fork@plt>
mov    $0x1e,%edi
mov    %eax,%esi
call   10a0 <_ensure@plt>
mov    %rax,%rbp
test   %rax,%rax
jne    1296 <main+0x106>
mov    $0x3,%edi
mov    %r14d,%esi
mov    %rbx,%rdx
call   1070 <chain_command@plt>
mov    $0x1f,%edi
mov    %eax,%esi
call   10a0 <_ensure@plt>
lea    0xc(%rsp),%rsi
mov    %rbp,%rdi
xor    %edx,%edx
call   1060 <waitpid@plt>
mov    $0x22,%edi
mov    %eax,%esi
call   10a0 <_ensure@plt>
mov    0xc(%rsp),%edi
call   1090 <WIFEXITED@plt>
test   %rax,%rax
je     12ca <main+0x13a>
mov    0xc(%rsp),%edi
call   1050 <WEXITSTATUS@plt>
jmp    12cf <main+0x13f>
mov    $0x1,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"uts\00"
@.str.1 = [4 x i8] c"ipc\00"
@.str.2 = [4 x i8] c"pid\00"
@.str.3 = [4 x i8] c"net\00"
@.str.4 = [4 x i8] c"mnt\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i64
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = call i32 @_ensure_argc(i32 19, i32 4, i32 %9)
store i32 0, i32* %6
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 1
%13 = load i8*, i8** %12
%14 = call i64 @strchr(i8* %13, i8 signext 117)
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %21
16: ; preds = %2
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 2
%19 = load i8*, i8** %18
%20 = call i32 @nsenter(i8* %19, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
br label %21
21: ; preds = %16, %2
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = load i8*, i8** %23
%25 = call i64 @strchr(i8* %24, i8 signext 105)
%26 = icmp ne i64 %25, 0
br i1 %26, label %27, label %32
27: ; preds = %21
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 2
%30 = load i8*, i8** %29
%31 = call i32 @nsenter(i8* %30, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
br label %32
32: ; preds = %27, %21
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i64 1
%35 = load i8*, i8** %34
%36 = call i64 @strchr(i8* %35, i8 signext 112)
%37 = icmp ne i64 %36, 0
br i1 %37, label %38, label %43
38: ; preds = %32
%39 = load i8**, i8*** %5
%40 = getelementptr inbounds i8*, i8** %39, i64 2
%41 = load i8*, i8** %40
%42 = call i32 @nsenter(i8* %41, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
br label %43
43: ; preds = %38, %32
%44 = load i8**, i8*** %5
%45 = getelementptr inbounds i8*, i8** %44, i64 1
%46 = load i8*, i8** %45
%47 = call i64 @strchr(i8* %46, i8 signext 110)
%48 = icmp ne i64 %47, 0
br i1 %48, label %49, label %54
49: ; preds = %43
%50 = load i8**, i8*** %5
%51 = getelementptr inbounds i8*, i8** %50, i64 2
%52 = load i8*, i8** %51
%53 = call i32 @nsenter(i8* %52, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
br label %54
54: ; preds = %49, %43
%55 = load i8**, i8*** %5
%56 = getelementptr inbounds i8*, i8** %55, i64 1
%57 = load i8*, i8** %56
%58 = call i64 @strchr(i8* %57, i8 signext 109)
%59 = icmp ne i64 %58, 0
br i1 %59, label %60, label %65
60: ; preds = %54
%61 = load i8**, i8*** %5
%62 = getelementptr inbounds i8*, i8** %61, i64 2
%63 = load i8*, i8** %62
%64 = call i32 @nsenter(i8* %63, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
br label %65
65: ; preds = %60, %54
%66 = call i32 (...) @fork()
%67 = call i64 @_ensure(i32 30, i32 %66)
store i64 %67, i64* %7
%68 = load i64, i64* %7
%69 = icmp eq i64 %68, 0
br i1 %69, label %70, label %75
70: ; preds = %65
%71 = load i32, i32* %4
%72 = load i8**, i8*** %5
%73 = call i32 @chain_command(i32 3, i32 %71, i8** %72)
%74 = call i64 @_ensure(i32 31, i32 %73)
br label %75
75: ; preds = %70, %65
%76 = load i64, i64* %7
%77 = call i32 @waitpid(i64 %76, i32* %8, i32 0)
%78 = call i64 @_ensure(i32 34, i32 %77)
%79 = load i32, i32* %8
%80 = call i64 @WIFEXITED(i32 %79)
%81 = icmp ne i64 %80, 0
br i1 %81, label %82, label %85
82: ; preds = %75
%83 = load i32, i32* %8
%84 = call i32 @WEXITSTATUS(i32 %83)
br label %86
85: ; preds = %75
br label %86
86: ; preds = %85, %82
%87 = phi i32 [ %84, %82 ], [ 1, %85 ]
ret i32 %87
}

LLVM IR (-O2):
@.str = [4 x i8] c"uts\00"
@.str.1 = [4 x i8] c"ipc\00"
@.str.2 = [4 x i8] c"pid\00"
@.str.3 = [4 x i8] c"net\00"
@.str.4 = [4 x i8] c"mnt\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = tail call i32 @_ensure_argc(i32 19, i32 4, i32 %0)
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i64 @strchr(i8* %6, i8 signext 117)
%8 = icmp eq i64 %7, 0
br i1 %8, label %13, label %9
9: ; preds = %2
%10 = getelementptr inbounds i8*, i8** %1, i64 2
%11 = load i8*, i8** %10
%12 = tail call i32 @nsenter(i8* %11, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
br label %13
13: ; preds = %9, %2
%14 = load i8*, i8** %5
%15 = tail call i64 @strchr(i8* %14, i8 signext 105)
%16 = icmp eq i64 %15, 0
br i1 %16, label %21, label %17
17: ; preds = %13
%18 = getelementptr inbounds i8*, i8** %1, i64 2
%19 = load i8*, i8** %18
%20 = tail call i32 @nsenter(i8* %19, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
br label %21
21: ; preds = %17, %13
%22 = load i8*, i8** %5
%23 = tail call i64 @strchr(i8* %22, i8 signext 112)
%24 = icmp eq i64 %23, 0
br i1 %24, label %29, label %25
25: ; preds = %21
%26 = getelementptr inbounds i8*, i8** %1, i64 2
%27 = load i8*, i8** %26
%28 = tail call i32 @nsenter(i8* %27, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
br label %29
29: ; preds = %25, %21
%30 = load i8*, i8** %5
%31 = tail call i64 @strchr(i8* %30, i8 signext 110)
%32 = icmp eq i64 %31, 0
br i1 %32, label %37, label %33
33: ; preds = %29
%34 = getelementptr inbounds i8*, i8** %1, i64 2
%35 = load i8*, i8** %34
%36 = tail call i32 @nsenter(i8* %35, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
br label %37
37: ; preds = %33, %29
%38 = load i8*, i8** %5
%39 = tail call i64 @strchr(i8* %38, i8 signext 109)
%40 = icmp eq i64 %39, 0
br i1 %40, label %45, label %41
41: ; preds = %37
%42 = getelementptr inbounds i8*, i8** %1, i64 2
%43 = load i8*, i8** %42
%44 = tail call i32 @nsenter(i8* %43, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
br label %45
45: ; preds = %41, %37
%46 = tail call i32 (...) @fork()
%47 = tail call i64 @_ensure(i32 30, i32 %46)
%48 = icmp eq i64 %47, 0
br i1 %48, label %49, label %52
49: ; preds = %45
%50 = tail call i32 @chain_command(i32 3, i32 %0, i8** %1)
%51 = tail call i64 @_ensure(i32 31, i32 %50)
br label %52
52: ; preds = %49, %45
%53 = bitcast i32* %3 to i8*
%54 = call i32 @waitpid(i64 %47, i32* %3, i32 0)
%55 = call i64 @_ensure(i32 34, i32 %54)
%56 = load i32, i32* %3
%57 = call i64 @WIFEXITED(i32 %56)
%58 = icmp eq i64 %57, 0
br i1 %58, label %62, label %59
59: ; preds = %52
%60 = load i32, i32* %3
%61 = call i32 @WEXITSTATUS(i32 %60)
br label %62
62: ; preds = %52, %59
%63 = phi i32 [ %61, %59 ], [ 1, %52 ]
ret i32 %63
}