#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 */
scalar_t__ errno;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
char *getenv(char *);
int /*<<< orphan*/ stderr;
int strtol(char *, char **, int);
int initpipe(void) {
  int pipenum;
  char *initpipe, *endptr;
  initpipe = getenv("_LIBCONTAINER_INITPIPE");
  if (initpipe == NULL || *initpipe == '\0')
    return -1;
  errno = 0;
  pipenum = strtol(initpipe, &endptr, 10);
  if (errno != 0 || *endptr != '\0')
    do {
      fprintf(stderr, "nsenter: "
                      "unable to parse _LIBCONTAINER_INITPIPE"
                      ": %m\n");
      exit(1 + 1);
    } while (0);
  return pipenum;
}


x86 assembly (clang, -O0):
<initpipe>:
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 <initpipe+0x33>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    117f <initpipe+0x3f>
movl   $0xffffffff,-0x4(%rbp)
jmp    11ed <initpipe+0xad>
mov    0x2e52(%rip),%rax
movq   $0x0,(%rax)
mov    -0x10(%rbp),%rdi
lea    -0x18(%rbp),%rsi
mov    $0xa,%edx
call   1050 <strtol@plt>
mov    %eax,-0x8(%rbp)
mov    0x2e2f(%rip),%rax
cmpq   $0x0,(%rax)
jne    11c3 <initpipe+0x83>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11e7 <initpipe+0xa7>
jmp    11c8 <initpipe+0x88>
mov    0x2e11(%rip),%rax
mov    (%rax),%edi
lea    0xe3f(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x2,%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):
<initpipe>:
push   %rbx
sub    $0x10,%rsp
lea    0xeb4(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,%rdi
mov    $0xffffffff,%eax
test   %rdi,%rdi
je     1190 <initpipe+0x50>
cmpb   $0x0,(%rdi)
je     1190 <initpipe+0x50>
mov    0x2e6e(%rip),%rbx
movq   $0x0,(%rbx)
lea    0x8(%rsp),%rsi
mov    $0xa,%edx
call   1050 <strtol@plt>
cmpq   $0x0,(%rbx)
jne    1196 <initpipe+0x56>
mov    0x8(%rsp),%rcx
cmpb   $0x0,(%rcx)
jne    1196 <initpipe+0x56>
add    $0x10,%rsp
pop    %rbx
ret
mov    0x2e43(%rip),%rax
mov    (%rax),%edi
lea    0xe71(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x2,%edi
call   1060 <exit@plt>

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

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