#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 utsname {
  int /*<<< orphan*/ release;
};
typedef scalar_t__ pid_t;

/* Variables and functions */
int /*<<< orphan*/ PR_SET_NO_NEW_PRIVS;
int WEXITSTATUS(int);
scalar_t__ WIFEXITED(int);
int /*<<< orphan*/ execvp(char *, char **);
int /*<<< orphan*/ exit(int);
scalar_t__ fork();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ perror(char *);
int prctl(int /*<<< orphan*/, int, int /*<<< orphan*/, int /*<<< orphan*/,
          int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, char *);
scalar_t__ strverscmp(int /*<<< orphan*/, char *);
scalar_t__ uname(struct utsname *);
scalar_t__ wait(int *);
int main(int argc, char **argv) {
  bool nobounded;
  struct utsname uts;
  pid_t pid;
  int rc, status;
  if (argc < 2) {
    fprintf(stderr, "usage:  %s command [args...]\n", argv[0]);
    exit(-1);
  }
  if (uname(&uts) < 0) {
    perror("uname");
    exit(-1);
  }
  nobounded = ((strcmp(argv[argc - 1], "test_nnp_bounded_t") == 0) &&
               (strverscmp(uts.release, "3.18") < 0));
  rc = prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0);
  if (rc < 0) {
    perror("prctl PR_SET_NO_NEW_PRIVS");
    exit(-1);
  }
  pid = fork();
  if (pid < 0) {
    perror("fork");
    exit(-1);
  }
  if (pid == 0) {
    execvp(argv[1], &argv[1]);
    perror(argv[1]);
    exit(-1);
  }
  pid = wait(&status);
  if (WIFEXITED(status)) {
    if (nobounded) {
      if (!WEXITSTATUS(status))
        exit(-1);
      printf("%s:  Kernels < v3.18 do not support bounded transitions under "
             "NNP.\n",
             argv[0]);
      exit(0);
    }
    exit(WEXITSTATUS(status));
  }
  fprintf(stderr, "Unexpected exit status 0x%x\n", status);
  exit(-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)
