#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 {
  scalar_t__ st_dev;
  scalar_t__ st_ino;
};
struct dirent {
  char *d_name;
};
typedef int /*<<< orphan*/ pid_net_path;
typedef int /*<<< orphan*/ net_path;
typedef int /*<<< orphan*/ DIR;

/* Variables and functions */
int MAXPATHLEN;
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ closedir(int /*<<< orphan*/ *);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
scalar_t__ fstat(int, struct stat *);
int /*<<< orphan*/ is_pid(char *);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ *opendir(char *);
int /*<<< orphan*/ printf(char *, char *);
struct dirent *readdir(int /*<<< orphan*/ *);
int /*<<< orphan*/ snprintf(char *, int, char *, char *, ...);
scalar_t__ stat(char *, struct stat *);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
int netns_pids(int argc, char **argv) {
  const char *name;
  char net_path[MAXPATHLEN];
  int netns;
  struct stat netst;
  DIR *dir;
  struct dirent *entry;
  if (argc < 1) {
    fprintf(stderr, "No netns name specified\n");
    return -1;
  }
  if (argc > 1) {
    fprintf(stderr, "extra arguments specified\n");
    return -1;
  }
  name = argv[0];
  snprintf(net_path, sizeof(net_path), "%s/%s", "/var/run/netns", name);
  netns = open(net_path, O_RDONLY);
  if (netns < 0) {
    fprintf(stderr, "Cannot open network namespace: %s\n", strerror(errno));
    return -1;
  }
  if (fstat(netns, &netst) < 0) {
    fprintf(stderr, "Stat of netns failed: %s\n", strerror(errno));
    return -1;
  }
  dir = opendir("/proc/");
  if (!dir) {
    fprintf(stderr, "Open of /proc failed: %s\n", strerror(errno));
    return -1;
  }
  while ((entry = readdir(dir))) {
    char pid_net_path[MAXPATHLEN];
    struct stat st;
    if (!is_pid(entry->d_name))
      continue;
    snprintf(pid_net_path, sizeof(pid_net_path), "/proc/%s/ns/net",
             entry->d_name);
    if (stat(pid_net_path, &st) != 0)
      continue;
    if ((st.st_dev == netst.st_dev) && (st.st_ino == netst.st_ino)) {
      printf("%s\n", entry->d_name);
    }
  }
  closedir(dir);
  return 0;
}


