#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*/ O_RDONLY;
int /*<<< orphan*/ _SC_CLK_TCK;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ isdigit(char);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ *opendir(char *);
int /*<<< orphan*/ printf(char *, char *, char *, char *, char *);
struct dirent *readdir(int /*<<< orphan*/ *);
int /*<<< orphan*/ sprintf(char *, char *, ...);
scalar_t__ strcmp(char *, char *);
int strlen(char *);
double sysconf(int /*<<< orphan*/);
char *ttyname(int);
int main(int argc, char **argv) {
  DIR *dir;
  struct dirent *ent;
  int i, fd_self, fd;
  unsigned long time, stime;
  char flag, *tty;
  char cmd[256], tty_self[256], path[256], time_s[256];
  FILE *file;
  dir = opendir("/proc");
  fd_self = open("/proc/self/fd/0", O_RDONLY);
  sprintf(tty_self, "%s", ttyname(fd_self));
  printf("%5s %s\t%8s %s\n", "PID", "TTY", "TIME", "CMD");
  while ((ent = readdir(dir)) != NULL) {
    flag = 1;
    for (i = 0; ent->d_name[i]; i++)
      if (!isdigit(ent->d_name[i])) {
        flag = 0;
        break;
      }
    if (flag) {
      sprintf(path, "/proc/%s/fd/0", ent->d_name);
      fd = open(path, O_RDONLY);
      tty = ttyname(fd);
      if (tty && strcmp(tty, tty_self) == 0) {
        sprintf(path, "/proc/%s/stat", ent->d_name);
        file = fopen(path, "r");
        fscanf(file, "%d%s%c%c%c", &i, cmd, &flag, &flag, &flag);
        cmd[strlen(cmd) - 1] = '\0';
        for (i = 0; i < 11; i++)
          fscanf(file, "%lu", &time);
        fscanf(file, "%lu", &stime);
        time = (int)((double)(time + stime) / sysconf(_SC_CLK_TCK));
        sprintf(time_s, "%02lu:%02lu:%02lu", (time / 3600) % 3600,
                (time / 60) % 60, time % 60);
        printf("%5s %s\t%8s %s\n", ent->d_name, tty + 5, time_s, cmd + 1);
        fclose(file);
      }
      close(fd);
    }
  }
  close(fd_self);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x480,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe20(%rip),%rdi
call   1050 <opendir@plt>
mov    %rax,-0x18(%rbp)
mov    0x2dd8(%rip),%rax
mov    (%rax),%esi
lea    0xe0d(%rip),%rdi
call   10d0 <open@plt>
mov    %eax,-0x28(%rbp)
lea    -0x250(%rbp),%rax
mov    %rax,-0x460(%rbp)
mov    -0x28(%rbp),%edi
call   10c0 <ttyname@plt>
mov    -0x460(%rbp),%rdi
mov    %rax,%rdx
lea    0xdee(%rip),%rsi
mov    $0x0,%al
call   1100 <sprintf@plt>
lea    0xde3(%rip),%rdi
lea    0xdeb(%rip),%rsi
lea    0xde8(%rip),%rdx
lea    0xde5(%rip),%rcx
lea    0xde3(%rip),%r8
call   1070 <printf@plt>
mov    -0x18(%rbp),%rdi
call   10b0 <readdir@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     1532 <main+0x352>
movb   $0x1,-0x41(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
movslq -0x24(%rbp),%rcx
cmpb   $0x0,(%rax,%rcx,1)
je     12e7 <main+0x107>
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
movslq -0x24(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%eax
jne    12d4 <main+0xf4>
movb   $0x0,-0x41(%rbp)
jmp    12e7 <main+0x107>
jmp    12d9 <main+0xf9>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1299 <main+0xb9>
cmpb   $0x0,-0x41(%rbp)
je     152d <main+0x34d>
lea    -0x350(%rbp),%rdi
mov    -0x20(%rbp),%rax
mov    (%rax),%rdx
lea    0xd53(%rip),%rsi
mov    $0x0,%al
call   1100 <sprintf@plt>
lea    -0x350(%rbp),%rdi
mov    0x2ccd(%rip),%rax
mov    (%rax),%esi
call   10d0 <open@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%edi
call   10c0 <ttyname@plt>
mov    %rax,-0x50(%rbp)
cmpq   $0x0,-0x50(%rbp)
je     1525 <main+0x345>
mov    -0x50(%rbp),%rdi
lea    -0x250(%rbp),%rsi
call   10a0 <strcmp@plt>
cmp    $0x0,%rax
jne    1525 <main+0x345>
lea    -0x350(%rbp),%rdi
mov    -0x20(%rbp),%rax
mov    (%rax),%rdx
lea    0xcfc(%rip),%rsi
mov    $0x0,%al
call   1100 <sprintf@plt>
lea    -0x350(%rbp),%rdi
lea    0xcf5(%rip),%rsi
call   10e0 <fopen@plt>
mov    %rax,-0x458(%rbp)
mov    -0x458(%rbp),%rdi
lea    -0x150(%rbp),%rcx
lea    0xcd6(%rip),%rsi
lea    -0x24(%rbp),%rdx
lea    -0x41(%rbp),%rax
mov    %rax,%r8
mov    %rax,%r9
mov    %rax,(%rsp)
mov    $0x0,%al
call   1080 <fscanf@plt>
lea    -0x150(%rbp),%rdi
call   1060 <strlen@plt>
sub    $0x1,%eax
cltq
movb   $0x0,-0x150(%rbp,%rax,1)
movl   $0x0,-0x24(%rbp)
cmpl   $0xb,-0x24(%rbp)
jge    140b <main+0x22b>
mov    -0x458(%rbp),%rdi
lea    0xc90(%rip),%rsi
lea    -0x38(%rbp),%rdx
mov    $0x0,%al
call   1080 <fscanf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    13da <main+0x1fa>
mov    -0x458(%rbp),%rdi
lea    0xc69(%rip),%rsi
xor    %eax,%eax
lea    -0x40(%rbp),%rdx
call   1080 <fscanf@plt>
mov    -0x38(%rbp),%rax
mov    -0x40(%rbp),%rcx
add    %rcx,%rax
movq   %rax,%xmm0
movaps 0xbc5(%rip),%xmm1
punpckldq %xmm1,%xmm0
movapd 0xbc9(%rip),%xmm1
subpd  %xmm1,%xmm0
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x470(%rbp)
ff
mov    0x2b73(%rip),%rax
mov    (%rax),%edi
call   10f0 <sysconf@plt>
movaps %xmm0,%xmm1
movsd  -0x470(%rbp),%xmm0
ff
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
cltq
mov    %rax,-0x38(%rbp)
lea    -0x450(%rbp),%rdi
mov    -0x38(%rbp),%rax
mov    $0xe10,%ecx
xor    %edx,%edx
div    %rcx
mov    $0xe10,%ecx
xor    %edx,%edx
div    %rcx
mov    %rdx,-0x468(%rbp)
mov    -0x38(%rbp),%rax
mov    $0x3c,%ecx
xor    %edx,%edx
div    %rcx
mov    $0x3c,%ecx
xor    %edx,%edx
div    %rcx
mov    %rdx,%rcx
mov    -0x38(%rbp),%rax
mov    $0x3c,%esi
xor    %edx,%edx
div    %rsi
mov    %rdx,%r8
mov    -0x468(%rbp),%rdx
lea    0xba1(%rip),%rsi
mov    $0x0,%al
call   1100 <sprintf@plt>
mov    -0x20(%rbp),%rax
mov    (%rax),%rsi
mov    -0x50(%rbp),%rdx
add    $0x5,%rdx
lea    -0x450(%rbp),%rcx
lea    -0x150(%rbp),%r8
add    $0x1,%r8
lea    0xb25(%rip),%rdi
call   1070 <printf@plt>
mov    -0x458(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x2c(%rbp),%edi
call   1090 <close@plt>
jmp    1277 <main+0x97>
mov    -0x28(%rbp),%edi
call   1090 <close@plt>
xor    %eax,%eax
add    $0x480,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x448,%rsp
lea    0xe18(%rip),%rdi
call   1060 <opendir@plt>
mov    %rax,%rbx
mov    0x2dd1(%rip),%rax
mov    (%rax),%esi
lea    0xe06(%rip),%rdi
call   10e0 <open@plt>
mov    %eax,0x14(%rsp)
mov    %eax,%edi
call   10d0 <ttyname@plt>
lea    0x240(%rsp),%rdi
mov    %rax,%rsi
call   1040 <strcpy@plt>
lea    0xdef(%rip),%rdi
lea    0xdf7(%rip),%rsi
lea    0xdf4(%rip),%rdx
lea    0xdf1(%rip),%rcx
lea    0xdef(%rip),%r8
call   1080 <printf@plt>
mov    %rbx,%rdi
call   10c0 <readdir@plt>
test   %rax,%rax
je     151a <main+0x32a>
mov    %rax,%r15
lea    0xdfc(%rip),%r13
mov    %rbx,0x20(%rsp)
jmp    12ac <main+0xbc>
nopw   0x0(%rax,%rax,1)
mov    %r12d,%edi
call   10a0 <close@plt>
mov    %rbx,%rdi
call   10c0 <readdir@plt>
mov    %rax,%r15
test   %rax,%rax
je     151a <main+0x32a>
movb   $0x1,0xf(%rsp)
movl   $0x0,0x10(%rsp)
mov    (%r15),%rdx
mov    (%rdx),%al
test   %al,%al
je     1300 <main+0x110>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsbl %al,%edi
call   1030 <isdigit@plt>
test   %eax,%eax
je     1510 <main+0x320>
movslq 0x10(%rsp),%rax
lea    0x1(%rax),%rcx
mov    %ecx,0x10(%rsp)
mov    (%r15),%rdx
movzbl 0x1(%rdx,%rax,1),%eax
test   %al,%al
jne    12d0 <main+0xe0>
cmpb   $0x0,0xf(%rsp)
je     1298 <main+0xa8>
lea    0x140(%rsp),%rbp
mov    %rbp,%rdi
lea    0xd44(%rip),%rsi
xor    %eax,%eax
call   1110 <sprintf@plt>
mov    0x2cc8(%rip),%rax
mov    (%rax),%esi
mov    %rbp,%rdi
call   10e0 <open@plt>
mov    %eax,%r12d
mov    %eax,%edi
call   10d0 <ttyname@plt>
test   %rax,%rax
je     1290 <main+0xa0>
mov    %rax,%r14
mov    %rax,%rdi
lea    0x240(%rsp),%rsi
call   10b0 <strcmp@plt>
test   %rax,%rax
jne    1290 <main+0xa0>
mov    (%r15),%rdx
lea    0x140(%rsp),%rbx
mov    %rbx,%rdi
lea    0xcf6(%rip),%rsi
xor    %eax,%eax
call   1110 <sprintf@plt>
mov    %rbx,%rdi
lea    0xcf3(%rip),%rsi
call   10f0 <fopen@plt>
mov    %rax,%rbx
lea    0xf(%rsp),%r8
mov    %r8,(%rsp)
mov    %rax,%rdi
lea    0xcda(%rip),%rsi
lea    0x10(%rsp),%rdx
lea    0x340(%rsp),%rbp
mov    %rbp,%rcx
mov    %r8,%r9
xor    %eax,%eax
call   1090 <fscanf@plt>
mov    %rbp,%rdi
call   1070 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%rbp,1)
movl   $0x0,0x10(%rsp)
lea    0x18(%rsp),%rbp
mov    %rbx,%rdi
mov    %r13,%rsi
mov    %rbp,%rdx
xor    %eax,%eax
call   1090 <fscanf@plt>
mov    0x10(%rsp),%eax
lea    0x1(%rax),%ecx
mov    %ecx,0x10(%rsp)
cmp    $0xa,%eax
jl     13d0 <main+0x1e0>
mov    %rbx,%rdi
mov    %r13,%rsi
lea    0x28(%rsp),%rdx
xor    %eax,%eax
call   1090 <fscanf@plt>
mov    0x28(%rsp),%rax
add    0x18(%rsp),%rax
movq   %rax,%xmm0
punpckldq 0xbe7(%rip),%xmm0
subpd  0xbef(%rip),%xmm0
movapd %xmm0,%xmm1
unpckhpd %xmm0,%xmm1
addsd  %xmm0,%xmm1
movapd %xmm1,0x30(%rsp)
mov    0x2b9e(%rip),%rax
mov    (%rax),%edi
call   1100 <sysconf@plt>
movapd 0x30(%rsp),%xmm1
divsd  %xmm0,%xmm1
cvttsd2si %xmm1,%eax
movslq %eax,%r8
mov    %r8,0x18(%rsp)
mov    %r8,%rax
shr    $0x4,%rax
movabs $0x91a2b3c4d5e6f81,%rcx
2b 1a 09
mul    %rcx
mov    %rdx,%rax
mov    %rdx,%rbp
shr    $0x3,%rbp
shr    $0x7,%rax
mul    %rcx
shr    $0x3,%rdx
imul   $0xe10,%rdx,%rax
sub    %rax,%rbp
mov    %r8,%rax
movabs $0x8888888888888889,%rsi
88 88 88
mul    %rsi
mov    %rdx,%rcx
shr    $0x5,%rcx
mov    %rcx,%rax
mul    %rsi
shr    $0x5,%rdx
imul   $0x3c,%rdx,%rax
imul   $0x3c,%rcx,%rdx
sub    %rax,%rcx
sub    %rdx,%r8
lea    0x40(%rsp),%rdi
lea    0xbbe(%rip),%rsi
mov    %rbp,%rdx
xor    %eax,%eax
call   1110 <sprintf@plt>
mov    (%r15),%rsi
add    $0x5,%r14
lea    0xb59(%rip),%rdi
mov    %r14,%rdx
lea    0x40(%rsp),%rcx
lea    0x341(%rsp),%r8
call   1080 <printf@plt>
mov    %rbx,%rdi
call   1050 <fclose@plt>
mov    0x20(%rsp),%rbx
jmp    1290 <main+0xa0>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movb   $0x0,0xf(%rsp)
jmp    1298 <main+0xa8>
mov    0x14(%rsp),%edi
call   10a0 <close@plt>
xor    %eax,%eax
add    $0x448,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.dirent = type { i8* }
@.str = [6 x i8] c"/proc\00"
@.str.1 = [16 x i8] c"/proc/self/fd/0\00"
@O_RDONLY = global i32 0
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [15 x i8] c"%5s %s\09%8s %s\0A\00"
@.str.4 = [4 x i8] c"PID\00"
@.str.5 = [4 x i8] c"TTY\00"
@.str.6 = [5 x i8] c"TIME\00"
@.str.7 = [4 x i8] c"CMD\00"
@.str.8 = [14 x i8] c"/proc/%s/fd/0\00"
@.str.9 = [14 x i8] c"/proc/%s/stat\00"
@.str.10 = [2 x i8] c"r\00"
@.str.11 = [11 x i8] c"%d%s%c%c%c\00"
@.str.12 = [4 x i8] c"%lu\00"
@_SC_CLK_TCK = global i32 0
@.str.13 = [18 x i8] c"%02lu:%02lu:%02lu\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 i32
%10 = alloca i32
%11 = alloca i64
%12 = alloca i64
%13 = alloca i8
%14 = alloca i8*
%15 = alloca [256 x i8]
%16 = alloca [256 x i8]
%17 = alloca [256 x i8]
%18 = alloca [256 x i8]
%19 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%20 = call i32* @opendir(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
store i32* %20, i32** %6
%21 = load i32, i32* @O_RDONLY
%22 = call i32 @open(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 %21)
store i32 %22, i32* %9
%23 = getelementptr inbounds [256 x i8], [256 x i8]* %16, i64 0, i64 0
%24 = load i32, i32* %9
%25 = call i8* @ttyname(i32 %24)
%26 = call i32 (i8*, i8*, ...) @sprintf(i8* %23, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %25)
%27 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
br label %28
28: ; preds = %139, %2
%29 = load i32*, i32** %6
%30 = call %struct.dirent* @readdir(i32* %29)
store %struct.dirent* %30, %struct.dirent** %7
%31 = icmp ne %struct.dirent* %30, null
br i1 %31, label %32, label %140
32: ; preds = %28
store i8 1, i8* %13
store i32 0, i32* %8
br label %33
33: ; preds = %54, %32
%34 = load %struct.dirent*, %struct.dirent** %7
%35 = getelementptr inbounds %struct.dirent, %struct.dirent* %34, i32 0, i32 0
%36 = load i8*, i8** %35
%37 = load i32, i32* %8
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i8, i8* %36, i64 %38
%40 = load i8, i8* %39
%41 = icmp ne i8 %40, 0
br i1 %41, label %42, label %57
42: ; preds = %33
%43 = load %struct.dirent*, %struct.dirent** %7
%44 = getelementptr inbounds %struct.dirent, %struct.dirent* %43, i32 0, i32 0
%45 = load i8*, i8** %44
%46 = load i32, i32* %8
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds i8, i8* %45, i64 %47
%49 = load i8, i8* %48
%50 = call i32 @isdigit(i8 signext %49)
%51 = icmp ne i32 %50, 0
br i1 %51, label %53, label %52
52: ; preds = %42
store i8 0, i8* %13
br label %57
53: ; preds = %42
br label %54
54: ; preds = %53
%55 = load i32, i32* %8
%56 = add nsw i32 %55, 1
store i32 %56, i32* %8
br label %33
57: ; preds = %52, %33
%58 = load i8, i8* %13
%59 = icmp ne i8 %58, 0
br i1 %59, label %60, label %139
60: ; preds = %57
%61 = getelementptr inbounds [256 x i8], [256 x i8]* %17, i64 0, i64 0
%62 = load %struct.dirent*, %struct.dirent** %7
%63 = getelementptr inbounds %struct.dirent, %struct.dirent* %62, i32 0, i32 0
%64 = load i8*, i8** %63
%65 = call i32 (i8*, i8*, ...) @sprintf(i8* %61, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.8, i64 0, i64 0), i8* %64)
%66 = getelementptr inbounds [256 x i8], [256 x i8]* %17, i64 0, i64 0
%67 = load i32, i32* @O_RDONLY
%68 = call i32 @open(i8* %66, i32 %67)
store i32 %68, i32* %10
%69 = load i32, i32* %10
%70 = call i8* @ttyname(i32 %69)
store i8* %70, i8** %14
%71 = load i8*, i8** %14
%72 = icmp ne i8* %71, null
br i1 %72, label %73, label %136
73: ; preds = %60
%74 = load i8*, i8** %14
%75 = getelementptr inbounds [256 x i8], [256 x i8]* %16, i64 0, i64 0
%76 = call i64 @strcmp(i8* %74, i8* %75)
%77 = icmp eq i64 %76, 0
br i1 %77, label %78, label %136
78: ; preds = %73
%79 = getelementptr inbounds [256 x i8], [256 x i8]* %17, i64 0, i64 0
%80 = load %struct.dirent*, %struct.dirent** %7
%81 = getelementptr inbounds %struct.dirent, %struct.dirent* %80, i32 0, i32 0
%82 = load i8*, i8** %81
%83 = call i32 (i8*, i8*, ...) @sprintf(i8* %79, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.9, i64 0, i64 0), i8* %82)
%84 = getelementptr inbounds [256 x i8], [256 x i8]* %17, i64 0, i64 0
%85 = call i32* @fopen(i8* %84, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0))
store i32* %85, i32** %19
%86 = load i32*, i32** %19
%87 = getelementptr inbounds [256 x i8], [256 x i8]* %15, i64 0, i64 0
%88 = call i32 (i32*, i8*, ...) @fscanf(i32* %86, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.11, i64 0, i64 0), i32* %8, i8* %87, i8* %13, i8* %13, i8* %13)
%89 = getelementptr inbounds [256 x i8], [256 x i8]* %15, i64 0, i64 0
%90 = call i32 @strlen(i8* %89)
%91 = sub nsw i32 %90, 1
%92 = sext i32 %91 to i64
%93 = getelementptr inbounds [256 x i8], [256 x i8]* %15, i64 0, i64 %92
store i8 0, i8* %93
store i32 0, i32* %8
br label %94
94: ; preds = %100, %78
%95 = load i32, i32* %8
%96 = icmp slt i32 %95, 11
br i1 %96, label %97, label %103
97: ; preds = %94
%98 = load i32*, i32** %19
%99 = call i32 (i32*, i8*, ...) @fscanf(i32* %98, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.12, i64 0, i64 0), i64* %11)
br label %100
100: ; preds = %97
%101 = load i32, i32* %8
%102 = add nsw i32 %101, 1
store i32 %102, i32* %8
br label %94
103: ; preds = %94
%104 = load i32*, i32** %19
%105 = call i32 (i32*, i8*, ...) @fscanf(i32* %104, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.12, i64 0, i64 0), i64* %12)
%106 = load i64, i64* %11
%107 = load i64, i64* %12
%108 = add i64 %106, %107
%109 = uitofp i64 %108 to double
%110 = load i32, i32* @_SC_CLK_TCK
%111 = call double @sysconf(i32 %110)
%112 = fdiv double %109, %111
%113 = fptosi double %112 to i32
%114 = sext i32 %113 to i64
store i64 %114, i64* %11
%115 = getelementptr inbounds [256 x i8], [256 x i8]* %18, i64 0, i64 0
%116 = load i64, i64* %11
%117 = udiv i64 %116, 3600
%118 = urem i64 %117, 3600
%119 = load i64, i64* %11
%120 = udiv i64 %119, 60
%121 = urem i64 %120, 60
%122 = load i64, i64* %11
%123 = urem i64 %122, 60
%124 = call i32 (i8*, i8*, ...) @sprintf(i8* %115, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.13, i64 0, i64 0), i64 %118, i64 %121, i64 %123)
%125 = load %struct.dirent*, %struct.dirent** %7
%126 = getelementptr inbounds %struct.dirent, %struct.dirent* %125, i32 0, i32 0
%127 = load i8*, i8** %126
%128 = load i8*, i8** %14
%129 = getelementptr inbounds i8, i8* %128, i64 5
%130 = getelementptr inbounds [256 x i8], [256 x i8]* %18, i64 0, i64 0
%131 = getelementptr inbounds [256 x i8], [256 x i8]* %15, i64 0, i64 0
%132 = getelementptr inbounds i8, i8* %131, i64 1
%133 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i8* %127, i8* %129, i8* %130, i8* %132)
%134 = load i32*, i32** %19
%135 = call i32 @fclose(i32* %134)
br label %136
136: ; preds = %103, %73, %60
%137 = load i32, i32* %10
%138 = call i32 @close(i32 %137)
br label %139
139: ; preds = %136, %57
br label %28
140: ; preds = %28
%141 = load i32, i32* %9
%142 = call i32 @close(i32 %141)
ret i32 0
}

