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

/* Variables and functions */
int /*<<< orphan*/ MNT_DETACH;
int PATH_MAX;
int /*<<< orphan*/ _nsntrace_remove_rundir(int /*<<< orphan*/);
int getpid();
int /*<<< orphan*/ getppid();
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ snprintf(char *, int, char *, char *, int);
int /*<<< orphan*/ umount2(char *, int /*<<< orphan*/);
scalar_t__ unlink(char *);
void _nsntrace_remove_ns() {
  char netns_path[PATH_MAX];
  snprintf(netns_path, sizeof(netns_path), "%s/nsntrace-%d", "/run/netns",
           getpid());
  umount2(netns_path, MNT_DETACH);
  if (unlink(netns_path) < 0) {
    perror("unlink");
  }
  _nsntrace_remove_rundir(getppid());
}


x86 assembly (clang, -O0):
<_nsntrace_remove_ns>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    0x2e71(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x8(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x18(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x10(%rbp)
mov    %eax,-0x1c(%rbp)
mov    $0x0,%al
call   1040 <getpid@plt>
mov    -0x1c(%rbp),%esi
mov    -0x18(%rbp),%rdi
mov    %eax,%r8d
lea    0xe41(%rip),%rdx
lea    0xe49(%rip),%rcx
call   1070 <snprintf@plt>
mov    -0x18(%rbp),%rdi
mov    0x2e02(%rip),%rax
mov    (%rax),%esi
call   1050 <umount2@plt>
mov    -0x18(%rbp),%rdi
call   1030 <unlink@plt>
cmp    $0x0,%rax
jge    11fc <_nsntrace_remove_ns+0x8c>
lea    0xe23(%rip),%rdi
call   1080 <perror@plt>
mov    $0x0,%al
call   1090 <getppid@plt>
mov    %eax,%edi
call   1060 <_nsntrace_remove_rundir@plt>
mov    -0x8(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_nsntrace_remove_ns>:
push   %rbp
mov    %rsp,%rbp
push   %r14
push   %rbx
mov    0x2e72(%rip),%rax
mov    (%rax),%r14d
mov    %rsp,%rbx
mov    %r14,%rax
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
xor    %eax,%eax
call   1040 <getpid@plt>
lea    0xe5d(%rip),%rdx
lea    0xe65(%rip),%rcx
mov    %rbx,%rdi
mov    %r14d,%esi
mov    %eax,%r8d
call   1070 <snprintf@plt>
mov    0x2e19(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   1050 <umount2@plt>
mov    %rbx,%rdi
call   1030 <unlink@plt>
test   %rax,%rax
js     11ed <_nsntrace_remove_ns+0x7d>
xor    %eax,%eax
call   1090 <getppid@plt>
mov    %eax,%edi
call   1060 <_nsntrace_remove_rundir@plt>
lea    -0x10(%rbp),%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
lea    0xe26(%rip),%rdi
call   1080 <perror@plt>
jmp    11d6 <_nsntrace_remove_ns+0x66>

LLVM IR (-O0):
@PATH_MAX = global i32 0
@.str = [15 x i8] c"%s/nsntrace-%d\00"
@.str.1 = [11 x i8] c"/run/netns\00"
@MNT_DETACH = global i32 0
@.str.2 = [7 x i8] c"unlink\00"
define void @_nsntrace_remove_ns() {
%1 = alloca i8*
%2 = alloca i64
%3 = load i32, i32* @PATH_MAX
%4 = zext i32 %3 to i64
%5 = call i8* @llvm.stacksave()
store i8* %5, i8** %1
%6 = alloca i8, i64 %4
store i64 %4, i64* %2
%7 = trunc i64 %4 to i32
%8 = call i32 (...) @getpid()
%9 = call i32 @snprintf(i8* %6, i32 %7, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %8)
%10 = load i32, i32* @MNT_DETACH
%11 = call i32 @umount2(i8* %6, i32 %10)
%12 = call i64 @unlink(i8* %6)
%13 = icmp slt i64 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %0
%15 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
br label %16
16: ; preds = %14, %0
%17 = call i32 (...) @getppid()
%18 = call i32 @_nsntrace_remove_rundir(i32 %17)
%19 = load i8*, i8** %1
ret void
}

LLVM IR (-O2):
@PATH_MAX = global i32 0
@.str = [15 x i8] c"%s/nsntrace-%d\00"
@.str.1 = [11 x i8] c"/run/netns\00"
@MNT_DETACH = global i32 0
@.str.2 = [7 x i8] c"unlink\00"
define void @_nsntrace_remove_ns() {
%1 = load i32, i32* @PATH_MAX
%2 = zext i32 %1 to i64
%3 = alloca i8, i64 %2
%4 = tail call i32 (...) @getpid()
%5 = call i32 @snprintf(i8* %3, i32 %1, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %4)
%6 = load i32, i32* @MNT_DETACH
%7 = call i32 @umount2(i8* %3, i32 %6)
%8 = call i64 @unlink(i8* %3)
%9 = icmp slt i64 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %0
%11 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
br label %12
12: ; preds = %10, %0
%13 = call i32 (...) @getppid()
%14 = call i32 @_nsntrace_remove_rundir(i32 %13)
ret void
}