x86 assembly (clang, -O0):
<netns_pids>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e17(%rip),%rax
mov    (%rax),%eax
mov    %rax,-0x88(%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,-0x80(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x28(%rbp)
cmpl   $0x1,-0x8(%rbp)
jge    1229 <netns_pids+0x79>
mov    0x2dca(%rip),%rax
mov    (%rax),%edi
lea    0xdf1(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x54(%rbp)
jmp    14df <netns_pids+0x32f>
cmpl   $0x1,-0x8(%rbp)
jle    125d <netns_pids+0xad>
mov    0x2d96(%rip),%rax
mov    (%rax),%edi
lea    0xdd6(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x54(%rbp)
jmp    14df <netns_pids+0x32f>
mov    -0x80(%rbp),%rdi
mov    -0x88(%rbp),%rax
mov    -0x10(%rbp),%rcx
mov    (%rcx),%rcx
mov    %rcx,-0x18(%rbp)
mov    %eax,%esi
mov    -0x18(%rbp),%r8
lea    0xdb4(%rip),%rdx
lea    0xdb3(%rip),%rcx
mov    $0x0,%al
call   1050 <snprintf@plt>
mov    -0x80(%rbp),%rdi
mov    0x2d4f(%rip),%rax
mov    (%rax),%esi
call   10a0 <open@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jge    12f4 <netns_pids+0x144>
mov    0x2d1c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8c(%rbp)
mov    0x2d05(%rip),%rax
mov    (%rax),%edi
call   10b0 <strerror@plt>
mov    -0x8c(%rbp),%edi
mov    %rax,%rdx
lea    0xd6f(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x54(%rbp)
jmp    14df <netns_pids+0x32f>
mov    -0x2c(%rbp),%edi
lea    -0x40(%rbp),%rsi
call   10d0 <fstat@plt>
cmp    $0x0,%rax
jge    1351 <netns_pids+0x1a1>
mov    0x2cbf(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x90(%rbp)
mov    0x2ca8(%rip),%rax
mov    (%rax),%edi
call   10b0 <strerror@plt>
mov    -0x90(%rbp),%edi
mov    %rax,%rdx
lea    0xd35(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x54(%rbp)
jmp    14df <netns_pids+0x32f>
lea    0xd2e(%rip),%rdi
call   1030 <opendir@plt>
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x48(%rbp)
jne    13b3 <netns_pids+0x203>
mov    0x2c5d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x94(%rbp)
mov    0x2c46(%rip),%rax
mov    (%rax),%edi
call   10b0 <strerror@plt>
mov    -0x94(%rbp),%edi
mov    %rax,%rdx
lea    0xcf4(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x54(%rbp)
jmp    14df <netns_pids+0x32f>
jmp    13b8 <netns_pids+0x208>
mov    -0x48(%rbp),%rdi
call   1090 <readdir@plt>
mov    %rax,-0x50(%rbp)
cmp    $0x0,%rax
je     14c8 <netns_pids+0x318>
mov    0x2c0a(%rip),%rax
mov    (%rax),%eax
mov    %rax,-0xa8(%rbp)
mov    %rsp,%rcx
mov    %rcx,-0x60(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0xa0(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x68(%rbp)
mov    -0x50(%rbp),%rax
mov    (%rax),%rdi
call   10c0 <is_pid@plt>
cmp    $0x0,%eax
jne    1426 <netns_pids+0x276>
movl   $0x2,-0x54(%rbp)
jmp    14a7 <netns_pids+0x2f7>
mov    -0xa0(%rbp),%rdi
mov    -0xa8(%rbp),%rax
mov    %eax,%esi
mov    -0x50(%rbp),%rax
mov    (%rax),%rcx
lea    0xc63(%rip),%rdx
mov    $0x0,%al
call   1050 <snprintf@plt>
mov    -0xa0(%rbp),%rdi
lea    -0x78(%rbp),%rsi
call   1080 <stat@plt>
cmp    $0x0,%rax
je     1471 <netns_pids+0x2c1>
movl   $0x2,-0x54(%rbp)
jmp    14a7 <netns_pids+0x2f7>
mov    -0x78(%rbp),%rax
cmp    -0x40(%rbp),%rax
jne    14a0 <netns_pids+0x2f0>
mov    -0x70(%rbp),%rax
cmp    -0x38(%rbp),%rax
jne    14a0 <netns_pids+0x2f0>
mov    -0x50(%rbp),%rax
mov    (%rax),%rsi
lea    0xc08(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x54(%rbp)
mov    -0x60(%rbp),%rax
mov    %rax,%rsp
mov    -0x54(%rbp),%eax
test   %eax,%eax
je     14c3 <netns_pids+0x313>
jmp    14be <netns_pids+0x30e>
jmp    13b8 <netns_pids+0x208>
jmp    13b8 <netns_pids+0x208>
mov    -0x48(%rbp),%rdi
call   1060 <closedir@plt>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x54(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<netns_pids>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rsi,%rax
mov    0x2e15(%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    1311 <netns_pids+0x161>
cmp    $0x1,%edi
jne    1323 <netns_pids+0x173>
mov    (%rax),%r8
lea    0xe3b(%rip),%rdx
lea    0xe3a(%rip),%rcx
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <snprintf@plt>
mov    0x2dd7(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   10a0 <open@plt>
test   %eax,%eax
js     133c <netns_pids+0x18c>
lea    -0x58(%rbp),%rsi
mov    %eax,%edi
call   10d0 <fstat@plt>
test   %rax,%rax
js     1368 <netns_pids+0x1b8>
lea    0xe48(%rip),%rdi
call   1030 <opendir@plt>
test   %rax,%rax
je     1388 <netns_pids+0x1d8>
mov    %rax,%r13
mov    %rax,%rdi
call   1090 <readdir@plt>
test   %rax,%rax
je     135c <netns_pids+0x1ac>
mov    %rax,%rbx
mov    -0x58(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x50(%rbp),%rax
mov    %rax,-0x30(%rbp)
jmp    1297 <netns_pids+0xe7>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r15,%rsp
mov    %r13,%rdi
call   1090 <readdir@plt>
mov    %rax,%rbx
test   %rax,%rax
je     135c <netns_pids+0x1ac>
mov    %rsp,%r15
mov    0x2d3f(%rip),%rax
mov    (%rax),%r14d
mov    %rsp,%r12
lea    0xf(%r14),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r12
mov    %r12,%rsp
mov    (%rbx),%rdi
call   10c0 <is_pid@plt>
test   %eax,%eax
je     1280 <netns_pids+0xd0>
mov    (%rbx),%rcx
mov    %r12,%rdi
mov    %r14d,%esi
lea    0xdd6(%rip),%rdx
xor    %eax,%eax
call   1050 <snprintf@plt>
mov    %r12,%rdi
lea    -0x48(%rbp),%rsi
call   1080 <stat@plt>
test   %rax,%rax
jne    1280 <netns_pids+0xd0>
mov    -0x38(%rbp),%rax
cmp    %rax,-0x48(%rbp)
jne    1280 <netns_pids+0xd0>
mov    -0x30(%rbp),%rax
cmp    %rax,-0x40(%rbp)
jne    1280 <netns_pids+0xd0>
mov    (%rbx),%rsi
lea    0xd9c(%rip),%rdi
call   1040 <printf@plt>
jmp    1280 <netns_pids+0xd0>
mov    0x2cb8(%rip),%rax
mov    (%rax),%edi
lea    0xcdf(%rip),%rsi
jmp    1333 <netns_pids+0x183>
mov    0x2ca6(%rip),%rax
mov    (%rax),%edi
lea    0xce6(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
jmp    13b2 <netns_pids+0x202>
mov    0x2c8d(%rip),%rax
mov    (%rax),%ebx
mov    0x2c7c(%rip),%rax
mov    (%rax),%edi
call   10b0 <strerror@plt>
lea    0xcef(%rip),%rsi
jmp    13a6 <netns_pids+0x1f6>
mov    %r13,%rdi
call   1060 <closedir@plt>
xor    %eax,%eax
jmp    13b7 <netns_pids+0x207>
mov    0x2c61(%rip),%rax
mov    (%rax),%ebx
mov    0x2c50(%rip),%rax
mov    (%rax),%edi
call   10b0 <strerror@plt>
lea    0xce6(%rip),%rsi
jmp    13a6 <netns_pids+0x1f6>
mov    0x2c41(%rip),%rax
mov    (%rax),%ebx
mov    0x2c30(%rip),%rax
mov    (%rax),%edi
call   10b0 <strerror@plt>
lea    0xce7(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    $0xffffffff,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.stat = type { i64, i64 }
%struct.dirent = type { i8* }
@MAXPATHLEN = global i32 0
@stderr = global i32 0
@.str = [25 x i8] c"No netns name specified\0A\00"
@.str.1 = [27 x i8] c"extra arguments specified\0A\00"
@.str.2 = [6 x i8] c"%s/%s\00"
@.str.3 = [15 x i8] c"/var/run/netns\00"
@O_RDONLY = global i32 0
@.str.4 = [35 x i8] c"Cannot open network namespace: %s\0A\00"
@errno = global i32 0
@.str.5 = [26 x i8] c"Stat of netns failed: %s\0A\00"
@.str.6 = [7 x i8] c"/proc/\00"
@.str.7 = [26 x i8] c"Open of /proc failed: %s\0A\00"
@.str.8 = [16 x i8] c"/proc/%s/ns/net\00"
@.str.9 = [4 x i8] c"%s\0A\00"
define i32 @netns_pids(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
%10 = alloca %struct.stat
%11 = alloca i32*
%12 = alloca %struct.dirent*
%13 = alloca i32
%14 = alloca i8*
%15 = alloca i64
%16 = alloca %struct.stat
store i32 %0, i32* %4
store i8** %1, i8*** %5
%17 = load i32, i32* @MAXPATHLEN
%18 = zext i32 %17 to i64
%19 = call i8* @llvm.stacksave()
store i8* %19, i8** %7
%20 = alloca i8, i64 %18
store i64 %18, i64* %8
%21 = load i32, i32* %4
%22 = icmp slt i32 %21, 1
br i1 %22, label %23, label %26
23: ; preds = %2
%24 = load i32, i32* @stderr
%25 = call i32 (i32, i8*, ...) @fprintf(i32 %24, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %3
store i32 1, i32* %13
br label %116
26: ; preds = %2
%27 = load i32, i32* %4
%28 = icmp sgt i32 %27, 1
br i1 %28, label %29, label %32
29: ; preds = %26
%30 = load i32, i32* @stderr
%31 = call i32 (i32, i8*, ...) @fprintf(i32 %30, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %3
store i32 1, i32* %13
br label %116
32: ; preds = %26
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i64 0
%35 = load i8*, i8** %34
store i8* %35, i8** %6
%36 = trunc i64 %18 to i32
%37 = load i8*, i8** %6
%38 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %20, i32 %36, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i8* %37)
%39 = load i32, i32* @O_RDONLY
%40 = call i32 @open(i8* %20, i32 %39)
store i32 %40, i32* %9
%41 = load i32, i32* %9
%42 = icmp slt i32 %41, 0
br i1 %42, label %43, label %48
43: ; preds = %32
%44 = load i32, i32* @stderr
%45 = load i32, i32* @errno
%46 = call i8* @strerror(i32 %45)
%47 = call i32 (i32, i8*, ...) @fprintf(i32 %44, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.4, i64 0, i64 0), i8* %46)
store i32 -1, i32* %3
store i32 1, i32* %13
br label %116
48: ; preds = %32
%49 = load i32, i32* %9
%50 = call i64 @fstat(i32 %49, %struct.stat* %10)
%51 = icmp slt i64 %50, 0
br i1 %51, label %52, label %57
52: ; preds = %48
%53 = load i32, i32* @stderr
%54 = load i32, i32* @errno
%55 = call i8* @strerror(i32 %54)
%56 = call i32 (i32, i8*, ...) @fprintf(i32 %53, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0), i8* %55)
store i32 -1, i32* %3
store i32 1, i32* %13
br label %116
57: ; preds = %48
%58 = call i32* @opendir(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
store i32* %58, i32** %11
%59 = load i32*, i32** %11
%60 = icmp ne i32* %59, null
br i1 %60, label %66, label %61
61: ; preds = %57
%62 = load i32, i32* @stderr
%63 = load i32, i32* @errno
%64 = call i8* @strerror(i32 %63)
%65 = call i32 (i32, i8*, ...) @fprintf(i32 %62, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.7, i64 0, i64 0), i8* %64)
store i32 -1, i32* %3
store i32 1, i32* %13
br label %116
66: ; preds = %57
br label %67
67: ; preds = %112, %109, %66
%68 = load i32*, i32** %11
%69 = call %struct.dirent* @readdir(i32* %68)
store %struct.dirent* %69, %struct.dirent** %12
%70 = icmp ne %struct.dirent* %69, null
br i1 %70, label %71, label %113
71: ; preds = %67
%72 = load i32, i32* @MAXPATHLEN
%73 = zext i32 %72 to i64
%74 = call i8* @llvm.stacksave()
store i8* %74, i8** %14
%75 = alloca i8, i64 %73
store i64 %73, i64* %15
%76 = load %struct.dirent*, %struct.dirent** %12
%77 = getelementptr inbounds %struct.dirent, %struct.dirent* %76, i32 0, i32 0
%78 = load i8*, i8** %77
%79 = call i32 @is_pid(i8* %78)
%80 = icmp ne i32 %79, 0
br i1 %80, label %82, label %81
81: ; preds = %71
store i32 2, i32* %13
br label %109
82: ; preds = %71
%83 = trunc i64 %73 to i32
%84 = load %struct.dirent*, %struct.dirent** %12
%85 = getelementptr inbounds %struct.dirent, %struct.dirent* %84, i32 0, i32 0
%86 = load i8*, i8** %85
%87 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %75, i32 %83, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0), i8* %86)
%88 = call i64 @stat(i8* %75, %struct.stat* %16)
%89 = icmp ne i64 %88, 0
br i1 %89, label %90, label %91
90: ; preds = %82
store i32 2, i32* %13
br label %109
91: ; preds = %82
%92 = getelementptr inbounds %struct.stat, %struct.stat* %16, i32 0, i32 0
%93 = load i64, i64* %92
%94 = getelementptr inbounds %struct.stat, %struct.stat* %10, i32 0, i32 0
%95 = load i64, i64* %94
%96 = icmp eq i64 %93, %95
br i1 %96, label %97, label %108
97: ; preds = %91
%98 = getelementptr inbounds %struct.stat, %struct.stat* %16, i32 0, i32 1
%99 = load i64, i64* %98
%100 = getelementptr inbounds %struct.stat, %struct.stat* %10, i32 0, i32 1
%101 = load i64, i64* %100
%102 = icmp eq i64 %99, %101
br i1 %102, label %103, label %108
103: ; preds = %97
%104 = load %struct.dirent*, %struct.dirent** %12
%105 = getelementptr inbounds %struct.dirent, %struct.dirent* %104, i32 0, i32 0
%106 = load i8*, i8** %105
%107 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), i8* %106)
br label %108
108: ; preds = %103, %97, %91
store i32 0, i32* %13
br label %109
109: ; preds = %108, %90, %81
%110 = load i8*, i8** %14
%111 = load i32, i32* %13
switch i32 %111, label %119 [
i32 0, label %112
i32 2, label %67
]
112: ; preds = %109
br label %67
113: ; preds = %67
%114 = load i32*, i32** %11
%115 = call i32 @closedir(i32* %114)
store i32 0, i32* %3
store i32 1, i32* %13
br label %116
116: ; preds = %113, %61, %52, %43, %29, %23
%117 = load i8*, i8** %7
%118 = load i32, i32* %3
ret i32 %118
119: ; preds = %109
unreachable
}

LLVM IR (-O2):
%struct.stat = type { i64, i64 }
%struct.dirent = type { i8* }
@MAXPATHLEN = global i32 0
@stderr = global i32 0
@.str = [25 x i8] c"No netns name specified\0A\00"
@.str.1 = [27 x i8] c"extra arguments specified\0A\00"
@.str.2 = [6 x i8] c"%s/%s\00"
@.str.3 = [15 x i8] c"/var/run/netns\00"
@O_RDONLY = global i32 0
@.str.4 = [35 x i8] c"Cannot open network namespace: %s\0A\00"
@errno = global i32 0
@.str.5 = [26 x i8] c"Stat of netns failed: %s\0A\00"
@.str.6 = [7 x i8] c"/proc/\00"
@.str.7 = [26 x i8] c"Open of /proc failed: %s\0A\00"
@.str.8 = [16 x i8] c"/proc/%s/ns/net\00"
@.str.9 = [4 x i8] c"%s\0A\00"
define i32 @netns_pids(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.stat
%4 = alloca %struct.stat
%5 = load i32, i32* @MAXPATHLEN
%6 = zext i32 %5 to i64
%7 = alloca i8, i64 %6
%8 = bitcast %struct.stat* %3 to i8*
%9 = icmp slt i32 %0, 1
br i1 %9, label %10, label %13
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = tail call i32 (i32, i8*, ...) @fprintf(i32 %11, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
br label %85
13: ; preds = %2
%14 = icmp eq i32 %0, 1
br i1 %14, label %18, label %15
15: ; preds = %13
%16 = load i32, i32* @stderr
%17 = tail call i32 (i32, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
br label %85
18: ; preds = %13
%19 = load i8*, i8** %1
%20 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %7, i32 %5, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i8* %19)
%21 = load i32, i32* @O_RDONLY
%22 = call i32 @open(i8* %7, i32 %21)
%23 = icmp slt i32 %22, 0
br i1 %23, label %24, label %29
24: ; preds = %18
%25 = load i32, i32* @stderr
%26 = load i32, i32* @errno
%27 = call i8* @strerror(i32 %26)
%28 = call i32 (i32, i8*, ...) @fprintf(i32 %25, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.4, i64 0, i64 0), i8* %27)
br label %85
29: ; preds = %18
%30 = call i64 @fstat(i32 %22, %struct.stat* %3)
%31 = icmp slt i64 %30, 0
br i1 %31, label %32, label %37
32: ; preds = %29
%33 = load i32, i32* @stderr
%34 = load i32, i32* @errno
%35 = call i8* @strerror(i32 %34)
%36 = call i32 (i32, i8*, ...) @fprintf(i32 %33, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0), i8* %35)
br label %85
37: ; preds = %29
%38 = call i32* @opendir(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
%39 = icmp eq i32* %38, null
br i1 %39, label %51, label %40
40: ; preds = %37
%41 = call %struct.dirent* @readdir(i32* %38)
%42 = icmp eq %struct.dirent* %41, null
br i1 %42, label %83, label %43
43: ; preds = %40
%44 = bitcast %struct.stat* %4 to i8*
%45 = getelementptr inbounds %struct.stat, %struct.stat* %4, i64 0, i32 0
%46 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0
%47 = load i64, i64* %46
%48 = getelementptr inbounds %struct.stat, %struct.stat* %4, i64 0, i32 1
%49 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 1
%50 = load i64, i64* %49
br label %56
51: ; preds = %37
%52 = load i32, i32* @stderr
%53 = load i32, i32* @errno
%54 = call i8* @strerror(i32 %53)
%55 = call i32 (i32, i8*, ...) @fprintf(i32 %52, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.7, i64 0, i64 0), i8* %54)
br label %85
56: ; preds = %43, %80
%57 = phi %struct.dirent* [ %41, %43 ], [ %81, %80 ]
%58 = load i32, i32* @MAXPATHLEN
%59 = zext i32 %58 to i64
%60 = call i8* @llvm.stacksave()
%61 = alloca i8, i64 %59
%62 = getelementptr inbounds %struct.dirent, %struct.dirent* %57, i64 0, i32 0
%63 = load i8*, i8** %62
%64 = call i32 @is_pid(i8* %63)
%65 = icmp eq i32 %64, 0
br i1 %65, label %80, label %66
66: ; preds = %56
%67 = load i8*, i8** %62
%68 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %61, i32 %58, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0), i8* %67)
%69 = call i64 @stat(i8* %61, %struct.stat* %4)
%70 = icmp eq i64 %69, 0
%71 = load i64, i64* %45
%72 = icmp eq i64 %71, %47
%73 = select i1 %70, i1 %72, i1 false
%74 = load i64, i64* %48
%75 = icmp eq i64 %74, %50
%76 = select i1 %73, i1 %75, i1 false
br i1 %76, label %77, label %80
77: ; preds = %66
%78 = load i8*, i8** %62
%79 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), i8* %78)
br label %80
80: ; preds = %77, %66, %56
%81 = call %struct.dirent* @readdir(i32* %38)
%82 = icmp eq %struct.dirent* %81, null
br i1 %82, label %83, label %56
83: ; preds = %80, %40
%84 = call i32 @closedir(i32* %38)
br label %85
85: ; preds = %83, %51, %32, %24, %15, %10
%86 = phi i32 [ -1, %10 ], [ -1, %15 ], [ -1, %24 ], [ -1, %32 ], [ 0, %83 ], [ -1, %51 ]
ret i32 %86
}