#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 MAXPATHLEN;
int /*<<< orphan*/ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ snprintf(char *, int, char *, char *, char const *);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
int /*<<< orphan*/ umount2(char *, int);
scalar_t__ unlink(char *);
int netns_delete(int argc, char **argv) {
  const char *name;
  char netns_path[MAXPATHLEN];
  if (argc < 1) {
    fprintf(stderr, "No netns name specified\n");
    return -1;
  }
  name = argv[0];
  snprintf(netns_path, sizeof(netns_path), "%s/%s", "/var/run/netns", name);
  umount2(netns_path, 0x00000002);
  if (unlink(netns_path) < 0) {
    fprintf(stderr, "Cannot remove namespace file \"%s\": %s\n", netns_path,
            strerror(errno));
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<netns_delete>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e82(%rip),%rax
mov    (%rax),%eax
mov    %rax,-0x40(%rbp)
mov    %rsp,%rcx
mov    %rcx,-0x20(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x38(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x28(%rbp)
cmpl   $0x1,-0x8(%rbp)
jge    11c3 <netns_delete+0x73>
mov    0x2e38(%rip),%rax
mov    (%rax),%edi
lea    0xe57(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x2c(%rbp)
jmp    1263 <netns_delete+0x113>
mov    -0x38(%rbp),%rdi
mov    -0x40(%rbp),%rax
mov    -0x10(%rbp),%rcx
mov    (%rcx),%rcx
mov    %rcx,-0x18(%rbp)
mov    %eax,%esi
mov    -0x18(%rbp),%r8
lea    0xe36(%rip),%rdx
lea    0xe35(%rip),%rcx
call   1050 <snprintf@plt>
mov    -0x38(%rbp),%rdi
mov    $0x2,%esi
call   1040 <umount2@plt>
mov    -0x38(%rbp),%rdi
call   1030 <unlink@plt>
cmp    $0x0,%rax
jge    1255 <netns_delete+0x105>
mov    0x2dc1(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x44(%rbp)
mov    0x2dad(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
mov    -0x44(%rbp),%edi
mov    -0x38(%rbp),%rdx
mov    %rax,%rcx
lea    0xdf3(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x2c(%rbp)
jmp    1263 <netns_delete+0x113>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x2c(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<netns_delete>:
push   %rbp
mov    %rsp,%rbp
push   %r14
push   %rbx
mov    %rsi,%rax
mov    0x2e87(%rip),%rcx
mov    (%rcx),%esi
mov    %rsp,%rbx
lea    0xf(%rsi),%rcx
and    $0xfffffffffffffff0,%rcx
sub    %rcx,%rbx
mov    %rbx,%rsp
test   %edi,%edi
jle    11e1 <netns_delete+0x91>
mov    (%rax),%r8
lea    0xe97(%rip),%rdx
lea    0xe96(%rip),%rcx
mov    %rbx,%rdi
call   1050 <snprintf@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
call   1040 <umount2@plt>
mov    %rbx,%rdi
call   1030 <unlink@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
jns    11fd <netns_delete+0xad>
mov    0x2e21(%rip),%rax
mov    (%rax),%r14d
mov    0x2e0f(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
lea    0xe5f(%rip),%rsi
mov    %r14d,%edi
mov    %rbx,%rdx
mov    %rax,%rcx
xor    %eax,%eax
call   1060 <fprintf@plt>
jmp    11f8 <netns_delete+0xa8>
mov    0x2df0(%rip),%rax
mov    (%rax),%edi
lea    0xe0f(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0xffffffff,%eax
lea    -0x10(%rbp),%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@MAXPATHLEN = global i32 0
@stderr = global i32 0
@.str = [25 x i8] c"No netns name specified\0A\00"
@.str.1 = [6 x i8] c"%s/%s\00"
@.str.2 = [15 x i8] c"/var/run/netns\00"
@.str.3 = [39 x i8] c"Cannot remove namespace file \22%s\22: %s\0A\00"
@errno = global i32 0
define i32 @netns_delete(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i32
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* @MAXPATHLEN
%11 = zext i32 %10 to i64
%12 = call i8* @llvm.stacksave()
store i8* %12, i8** %7
%13 = alloca i8, i64 %11
store i64 %11, i64* %8
%14 = load i32, i32* %4
%15 = icmp slt i32 %14, 1
br i1 %15, label %16, label %19
16: ; preds = %2
%17 = load i32, i32* @stderr
%18 = call i32 (i32, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %3
store i32 1, i32* %9
br label %35
19: ; preds = %2
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 0
%22 = load i8*, i8** %21
store i8* %22, i8** %6
%23 = trunc i64 %11 to i32
%24 = load i8*, i8** %6
%25 = call i32 @snprintf(i8* %13, i32 %23, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* %24)
%26 = call i32 @umount2(i8* %13, i32 2)
%27 = call i64 @unlink(i8* %13)
%28 = icmp slt i64 %27, 0
br i1 %28, label %29, label %34
29: ; preds = %19
%30 = load i32, i32* @stderr
%31 = load i32, i32* @errno
%32 = call i8* @strerror(i32 %31)
%33 = call i32 (i32, i8*, ...) @fprintf(i32 %30, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0), i8* %13, i8* %32)
store i32 -1, i32* %3
store i32 1, i32* %9
br label %35
34: ; preds = %19
store i32 0, i32* %3
store i32 1, i32* %9
br label %35
35: ; preds = %34, %29, %16
%36 = load i8*, i8** %7
%37 = load i32, i32* %3
ret i32 %37
}

LLVM IR (-O2):
@MAXPATHLEN = global i32 0
@stderr = global i32 0
@.str = [25 x i8] c"No netns name specified\0A\00"
@.str.1 = [6 x i8] c"%s/%s\00"
@.str.2 = [15 x i8] c"/var/run/netns\00"
@.str.3 = [39 x i8] c"Cannot remove namespace file \22%s\22: %s\0A\00"
@errno = global i32 0
define i32 @netns_delete(i32 %0, i8** nocapture %1) {
%3 = load i32, i32* @MAXPATHLEN
%4 = zext i32 %3 to i64
%5 = alloca i8, i64 %4
%6 = icmp slt i32 %0, 1
br i1 %6, label %7, label %10
7: ; preds = %2
%8 = load i32, i32* @stderr
%9 = tail call i32 (i32, i8*, ...) @fprintf(i32 %8, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
br label %21
10: ; preds = %2
%11 = load i8*, i8** %1
%12 = call i32 @snprintf(i8* %5, i32 %3, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* %11)
%13 = call i32 @umount2(i8* %5, i32 2)
%14 = call i64 @unlink(i8* %5)
%15 = icmp slt i64 %14, 0
br i1 %15, label %16, label %21
16: ; preds = %10
%17 = load i32, i32* @stderr
%18 = load i32, i32* @errno
%19 = call i8* @strerror(i32 %18)
%20 = call i32 (i32, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0), i8* %5, i8* %19)
br label %21
21: ; preds = %10, %16, %7
%22 = phi i32 [ -1, %7 ], [ -1, %16 ], [ 0, %10 ]
ret i32 %22
}