#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*/ pidns_path;
typedef int /*<<< orphan*/ path;
typedef int /*<<< orphan*/ DIR;

/* Variables and functions */
scalar_t__ ENOENT;
int EXIT_FAILURE;
int EXIT_SUCCESS;
int MAXPATHLEN;
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ closedir(int /*<<< orphan*/ *);
scalar_t__ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
scalar_t__ fstat(int, struct stat *);
int /*<<< orphan*/ is_pid(char const *);
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 const *, ...);
scalar_t__ stat(char *, struct stat *);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, char *);
char *strerror(scalar_t__);
int identify(int argc, char **argv) {
  const char *pidstr;
  int pidns;
  char pidns_path[MAXPATHLEN];
  struct stat pidst;
  DIR *dir;
  struct dirent *entry;
  if (argc < 1) {
    fprintf(stderr, "No pid specified\n");
    return EXIT_FAILURE;
  }
  if (argc > 1) {
    fprintf(stderr, "extra arguments specified\n");
    return EXIT_FAILURE;
  }
  pidstr = argv[0];
  if (!is_pid(pidstr)) {
    fprintf(stderr, "Specified string '%s' is not a pid\n", pidstr);
    return EXIT_FAILURE;
  }
  snprintf(pidns_path, sizeof(pidns_path), "/proc/%s/ns/pid", pidstr);
  pidns = open(pidns_path, O_RDONLY);
  if (pidns < 0) {
    fprintf(stderr, "Cannot open pid namespace: %s\n", strerror(errno));
    return EXIT_FAILURE;
  }
  if (fstat(pidns, &pidst) < 0) {
    fprintf(stderr, "Stat of pidns failed: %s\n", strerror(errno));
    return EXIT_FAILURE;
  }
  dir = opendir("/var/run/pidns");
  if (!dir) {
    if (errno == ENOENT) {
      return EXIT_SUCCESS;
    }
    fprintf(stderr, "Failed to open directory %s:%s\n", "/var/run/pidns",
            strerror(errno));
    return EXIT_FAILURE;
  }
  while ((entry = readdir(dir))) {
    char path[MAXPATHLEN];
    struct stat st;
    if (strcmp(entry->d_name, ".") == 0)
      continue;
    if (strcmp(entry->d_name, "..") == 0)
      continue;
    snprintf(path, sizeof(path), "%s/%s/pid", "/var/run/pidns", entry->d_name);
    if (stat(path, &st) != 0)
      continue;
    if ((st.st_dev == pidst.st_dev) && (st.st_ino == pidst.st_ino)) {
      printf("%s\n", entry->d_name);
    }
  }
  closedir(dir);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<identify>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e07(%rip),%rax
mov    (%rax),%eax
mov    %rax,-0x88(%rbp)
mov    %rsp,%rcx
mov    %rcx,-0x28(%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,-0x30(%rbp)
cmpl   $0x1,-0x8(%rbp)
jge    123e <identify+0x7e>
mov    0x2dba(%rip),%rax
mov    (%rax),%edi
lea    0xde1(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x2d93(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x54(%rbp)
jmp    15bf <identify+0x3ff>
cmpl   $0x1,-0x8(%rbp)
jle    1277 <identify+0xb7>
mov    0x2d81(%rip),%rax
mov    (%rax),%edi
lea    0xdba(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x2d5a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x54(%rbp)
jmp    15bf <identify+0x3ff>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   10d0 <is_pid@plt>
cmp    $0x0,%eax
jne    12c7 <identify+0x107>
mov    0x2d35(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
lea    0xd85(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x2d0a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x54(%rbp)
jmp    15bf <identify+0x3ff>
mov    -0x80(%rbp),%rdi
mov    -0x88(%rbp),%rax
mov    %eax,%esi
mov    -0x18(%rbp),%rcx
lea    0xd72(%rip),%rdx
mov    $0x0,%al
call   1050 <snprintf@plt>
mov    -0x80(%rbp),%rdi
mov    0x2cf7(%rip),%rax
mov    (%rax),%esi
call   10b0 <open@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    1352 <identify+0x192>
mov    0x2cc4(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8c(%rbp)
mov    0x2cad(%rip),%rax
mov    (%rax),%rdi
call   10c0 <strerror@plt>
mov    -0x8c(%rbp),%edi
mov    %rax,%rdx
lea    0xd2e(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x2c7f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x54(%rbp)
jmp    15bf <identify+0x3ff>
mov    -0x1c(%rbp),%edi
lea    -0x40(%rbp),%rsi
call   10e0 <fstat@plt>
cmp    $0x0,%rax
jge    13b5 <identify+0x1f5>
mov    0x2c61(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x90(%rbp)
mov    0x2c4a(%rip),%rax
mov    (%rax),%rdi
call   10c0 <strerror@plt>
mov    -0x90(%rbp),%edi
mov    %rax,%rdx
lea    0xcea(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x2c1c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x54(%rbp)
jmp    15bf <identify+0x3ff>
lea    0xcde(%rip),%rdi
call   1030 <opendir@plt>
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x48(%rbp)
jne    1456 <identify+0x296>
mov    0x2bf1(%rip),%rax
mov    (%rax),%rax
mov    0x2bc7(%rip),%rcx
cmp    (%rcx),%rax
jne    1402 <identify+0x242>
mov    0x2bc7(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x54(%rbp)
jmp    15bf <identify+0x3ff>
mov    0x2bc7(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x94(%rbp)
mov    0x2bb0(%rip),%rax
mov    (%rax),%rdi
call   10c0 <strerror@plt>
mov    -0x94(%rbp),%edi
mov    %rax,%rcx
lea    0xc79(%rip),%rsi
lea    0xc63(%rip),%rdx
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x2b7b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x54(%rbp)
jmp    15bf <identify+0x3ff>
jmp    145b <identify+0x29b>
mov    -0x48(%rbp),%rdi
call   10a0 <readdir@plt>
mov    %rax,-0x50(%rbp)
cmp    $0x0,%rax
je     15a3 <identify+0x3e3>
mov    0x2b67(%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
lea    0xc14(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    14d1 <identify+0x311>
movl   $0x2,-0x54(%rbp)
jmp    1582 <identify+0x3c2>
mov    -0x50(%rbp),%rax
mov    (%rax),%rdi
lea    0xbea(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    14fa <identify+0x33a>
movl   $0x2,-0x54(%rbp)
jmp    1582 <identify+0x3c2>
mov    -0xa0(%rbp),%rdi
mov    -0xa8(%rbp),%rax
mov    %eax,%esi
mov    -0x50(%rbp),%rax
mov    (%rax),%r8
lea    0xbb4(%rip),%rdx
lea    0xb7b(%rip),%rcx
mov    $0x0,%al
call   1050 <snprintf@plt>
mov    -0xa0(%rbp),%rdi
lea    -0x78(%rbp),%rsi
call   1090 <stat@plt>
cmp    $0x0,%rax
je     154c <identify+0x38c>
movl   $0x2,-0x54(%rbp)
jmp    1582 <identify+0x3c2>
mov    -0x78(%rbp),%rax
cmp    -0x40(%rbp),%rax
jne    157b <identify+0x3bb>
mov    -0x70(%rbp),%rax
cmp    -0x38(%rbp),%rax
jne    157b <identify+0x3bb>
mov    -0x50(%rbp),%rax
mov    (%rax),%rsi
lea    0xb20(%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     159e <identify+0x3de>
jmp    1599 <identify+0x3d9>
jmp    145b <identify+0x29b>
jmp    145b <identify+0x29b>
mov    -0x48(%rbp),%rdi
call   1060 <closedir@plt>
mov    0x2a05(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x54(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<identify>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    0x2e08(%rip),%r12
mov    (%r12),%r14d
mov    %rsp,%rbx
lea    0xf(%r14),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
test   %edi,%edi
jle    1365 <identify+0x1a5>
cmp    $0x1,%edi
jne    1377 <identify+0x1b7>
mov    (%rsi),%r15
mov    %r15,%rdi
call   10d0 <is_pid@plt>
test   %eax,%eax
je     1390 <identify+0x1d0>
lea    0xe39(%rip),%rdx
mov    %rbx,%rdi
mov    %r14d,%esi
mov    %r15,%rcx
xor    %eax,%eax
call   1050 <snprintf@plt>
mov    0x2db9(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   10b0 <open@plt>
test   %eax,%eax
js     13a5 <identify+0x1e5>
lea    -0x58(%rbp),%rsi
mov    %eax,%edi
call   10e0 <fstat@plt>
test   %rax,%rax
js     13d0 <identify+0x210>
lea    0xe3e(%rip),%rdi
call   1030 <opendir@plt>
test   %rax,%rax
je     1413 <identify+0x253>
mov    %rax,%rbx
mov    %rax,%rdi
call   10a0 <readdir@plt>
test   %rax,%rax
je     13c6 <identify+0x206>
mov    %rax,%r13
mov    -0x58(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x50(%rbp),%rax
mov    %rax,-0x30(%rbp)
jmp    12be <identify+0xfe>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r14,%rsp
mov    %rbx,%rdi
call   10a0 <readdir@plt>
mov    %rax,%r13
test   %rax,%rax
mov    0x2d28(%rip),%r12
je     13c6 <identify+0x206>
mov    %rsp,%r14
mov    (%r12),%r15d
mov    %rsp,%r12
lea    0xf(%r15),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r12
mov    %r12,%rsp
mov    0x0(%r13),%rdi
lea    0xde9(%rip),%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
je     12a0 <identify+0xe0>
mov    0x0(%r13),%rdi
lea    0xdd3(%rip),%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
je     12a0 <identify+0xe0>
mov    0x0(%r13),%r8
mov    %r12,%rdi
mov    %r15d,%esi
lea    0xdbb(%rip),%rdx
lea    0xd82(%rip),%rcx
xor    %eax,%eax
call   1050 <snprintf@plt>
mov    %r12,%rdi
lea    -0x48(%rbp),%rsi
call   1090 <stat@plt>
test   %rax,%rax
jne    12a0 <identify+0xe0>
mov    -0x38(%rbp),%rax
cmp    %rax,-0x48(%rbp)
jne    12a0 <identify+0xe0>
mov    -0x30(%rbp),%rax
cmp    %rax,-0x40(%rbp)
jne    12a0 <identify+0xe0>
mov    0x0(%r13),%rsi
lea    0xd3b(%rip),%rdi
call   1040 <printf@plt>
jmp    12a0 <identify+0xe0>
mov    0x2c64(%rip),%rax
mov    (%rax),%edi
lea    0xc8b(%rip),%rsi
jmp    1387 <identify+0x1c7>
mov    0x2c52(%rip),%rax
mov    (%rax),%edi
lea    0xc8b(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
jmp    13fb <identify+0x23b>
mov    0x2c39(%rip),%rax
mov    (%rax),%edi
lea    0xc8d(%rip),%rsi
mov    %r15,%rdx
jmp    13f4 <identify+0x234>
mov    0x2c24(%rip),%rax
mov    (%rax),%ebx
mov    0x2c13(%rip),%rax
mov    (%rax),%rdi
call   10c0 <strerror@plt>
lea    0xc9d(%rip),%rsi
jmp    13ef <identify+0x22f>
mov    %rbx,%rdi
call   1060 <closedir@plt>
jmp    1429 <identify+0x269>
mov    0x2bf9(%rip),%rax
mov    (%rax),%ebx
mov    0x2be8(%rip),%rax
mov    (%rax),%rdi
call   10c0 <strerror@plt>
lea    0xc91(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    0x2bbe(%rip),%rax
mov    (%rax),%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2bae(%rip),%rax
mov    (%rax),%rdi
mov    0x2b84(%rip),%rax
cmp    (%rax),%rdi
jne    1432 <identify+0x272>
mov    0x2b88(%rip),%rax
jmp    1402 <identify+0x242>
mov    0x2b97(%rip),%rax
mov    (%rax),%ebx
call   10c0 <strerror@plt>
lea    0xc62(%rip),%rsi
lea    0xc4c(%rip),%rdx
mov    %ebx,%edi
mov    %rax,%rcx
xor    %eax,%eax
call   1080 <fprintf@plt>
jmp    13fb <identify+0x23b>

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

LLVM IR (-O2):
%struct.stat = type { i64, i64 }
%struct.dirent = type { i8* }
@MAXPATHLEN = global i32 0
@stderr = global i32 0
@.str = [18 x i8] c"No pid specified\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [27 x i8] c"extra arguments specified\0A\00"
@.str.2 = [36 x i8] c"Specified string '%s' is not a pid\0A\00"
@.str.3 = [16 x i8] c"/proc/%s/ns/pid\00"
@O_RDONLY = global i32 0
@.str.4 = [31 x i8] c"Cannot open pid namespace: %s\0A\00"
@errno = global i64 0
@.str.5 = [26 x i8] c"Stat of pidns failed: %s\0A\00"
@.str.6 = [15 x i8] c"/var/run/pidns\00"
@ENOENT = global i64 0
@EXIT_SUCCESS = global i32 0
@.str.7 = [32 x i8] c"Failed to open directory %s:%s\0A\00"
@.str.8 = [2 x i8] c".\00"
@.str.9 = [3 x i8] c"..\00"
@.str.10 = [10 x i8] c"%s/%s/pid\00"
@.str.11 = [4 x i8] c"%s\0A\00"
define i32 @identify(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 ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
br label %98
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 %98
18: ; preds = %13
%19 = load i8*, i8** %1
%20 = tail call i32 @is_pid(i8* %19)
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %25
22: ; preds = %18
%23 = load i32, i32* @stderr
%24 = tail call i32 (i32, i8*, ...) @fprintf(i32 %23, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0), i8* %19)
br label %98
25: ; preds = %18
%26 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %7, i32 %5, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i8* %19)
%27 = load i32, i32* @O_RDONLY
%28 = call i32 @open(i8* %7, i32 %27)
%29 = icmp slt i32 %28, 0
br i1 %29, label %30, label %35
30: ; preds = %25
%31 = load i32, i32* @stderr
%32 = load i64, i64* @errno
%33 = call i8* @strerror(i64 %32)
%34 = call i32 (i32, i8*, ...) @fprintf(i32 %31, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0), i8* %33)
br label %98
35: ; preds = %25
%36 = call i64 @fstat(i32 %28, %struct.stat* %3)
%37 = icmp slt i64 %36, 0
br i1 %37, label %38, label %43
38: ; preds = %35
%39 = load i32, i32* @stderr
%40 = load i64, i64* @errno
%41 = call i8* @strerror(i64 %40)
%42 = call i32 (i32, i8*, ...) @fprintf(i32 %39, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0), i8* %41)
br label %98
43: ; preds = %35
%44 = call i32* @opendir(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0))
%45 = icmp eq i32* %44, null
br i1 %45, label %57, label %46
46: ; preds = %43
%47 = call %struct.dirent* @readdir(i32* %44)
%48 = icmp eq %struct.dirent* %47, null
br i1 %48, label %96, label %49
49: ; preds = %46
%50 = bitcast %struct.stat* %4 to i8*
%51 = getelementptr inbounds %struct.stat, %struct.stat* %4, i64 0, i32 0
%52 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0
%53 = load i64, i64* %52
%54 = getelementptr inbounds %struct.stat, %struct.stat* %4, i64 0, i32 1
%55 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 1
%56 = load i64, i64* %55
br label %65
57: ; preds = %43
%58 = load i64, i64* @errno
%59 = load i64, i64* @ENOENT
%60 = icmp eq i64 %58, %59
br i1 %60, label %98, label %61
61: ; preds = %57
%62 = load i32, i32* @stderr
%63 = call i8* @strerror(i64 %58)
%64 = call i32 (i32, i8*, ...) @fprintf(i32 %62, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0), i8* %63)
br label %98
65: ; preds = %49, %93
%66 = phi %struct.dirent* [ %47, %49 ], [ %94, %93 ]
%67 = load i32, i32* @MAXPATHLEN
%68 = zext i32 %67 to i64
%69 = call i8* @llvm.stacksave()
%70 = alloca i8, i64 %68
%71 = getelementptr inbounds %struct.dirent, %struct.dirent* %66, i64 0, i32 0
%72 = load i8*, i8** %71
%73 = call i64 @strcmp(i8* %72, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
%74 = icmp eq i64 %73, 0
br i1 %74, label %93, label %75
75: ; preds = %65
%76 = load i8*, i8** %71
%77 = call i64 @strcmp(i8* %76, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0))
%78 = icmp eq i64 %77, 0
br i1 %78, label %93, label %79
79: ; preds = %75
%80 = load i8*, i8** %71
%81 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %70, i32 %67, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0), i8* %80)
%82 = call i64 @stat(i8* %70, %struct.stat* %4)
%83 = icmp eq i64 %82, 0
%84 = load i64, i64* %51
%85 = icmp eq i64 %84, %53
%86 = select i1 %83, i1 %85, i1 false
%87 = load i64, i64* %54
%88 = icmp eq i64 %87, %56
%89 = select i1 %86, i1 %88, i1 false
br i1 %89, label %90, label %93
90: ; preds = %79
%91 = load i8*, i8** %71
%92 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i64 0, i64 0), i8* %91)
br label %93
93: ; preds = %90, %79, %75, %65
%94 = call %struct.dirent* @readdir(i32* %44)
%95 = icmp eq %struct.dirent* %94, null
br i1 %95, label %96, label %65
96: ; preds = %93, %46
%97 = call i32 @closedir(i32* %44)
br label %98
98: ; preds = %57, %96, %61, %38, %30, %22, %15, %10
%99 = phi i32* [ @EXIT_FAILURE, %10 ], [ @EXIT_FAILURE, %15 ], [ @EXIT_FAILURE, %30 ], [ @EXIT_FAILURE, %38 ], [ @EXIT_SUCCESS, %96 ], [ @EXIT_FAILURE, %61 ], [ @EXIT_FAILURE, %22 ], [ @EXIT_SUCCESS, %57 ]
%100 = load i32, i32* %99
ret i32 %100
}