#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 */
struct stat {
  int /*<<< orphan*/ st_ino;
};
typedef int /*<<< orphan*/ ino_t;

/* Variables and functions */
int /*<<< orphan*/ perror(char *);
int stat(char *, struct stat *);
int current_ns_inode(ino_t *inode) {
  struct stat nsstat;
  if (stat("/proc/self/ns/net", &nsstat) == -1) {
    perror("nsdo"
           ": stat(\"/proc/self/ns/net\")");
    return 0;
  }
  *inode = nsstat.st_ino;
  return 1;
}


x86 assembly (clang, -O0):
<current_ns_inode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
lea    0xecd(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1030 <stat@plt>
cmp    $0xffffffff,%eax
jne    115d <current_ns_inode+0x3d>
lea    0xec6(%rip),%rdi
call   1040 <perror@plt>
movl   $0x0,-0x4(%rbp)
jmp    116d <current_ns_inode+0x4d>
mov    -0x18(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<current_ns_inode>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
lea    0xed1(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1030 <stat@plt>
cmp    $0xffffffff,%eax
je     114f <current_ns_inode+0x2f>
mov    0x8(%rsp),%eax
mov    %eax,(%rbx)
mov    $0x1,%eax
add    $0x10,%rsp
pop    %rbx
ret
lea    0xebc(%rip),%rdi
call   1040 <perror@plt>
xor    %eax,%eax
jmp    1149 <current_ns_inode+0x29>

LLVM IR (-O0):
%struct.stat = type { i32 }
@.str = [18 x i8] c"/proc/self/ns/net\00"
@.str.1 = [32 x i8] c"nsdo: stat(\22/proc/self/ns/net\22)\00"
define i32 @current_ns_inode(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca %struct.stat
store i32* %0, i32** %3
%5 = call i32 @stat(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), %struct.stat* %4)
%6 = icmp eq i32 %5, -1
br i1 %6, label %7, label %9
7: ; preds = %1
%8 = call i32 @perror(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %2
br label %13
9: ; preds = %1
%10 = getelementptr inbounds %struct.stat, %struct.stat* %4, i32 0, i32 0
%11 = load i32, i32* %10
%12 = load i32*, i32** %3
store i32 %11, i32* %12
store i32 1, i32* %2
br label %13
13: ; preds = %9, %7
%14 = load i32, i32* %2
ret i32 %14
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@.str = [18 x i8] c"/proc/self/ns/net\00"
@.str.1 = [32 x i8] c"nsdo: stat(\22/proc/self/ns/net\22)\00"
define i32 @current_ns_inode(i32* nocapture writeonly %0) {
%2 = alloca %struct.stat
%3 = bitcast %struct.stat* %2 to i8*
%4 = call i32 @stat(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), %struct.stat* %2)
%5 = icmp eq i32 %4, -1
br i1 %5, label %6, label %8
6: ; preds = %1
%7 = tail call i32 @perror(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
br label %11
8: ; preds = %1
%9 = getelementptr inbounds %struct.stat, %struct.stat* %2, i64 0, i32 0
%10 = load i32, i32* %9
store i32 %10, i32* %0
br label %11
11: ; preds = %8, %6
%12 = phi i32 [ 0, %6 ], [ 1, %8 ]
ret i32 %12
}