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

/* Variables and functions */
int /*<<< orphan*/ F_OK;
int MAXPATHLEN;
int access(char *, int /*<<< orphan*/);
int /*<<< orphan*/ snprintf(char *, int, char *, char *, char const *);
int namespace_alive(const char *name) {
  char pidns_path[MAXPATHLEN];
  snprintf(pidns_path, sizeof(pidns_path), "%s/%s/pid", "/var/run/pidns", name);
  if (access(pidns_path, F_OK) != -1) {
    return 0;
  }
  return -1;
}


x86 assembly (clang, -O0):
<namespace_alive>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    0x2eb5(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x30(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x20(%rbp)
mov    %eax,%esi
mov    -0x10(%rbp),%r8
lea    0xe9b(%rip),%rdx
lea    0xe9e(%rip),%rcx
call   1030 <snprintf@plt>
mov    -0x30(%rbp),%rdi
mov    0x2e54(%rip),%rax
mov    (%rax),%esi
call   1040 <access@plt>
cmp    $0xffffffff,%eax
je     119f <namespace_alive+0x7f>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x24(%rbp)
jmp    11ad <namespace_alive+0x8d>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x24(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<namespace_alive>:
push   %rbp
mov    %rsp,%rbp
push   %rbx
push   %rax
mov    %rdi,%r8
mov    0x2eb8(%rip),%rax
mov    (%rax),%esi
mov    %rsp,%rbx
mov    %rsi,%rax
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
lea    0xeb3(%rip),%rdx
lea    0xeb6(%rip),%rcx
mov    %rbx,%rdi
call   1030 <snprintf@plt>
mov    0x2e6d(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   1040 <access@plt>
xor    %ecx,%ecx
cmp    $0xffffffff,%eax
sete   %cl
neg    %ecx
mov    %ecx,%eax
lea    -0x8(%rbp),%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@MAXPATHLEN = global i32 0
@.str = [10 x i8] c"%s/%s/pid\00"
@.str.1 = [15 x i8] c"/var/run/pidns\00"
@F_OK = global i32 0
define i32 @namespace_alive(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i32
store i8* %0, i8** %3
%7 = load i32, i32* @MAXPATHLEN
%8 = zext i32 %7 to i64
%9 = call i8* @llvm.stacksave()
store i8* %9, i8** %4
%10 = alloca i8, i64 %8
store i64 %8, i64* %5
%11 = trunc i64 %8 to i32
%12 = load i8*, i8** %3
%13 = call i32 @snprintf(i8* %10, i32 %11, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %12)
%14 = load i32, i32* @F_OK
%15 = call i32 @access(i8* %10, i32 %14)
%16 = icmp ne i32 %15, -1
br i1 %16, label %17, label %18
17: ; preds = %1
store i32 0, i32* %2
store i32 1, i32* %6
br label %19
18: ; preds = %1
store i32 -1, i32* %2
store i32 1, i32* %6
br label %19
19: ; preds = %18, %17
%20 = load i8*, i8** %4
%21 = load i32, i32* %2
ret i32 %21
}

LLVM IR (-O2):
@MAXPATHLEN = global i32 0
@.str = [10 x i8] c"%s/%s/pid\00"
@.str.1 = [15 x i8] c"/var/run/pidns\00"
@F_OK = global i32 0
define i32 @namespace_alive(i8* %0) {
%2 = load i32, i32* @MAXPATHLEN
%3 = zext i32 %2 to i64
%4 = alloca i8, i64 %3
%5 = call i32 @snprintf(i8* %4, i32 %2, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%6 = load i32, i32* @F_OK
%7 = call i32 @access(i8* %4, i32 %6)
%8 = icmp eq i32 %7, -1
%9 = sext i1 %8 to i32
ret i32 %9
}