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

/* Variables and functions */
int PATH_MAX;
int atoi(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
char *getenv(char *);
int /*<<< orphan*/ snprintf(char *, int, char *, int);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, char *);
int get_init_pipe() {
  char buf[PATH_MAX];
  char *initpipe;
  int pipenum = -1;
  initpipe = getenv("_LIBCONTAINER_INITPIPE");
  if (initpipe == NULL) {
    return -1;
  }
  pipenum = atoi(initpipe);
  snprintf(buf, sizeof(buf), "%d", pipenum);
  if (strcmp(initpipe, buf)) {
    fprintf(stderr, "nsenter: "
                    "Unable to parse _LIBCONTAINER_INITPIPE"
                    ": %m\n");
    exit(1);
  }
  return pipenum;
}


x86 assembly (clang, -O0):
<get_init_pipe>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    0x2e81(%rip),%rax
mov    (%rax),%eax
mov    %rax,-0x38(%rbp)
mov    %rsp,%rcx
mov    %rcx,-0x10(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x18(%rbp)
movl   $0xffffffff,-0x24(%rbp)
lea    0xe5a(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11cd <get_init_pipe+0x6d>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x28(%rbp)
jmp    1237 <get_init_pipe+0xd7>
mov    -0x20(%rbp),%rdi
call   1070 <atoi@plt>
mov    -0x30(%rbp),%rdi
mov    %eax,%ecx
mov    -0x38(%rbp),%rax
mov    %ecx,-0x24(%rbp)
mov    %eax,%esi
mov    -0x24(%rbp),%ecx
lea    0xe28(%rip),%rdx
call   1040 <snprintf@plt>
mov    -0x30(%rbp),%rsi
mov    -0x20(%rbp),%rdi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     122a <get_init_pipe+0xca>
mov    0x2dc6(%rip),%rax
mov    (%rax),%edi
lea    0xdff(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_init_pipe>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    0x2e7e(%rip),%rax
mov    (%rax),%r14d
mov    %rsp,%rbx
lea    0xf(%r14),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
lea    0xe73(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     11e8 <get_init_pipe+0x88>
mov    %rax,%r12
mov    %rax,%rdi
call   1070 <atoi@plt>
mov    %eax,%r15d
lea    0xe6b(%rip),%rdx
mov    %rbx,%rdi
mov    %r14d,%esi
mov    %eax,%ecx
call   1040 <snprintf@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     11ee <get_init_pipe+0x8e>
mov    0x2e08(%rip),%rax
mov    (%rax),%edi
lea    0xe41(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    $0xffffffff,%r15d
mov    %r15d,%eax
lea    -0x20(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@PATH_MAX = global i32 0
@.str = [23 x i8] c"_LIBCONTAINER_INITPIPE\00"
@.str.1 = [3 x i8] c"%d\00"
@stderr = global i32 0
@.str.2 = [53 x i8] c"nsenter: Unable to parse _LIBCONTAINER_INITPIPE: %m\0A\00"
define i32 @get_init_pipe() {
%1 = load i32, i32* @PATH_MAX
%2 = zext i32 %1 to i64
%3 = alloca i8, i64 %2
%4 = tail call i8* @getenv(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i8* %4, null
br i1 %5, label %15, label %6
6: ; preds = %0
%7 = tail call i32 @atoi(i8* %4)
%8 = call i32 @snprintf(i8* %3, i32 %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %7)
%9 = call i64 @strcmp(i8* %4, i8* %3)
%10 = icmp eq i64 %9, 0
br i1 %10, label %15, label %11
11: ; preds = %6
%12 = load i32, i32* @stderr
%13 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.2, i64 0, i64 0))
%14 = call i32 @exit(i32 1)
unreachable
15: ; preds = %6, %0
%16 = phi i32 [ -1, %0 ], [ %7, %6 ]
ret i32 %16
}