#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__ EEXIST;
int S_IRGRP;
int S_IROTH;
int S_IRWXU;
int S_IXGRP;
int S_IXOTH;
scalar_t__ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, char *);
scalar_t__ mkdir(char *, int);
int /*<<< orphan*/ stderr;
char *strerror(scalar_t__);
int create_netns_dir(void) {
  if (mkdir("/var/run/netns",
            S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)) {
    if (errno != EEXIST) {
      fprintf(stderr, "mkdir %s failed: %s\n", "/var/run/netns",
              strerror(errno));
      return -1;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<create_netns_dir>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0x2ea9(%rip),%rax
mov    (%rax),%esi
mov    0x2e68(%rip),%rax
or     (%rax),%esi
mov    0x2e87(%rip),%rax
or     (%rax),%esi
mov    0x2e4e(%rip),%rax
or     (%rax),%esi
mov    0x2e7d(%rip),%rax
or     (%rax),%esi
lea    0xe94(%rip),%rdi
call   1030 <mkdir@plt>
cmp    $0x0,%rax
je     11da <create_netns_dir+0xaa>
mov    0x2e36(%rip),%rax
mov    (%rax),%rax
mov    0x2e3c(%rip),%rcx
cmp    (%rcx),%rax
je     11d5 <create_netns_dir+0xa5>
mov    0x2e24(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8(%rbp)
mov    0x2e10(%rip),%rax
mov    (%rax),%rdi
call   1050 <strerror@plt>
mov    -0x8(%rbp),%edi
mov    %rax,%rcx
lea    0xe52(%rip),%rsi
lea    0xe3c(%rip),%rdx
call   1040 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11e1 <create_netns_dir+0xb1>
jmp    11da <create_netns_dir+0xaa>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<create_netns_dir>:
push   %rbx
mov    0x2eb0(%rip),%rax
mov    0x2e71(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x2e8e(%rip),%rax
or     (%rax),%esi
mov    0x2e55(%rip),%rax
or     (%rax),%esi
mov    0x2e84(%rip),%rax
or     (%rax),%esi
lea    0xe9b(%rip),%rdi
call   1030 <mkdir@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
je     11b5 <create_netns_dir+0x85>
mov    0x2e3d(%rip),%rcx
mov    (%rcx),%rdi
mov    0x2e43(%rip),%rcx
cmp    (%rcx),%rdi
je     11b5 <create_netns_dir+0x85>
mov    0x2e2f(%rip),%rax
mov    (%rax),%ebx
call   1050 <strerror@plt>
lea    0xe70(%rip),%rsi
lea    0xe5a(%rip),%rdx
mov    %ebx,%edi
mov    %rax,%rcx
call   1040 <fprintf@plt>
mov    $0xffffffff,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [15 x i8] c"/var/run/netns\00"
@S_IRWXU = global i32 0
@S_IRGRP = global i32 0
@S_IXGRP = global i32 0
@S_IROTH = global i32 0
@S_IXOTH = global i32 0
@errno = global i64 0
@EEXIST = global i64 0
@stderr = global i32 0
@.str.1 = [21 x i8] c"mkdir %s failed: %s\0A\00"
define i32 @create_netns_dir() {
%1 = alloca i32
%2 = load i32, i32* @S_IRWXU
%3 = load i32, i32* @S_IRGRP
%4 = or i32 %2, %3
%5 = load i32, i32* @S_IXGRP
%6 = or i32 %4, %5
%7 = load i32, i32* @S_IROTH
%8 = or i32 %6, %7
%9 = load i32, i32* @S_IXOTH
%10 = or i32 %8, %9
%11 = call i64 @mkdir(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %10)
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %23
13: ; preds = %0
%14 = load i64, i64* @errno
%15 = load i64, i64* @EEXIST
%16 = icmp ne i64 %14, %15
br i1 %16, label %17, label %22
17: ; preds = %13
%18 = load i32, i32* @stderr
%19 = load i64, i64* @errno
%20 = call i8* @strerror(i64 %19)
%21 = call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %20)
store i32 -1, i32* %1
br label %24
22: ; preds = %13
br label %23
23: ; preds = %22, %0
store i32 0, i32* %1
br label %24
24: ; preds = %23, %17
%25 = load i32, i32* %1
ret i32 %25
}

LLVM IR (-O2):
@.str = [15 x i8] c"/var/run/netns\00"
@S_IRWXU = global i32 0
@S_IRGRP = global i32 0
@S_IXGRP = global i32 0
@S_IROTH = global i32 0
@S_IXOTH = global i32 0
@errno = global i64 0
@EEXIST = global i64 0
@stderr = global i32 0
@.str.1 = [21 x i8] c"mkdir %s failed: %s\0A\00"
define i32 @create_netns_dir() {
%1 = load i32, i32* @S_IRWXU
%2 = load i32, i32* @S_IRGRP
%3 = or i32 %2, %1
%4 = load i32, i32* @S_IXGRP
%5 = or i32 %3, %4
%6 = load i32, i32* @S_IROTH
%7 = or i32 %5, %6
%8 = load i32, i32* @S_IXOTH
%9 = or i32 %7, %8
%10 = tail call i64 @mkdir(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = icmp eq i64 %10, 0
br i1 %11, label %20, label %12
12: ; preds = %0
%13 = load i64, i64* @errno
%14 = load i64, i64* @EEXIST
%15 = icmp eq i64 %13, %14
br i1 %15, label %20, label %16
16: ; preds = %12
%17 = load i32, i32* @stderr
%18 = tail call i8* @strerror(i64 %13)
%19 = tail call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %18)
br label %20
20: ; preds = %0, %12, %16
%21 = phi i32 [ -1, %16 ], [ 0, %12 ], [ 0, %0 ]
ret i32 %21
}