#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 dirent {
  char *d_name;
};
typedef int /*<<< orphan*/ FILE;
typedef int /*<<< orphan*/ DIR;

/* Variables and functions */
int /*<<< orphan*/ closedir(int /*<<< orphan*/ *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ *opendir(char *);
int /*<<< orphan*/ printf(char *, ...);
struct dirent *readdir(int /*<<< orphan*/ *);
int /*<<< orphan*/ sprintf(char *, char *, char *, ...);
scalar_t__ strcmp(char *, char *);
char *strtok(char *, char *);
int main(int argc, char *argv[]) {
  DIR *d;
  struct dirent *e;
  FILE *fd;
  char buf[100];
  char *tok, *sep = " ", *sep1 = ",";
  char *name, *pid, *ppid, *uid, *gid;
  char *pgid, *sid, *tty, *cred;
  char *major, *minor;
  char con[10];
  d = opendir("/proc");
  printf(" PID   PPID  TTY  COMMAND\n");
  while ((e = readdir(d)) != NULL) {
    if (e->d_name[0] == '.')
      continue;
    if (e->d_name[0] == 'c')
      continue;
    sprintf(buf, "/proc/%s/status", e->d_name);
    fd = fopen(buf, "r");
    fgets(buf, 99, fd);
    fclose(fd);
    name = strtok(buf, sep);
    pid = strtok(NULL, sep);
    ppid = strtok(NULL, sep);
    pgid = strtok(NULL, sep);
    sid = strtok(NULL, sep);
    tty = strtok(NULL, sep);
    tok = strtok(NULL, sep);
    tok = strtok(NULL, sep);
    tok = strtok(NULL, sep);
    tok = strtok(NULL, sep);
    tok = strtok(NULL, sep);
    cred = strtok(NULL, sep);
    major = strtok(tty, sep1);
    minor = strtok(NULL, sep1);
    if (strcmp(minor, "-1") == 0) {
      minor = "?";
    }
    if (strcmp(major, "-1") == 0) {
      major = "?";
    } else if (strcmp(major, "12") == 0) {
      major = "v";
    } else if (strcmp(major, "0") == 0) {
      major = "con";
      minor = "-";
    } else if (strcmp(major, "5") == 0) {
      major = "p";
    } else
      major = "x";
    if ((strcmp(major, "v") == 0) && (strcmp(minor, "255") == 0)) {
      major = "con";
      minor = "-";
    }
    sprintf(con, "%s%s", major, minor);
    printf("%5s %5s %4s (%s)\n", pid, ppid, con, name);
  }
  closedir(d);
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe30(%rip),%rax
mov    %rax,-0xa0(%rbp)
lea    0xe24(%rip),%rax
mov    %rax,-0xa8(%rbp)
lea    0xe18(%rip),%rdi
call   1040 <opendir@plt>
mov    %rax,-0x18(%rbp)
lea    0xe0e(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1090 <readdir@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     15a1 <main+0x3f1>
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
jne    1232 <main+0x82>
jmp    1203 <main+0x53>
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%eax
cmp    $0x63,%eax
jne    124a <main+0x9a>
jmp    1203 <main+0x53>
lea    -0x90(%rbp),%rdi
mov    -0x20(%rbp),%rax
mov    (%rax),%rdx
lea    0xdc6(%rip),%rsi
mov    $0x0,%al
call   10c0 <sprintf@plt>
lea    -0x90(%rbp),%rdi
lea    0xdc1(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x28(%rbp)
lea    -0x90(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    $0x63,%esi
call   1070 <fgets@plt>
mov    -0x28(%rbp),%rdi
call   1030 <fclose@plt>
lea    -0x90(%rbp),%rdi
mov    -0xa0(%rbp),%rsi
call   10b0 <strtok@plt>
mov    %rax,-0xb0(%rbp)
mov    -0xa0(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edi
call   10b0 <strtok@plt>
mov    %rax,-0xb8(%rbp)
mov    -0xa0(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edi
call   10b0 <strtok@plt>
mov    %rax,-0xc0(%rbp)
mov    -0xa0(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edi
call   10b0 <strtok@plt>
mov    %rax,-0xd8(%rbp)
mov    -0xa0(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edi
call   10b0 <strtok@plt>
mov    %rax,-0xe0(%rbp)
mov    -0xa0(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edi
call   10b0 <strtok@plt>
mov    %rax,-0xe8(%rbp)
mov    -0xa0(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edi
call   10b0 <strtok@plt>
mov    %rax,-0x98(%rbp)
mov    -0xa0(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edi
call   10b0 <strtok@plt>
mov    %rax,-0x98(%rbp)
mov    -0xa0(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edi
call   10b0 <strtok@plt>
mov    %rax,-0x98(%rbp)
mov    -0xa0(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edi
call   10b0 <strtok@plt>
mov    %rax,-0x98(%rbp)
mov    -0xa0(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edi
call   10b0 <strtok@plt>
mov    %rax,-0x98(%rbp)
mov    -0xa0(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edi
call   10b0 <strtok@plt>
mov    %rax,-0xf0(%rbp)
mov    -0xe8(%rbp),%rdi
mov    -0xa8(%rbp),%rsi
call   10b0 <strtok@plt>
mov    %rax,-0xf8(%rbp)
mov    -0xa8(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edi
call   10b0 <strtok@plt>
mov    %rax,-0x100(%rbp)
mov    -0x100(%rbp),%rdi
lea    0xc46(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    140e <main+0x25e>
lea    0xc33(%rip),%rax
mov    %rax,-0x100(%rbp)
mov    -0xf8(%rbp),%rdi
lea    0xc1b(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    143e <main+0x28e>
lea    0xc08(%rip),%rax
mov    %rax,-0xf8(%rbp)
jmp    14f9 <main+0x349>
mov    -0xf8(%rbp),%rdi
lea    0xbf0(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    146e <main+0x2be>
lea    0xbdd(%rip),%rax
mov    %rax,-0xf8(%rbp)
jmp    14f4 <main+0x344>
mov    -0xf8(%rbp),%rdi
lea    0xbc5(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    14ac <main+0x2fc>
lea    0xbb1(%rip),%rax
mov    %rax,-0xf8(%rbp)
lea    0xba7(%rip),%rax
mov    %rax,-0x100(%rbp)
jmp    14ef <main+0x33f>
mov    -0xf8(%rbp),%rdi
lea    0xb95(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    14dc <main+0x32c>
lea    0xb79(%rip),%rax
mov    %rax,-0xf8(%rbp)
jmp    14ea <main+0x33a>
lea    0xb68(%rip),%rax
mov    %rax,-0xf8(%rbp)
jmp    14ef <main+0x33f>
jmp    14f4 <main+0x344>
jmp    14f9 <main+0x349>
mov    -0xf8(%rbp),%rdi
lea    0xb38(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    154f <main+0x39f>
mov    -0x100(%rbp),%rdi
lea    0xb29(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    154f <main+0x39f>
lea    0xb09(%rip),%rax
mov    %rax,-0xf8(%rbp)
lea    0xaff(%rip),%rax
mov    %rax,-0x100(%rbp)
lea    -0x10a(%rbp),%rdi
mov    -0xf8(%rbp),%rdx
mov    -0x100(%rbp),%rcx
lea    0xae6(%rip),%rsi
mov    $0x0,%al
call   10c0 <sprintf@plt>
mov    -0xb8(%rbp),%rsi
mov    -0xc0(%rbp),%rdx
lea    -0x10a(%rbp),%rcx
mov    -0xb0(%rbp),%r8
lea    0xac1(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1203 <main+0x53>
mov    -0x18(%rbp),%rdi
call   1060 <closedir@plt>
xor    %edi,%edi
call   10d0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x98,%rsp
lea    0xe2c(%rip),%rdi
call   1050 <opendir@plt>
mov    %rax,%rbp
lea    0xe66(%rip),%rdi
call   1030 <puts@plt>
mov    %rbp,%rdi
call   10a0 <readdir@plt>
test   %rax,%rax
jne    1208 <main+0x48>
mov    %rbp,%rdi
call   1070 <closedir@plt>
xor    %edi,%edi
call   10e0 <exit@plt>
lea    0xdf1(%rip),%r12
lea    0xe09(%rip),%r14
mov    %rbp,0x10(%rsp)
jmp    1276 <main+0xb6>
nopl   (%rax)
mov    0x8(%rsp),%r13
lea    0x26(%rsp),%rbx
mov    %rbx,%rdi
lea    0xe02(%rip),%rsi
mov    %rbp,%rdx
mov    %r14,%rcx
xor    %eax,%eax
call   10d0 <sprintf@plt>
lea    0xdf3(%rip),%rdi
mov    %r13,%rsi
mov    0x18(%rsp),%rdx
mov    %rbx,%rcx
mov    %r15,%r8
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x10(%rsp),%rbp
lea    0xdb6(%rip),%r14
mov    %rbp,%rdi
call   10a0 <readdir@plt>
test   %rax,%rax
je     11f9 <main+0x39>
mov    (%rax),%rdx
movzbl (%rdx),%eax
cmp    $0x2e,%al
je     1269 <main+0xa9>
cmp    $0x63,%al
je     1269 <main+0xa9>
lea    0x30(%rsp),%rbx
mov    %rbx,%rdi
lea    0xd77(%rip),%rsi
xor    %eax,%eax
call   10d0 <sprintf@plt>
mov    %rbx,%rdi
lea    0xd76(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,%rbp
mov    %rbx,%rdi
mov    $0x63,%esi
mov    %rax,%rdx
call   1080 <fgets@plt>
mov    %rbp,%rdi
call   1040 <fclose@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   10c0 <strtok@plt>
mov    %rax,%rbx
xor    %edi,%edi
mov    %r12,%rsi
call   10c0 <strtok@plt>
mov    %rax,0x8(%rsp)
xor    %edi,%edi
mov    %r12,%rsi
call   10c0 <strtok@plt>
mov    %rax,0x18(%rsp)
xor    %edi,%edi
mov    %r12,%rsi
call   10c0 <strtok@plt>
xor    %edi,%edi
mov    %r12,%rsi
call   10c0 <strtok@plt>
xor    %edi,%edi
mov    %r12,%rsi
call   10c0 <strtok@plt>
mov    %rax,%rbp
xor    %edi,%edi
mov    %r12,%rsi
call   10c0 <strtok@plt>
xor    %edi,%edi
mov    %r12,%rsi
call   10c0 <strtok@plt>
xor    %edi,%edi
mov    %r12,%rsi
call   10c0 <strtok@plt>
xor    %edi,%edi
mov    %r12,%rsi
call   10c0 <strtok@plt>
xor    %edi,%edi
mov    %r12,%rsi
call   10c0 <strtok@plt>
xor    %edi,%edi
mov    %r12,%rsi
call   10c0 <strtok@plt>
mov    %rbp,%rdi
lea    0xcab(%rip),%rbp
mov    %rbp,%rsi
call   10c0 <strtok@plt>
mov    %rax,%r13
xor    %edi,%edi
mov    %rbp,%rsi
call   10c0 <strtok@plt>
mov    %rax,%r15
mov    %rax,%rdi
lea    0xca3(%rip),%rbp
mov    %rbp,%rsi
call   1090 <strcmp@plt>
test   %rax,%rax
cmove  %r14,%r15
mov    %r13,%rdi
mov    %rbp,%rsi
call   1090 <strcmp@plt>
test   %rax,%rax
je     13f4 <main+0x234>
mov    %r13,%rdi
lea    0xc7f(%rip),%rsi
call   1090 <strcmp@plt>
test   %rax,%rax
je     13f9 <main+0x239>
mov    %r13,%rdi
lea    0xc70(%rip),%rsi
call   1090 <strcmp@plt>
lea    0xc66(%rip),%rbp
lea    0xc63(%rip),%r14
test   %rax,%rax
je     1403 <main+0x243>
mov    %r13,%rdi
lea    0xc5c(%rip),%rsi
call   1090 <strcmp@plt>
test   %rax,%rax
lea    0xc49(%rip),%rbp
lea    0xc40(%rip),%rax
cmove  %rax,%rbp
jmp    1400 <main+0x240>
mov    %r14,%rbp
jmp    1400 <main+0x240>
lea    0xc24(%rip),%rbp
mov    %r15,%r14
mov    %rbp,%rdi
lea    0xc17(%rip),%rsi
call   1090 <strcmp@plt>
mov    %rbx,%r15
test   %rax,%rax
jne    1220 <main+0x60>
mov    %r14,%rdi
lea    0xc0a(%rip),%rsi
call   1090 <strcmp@plt>
test   %rax,%rax
mov    0x8(%rsp),%r13
jne    1225 <main+0x65>
lea    0xbe6(%rip),%rbp
lea    0xbe3(%rip),%r14
jmp    1225 <main+0x65>

LLVM IR (-O0):
%struct.dirent = type { i8* }
@.str = [2 x i8] c" \00"
@.str.1 = [2 x i8] c",\00"
@.str.2 = [6 x i8] c"/proc\00"
@.str.3 = [27 x i8] c" PID PPID TTY COMMAND\0A\00"
@.str.4 = [16 x i8] c"/proc/%s/status\00"
@.str.5 = [2 x i8] c"r\00"
@.str.6 = [3 x i8] c"-1\00"
@.str.7 = [2 x i8] c"?\00"
@.str.8 = [3 x i8] c"12\00"
@.str.9 = [2 x i8] c"v\00"
@.str.10 = [2 x i8] c"0\00"
@.str.11 = [4 x i8] c"con\00"
@.str.12 = [2 x i8] c"-\00"
@.str.13 = [2 x i8] c"5\00"
@.str.14 = [2 x i8] c"p\00"
@.str.15 = [2 x i8] c"x\00"
@.str.16 = [4 x i8] c"255\00"
@.str.17 = [5 x i8] c"%s%s\00"
@.str.18 = [18 x i8] c"%5s %5s %4s (%s)\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca %struct.dirent*
%8 = alloca i32*
%9 = alloca [100 x i8]
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i8*
%15 = alloca i8*
%16 = alloca i8*
%17 = alloca i8*
%18 = alloca i8*
%19 = alloca i8*
%20 = alloca i8*
%21 = alloca i8*
%22 = alloca i8*
%23 = alloca i8*
%24 = alloca [10 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8** %11
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8** %12
%25 = call i32* @opendir(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
store i32* %25, i32** %6
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0))
br label %27
27: ; preds = %129, %48, %39, %2
%28 = load i32*, i32** %6
%29 = call %struct.dirent* @readdir(i32* %28)
store %struct.dirent* %29, %struct.dirent** %7
%30 = icmp ne %struct.dirent* %29, null
br i1 %30, label %31, label %139
31: ; preds = %27
%32 = load %struct.dirent*, %struct.dirent** %7
%33 = getelementptr inbounds %struct.dirent, %struct.dirent* %32, i32 0, i32 0
%34 = load i8*, i8** %33
%35 = getelementptr inbounds i8, i8* %34, i64 0
%36 = load i8, i8* %35
%37 = sext i8 %36 to i32
%38 = icmp eq i32 %37, 46
br i1 %38, label %39, label %40
39: ; preds = %31
br label %27
40: ; preds = %31
%41 = load %struct.dirent*, %struct.dirent** %7
%42 = getelementptr inbounds %struct.dirent, %struct.dirent* %41, i32 0, i32 0
%43 = load i8*, i8** %42
%44 = getelementptr inbounds i8, i8* %43, i64 0
%45 = load i8, i8* %44
%46 = sext i8 %45 to i32
%47 = icmp eq i32 %46, 99
br i1 %47, label %48, label %49
48: ; preds = %40
br label %27
49: ; preds = %40
%50 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 0
%51 = load %struct.dirent*, %struct.dirent** %7
%52 = getelementptr inbounds %struct.dirent, %struct.dirent* %51, i32 0, i32 0
%53 = load i8*, i8** %52
%54 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %50, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i8* %53)
%55 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 0
%56 = call i32* @fopen(i8* %55, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
store i32* %56, i32** %8
%57 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 0
%58 = load i32*, i32** %8
%59 = call i32 @fgets(i8* %57, i32 99, i32* %58)
%60 = load i32*, i32** %8
%61 = call i32 @fclose(i32* %60)
%62 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 0
%63 = load i8*, i8** %11
%64 = call i8* @strtok(i8* %62, i8* %63)
store i8* %64, i8** %13
%65 = load i8*, i8** %11
%66 = call i8* @strtok(i8* null, i8* %65)
store i8* %66, i8** %14
%67 = load i8*, i8** %11
%68 = call i8* @strtok(i8* null, i8* %67)
store i8* %68, i8** %15
%69 = load i8*, i8** %11
%70 = call i8* @strtok(i8* null, i8* %69)
store i8* %70, i8** %18
%71 = load i8*, i8** %11
%72 = call i8* @strtok(i8* null, i8* %71)
store i8* %72, i8** %19
%73 = load i8*, i8** %11
%74 = call i8* @strtok(i8* null, i8* %73)
store i8* %74, i8** %20
%75 = load i8*, i8** %11
%76 = call i8* @strtok(i8* null, i8* %75)
store i8* %76, i8** %10
%77 = load i8*, i8** %11
%78 = call i8* @strtok(i8* null, i8* %77)
store i8* %78, i8** %10
%79 = load i8*, i8** %11
%80 = call i8* @strtok(i8* null, i8* %79)
store i8* %80, i8** %10
%81 = load i8*, i8** %11
%82 = call i8* @strtok(i8* null, i8* %81)
store i8* %82, i8** %10
%83 = load i8*, i8** %11
%84 = call i8* @strtok(i8* null, i8* %83)
store i8* %84, i8** %10
%85 = load i8*, i8** %11
%86 = call i8* @strtok(i8* null, i8* %85)
store i8* %86, i8** %21
%87 = load i8*, i8** %20
%88 = load i8*, i8** %12
%89 = call i8* @strtok(i8* %87, i8* %88)
store i8* %89, i8** %22
%90 = load i8*, i8** %12
%91 = call i8* @strtok(i8* null, i8* %90)
store i8* %91, i8** %23
%92 = load i8*, i8** %23
%93 = call i64 @strcmp(i8* %92, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%94 = icmp eq i64 %93, 0
br i1 %94, label %95, label %96
95: ; preds = %49
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0), i8** %23
br label %96
96: ; preds = %95, %49
%97 = load i8*, i8** %22
%98 = call i64 @strcmp(i8* %97, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%99 = icmp eq i64 %98, 0
br i1 %99, label %100, label %101
100: ; preds = %96
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0), i8** %22
br label %120
101: ; preds = %96
%102 = load i8*, i8** %22
%103 = call i64 @strcmp(i8* %102, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0))
%104 = icmp eq i64 %103, 0
br i1 %104, label %105, label %106
105: ; preds = %101
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0), i8** %22
br label %119
106: ; preds = %101
%107 = load i8*, i8** %22
%108 = call i64 @strcmp(i8* %107, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0))
%109 = icmp eq i64 %108, 0
br i1 %109, label %110, label %111
110: ; preds = %106
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i64 0, i64 0), i8** %22
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.12, i64 0, i64 0), i8** %23
br label %118
111: ; preds = %106
%112 = load i8*, i8** %22
%113 = call i64 @strcmp(i8* %112, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.13, i64 0, i64 0))
%114 = icmp eq i64 %113, 0
br i1 %114, label %115, label %116
115: ; preds = %111
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.14, i64 0, i64 0), i8** %22
br label %117
116: ; preds = %111
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.15, i64 0, i64 0), i8** %22
br label %117
117: ; preds = %116, %115
br label %118
118: ; preds = %117, %110
br label %119
119: ; preds = %118, %105
br label %120
120: ; preds = %119, %100
%121 = load i8*, i8** %22
%122 = call i64 @strcmp(i8* %121, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
%123 = icmp eq i64 %122, 0
br i1 %123, label %124, label %129
124: ; preds = %120
%125 = load i8*, i8** %23
%126 = call i64 @strcmp(i8* %125, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.16, i64 0, i64 0))
%127 = icmp eq i64 %126, 0
br i1 %127, label %128, label %129
128: ; preds = %124
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i64 0, i64 0), i8** %22
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.12, i64 0, i64 0), i8** %23
br label %129
129: ; preds = %128, %124, %120
%130 = getelementptr inbounds [10 x i8], [10 x i8]* %24, i64 0, i64 0
%131 = load i8*, i8** %22
%132 = load i8*, i8** %23
%133 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %130, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.17, i64 0, i64 0), i8* %131, i8* %132)
%134 = load i8*, i8** %14
%135 = load i8*, i8** %15
%136 = getelementptr inbounds [10 x i8], [10 x i8]* %24, i64 0, i64 0
%137 = load i8*, i8** %13
%138 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.18, i64 0, i64 0), i8* %134, i8* %135, i8* %136, i8* %137)
br label %27
139: ; preds = %27
%140 = load i32*, i32** %6
%141 = call i32 @closedir(i32* %140)
%142 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
%struct.dirent = type { i8* }
@.str = [2 x i8] c" \00"
@.str.1 = [2 x i8] c",\00"
@.str.2 = [6 x i8] c"/proc\00"
@.str.4 = [16 x i8] c"/proc/%s/status\00"
@.str.5 = [2 x i8] c"r\00"
@.str.6 = [3 x i8] c"-1\00"
@.str.7 = [2 x i8] c"?\00"
@.str.8 = [3 x i8] c"12\00"
@.str.9 = [2 x i8] c"v\00"
@.str.10 = [2 x i8] c"0\00"
@.str.11 = [4 x i8] c"con\00"
@.str.12 = [2 x i8] c"-\00"
@.str.13 = [2 x i8] c"5\00"
@.str.14 = [2 x i8] c"p\00"
@.str.15 = [2 x i8] c"x\00"
@.str.16 = [4 x i8] c"255\00"
@.str.17 = [5 x i8] c"%s%s\00"
@.str.18 = [18 x i8] c"%5s %5s %4s (%s)\0A\00"
@str = [26 x i8] c" PID PPID TTY COMMAND\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [100 x i8]
%4 = alloca [10 x i8]
%5 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 0
%7 = tail call i32* @opendir(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
%9 = call %struct.dirent* @readdir(i32* %7)
%10 = icmp eq %struct.dirent* %9, null
br i1 %10, label %67, label %11
11: ; preds = %2, %64
%12 = phi %struct.dirent* [ %65, %64 ], [ %9, %2 ]
%13 = getelementptr inbounds %struct.dirent, %struct.dirent* %12, i64 0, i32 0
%14 = load i8*, i8** %13
%15 = load i8, i8* %14
switch i8 %15, label %16 [
i8 46, label %64
i8 99, label %64
]
16: ; preds = %11
%17 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i8* %14)
%18 = call i32* @fopen(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%19 = call i32 @fgets(i8* %5, i32 99, i32* %18)
%20 = call i32 @fclose(i32* %18)
%21 = call i8* @strtok(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%22 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%23 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%24 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%25 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%26 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%27 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%28 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%29 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%30 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%31 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%32 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%33 = call i8* @strtok(i8* %26, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%34 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%35 = call i64 @strcmp(i8* %34, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%36 = icmp eq i64 %35, 0
%37 = select i1 %36, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0), i8* %34
%38 = call i64 @strcmp(i8* %33, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%39 = icmp eq i64 %38, 0
br i1 %39, label %50, label %40
40: ; preds = %16
%41 = call i64 @strcmp(i8* %33, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0))
%42 = icmp eq i64 %41, 0
br i1 %42, label %50, label %43
43: ; preds = %40
%44 = call i64 @strcmp(i8* %33, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0))
%45 = icmp eq i64 %44, 0
br i1 %45, label %50, label %46
46: ; preds = %43
%47 = call i64 @strcmp(i8* %33, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.13, i64 0, i64 0))
%48 = icmp eq i64 %47, 0
%49 = select i1 %48, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.14, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.15, i64 0, i64 0)
br label %50
50: ; preds = %46, %43, %40, %16
%51 = phi i8* [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0), %16 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0), %40 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i64 0, i64 0), %43 ], [ %49, %46 ]
%52 = phi i8* [ %37, %16 ], [ %37, %40 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str.12, i64 0, i64 0), %43 ], [ %37, %46 ]
%53 = call i64 @strcmp(i8* %51, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
%54 = icmp eq i64 %53, 0
br i1 %54, label %55, label %59
55: ; preds = %50
%56 = call i64 @strcmp(i8* %52, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.16, i64 0, i64 0))
%57 = icmp eq i64 %56, 0
br i1 %57, label %58, label %59
58: ; preds = %55
br label %59
59: ; preds = %58, %55, %50
%60 = phi i8* [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i64 0, i64 0), %58 ], [ %51, %55 ], [ %51, %50 ]
%61 = phi i8* [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str.12, i64 0, i64 0), %58 ], [ %52, %55 ], [ %52, %50 ]
%62 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.17, i64 0, i64 0), i8* %60, i8* %61)
%63 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.18, i64 0, i64 0), i8* %22, i8* %23, i8* %6, i8* %21)
br label %64
64: ; preds = %59, %11, %11
%65 = call %struct.dirent* @readdir(i32* %7)
%66 = icmp eq %struct.dirent* %65, null
br i1 %66, label %67, label %11
67: ; preds = %64, %2
%68 = call i32 @closedir(i32* %7)
%69 = call i32 @exit(i32 0)
unreachable
}