#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 scalar_t__ uid_t;
struct stat {
  scalar_t__ st_uid;
  int /*<<< orphan*/ st_rdev;
  int /*<<< orphan*/ st_mtime;
  int /*<<< orphan*/ st_atime;
};
struct dirent {
  char *d_name;
};
typedef int /*<<< orphan*/ path;
typedef int /*<<< orphan*/ file_path;
typedef int /*<<< orphan*/ fd_path;
typedef int /*<<< orphan*/ DIR;

/* Variables and functions */
int /*<<< orphan*/ EXIT_SUCCESS;
int PATH_MAX;
int /*<<< orphan*/ closedir(int /*<<< orphan*/ *);
int /*<<< orphan*/ die(char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
scalar_t__ getuid();
int major(int /*<<< orphan*/);
int /*<<< orphan*/ *opendir(char *);
int /*<<< orphan*/ printf(char *, char *, char *, scalar_t__, int,
                          int /*<<< orphan*/, int /*<<< orphan*/);
int readdir_r(int /*<<< orphan*/ *, struct dirent *, struct dirent **);
int readlink(char *, char *, int);
int /*<<< orphan*/ snprintf(char *, int, char *, char *, ...);
int stat(char *, struct stat *);
int /*<<< orphan*/ stderr;
int main(void) {
  DIR *proc;
  DIR *fd;
  struct dirent proc_entry;
  struct dirent *proc_entryp;
  struct dirent fd_entry;
  struct dirent *fd_entryp;
  char path[PATH_MAX];
  char fd_path[PATH_MAX];
  char file_path[PATH_MAX];
  struct stat info;
  int err;
  uid_t uid;
  uid = getuid();
  proc = opendir("/proc");
  if (proc == NULL) {
    die("Could not open proc");
  }
  err = readdir_r(proc, &proc_entry, &proc_entryp);
  while (err == 0 && proc_entryp != NULL) {
    snprintf(path, sizeof(path), "/proc/%s", proc_entry.d_name);
    err = stat(path, &info);
    if (err == 0) {
      if (info.st_uid == uid) {
        snprintf(fd_path, sizeof(fd_path), "%s/fd", path);
        fd = opendir(fd_path);
        if (fd == NULL) {
          fprintf(stderr, "Error reading path: %s\n", fd_path);
        } else {
          err = readdir_r(fd, &fd_entry, &fd_entryp);
          while (err == 0 && fd_entryp != NULL) {
            snprintf(fd_path, sizeof(fd_path), "%s/fd/%s", path,
                     fd_entry.d_name);
            err = readlink(fd_path, file_path, sizeof(file_path));
            file_path[err] = 0;
            err = stat(file_path, &info);
            if (err != 0) {
              fprintf(stderr, "Could not stat: %s\n", file_path);
            } else {
              printf("%s\t%s\t%i\t%i\t%lu\t%lu\n", proc_entry.d_name, file_path,
                     info.st_uid, major(info.st_rdev), info.st_atime,
                     info.st_mtime);
            }
            err = readdir_r(fd, &fd_entry, &fd_entryp);
          }
          if (err != 0) {
            fprintf(stderr, "Could not read directory: %s\n", fd_path);
          }
          closedir(fd);
        }
      }
    } else {
      fprintf(stderr, "Error reading path: %s\n", path);
    }
    err = readdir_r(proc, &proc_entry, &proc_entryp);
  }
  if (err != 0) {
    die("Could not read proc");
  }
  closedir(proc);
  exit(EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd0,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e17(%rip),%rax
mov    (%rax),%ecx
mov    %rcx,-0xb0(%rbp)
mov    %rsp,%rdx
mov    %rdx,-0x40(%rbp)
mov    %rcx,%rsi
add    $0xf,%rsi
and    $0xfffffffffffffff0,%rsi
mov    %rsp,%rdx
sub    %rsi,%rdx
mov    %rdx,-0xa8(%rbp)
mov    %rdx,%rsp
mov    %rcx,-0x48(%rbp)
mov    (%rax),%ecx
mov    %rcx,-0xa0(%rbp)
mov    %rcx,%rsi
add    $0xf,%rsi
and    $0xfffffffffffffff0,%rsi
mov    %rsp,%rdx
sub    %rsi,%rdx
mov    %rdx,-0x98(%rbp)
mov    %rdx,%rsp
mov    %rcx,-0x50(%rbp)
mov    (%rax),%eax
mov    %rax,-0x90(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x88(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x58(%rbp)
mov    $0x0,%al
call   1060 <getuid@plt>
mov    %rax,-0x80(%rbp)
lea    0xd96(%rip),%rdi
call   1050 <opendir@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    128a <main+0xca>
lea    0xd81(%rip),%rdi
call   10d0 <die@plt>
mov    -0x10(%rbp),%rdi
lea    -0x20(%rbp),%rsi
lea    -0x28(%rbp),%rdx
call   1040 <readdir_r@plt>
mov    %eax,-0x74(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x74(%rbp)
mov    %al,-0xb1(%rbp)
jne    12be <main+0xfe>
cmpq   $0x0,-0x28(%rbp)
setne  %al
mov    %al,-0xb1(%rbp)
mov    -0xb1(%rbp),%al
test   $0x1,%al
jne    12d1 <main+0x111>
jmp    152f <main+0x36f>
mov    -0xa8(%rbp),%rdi
mov    -0xb0(%rbp),%rax
mov    %eax,%esi
mov    -0x20(%rbp),%rcx
lea    0xd2e(%rip),%rdx
mov    $0x0,%al
call   1080 <snprintf@plt>
mov    -0xa8(%rbp),%rdi
lea    -0x70(%rbp),%rsi
call   10c0 <stat@plt>
mov    %eax,-0x74(%rbp)
cmpl   $0x0,-0x74(%rbp)
jne    14fa <main+0x33a>
mov    -0x70(%rbp),%rax
cmp    -0x80(%rbp),%rax
jne    14f5 <main+0x335>
mov    -0x98(%rbp),%rdi
mov    -0xa8(%rbp),%rcx
mov    -0xa0(%rbp),%rax
mov    %eax,%esi
lea    0xce7(%rip),%rdx
mov    $0x0,%al
call   1080 <snprintf@plt>
mov    -0x98(%rbp),%rdi
call   1050 <opendir@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    137f <main+0x1bf>
mov    -0x98(%rbp),%rdx
mov    0x2c6c(%rip),%rax
mov    (%rax),%edi
lea    0xcb4(%rip),%rsi
call   10b0 <fprintf@plt>
jmp    14f0 <main+0x330>
mov    -0x18(%rbp),%rdi
lea    -0x30(%rbp),%rsi
lea    -0x38(%rbp),%rdx
call   1040 <readdir_r@plt>
mov    %eax,-0x74(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x74(%rbp)
mov    %al,-0xb2(%rbp)
jne    13b3 <main+0x1f3>
cmpq   $0x0,-0x38(%rbp)
setne  %al
mov    %al,-0xb2(%rbp)
mov    -0xb2(%rbp),%al
test   $0x1,%al
jne    13c6 <main+0x206>
jmp    14c1 <main+0x301>
mov    -0x98(%rbp),%rdi
mov    -0xa8(%rbp),%rcx
mov    -0xa0(%rbp),%rax
mov    %eax,%esi
mov    -0x30(%rbp),%r8
lea    0xc59(%rip),%rdx
mov    $0x0,%al
call   1080 <snprintf@plt>
mov    -0x98(%rbp),%rdi
mov    -0x88(%rbp),%rsi
mov    -0x90(%rbp),%rax
mov    %eax,%edx
call   1030 <readlink@plt>
mov    -0x88(%rbp),%rdi
mov    %eax,-0x74(%rbp)
movslq -0x74(%rbp),%rax
movb   $0x0,(%rdi,%rax,1)
lea    -0x70(%rbp),%rsi
call   10c0 <stat@plt>
mov    %eax,-0x74(%rbp)
cmpl   $0x0,-0x74(%rbp)
je     1454 <main+0x294>
mov    -0x88(%rbp),%rdx
mov    0x2b97(%rip),%rax
mov    (%rax),%edi
lea    0xc00(%rip),%rsi
call   10b0 <fprintf@plt>
jmp    14a8 <main+0x2e8>
mov    -0x20(%rbp),%rax
mov    %rax,-0xc8(%rbp)
mov    -0x70(%rbp),%rax
mov    %rax,-0xc0(%rbp)
mov    -0x68(%rbp),%edi
call   1090 <major@plt>
mov    -0xc8(%rbp),%rsi
mov    -0x88(%rbp),%rdx
mov    -0xc0(%rbp),%rcx
mov    %eax,%r8d
mov    -0x60(%rbp),%r9d
mov    -0x64(%rbp),%eax
lea    0xbc6(%rip),%rdi
sub    $0x10,%rsp
mov    %eax,(%rsp)
call   1070 <printf@plt>
add    $0x10,%rsp
mov    -0x18(%rbp),%rdi
lea    -0x30(%rbp),%rsi
lea    -0x38(%rbp),%rdx
call   1040 <readdir_r@plt>
mov    %eax,-0x74(%rbp)
jmp    1393 <main+0x1d3>
cmpl   $0x0,-0x74(%rbp)
je     14e7 <main+0x327>
mov    -0x98(%rbp),%rdx
mov    0x2aff(%rip),%rax
mov    (%rax),%edi
lea    0xb91(%rip),%rsi
call   10b0 <fprintf@plt>
mov    -0x18(%rbp),%rdi
call   10a0 <closedir@plt>
jmp    14f5 <main+0x335>
jmp    1516 <main+0x356>
mov    -0xa8(%rbp),%rdx
mov    0x2ad0(%rip),%rax
mov    (%rax),%edi
lea    0xb18(%rip),%rsi
call   10b0 <fprintf@plt>
mov    -0x10(%rbp),%rdi
lea    -0x20(%rbp),%rsi
lea    -0x28(%rbp),%rdx
call   1040 <readdir_r@plt>
mov    %eax,-0x74(%rbp)
jmp    129e <main+0xde>
cmpl   $0x0,-0x74(%rbp)
je     1545 <main+0x385>
lea    0xb51(%rip),%rdi
call   10d0 <die@plt>
mov    -0x10(%rbp),%rdi
call   10a0 <closedir@plt>
mov    0x2a7b(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    0x2e18(%rip),%rax
mov    (%rax),%ebx
mov    %rsp,%r14
lea    0xf(%rbx),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r14
mov    %r14,%rsp
mov    %rsp,%r15
sub    %rax,%r15
mov    %r15,%rsp
mov    %rsp,%r13
sub    %rax,%r13
mov    %r13,%rsp
xor    %eax,%eax
call   1060 <getuid@plt>
mov    %rax,-0x78(%rbp)
lea    0xdf1(%rip),%rdi
call   1050 <opendir@plt>
mov    %rax,-0x30(%rbp)
test   %rax,%rax
jne    1229 <main+0x69>
lea    0xde2(%rip),%rdi
call   10d0 <die@plt>
lea    -0x50(%rbp),%rsi
lea    -0x48(%rbp),%rdx
mov    -0x30(%rbp),%rdi
call   1040 <readdir_r@plt>
test   %eax,%eax
sete   %al
jne    142d <main+0x26d>
cmpq   $0x0,-0x48(%rbp)
je     142d <main+0x26d>
lea    -0x70(%rbp),%r12
mov    %r14,-0x80(%rbp)
nopl   0x0(%rax,%rax,1)
mov    -0x50(%rbp),%rcx
mov    %r14,%rdi
mov    %ebx,%esi
lea    0xdaa(%rip),%rdx
xor    %eax,%eax
call   1080 <snprintf@plt>
mov    %r14,%rdi
mov    %r12,%rsi
call   10c0 <stat@plt>
test   %eax,%eax
je     12b0 <main+0xf0>
mov    0x2d4b(%rip),%rax
mov    (%rax),%edi
lea    0xd93(%rip),%rsi
mov    %r14,%rdx
call   10b0 <fprintf@plt>
jmp    13f0 <main+0x230>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    -0x78(%rbp),%rax
cmp    %rax,-0x70(%rbp)
jne    13f0 <main+0x230>
mov    %r15,%rdi
mov    %ebx,%esi
lea    0xd59(%rip),%rdx
mov    %r14,%rcx
xor    %eax,%eax
call   1080 <snprintf@plt>
mov    %r15,%rdi
call   1050 <opendir@plt>
test   %rax,%rax
je     1415 <main+0x255>
mov    %rax,-0x38(%rbp)
mov    %rax,%rdi
jmp    130c <main+0x14c>
xchg   %ax,%ax
mov    0x2ce1(%rip),%rax
mov    (%rax),%edi
lea    0xd4a(%rip),%rsi
mov    %r13,%rdx
call   10b0 <fprintf@plt>
mov    -0x38(%rbp),%rdi
lea    -0x58(%rbp),%rsi
lea    -0x40(%rbp),%rdx
call   1040 <readdir_r@plt>
test   %eax,%eax
sete   %al
jne    13c8 <main+0x208>
cmpq   $0x0,-0x40(%rbp)
je     13c8 <main+0x208>
mov    -0x58(%rbp),%r8
mov    %r15,%rdi
mov    %ebx,%esi
lea    0xd02(%rip),%rdx
mov    %r14,%rcx
xor    %eax,%eax
call   1080 <snprintf@plt>
mov    %r15,%rdi
mov    %r13,%rsi
mov    %ebx,%edx
call   1030 <readlink@plt>
cltq
movb   $0x0,0x0(%r13,%rax,1)
mov    %r13,%rdi
mov    %r12,%rsi
call   10c0 <stat@plt>
test   %eax,%eax
jne    12f0 <main+0x130>
mov    %r13,%r12
mov    %r15,%r13
mov    -0x50(%rbp),%r15
mov    -0x70(%rbp),%r14
mov    -0x68(%rbp),%edi
call   1090 <major@plt>
mov    %rbx,%r10
mov    -0x64(%rbp),%ebx
mov    -0x60(%rbp),%r9d
sub    $0x8,%rsp
lea    0xcc6(%rip),%rdi
mov    %r15,%rsi
mov    %r13,%r15
mov    %r12,%r13
lea    -0x70(%rbp),%r12
mov    %r13,%rdx
mov    %r14,%rcx
mov    -0x80(%rbp),%r14
mov    %eax,%r8d
push   %rbx
mov    %r10,%rbx
call   1070 <printf@plt>
add    $0x10,%rsp
mov    -0x38(%rbp),%rdi
jmp    130c <main+0x14c>
test   %al,%al
jne    13e4 <main+0x224>
mov    0x2c05(%rip),%rax
mov    (%rax),%edi
lea    0xc97(%rip),%rsi
mov    %r15,%rdx
call   10b0 <fprintf@plt>
mov    -0x38(%rbp),%rdi
call   10a0 <closedir@plt>
nopl   (%rax)
mov    -0x30(%rbp),%rdi
lea    -0x50(%rbp),%rsi
lea    -0x48(%rbp),%rdx
call   1040 <readdir_r@plt>
test   %eax,%eax
sete   %al
jne    142d <main+0x26d>
cmpq   $0x0,-0x48(%rbp)
jne    1260 <main+0xa0>
jmp    142d <main+0x26d>
mov    0x2bbc(%rip),%rax
mov    (%rax),%edi
lea    0xc04(%rip),%rsi
mov    %r15,%rdx
jmp    1299 <main+0xd9>
test   %al,%al
jne    143d <main+0x27d>
lea    0xc59(%rip),%rdi
call   10d0 <die@plt>
mov    -0x30(%rbp),%rdi
call   10a0 <closedir@plt>
mov    0x2b83(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>

LLVM IR (-O0):
%struct.dirent = type { i8* }
%struct.stat = type { i64, i32, i32, i32 }
@PATH_MAX = global i32 0
@.str = [6 x i8] c"/proc\00"
@.str.1 = [20 x i8] c"Could not open proc\00"
@.str.2 = [9 x i8] c"/proc/%s\00"
@.str.3 = [6 x i8] c"%s/fd\00"
@stderr = global i32 0
@.str.4 = [24 x i8] c"Error reading path: %s\0A\00"
@.str.5 = [9 x i8] c"%s/fd/%s\00"
@.str.6 = [20 x i8] c"Could not stat: %s\0A\00"
@.str.7 = [21 x i8] c"%s\09%s\09%i\09%i\09%lu\09%lu\0A\00"
@.str.8 = [30 x i8] c"Could not read directory: %s\0A\00"
@.str.9 = [20 x i8] c"Could not read proc\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32*
%4 = alloca %struct.dirent
%5 = alloca %struct.dirent*
%6 = alloca %struct.dirent
%7 = alloca %struct.dirent*
%8 = alloca i8*
%9 = alloca i64
%10 = alloca i64
%11 = alloca i64
%12 = alloca %struct.stat
%13 = alloca i32
%14 = alloca i64
store i32 0, i32* %1
%15 = load i32, i32* @PATH_MAX
%16 = zext i32 %15 to i64
%17 = call i8* @llvm.stacksave()
store i8* %17, i8** %8
%18 = alloca i8, i64 %16
store i64 %16, i64* %9
%19 = load i32, i32* @PATH_MAX
%20 = zext i32 %19 to i64
%21 = alloca i8, i64 %20
store i64 %20, i64* %10
%22 = load i32, i32* @PATH_MAX
%23 = zext i32 %22 to i64
%24 = alloca i8, i64 %23
store i64 %23, i64* %11
%25 = call i64 (...) @getuid()
store i64 %25, i64* %14
%26 = call i32* @opendir(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
store i32* %26, i32** %2
%27 = load i32*, i32** %2
%28 = icmp eq i32* %27, null
br i1 %28, label %29, label %31
29: ; preds = %0
%30 = call i32 @die(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
br label %31
31: ; preds = %29, %0
%32 = load i32*, i32** %2
%33 = call i32 @readdir_r(i32* %32, %struct.dirent* %4, %struct.dirent** %5)
store i32 %33, i32* %13
br label %34
34: ; preds = %121, %31
%35 = load i32, i32* %13
%36 = icmp eq i32 %35, 0
br i1 %36, label %37, label %40
37: ; preds = %34
%38 = load %struct.dirent*, %struct.dirent** %5
%39 = icmp ne %struct.dirent* %38, null
br label %40
40: ; preds = %37, %34
%41 = phi i1 [ false, %34 ], [ %39, %37 ]
br i1 %41, label %42, label %124
42: ; preds = %40
%43 = trunc i64 %16 to i32
%44 = getelementptr inbounds %struct.dirent, %struct.dirent* %4, i32 0, i32 0
%45 = load i8*, i8** %44
%46 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %18, i32 %43, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %45)
%47 = call i32 @stat(i8* %18, %struct.stat* %12)
store i32 %47, i32* %13
%48 = load i32, i32* %13
%49 = icmp eq i32 %48, 0
br i1 %49, label %50, label %118
50: ; preds = %42
%51 = getelementptr inbounds %struct.stat, %struct.stat* %12, i32 0, i32 0
%52 = load i64, i64* %51
%53 = load i64, i64* %14
%54 = icmp eq i64 %52, %53
br i1 %54, label %55, label %117
55: ; preds = %50
%56 = trunc i64 %20 to i32
%57 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %21, i32 %56, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8* %18)
%58 = call i32* @opendir(i8* %21)
store i32* %58, i32** %3
%59 = load i32*, i32** %3
%60 = icmp eq i32* %59, null
br i1 %60, label %61, label %64
61: ; preds = %55
%62 = load i32, i32* @stderr
%63 = call i32 @fprintf(i32 %62, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i8* %21)
br label %116
64: ; preds = %55
%65 = load i32*, i32** %3
%66 = call i32 @readdir_r(i32* %65, %struct.dirent* %6, %struct.dirent** %7)
store i32 %66, i32* %13
br label %67
67: ; preds = %104, %64
%68 = load i32, i32* %13
%69 = icmp eq i32 %68, 0
br i1 %69, label %70, label %73
70: ; preds = %67
%71 = load %struct.dirent*, %struct.dirent** %7
%72 = icmp ne %struct.dirent* %71, null
br label %73
73: ; preds = %70, %67
%74 = phi i1 [ false, %67 ], [ %72, %70 ]
br i1 %74, label %75, label %107
75: ; preds = %73
%76 = trunc i64 %20 to i32
%77 = getelementptr inbounds %struct.dirent, %struct.dirent* %6, i32 0, i32 0
%78 = load i8*, i8** %77
%79 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %21, i32 %76, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i8* %18, i8* %78)
%80 = trunc i64 %23 to i32
%81 = call i32 @readlink(i8* %21, i8* %24, i32 %80)
store i32 %81, i32* %13
%82 = load i32, i32* %13
%83 = sext i32 %82 to i64
%84 = getelementptr inbounds i8, i8* %24, i64 %83
store i8 0, i8* %84
%85 = call i32 @stat(i8* %24, %struct.stat* %12)
store i32 %85, i32* %13
%86 = load i32, i32* %13
%87 = icmp ne i32 %86, 0
br i1 %87, label %88, label %91
88: ; preds = %75
%89 = load i32, i32* @stderr
%90 = call i32 @fprintf(i32 %89, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i8* %24)
br label %104
91: ; preds = %75
%92 = getelementptr inbounds %struct.dirent, %struct.dirent* %4, i32 0, i32 0
%93 = load i8*, i8** %92
%94 = getelementptr inbounds %struct.stat, %struct.stat* %12, i32 0, i32 0
%95 = load i64, i64* %94
%96 = getelementptr inbounds %struct.stat, %struct.stat* %12, i32 0, i32 1
%97 = load i32, i32* %96
%98 = call i32 @major(i32 %97)
%99 = getelementptr inbounds %struct.stat, %struct.stat* %12, i32 0, i32 3
%100 = load i32, i32* %99
%101 = getelementptr inbounds %struct.stat, %struct.stat* %12, i32 0, i32 2
%102 = load i32, i32* %101
%103 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0), i8* %93, i8* %24, i64 %95, i32 %98, i32 %100, i32 %102)
br label %104
104: ; preds = %91, %88
%105 = load i32*, i32** %3
%106 = call i32 @readdir_r(i32* %105, %struct.dirent* %6, %struct.dirent** %7)
store i32 %106, i32* %13
br label %67
107: ; preds = %73
%108 = load i32, i32* %13
%109 = icmp ne i32 %108, 0
br i1 %109, label %110, label %113
110: ; preds = %107
%111 = load i32, i32* @stderr
%112 = call i32 @fprintf(i32 %111, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.8, i64 0, i64 0), i8* %21)
br label %113
113: ; preds = %110, %107
%114 = load i32*, i32** %3
%115 = call i32 @closedir(i32* %114)
br label %116
116: ; preds = %113, %61
br label %117
117: ; preds = %116, %50
br label %121
118: ; preds = %42
%119 = load i32, i32* @stderr
%120 = call i32 @fprintf(i32 %119, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i8* %18)
br label %121
121: ; preds = %118, %117
%122 = load i32*, i32** %2
%123 = call i32 @readdir_r(i32* %122, %struct.dirent* %4, %struct.dirent** %5)
store i32 %123, i32* %13
br label %34
124: ; preds = %40
%125 = load i32, i32* %13
%126 = icmp ne i32 %125, 0
br i1 %126, label %127, label %129
127: ; preds = %124
%128 = call i32 @die(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.9, i64 0, i64 0))
br label %129
129: ; preds = %127, %124
%130 = load i32*, i32** %2
%131 = call i32 @closedir(i32* %130)
%132 = load i32, i32* @EXIT_SUCCESS
%133 = call i32 @exit(i32 %132)
unreachable
}

LLVM IR (-O2):
%struct.dirent = type { i8* }
%struct.stat = type { i64, i32, i32, i32 }
@PATH_MAX = global i32 0
@.str = [6 x i8] c"/proc\00"
@.str.1 = [20 x i8] c"Could not open proc\00"
@.str.2 = [9 x i8] c"/proc/%s\00"
@.str.3 = [6 x i8] c"%s/fd\00"
@stderr = global i32 0
@.str.4 = [24 x i8] c"Error reading path: %s\0A\00"
@.str.5 = [9 x i8] c"%s/fd/%s\00"
@.str.6 = [20 x i8] c"Could not stat: %s\0A\00"
@.str.7 = [21 x i8] c"%s\09%s\09%i\09%i\09%lu\09%lu\0A\00"
@.str.8 = [30 x i8] c"Could not read directory: %s\0A\00"
@.str.9 = [20 x i8] c"Could not read proc\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca %struct.dirent
%2 = alloca %struct.dirent*
%3 = alloca %struct.dirent
%4 = alloca %struct.dirent*
%5 = alloca %struct.stat
%6 = bitcast %struct.dirent* %1 to i8*
%7 = bitcast %struct.dirent** %2 to i8*
%8 = bitcast %struct.dirent* %3 to i8*
%9 = bitcast %struct.dirent** %4 to i8*
%10 = load i32, i32* @PATH_MAX
%11 = zext i32 %10 to i64
%12 = alloca i8, i64 %11
%13 = alloca i8, i64 %11
%14 = alloca i8, i64 %11
%15 = bitcast %struct.stat* %5 to i8*
%16 = tail call i64 (...) @getuid()
%17 = tail call i32* @opendir(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%18 = icmp eq i32* %17, null
br i1 %18, label %19, label %21
19: ; preds = %0
%20 = tail call i32 @die(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
br label %21
21: ; preds = %19, %0
%22 = call i32 @readdir_r(i32* %17, %struct.dirent* %1, %struct.dirent** %2)
%23 = icmp eq i32 %22, 0
%24 = load %struct.dirent*, %struct.dirent** %2
%25 = icmp ne %struct.dirent* %24, null
%26 = select i1 %23, i1 %25, i1 false
br i1 %26, label %27, label %96
27: ; preds = %21
%28 = getelementptr inbounds %struct.dirent, %struct.dirent* %1, i64 0, i32 0
%29 = getelementptr inbounds %struct.stat, %struct.stat* %5, i64 0, i32 0
%30 = getelementptr inbounds %struct.dirent, %struct.dirent* %3, i64 0, i32 0
%31 = getelementptr inbounds %struct.stat, %struct.stat* %5, i64 0, i32 1
%32 = getelementptr inbounds %struct.stat, %struct.stat* %5, i64 0, i32 3
%33 = getelementptr inbounds %struct.stat, %struct.stat* %5, i64 0, i32 2
br label %34
34: ; preds = %27, %90
%35 = load i8*, i8** %28
%36 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %12, i32 %10, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %35)
%37 = call i32 @stat(i8* %12, %struct.stat* %5)
%38 = icmp eq i32 %37, 0
br i1 %38, label %39, label %87
39: ; preds = %34
%40 = load i64, i64* %29
%41 = icmp eq i64 %40, %16
br i1 %41, label %42, label %90
42: ; preds = %39
%43 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %13, i32 %10, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8* %12)
%44 = call i32* @opendir(i8* %13)
%45 = icmp eq i32* %44, null
br i1 %45, label %46, label %49
46: ; preds = %42
%47 = load i32, i32* @stderr
%48 = call i32 @fprintf(i32 %47, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i8* %13)
br label %90
49: ; preds = %42
%50 = call i32 @readdir_r(i32* %44, %struct.dirent* %3, %struct.dirent** %4)
%51 = icmp eq i32 %50, 0
%52 = load %struct.dirent*, %struct.dirent** %4
%53 = icmp ne %struct.dirent* %52, null
%54 = select i1 %51, i1 %53, i1 false
br i1 %54, label %55, label %80
55: ; preds = %49, %74
%56 = load i8*, i8** %30
%57 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %13, i32 %10, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i8* %12, i8* %56)
%58 = call i32 @readlink(i8* %13, i8* %14, i32 %10)
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds i8, i8* %14, i64 %59
store i8 0, i8* %60
%61 = call i32 @stat(i8* %14, %struct.stat* %5)
%62 = icmp eq i32 %61, 0
br i1 %62, label %66, label %63
63: ; preds = %55
%64 = load i32, i32* @stderr
%65 = call i32 @fprintf(i32 %64, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i8* %14)
br label %74
66: ; preds = %55
%67 = load i8*, i8** %28
%68 = load i64, i64* %29
%69 = load i32, i32* %31
%70 = call i32 @major(i32 %69)
%71 = load i32, i32* %32
%72 = load i32, i32* %33
%73 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0), i8* %67, i8* %14, i64 %68, i32 %70, i32 %71, i32 %72)
br label %74
74: ; preds = %66, %63
%75 = call i32 @readdir_r(i32* %44, %struct.dirent* %3, %struct.dirent** %4)
%76 = icmp eq i32 %75, 0
%77 = load %struct.dirent*, %struct.dirent** %4
%78 = icmp ne %struct.dirent* %77, null
%79 = select i1 %76, i1 %78, i1 false
br i1 %79, label %55, label %80
80: ; preds = %74, %49
%81 = phi i1 [ %51, %49 ], [ %76, %74 ]
br i1 %81, label %85, label %82
82: ; preds = %80
%83 = load i32, i32* @stderr
%84 = call i32 @fprintf(i32 %83, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.8, i64 0, i64 0), i8* %13)
br label %85
85: ; preds = %82, %80
%86 = call i32 @closedir(i32* %44)
br label %90
87: ; preds = %34
%88 = load i32, i32* @stderr
%89 = call i32 @fprintf(i32 %88, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i8* %12)
br label %90
90: ; preds = %39, %85, %46, %87
%91 = call i32 @readdir_r(i32* %17, %struct.dirent* %1, %struct.dirent** %2)
%92 = icmp eq i32 %91, 0
%93 = load %struct.dirent*, %struct.dirent** %2
%94 = icmp ne %struct.dirent* %93, null
%95 = select i1 %92, i1 %94, i1 false
br i1 %95, label %34, label %96
96: ; preds = %90, %21
%97 = phi i1 [ %23, %21 ], [ %92, %90 ]
br i1 %97, label %100, label %98
98: ; preds = %96
%99 = call i32 @die(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.9, i64 0, i64 0))
br label %100
100: ; preds = %98, %96
%101 = call i32 @closedir(i32* %17)
%102 = load i32, i32* @EXIT_SUCCESS
%103 = call i32 @exit(i32 %102)
unreachable
}