cmpl   $0x2,-0x8(%rbp)
jge    1218 <main+0x48>
mov    0x2de9(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xdf9(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    $0xffffffff,%edi
call   10d0 <exit@plt>
lea    -0x18(%rbp),%rdi
call   1050 <uname@plt>
cmp    $0x0,%rax
jge    1241 <main+0x71>
lea    0xdec(%rip),%rdi
call   10a0 <perror@plt>
mov    $0xffffffff,%edi
call   10d0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xdcb(%rip),%rsi
call   1060 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x29(%rbp)
jne    1289 <main+0xb9>
mov    -0x18(%rbp),%edi
lea    0xdbd(%rip),%rsi
call   1030 <strverscmp@plt>
cmp    $0x0,%rax
setl   %al
mov    %al,-0x29(%rbp)
mov    -0x29(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x14(%rbp)
mov    0x2d3d(%rip),%rax
mov    (%rax),%edi
mov    $0x1,%esi
xor    %r8d,%r8d
mov    %r8d,%edx
mov    %r8d,%ecx
call   1080 <prctl@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jge    12d3 <main+0x103>
lea    0xd78(%rip),%rdi
call   10a0 <perror@plt>
mov    $0xffffffff,%edi
call   10d0 <exit@plt>
mov    $0x0,%al
call   10f0 <fork@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jge    12ff <main+0x12f>
lea    0xd66(%rip),%rdi
call   10a0 <perror@plt>
mov    $0xffffffff,%edi
call   10d0 <exit@plt>
cmpq   $0x0,-0x20(%rbp)
jne    1336 <main+0x166>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x10(%rbp),%rsi
add    $0x8,%rsi
call   10b0 <execvp@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10a0 <perror@plt>
mov    $0xffffffff,%edi
call   10d0 <exit@plt>
lea    -0x28(%rbp),%rdi
call   10e0 <wait@plt>
mov    %rax,-0x20(%rbp)
mov    -0x28(%rbp),%edi
call   10c0 <WIFEXITED@plt>
cmp    $0x0,%rax
je     13a3 <main+0x1d3>
cmpl   $0x0,-0x14(%rbp)
je     1394 <main+0x1c4>
mov    -0x28(%rbp),%edi
call   1090 <WEXITSTATUS@plt>
cmp    $0x0,%eax
jne    137a <main+0x1aa>
mov    $0xffffffff,%edi
call   10d0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xcd3(%rip),%rdi
call   1040 <printf@plt>
xor    %edi,%edi
call   10d0 <exit@plt>
mov    -0x28(%rbp),%edi
call   1090 <WEXITSTATUS@plt>
mov    %eax,%edi
call   10d0 <exit@plt>
mov    0x2c36(%rip),%rax
mov    (%rax),%edi
mov    -0x28(%rbp),%edx
lea    0xce9(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    $0xffffffff,%edi
call   10d0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r15
cmp    $0x1,%edi
jg     1205 <main+0x35>
mov    0x2df8(%rip),%rax
mov    (%rax),%edi
mov    (%r15),%rdx
lea    0xe0c(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    $0xffffffff,%edi
call   10d0 <exit@plt>
mov    %edi,%ebx
lea    0x8(%rsp),%rdi
call   1050 <uname@plt>
test   %rax,%rax
jns    1222 <main+0x52>
lea    0xe01(%rip),%rdi
jmp    12a5 <main+0xd5>
add    $0xffffffff,%ebx
mov    (%r15,%rbx,8),%rdi
lea    0xdf4(%rip),%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
jne    1253 <main+0x83>
mov    0x8(%rsp),%edi
lea    0xdf2(%rip),%rsi
call   1030 <strverscmp@plt>
mov    %rax,%r14
shr    $0x3f,%r14
jmp    1256 <main+0x86>
xor    %r14d,%r14d
mov    0x2d7b(%rip),%rax
mov    (%rax),%edi
mov    $0x1,%esi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1080 <prctl@plt>
test   %eax,%eax
jns    127d <main+0xad>
lea    0xdc1(%rip),%rdi
jmp    12a5 <main+0xd5>
xor    %eax,%eax
call   10f0 <fork@plt>
test   %rax,%rax
jns    1292 <main+0xc2>
lea    0xdc6(%rip),%rdi
jmp    12a5 <main+0xd5>
jne    12b4 <main+0xe4>
lea    0x8(%r15),%rsi
mov    0x8(%r15),%rdi
call   10b0 <execvp@plt>
mov    0x8(%r15),%rdi
call   10a0 <perror@plt>
mov    $0xffffffff,%edi
call   10d0 <exit@plt>
lea    0x4(%rsp),%rdi
call   10e0 <wait@plt>
mov    0x4(%rsp),%edi
call   10c0 <WIFEXITED@plt>
test   %rax,%rax
jne    12f1 <main+0x121>
mov    0x2d0d(%rip),%rax
mov    (%rax),%edi
mov    0x4(%rsp),%edx
lea    0xdbf(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    $0xffffffff,%edi
call   10d0 <exit@plt>
mov    0x4(%rsp),%edi
call   1090 <WEXITSTATUS@plt>
test   %r14b,%r14b
je     131d <main+0x14d>
test   %eax,%eax
je     11fb <main+0x2b>
mov    (%r15),%rsi
lea    0xd4a(%rip),%rdi
call   1040 <printf@plt>
xor    %edi,%edi
call   10d0 <exit@plt>
mov    %eax,%edi
call   10d0 <exit@plt>

LLVM IR (-O0):
%struct.utsname = type { i32 }
@stderr = global i32 0
@.str = [30 x i8] c"usage: %s command [args...]\0A\00"
@.str.1 = [6 x i8] c"uname\00"
@.str.2 = [19 x i8] c"test_nnp_bounded_t\00"
@.str.3 = [5 x i8] c"3.18\00"
@PR_SET_NO_NEW_PRIVS = global i32 0
@.str.4 = [26 x i8] c"prctl PR_SET_NO_NEW_PRIVS\00"
@.str.5 = [5 x i8] c"fork\00"
@.str.6 = [68 x i8] c"%s: Kernels < v3.18 do not support bounded transitions under NNP.\0A\00"
@.str.7 = [29 x i8] c"Unexpected exit status 0x%x\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca %struct.utsname
%8 = alloca i64
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* %4
%12 = icmp slt i32 %11, 2
br i1 %12, label %13, label %20
13: ; preds = %2
%14 = load i32, i32* @stderr
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 0
%17 = load i8*, i8** %16
%18 = call i32 (i32, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* %17)
%19 = call i32 @exit(i32 -1)
unreachable
20: ; preds = %2
%21 = call i64 @uname(%struct.utsname* %7)
%22 = icmp slt i64 %21, 0
br i1 %22, label %23, label %26
23: ; preds = %20
%24 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%25 = call i32 @exit(i32 -1)
unreachable
26: ; preds = %20
%27 = load i8**, i8*** %5
%28 = load i32, i32* %4
%29 = sub nsw i32 %28, 1
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8*, i8** %27, i64 %30
%32 = load i8*, i8** %31
%33 = call i64 @strcmp(i8* %32, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
%34 = icmp eq i64 %33, 0
br i1 %34, label %35, label %40
35: ; preds = %26
%36 = getelementptr inbounds %struct.utsname, %struct.utsname* %7, i32 0, i32 0
%37 = load i32, i32* %36
%38 = call i64 @strverscmp(i32 %37, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%39 = icmp slt i64 %38, 0
br label %40
40: ; preds = %35, %26
%41 = phi i1 [ false, %26 ], [ %39, %35 ]
%42 = zext i1 %41 to i32
store i32 %42, i32* %6
%43 = load i32, i32* @PR_SET_NO_NEW_PRIVS
%44 = call i32 @prctl(i32 %43, i32 1, i32 0, i32 0, i32 0)
store i32 %44, i32* %9
%45 = load i32, i32* %9
%46 = icmp slt i32 %45, 0
br i1 %46, label %47, label %50
47: ; preds = %40
%48 = call i32 @perror(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0))
%49 = call i32 @exit(i32 -1)
unreachable
50: ; preds = %40
%51 = call i64 (...) @fork()
store i64 %51, i64* %8
%52 = load i64, i64* %8
%53 = icmp slt i64 %52, 0
br i1 %53, label %54, label %57
54: ; preds = %50
%55 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%56 = call i32 @exit(i32 -1)
unreachable
57: ; preds = %50
%58 = load i64, i64* %8
%59 = icmp eq i64 %58, 0
br i1 %59, label %60, label %72
60: ; preds = %57
%61 = load i8**, i8*** %5
%62 = getelementptr inbounds i8*, i8** %61, i64 1
%63 = load i8*, i8** %62
%64 = load i8**, i8*** %5
%65 = getelementptr inbounds i8*, i8** %64, i64 1
%66 = call i32 @execvp(i8* %63, i8** %65)
%67 = load i8**, i8*** %5
%68 = getelementptr inbounds i8*, i8** %67, i64 1
%69 = load i8*, i8** %68
%70 = call i32 @perror(i8* %69)
%71 = call i32 @exit(i32 -1)
unreachable
72: ; preds = %57
%73 = call i64 @wait(i32* %10)
store i64 %73, i64* %8
%74 = load i32, i32* %10
%75 = call i64 @WIFEXITED(i32 %74)
%76 = icmp ne i64 %75, 0
br i1 %76, label %77, label %96
77: ; preds = %72
%78 = load i32, i32* %6
%79 = icmp ne i32 %78, 0
br i1 %79, label %80, label %92
80: ; preds = %77
%81 = load i32, i32* %10
%82 = call i32 @WEXITSTATUS(i32 %81)
%83 = icmp ne i32 %82, 0
br i1 %83, label %86, label %84
84: ; preds = %80
%85 = call i32 @exit(i32 -1)
unreachable
86: ; preds = %80
%87 = load i8**, i8*** %5
%88 = getelementptr inbounds i8*, i8** %87, i64 0
%89 = load i8*, i8** %88
%90 = call i32 @printf(i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.6, i64 0, i64 0), i8* %89)
%91 = call i32 @exit(i32 0)
unreachable
92: ; preds = %77
%93 = load i32, i32* %10
%94 = call i32 @WEXITSTATUS(i32 %93)
%95 = call i32 @exit(i32 %94)
unreachable
96: ; preds = %72
%97 = load i32, i32* @stderr
%98 = load i32, i32* %10
%99 = call i32 (i32, i8*, ...) @fprintf(i32 %97, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.7, i64 0, i64 0), i32 %98)
%100 = call i32 @exit(i32 -1)
unreachable
}

LLVM IR (-O2):
%struct.utsname = type { i32 }
@stderr = global i32 0
@.str = [30 x i8] c"usage: %s command [args...]\0A\00"
@.str.1 = [6 x i8] c"uname\00"
@.str.2 = [19 x i8] c"test_nnp_bounded_t\00"
@.str.3 = [5 x i8] c"3.18\00"
@PR_SET_NO_NEW_PRIVS = global i32 0
@.str.4 = [26 x i8] c"prctl PR_SET_NO_NEW_PRIVS\00"
@.str.5 = [5 x i8] c"fork\00"
@.str.6 = [68 x i8] c"%s: Kernels < v3.18 do not support bounded transitions under NNP.\0A\00"
@.str.7 = [29 x i8] c"Unexpected exit status 0x%x\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca %struct.utsname
%4 = alloca i32
%5 = bitcast %struct.utsname* %3 to i8*
%6 = bitcast i32* %4 to i8*
%7 = icmp slt i32 %0, 2
br i1 %7, label %8, label %13
8: ; preds = %2
%9 = load i32, i32* @stderr
%10 = load i8*, i8** %1
%11 = tail call i32 (i32, i8*, ...) @fprintf(i32 %9, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* %10)
%12 = tail call i32 @exit(i32 -1)
unreachable
13: ; preds = %2
%14 = call i64 @uname(%struct.utsname* %3)
%15 = icmp slt i64 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %13
%17 = tail call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%18 = tail call i32 @exit(i32 -1)
unreachable
19: ; preds = %13
%20 = add nsw i32 %0, -1
%21 = zext i32 %20 to i64
%22 = getelementptr inbounds i8*, i8** %1, i64 %21
%23 = load i8*, i8** %22
%24 = tail call i64 @strcmp(i8* %23, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %31
26: ; preds = %19
%27 = getelementptr inbounds %struct.utsname, %struct.utsname* %3, i64 0, i32 0
%28 = load i32, i32* %27
%29 = tail call i64 @strverscmp(i32 %28, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%30 = icmp slt i64 %29, 0
br label %31
31: ; preds = %26, %19
%32 = phi i1 [ false, %19 ], [ %30, %26 ]
%33 = load i32, i32* @PR_SET_NO_NEW_PRIVS
%34 = tail call i32 @prctl(i32 %33, i32 1, i32 0, i32 0, i32 0)
%35 = icmp slt i32 %34, 0
br i1 %35, label %36, label %39
36: ; preds = %31
%37 = tail call i32 @perror(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0))
%38 = tail call i32 @exit(i32 -1)
unreachable
39: ; preds = %31
%40 = tail call i64 (...) @fork()
%41 = icmp slt i64 %40, 0
br i1 %41, label %42, label %45
42: ; preds = %39
%43 = tail call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%44 = tail call i32 @exit(i32 -1)
unreachable
45: ; preds = %39
%46 = icmp eq i64 %40, 0
br i1 %46, label %47, label %54
47: ; preds = %45
%48 = getelementptr inbounds i8*, i8** %1, i64 1
%49 = load i8*, i8** %48
%50 = tail call i32 @execvp(i8* %49, i8** %48)
%51 = load i8*, i8** %48
%52 = tail call i32 @perror(i8* %51)
%53 = tail call i32 @exit(i32 -1)
unreachable
54: ; preds = %45
%55 = call i64 @wait(i32* %4)
%56 = load i32, i32* %4
%57 = call i64 @WIFEXITED(i32 %56)
%58 = icmp eq i64 %57, 0
br i1 %58, label %72, label %59
59: ; preds = %54
%60 = load i32, i32* %4
%61 = call i32 @WEXITSTATUS(i32 %60)
br i1 %32, label %62, label %70
62: ; preds = %59
%63 = icmp eq i32 %61, 0
br i1 %63, label %64, label %66
64: ; preds = %62
%65 = call i32 @exit(i32 -1)
unreachable
66: ; preds = %62
%67 = load i8*, i8** %1
%68 = call i32 @printf(i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.6, i64 0, i64 0), i8* %67)
%69 = call i32 @exit(i32 0)
unreachable
70: ; preds = %59
%71 = call i32 @exit(i32 %61)
unreachable
72: ; preds = %54
%73 = load i32, i32* @stderr
%74 = load i32, i32* %4
%75 = call i32 (i32, i8*, ...) @fprintf(i32 %73, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.7, i64 0, i64 0), i32 %74)
%76 = call i32 @exit(i32 -1)
unreachable
}