LLVM IR (-O2):
%struct.dirent = type { i8* }
@.str = [6 x i8] c"/proc\00"
@.str.1 = [16 x i8] c"/proc/self/fd/0\00"
@O_RDONLY = global i32 0
@.str.3 = [15 x i8] c"%5s %s\09%8s %s\0A\00"
@.str.4 = [4 x i8] c"PID\00"
@.str.5 = [4 x i8] c"TTY\00"
@.str.6 = [5 x i8] c"TIME\00"
@.str.7 = [4 x i8] c"CMD\00"
@.str.8 = [14 x i8] c"/proc/%s/fd/0\00"
@.str.9 = [14 x i8] c"/proc/%s/stat\00"
@.str.10 = [2 x i8] c"r\00"
@.str.11 = [11 x i8] c"%d%s%c%c%c\00"
@.str.12 = [4 x i8] c"%lu\00"
@_SC_CLK_TCK = global i32 0
@.str.13 = [18 x i8] c"%02lu:%02lu:%02lu\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca i64
%5 = alloca i64
%6 = alloca i8
%7 = alloca [256 x i8]
%8 = alloca [256 x i8]
%9 = alloca [256 x i8]
%10 = alloca [256 x i8]
%11 = bitcast i32* %3 to i8*
%12 = bitcast i64* %4 to i8*
%13 = bitcast i64* %5 to i8*
%14 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%15 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%16 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 0
%17 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%18 = tail call i32* @opendir(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%19 = load i32, i32* @O_RDONLY
%20 = tail call i32 @open(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 %19)
%21 = tail call i8* @ttyname(i32 %20)
%22 = call i8* @strcpy(i8* %15, i8* dereferenceable(1) %21)
%23 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
%24 = call %struct.dirent* @readdir(i32* %18)
%25 = icmp eq %struct.dirent* %24, null
br i1 %25, label %100, label %26
26: ; preds = %2
%27 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 1
br label %28
28: ; preds = %26, %97
%29 = phi %struct.dirent* [ %24, %26 ], [ %98, %97 ]
store i8 1, i8* %6
%30 = getelementptr inbounds %struct.dirent, %struct.dirent* %29, i64 0, i32 0
store i32 0, i32* %3
%31 = load i8*, i8** %30
%32 = load i8, i8* %31
%33 = icmp eq i8 %32, 0
br i1 %33, label %50, label %34
34: ; preds = %28, %39
%35 = phi i8 [ %45, %39 ], [ %32, %28 ]
%36 = call i32 @isdigit(i8 signext %35)
%37 = icmp eq i32 %36, 0
br i1 %37, label %38, label %39
38: ; preds = %34
store i8 0, i8* %6
br label %97
39: ; preds = %34
%40 = load i32, i32* %3
%41 = add nsw i32 %40, 1
store i32 %41, i32* %3
%42 = load i8*, i8** %30
%43 = sext i32 %41 to i64
%44 = getelementptr inbounds i8, i8* %42, i64 %43
%45 = load i8, i8* %44
%46 = icmp eq i8 %45, 0
br i1 %46, label %47, label %34
47: ; preds = %39
%48 = load i8, i8* %6
%49 = icmp eq i8 %48, 0
br i1 %49, label %97, label %50
50: ; preds = %28, %47
%51 = phi i8* [ %42, %47 ], [ %31, %28 ]
%52 = call i32 (i8*, i8*, ...) @sprintf(i8* %16, i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.8, i64 0, i64 0), i8* %51)
%53 = load i32, i32* @O_RDONLY
%54 = call i32 @open(i8* %16, i32 %53)
%55 = call i8* @ttyname(i32 %54)
%56 = icmp eq i8* %55, null
br i1 %56, label %95, label %57
57: ; preds = %50
%58 = call i64 @strcmp(i8* %55, i8* %15)
%59 = icmp eq i64 %58, 0
br i1 %59, label %60, label %95
60: ; preds = %57
%61 = load i8*, i8** %30
%62 = call i32 (i8*, i8*, ...) @sprintf(i8* %16, i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.9, i64 0, i64 0), i8* %61)
%63 = call i32* @fopen(i8* %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0))
%64 = call i32 (i32*, i8*, ...) @fscanf(i32* %63, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.11, i64 0, i64 0), i32* %3, i8* %14, i8* %6, i8* %6, i8* %6)
%65 = call i32 @strlen(i8* %14)
%66 = add nsw i32 %65, -1
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 %67
store i8 0, i8* %68
store i32 0, i32* %3
br label %69
69: ; preds = %60, %69
%70 = call i32 (i32*, i8*, ...) @fscanf(i32* %63, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.12, i64 0, i64 0), i64* %4)
%71 = load i32, i32* %3
%72 = add nsw i32 %71, 1
store i32 %72, i32* %3
%73 = icmp slt i32 %71, 10
br i1 %73, label %69, label %74
74: ; preds = %69
%75 = call i32 (i32*, i8*, ...) @fscanf(i32* %63, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.12, i64 0, i64 0), i64* %5)
%76 = load i64, i64* %4
%77 = load i64, i64* %5
%78 = add i64 %77, %76
%79 = uitofp i64 %78 to double
%80 = load i32, i32* @_SC_CLK_TCK
%81 = call double @sysconf(i32 %80)
%82 = fdiv double %79, %81
%83 = fptosi double %82 to i32
%84 = sext i32 %83 to i64
store i64 %84, i64* %4
%85 = udiv i64 %84, 3600
%86 = urem i64 %85, 3600
%87 = udiv i64 %84, 60
%88 = urem i64 %87, 60
%89 = urem i64 %84, 60
%90 = call i32 (i8*, i8*, ...) @sprintf(i8* %17, i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.13, i64 0, i64 0), i64 %86, i64 %88, i64 %89)
%91 = load i8*, i8** %30
%92 = getelementptr inbounds i8, i8* %55, i64 5
%93 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i8* %91, i8* %92, i8* %17, i8* %27)
%94 = call i32 @fclose(i32* %63)
br label %95
95: ; preds = %74, %57, %50
%96 = call i32 @close(i32 %54)
br label %97
97: ; preds = %38, %95, %47
%98 = call %struct.dirent* @readdir(i32* %18)
%99 = icmp eq %struct.dirent* %98, null
br i1 %99, label %100, label %28
100: ; preds = %97, %2
%101 = call i32 @close(i32 %20)
ret i32 0
}