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

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
char *getenv(char *);
int /*<<< orphan*/ stderr;
int strtol(char *, char **, int);
int get_RUNVNETNSPID(void) {
  int pid;
  char *nspidStr, *endptr;
  nspidStr = getenv("_RUNVNETNSPID");
  if (nspidStr == NULL || *nspidStr == '\0')
    return -1;
  pid = strtol(nspidStr, &endptr, 10);
  if (*endptr != '\0')
    do {
      int ret = 0 + 1;
      fprintf(stderr, "nsenter: "
                      "unable to parse _RUNVNETNSPID"
                      ": %m\n");
      exit(ret);
    } while (0);
  return pid;
}


x86 assembly (clang, -O0):
<get_RUNVNETNSPID>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xeb1(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1173 <get_RUNVNETNSPID+0x33>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    117f <get_RUNVNETNSPID+0x3f>
movl   $0xffffffff,-0x4(%rbp)
jmp    11d3 <get_RUNVNETNSPID+0x93>
mov    -0x10(%rbp),%rdi
lea    -0x18(%rbp),%rsi
mov    $0xa,%edx
call   1050 <strtol@plt>
mov    %eax,-0x8(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11cd <get_RUNVNETNSPID+0x8d>
jmp    11a9 <get_RUNVNETNSPID+0x69>
movl   $0x1,-0x1c(%rbp)
mov    0x2e29(%rip),%rax
mov    (%rax),%edi
lea    0xe4e(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x1c(%rbp),%edi
call   1060 <exit@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_RUNVNETNSPID>:
push   %rax
lea    0xeb8(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,%rdi
mov    $0xffffffff,%eax
test   %rdi,%rdi
je     1175 <get_RUNVNETNSPID+0x35>
cmpb   $0x0,(%rdi)
je     1175 <get_RUNVNETNSPID+0x35>
mov    %rsp,%rsi
mov    $0xa,%edx
call   1050 <strtol@plt>
mov    (%rsp),%rcx
cmpb   $0x0,(%rcx)
jne    1177 <get_RUNVNETNSPID+0x37>
pop    %rcx
ret
mov    0x2e62(%rip),%rax
mov    (%rax),%edi
lea    0xe87(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [14 x i8] c"_RUNVNETNSPID\00"
@stderr = global i32 0
@.str.1 = [44 x i8] c"nsenter: unable to parse _RUNVNETNSPID: %m\0A\00"
define i32 @get_RUNVNETNSPID() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = call i8* @getenv(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
store i8* %6, i8** %3
%7 = load i8*, i8** %3
%8 = icmp eq i8* %7, null
br i1 %8, label %14, label %9
9: ; preds = %0
%10 = load i8*, i8** %3
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %9, %0
store i32 -1, i32* %1
br label %31
15: ; preds = %9
%16 = load i8*, i8** %3
%17 = call i32 @strtol(i8* %16, i8** %4, i32 10)
store i32 %17, i32* %2
%18 = load i8*, i8** %4
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %29
22: ; preds = %15
br label %23
23: ; preds = %22
store i32 1, i32* %5
%24 = load i32, i32* @stderr
%25 = call i32 @fprintf(i32 %24, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.1, i64 0, i64 0))
%26 = load i32, i32* %5
%27 = call i32 @exit(i32 %26)
unreachable
28: ; No predecessors!
br label %29
29: ; preds = %28, %15
%30 = load i32, i32* %2
store i32 %30, i32* %1
br label %31
31: ; preds = %29, %14
%32 = load i32, i32* %1
ret i32 %32
}

LLVM IR (-O2):
@.str = [14 x i8] c"_RUNVNETNSPID\00"
@stderr = global i32 0
@.str.1 = [44 x i8] c"nsenter: unable to parse _RUNVNETNSPID: %m\0A\00"
define i32 @get_RUNVNETNSPID() {
%1 = alloca i8*
%2 = bitcast i8** %1 to i8*
%3 = tail call i8* @getenv(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i8* %3, null
br i1 %4, label %17, label %5
5: ; preds = %0
%6 = load i8, i8* %3
%7 = icmp eq i8 %6, 0
br i1 %7, label %17, label %8
8: ; preds = %5
%9 = call i32 @strtol(i8* %3, i8** %1, i32 10)
%10 = load i8*, i8** %1
%11 = load i8, i8* %10
%12 = icmp eq i8 %11, 0
br i1 %12, label %17, label %13
13: ; preds = %8
%14 = load i32, i32* @stderr
%15 = tail call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.1, i64 0, i64 0))
%16 = tail call i32 @exit(i32 1)
unreachable
17: ; preds = %8, %0, %5
%18 = phi i32 [ -1, %5 ], [ -1, %0 ], [ %9, %8 ]
ret i32 %18
}