#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 */
typedef struct TYPE_4__ TYPE_2__;
typedef struct TYPE_3__ TYPE_1__;

/* Type definitions */
struct timeval {
  int tv_sec;
  int tv_usec;
};
struct TYPE_4__ {
  int tv_sec;
  int tv_usec;
};
struct TYPE_3__ {
  int tv_sec;
  int tv_usec;
};
struct rusage {
  int ru_nivcsw;
  int ru_nvcsw;
  int ru_majflt;
  int ru_minflt;
  TYPE_2__ ru_stime;
  TYPE_1__ ru_utime;
};
typedef int pid_t;

/* Variables and functions */
int /*<<< orphan*/ RUSAGE_CHILDREN;
scalar_t__ chdir(char *);
scalar_t__ errno;
scalar_t__ execvp(char *, char ***);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int fork();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ getrusage(int /*<<< orphan*/, struct rusage *);
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
scalar_t__ strcmp(char *, char *);
char *strtok(char *, char *);
int /*<<< orphan*/ wait(int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  pid_t pid;
  struct rusage usage;
  struct timeval starttime;
  struct timeval endtime;
  char *cmd;
  char line[128];
  char *line2[32];
  long double systime = 0;
  long double usrtime = 0;
  int nivcsw = 0;
  int nvcsw = 0;
  int minflts = 0;
  int majflts = 0;
  int i;
  char *a;
  while (1) {
    printf("==>");
    fgets(line, 128, stdin);
    cmd = strtok(line, " \t\r\n");
    line2[0] = cmd;
    if (cmd == NULL) {
      continue;
    }
    for (i = 1; i < 32; i++) {
      char *arg2 = strtok(NULL, " \t\r\n");
      if (arg2 == NULL) {
        line2[i] = NULL;
        break;
      } else {
        line2[i] = arg2;
      }
    }
    errno = 0;
    if (strcmp(line2[0], "cd") == 0) {
      if (chdir(line2[1]) != 0)
        fprintf(stderr, "directory does not exist.\n");
      else
        chdir(line2[1]);
    } else if (strcmp(cmd, "exit") == 0) {
      break;
    } else {
      gettimeofday(&starttime, NULL);
      pid = fork();
      if (pid == -1) {
        perror("Error forking");
        return -1;
      } else if (pid > 0) {
        wait(0);
        getrusage(RUSAGE_CHILDREN, &usage);
      } else {
        if (execvp(cmd, &line2) < 0) {
          perror("error in execvp somewhere");
          exit(1);
        } else {
          exit(0);
        }
      }
      gettimeofday(&endtime, NULL);
      printf("\nWall clock time in milliseconds: %0.3f milliseconds\n",
             (float)((endtime.tv_sec * 1000 + endtime.tv_usec / 1000) -
                     (starttime.tv_sec * 1000 + starttime.tv_usec / 1000)));
      printf("CPU time: %ld milliseconds user, %ld milliseconds system\n",
             ((usage.ru_utime.tv_sec * 1000 + usage.ru_utime.tv_usec / 1000) -
              usrtime),
             ((usage.ru_stime.tv_sec * 1000 + usage.ru_stime.tv_usec / 1000) -
              systime));
      printf("Number of times process was pre-empted involuntarily: %d \n",
             (int)(usage.ru_nivcsw - nivcsw));
      printf("Number of times process voluntarily gave up CPU: %d \n",
             (int)(usage.ru_nvcsw - nvcsw));
      printf("Total number of page faults: %d \n",
             (int)((usage.ru_majflt + usage.ru_minflt) - (majflts + minflts)));
      printf("Number of page faults able to be satisfied by kernel: %d \n",
             (int)(usage.ru_minflt) - (minflts));
      systime = (usage.ru_utime.tv_sec * 1000 + usage.ru_utime.tv_usec / 1000);
      usrtime = (usage.ru_stime.tv_sec * 1000 + usage.ru_stime.tv_usec / 1000);
      nivcsw = (int)usage.ru_nivcsw;
      nvcsw = (int)usage.ru_nvcsw;
      minflts = (int)usage.ru_minflt;
      majflts = (int)usage.ru_majflt;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x250,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
fldz
fld    %st(0)
fstpt  -0x1e0(%rbp)
fstpt  -0x1f0(%rbp)
movl   $0x0,-0x1f4(%rbp)
movl   $0x0,-0x1f8(%rbp)
movl   $0x0,-0x1fc(%rbp)
movl   $0x0,-0x200(%rbp)
lea    0xdd8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0xd0(%rbp),%rdi
mov    0x2dab(%rip),%rax
mov    (%rax),%edx
mov    $0x80,%esi
call   1060 <fgets@plt>
lea    -0xd0(%rbp),%rdi
lea    0xdad(%rip),%rsi
call   10b0 <strtok@plt>
mov    %rax,-0x50(%rbp)
mov    -0x50(%rbp),%rax
mov    %rax,-0x1d0(%rbp)
cmpq   $0x0,-0x50(%rbp)
jne    127b <main+0xab>
jmp    1221 <main+0x51>
movl   $0x1,-0x204(%rbp)
cmpl   $0x20,-0x204(%rbp)
jge    12fe <main+0x12e>
xor    %eax,%eax
mov    %eax,%edi
lea    0xd67(%rip),%rsi
call   10b0 <strtok@plt>
mov    %rax,-0x218(%rbp)
cmpq   $0x0,-0x218(%rbp)
jne    12cf <main+0xff>
movslq -0x204(%rbp),%rax
movq   $0x0,-0x1d0(%rbp,%rax,8)
jmp    12fe <main+0x12e>
mov    -0x218(%rbp),%rcx
movslq -0x204(%rbp),%rax
mov    %rcx,-0x1d0(%rbp,%rax,8)
ff
jmp    12ea <main+0x11a>
mov    -0x204(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x204(%rbp)
jmp    1285 <main+0xb5>
mov    0x2cc3(%rip),%rax
movq   $0x0,(%rax)
mov    -0x1d0(%rbp),%rdi
lea    0xcef(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    136a <main+0x19a>
mov    -0x1c8(%rbp),%rdi
call   1030 <chdir@plt>
cmp    $0x0,%rax
je     1359 <main+0x189>
mov    0x2c92(%rip),%rax
mov    (%rax),%edi
lea    0xcbd(%rip),%rsi
call   1080 <fprintf@plt>
jmp    1365 <main+0x195>
mov    -0x1c8(%rbp),%rdi
call   1030 <chdir@plt>
jmp    1639 <main+0x469>
mov    -0x50(%rbp),%rdi
lea    0xcb2(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    1389 <main+0x1b9>
jmp    163e <main+0x46e>
lea    -0x40(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <gettimeofday@plt>
mov    $0x0,%al
call   10f0 <fork@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    13c2 <main+0x1f2>
lea    0xc7b(%rip),%rdi
call   10a0 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1645 <main+0x475>
cmpl   $0x0,-0x14(%rbp)
jle    13ea <main+0x21a>
xor    %edi,%edi
call   10e0 <wait@plt>
mov    0x2bf6(%rip),%rax
mov    (%rax),%edi
lea    -0x38(%rbp),%rsi
call   1090 <getrusage@plt>
jmp    1421 <main+0x251>
mov    -0x50(%rbp),%rdi
lea    -0x1d0(%rbp),%rsi
call   10c0 <execvp@plt>
cmp    $0x0,%rax
jge    141a <main+0x24a>
lea    0xc2f(%rip),%rdi
call   10a0 <perror@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
xor    %edi,%edi
call   10d0 <exit@plt>
jmp    1426 <main+0x256>
xor    %eax,%eax
mov    %eax,-0x230(%rbp)
mov    %eax,%esi
lea    -0x48(%rbp),%rdi
call   1050 <gettimeofday@plt>
mov    -0x48(%rbp),%eax
imul   $0x3e8,%eax,%eax
movslq -0x44(%rbp),%rcx
imul   $0x10624dd3,%rcx,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x26,%rcx
add    %edx,%ecx
add    %ecx,%eax
mov    -0x40(%rbp),%ecx
imul   $0x3e8,%ecx,%ecx
movslq -0x3c(%rbp),%rdx
imul   $0x10624dd3,%rdx,%rdx
mov    %rdx,%rsi
shr    $0x3f,%rsi
sar    $0x26,%rdx
add    %esi,%edx
add    %edx,%ecx
sub    %ecx,%eax
cvtsi2ss %eax,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xbc4(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    -0x230(%rbp),%eax
mov    -0x28(%rbp),%ecx
mov    -0x20(%rbp),%edx
imul   $0x3e8,%edx,%edx
movslq -0x1c(%rbp),%rsi
imul   $0x10624dd3,%rsi,%rsi
mov    %rsi,%rdi
shr    $0x3f,%rdi
sar    $0x26,%rsi
add    %edi,%esi
add    %esi,%edx
mov    %edx,-0x228(%rbp)
fildl  -0x228(%rbp)
fldt   -0x1f0(%rbp)
fsubrp %st,%st(1)
imul   $0x3e8,%ecx,%ecx
movslq -0x24(%rbp),%rdx
imul   $0x10624dd3,%rdx,%rdx
mov    %rdx,%rsi
shr    $0x3f,%rsi
sar    $0x26,%rdx
add    %esi,%edx
add    %edx,%ecx
mov    %ecx,-0x224(%rbp)
fildl  -0x224(%rbp)
fldt   -0x1e0(%rbp)
fsubrp %st,%st(1)
mov    %rsp,%rcx
fstpt  0x10(%rcx)
fstpt  (%rcx)
lea    0xb70(%rip),%rdi
mov    %al,-0x229(%rbp)
call   1040 <printf@plt>
mov    -0x229(%rbp),%al
mov    -0x38(%rbp),%esi
mov    -0x1f4(%rbp),%ecx
sub    %ecx,%esi
lea    0xb87(%rip),%rdi
call   1040 <printf@plt>
mov    -0x229(%rbp),%al
mov    -0x34(%rbp),%esi
mov    -0x1f8(%rbp),%ecx
sub    %ecx,%esi
lea    0xba5(%rip),%rdi
call   1040 <printf@plt>
mov    -0x229(%rbp),%al
mov    -0x30(%rbp),%esi
mov    -0x2c(%rbp),%ecx
add    %ecx,%esi
mov    -0x200(%rbp),%ecx
mov    -0x1fc(%rbp),%edx
add    %edx,%ecx
sub    %ecx,%esi
lea    0xbb1(%rip),%rdi
call   1040 <printf@plt>
mov    -0x229(%rbp),%al
mov    -0x2c(%rbp),%esi
mov    -0x1fc(%rbp),%ecx
sub    %ecx,%esi
lea    0xbb6(%rip),%rdi
call   1040 <printf@plt>
mov    -0x20(%rbp),%eax
imul   $0x3e8,%eax,%eax
movslq -0x1c(%rbp),%rcx
imul   $0x10624dd3,%rcx,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x26,%rcx
add    %edx,%ecx
add    %ecx,%eax
mov    %eax,-0x220(%rbp)
fildl  -0x220(%rbp)
fstpt  -0x1e0(%rbp)
mov    -0x28(%rbp),%eax
imul   $0x3e8,%eax,%eax
movslq -0x24(%rbp),%rcx
imul   $0x10624dd3,%rcx,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x26,%rcx
add    %edx,%ecx
add    %ecx,%eax
mov    %eax,-0x21c(%rbp)
fildl  -0x21c(%rbp)
fstpt  -0x1f0(%rbp)
mov    -0x38(%rbp),%eax
mov    %eax,-0x1f4(%rbp)
mov    -0x34(%rbp),%eax
mov    %eax,-0x1f8(%rbp)
mov    -0x2c(%rbp),%eax
mov    %eax,-0x1fc(%rbp)
mov    -0x30(%rbp),%eax
mov    %eax,-0x200(%rbp)
jmp    1639 <main+0x469>
jmp    1221 <main+0x51>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x250,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x218,%rsp
fldz
lea    0xe16(%rip),%r14
mov    0x2df7(%rip),%r13
lea    0x190(%rsp),%rbx
lea    0xe04(%rip),%r15
fld    %st(0)
fstpt  0x78(%rsp)
fstpt  0x84(%rsp)
movl   $0x0,0x28(%rsp)
movl   $0x0,0x2c(%rsp)
movl   $0x0,0x34(%rsp)
movl   $0x0,0x30(%rsp)
jmp    1240 <main+0x70>
mov    %rbp,%rdi
call   1030 <chdir@plt>
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x0(%r13),%edx
mov    %rbx,%rdi
mov    $0x80,%esi
call   1060 <fgets@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   10b0 <strtok@plt>
mov    %rax,0x90(%rsp)
test   %rax,%rax
je     1240 <main+0x70>
mov    %rax,%rbp
mov    $0x1,%r12d
nopl   0x0(%rax)
xor    %edi,%edi
mov    %r15,%rsi
call   10b0 <strtok@plt>
test   %rax,%rax
je     12a6 <main+0xd6>
mov    %rax,0x90(%rsp,%r12,8)
add    $0x1,%r12
cmp    $0x20,%r12
jne    1280 <main+0xb0>
mov    %rbp,%rdi
jmp    12ba <main+0xea>
movq   $0x0,0x90(%rsp,%r12,8)
mov    0x90(%rsp),%rdi
mov    0x2d07(%rip),%rax
movq   $0x0,(%rax)
lea    0xd3a(%rip),%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
jne    130c <main+0x13c>
mov    0x98(%rsp),%rbp
mov    %rbp,%rdi
call   1030 <chdir@plt>
test   %rax,%rax
je     122f <main+0x5f>
mov    0x2cdf(%rip),%rax
mov    (%rax),%edi
lea    0xd0a(%rip),%rsi
call   1080 <fprintf@plt>
jmp    1240 <main+0x70>
mov    %rbp,%rdi
lea    0xd11(%rip),%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
je     1526 <main+0x356>
lea    0x70(%rsp),%rdi
xor    %esi,%esi
call   1050 <gettimeofday@plt>
xor    %eax,%eax
call   10f0 <fork@plt>
cmp    $0xffffffff,%eax
je     153a <main+0x36a>
test   %eax,%eax
jle    154d <main+0x37d>
xor    %edi,%edi
call   10e0 <wait@plt>
mov    0x2c7a(%rip),%rax
mov    (%rax),%edi
lea    0x38(%rsp),%rsi
call   1090 <getrusage@plt>
lea    0x68(%rsp),%rdi
xor    %esi,%esi
call   1050 <gettimeofday@plt>
mov    0x68(%rsp),%eax
movslq 0x6c(%rsp),%rcx
imul   $0x10624dd3,%rcx,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x26,%rcx
add    %edx,%ecx
movslq 0x74(%rsp),%rdx
imul   $0xffffffffef9db22d,%rdx,%rdx
mov    %rdx,%rsi
shr    $0x3f,%rsi
sar    $0x26,%rdx
add    %esi,%edx
add    %ecx,%edx
sub    0x70(%rsp),%eax
imul   $0x3e8,%eax,%eax
add    %edx,%eax
cvtsi2ss %eax,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xc93(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
imul   $0x3e8,0x50(%rsp),%eax
movslq 0x54(%rsp),%rcx
imul   $0x10624dd3,%rcx,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x26,%rcx
add    %edx,%ecx
add    %eax,%ecx
mov    %ecx,0x58(%rsp)
fldt   0x78(%rsp)
fisubrl 0x58(%rsp)
imul   $0x3e8,0x48(%rsp),%eax
movslq 0x4c(%rsp),%rcx
imul   $0x10624dd3,%rcx,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x26,%rcx
add    %edx,%ecx
add    %eax,%ecx
mov    %ecx,0x5c(%rsp)
fldt   0x84(%rsp)
fisubrl 0x5c(%rsp)
fstpt  0x10(%rsp)
fstpt  (%rsp)
lea    0xc53(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x38(%rsp),%esi
sub    0x28(%rsp),%esi
lea    0xc77(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x3c(%rsp),%esi
sub    0x2c(%rsp),%esi
lea    0xc9c(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x40(%rsp),%esi
mov    0x34(%rsp),%ebp
mov    0x30(%rsp),%eax
add    %ebp,%eax
sub    %eax,%esi
add    0x44(%rsp),%esi
lea    0xcb0(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x44(%rsp),%esi
sub    %ebp,%esi
lea    0xcbe(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
imul   $0x3e8,0x50(%rsp),%eax
movslq 0x54(%rsp),%rcx
imul   $0x10624dd3,%rcx,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x26,%rcx
add    %edx,%ecx
add    %eax,%ecx
mov    %ecx,0x60(%rsp)
fildl  0x60(%rsp)
fstpt  0x84(%rsp)
imul   $0x3e8,0x48(%rsp),%eax
movslq 0x4c(%rsp),%rcx
imul   $0x10624dd3,%rcx,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x26,%rcx
add    %edx,%ecx
add    %eax,%ecx
mov    %ecx,0x64(%rsp)
fildl  0x64(%rsp)
fstpt  0x78(%rsp)
mov    0x38(%rsp),%eax
mov    %eax,0x28(%rsp)
mov    0x3c(%rsp),%eax
mov    %eax,0x2c(%rsp)
mov    0x44(%rsp),%eax
mov    %eax,0x34(%rsp)
mov    0x40(%rsp),%eax
mov    %eax,0x30(%rsp)
jmp    1240 <main+0x70>
xor    %eax,%eax
add    $0x218,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xaeb(%rip),%rdi
call   10a0 <perror@plt>
mov    $0xffffffff,%eax
jmp    1528 <main+0x358>
lea    0x90(%rsp),%rsi
mov    %rbp,%rdi
call   10c0 <execvp@plt>
test   %rax,%rax
jns    1578 <main+0x3a8>
lea    0xad1(%rip),%rdi
call   10a0 <perror@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
xor    %edi,%edi
call   10d0 <exit@plt>

LLVM IR (-O0):
%struct.rusage = type { i32, i32, i32, i32, %struct.TYPE_4__, %struct.TYPE_3__ }
%struct.TYPE_4__ = type { i32, i32 }
%struct.TYPE_3__ = type { i32, i32 }
%struct.timeval = type { i32, i32 }
@.str = [4 x i8] c"==>\00"
@stdin = global i32 0
@.str.1 = [5 x i8] c" \09\0D\0A\00"
@errno = global i64 0
@.str.2 = [3 x i8] c"cd\00"
@stderr = global i32 0
@.str.3 = [27 x i8] c"directory does not exist.\0A\00"
@.str.4 = [5 x i8] c"exit\00"
@.str.5 = [14 x i8] c"Error forking\00"
@RUSAGE_CHILDREN = global i32 0
@.str.6 = [26 x i8] c"error in execvp somewhere\00"
@.str.7 = [54 x i8] c"\0AWall clock time in milliseconds: %0.3f milliseconds\0A\00"
@.str.8 = [58 x i8] c"CPU time: %ld milliseconds user, %ld milliseconds system\0A\00"
@.str.9 = [59 x i8] c"Number of times process was pre-empted involuntarily: %d \0A\00"
@.str.10 = [54 x i8] c"Number of times process voluntarily gave up CPU: %d \0A\00"
@.str.11 = [34 x i8] c"Total number of page faults: %d \0A\00"
@.str.12 = [59 x i8] c"Number of page faults able to be satisfied by kernel: %d \0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca %struct.rusage
%8 = alloca %struct.timeval
%9 = alloca %struct.timeval
%10 = alloca i8*
%11 = alloca [128 x i8]
%12 = alloca [32 x i8*]
%13 = alloca x86_fp80
%14 = alloca x86_fp80
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i8*
%21 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store x86_fp80 0xK00000000000000000000, x86_fp80* %13
store x86_fp80 0xK00000000000000000000, x86_fp80* %14
store i32 0, i32* %15
store i32 0, i32* %16
store i32 0, i32* %17
store i32 0, i32* %18
br label %22
22: ; preds = %2, %33, %202
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%24 = getelementptr inbounds [128 x i8], [128 x i8]* %11, i64 0, i64 0
%25 = load i32, i32* @stdin
%26 = call i32 @fgets(i8* %24, i32 128, i32 %25)
%27 = getelementptr inbounds [128 x i8], [128 x i8]* %11, i64 0, i64 0
%28 = call i8* @strtok(i8* %27, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
store i8* %28, i8** %10
%29 = load i8*, i8** %10
%30 = getelementptr inbounds [32 x i8*], [32 x i8*]* %12, i64 0, i64 0
store i8* %29, i8** %30
%31 = load i8*, i8** %10
%32 = icmp eq i8* %31, null
br i1 %32, label %33, label %34
33: ; preds = %22
br label %22
34: ; preds = %22
store i32 1, i32* %19
br label %35
35: ; preds = %52, %34
%36 = load i32, i32* %19
%37 = icmp slt i32 %36, 32
br i1 %37, label %38, label %55
38: ; preds = %35
%39 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
store i8* %39, i8** %21
%40 = load i8*, i8** %21
%41 = icmp eq i8* %40, null
br i1 %41, label %42, label %46
42: ; preds = %38
%43 = load i32, i32* %19
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds [32 x i8*], [32 x i8*]* %12, i64 0, i64 %44
store i8* null, i8** %45
br label %55
46: ; preds = %38
%47 = load i8*, i8** %21
%48 = load i32, i32* %19
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds [32 x i8*], [32 x i8*]* %12, i64 0, i64 %49
store i8* %47, i8** %50
br label %51
51: ; preds = %46
br label %52
52: ; preds = %51
%53 = load i32, i32* %19
%54 = add nsw i32 %53, 1
store i32 %54, i32* %19
br label %35
55: ; preds = %42, %35
store i64 0, i64* @errno
%56 = getelementptr inbounds [32 x i8*], [32 x i8*]* %12, i64 0, i64 0
%57 = load i8*, i8** %56
%58 = call i64 @strcmp(i8* %57, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%59 = icmp eq i64 %58, 0
br i1 %59, label %60, label %73
60: ; preds = %55
%61 = getelementptr inbounds [32 x i8*], [32 x i8*]* %12, i64 0, i64 1
%62 = load i8*, i8** %61
%63 = call i64 @chdir(i8* %62)
%64 = icmp ne i64 %63, 0
br i1 %64, label %65, label %68
65: ; preds = %60
%66 = load i32, i32* @stderr
%67 = call i32 @fprintf(i32 %66, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0))
br label %72
68: ; preds = %60
%69 = getelementptr inbounds [32 x i8*], [32 x i8*]* %12, i64 0, i64 1
%70 = load i8*, i8** %69
%71 = call i64 @chdir(i8* %70)
br label %72
72: ; preds = %68, %65
br label %202
73: ; preds = %55
%74 = load i8*, i8** %10
%75 = call i64 @strcmp(i8* %74, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%76 = icmp eq i64 %75, 0
br i1 %76, label %77, label %78
77: ; preds = %73
br label %203
78: ; preds = %73
%79 = call i32 @gettimeofday(%struct.timeval* %8, i32* null)
%80 = call i32 (...) @fork()
store i32 %80, i32* %6
%81 = load i32, i32* %6
%82 = icmp eq i32 %81, -1
br i1 %82, label %83, label %85
83: ; preds = %78
%84 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0))
store i32 -1, i32* %3
br label %204
85: ; preds = %78
%86 = load i32, i32* %6
%87 = icmp sgt i32 %86, 0
br i1 %87, label %88, label %92
88: ; preds = %85
%89 = call i32 @wait(i32 0)
%90 = load i32, i32* @RUSAGE_CHILDREN
%91 = call i32 @getrusage(i32 %90, %struct.rusage* %7)
br label %102
92: ; preds = %85
%93 = load i8*, i8** %10
%94 = bitcast [32 x i8*]* %12 to i8***
%95 = call i64 @execvp(i8* %93, i8*** %94)
%96 = icmp slt i64 %95, 0
br i1 %96, label %97, label %100
97: ; preds = %92
%98 = call i32 @perror(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i64 0, i64 0))
%99 = call i32 @exit(i32 1)
unreachable
100: ; preds = %92
%101 = call i32 @exit(i32 0)
unreachable
102: ; preds = %88
br label %103
103: ; preds = %102
%104 = call i32 @gettimeofday(%struct.timeval* %9, i32* null)
%105 = getelementptr inbounds %struct.timeval, %struct.timeval* %9, i32 0, i32 0
%106 = load i32, i32* %105
%107 = mul nsw i32 %106, 1000
%108 = getelementptr inbounds %struct.timeval, %struct.timeval* %9, i32 0, i32 1
%109 = load i32, i32* %108
%110 = sdiv i32 %109, 1000
%111 = add nsw i32 %107, %110
%112 = getelementptr inbounds %struct.timeval, %struct.timeval* %8, i32 0, i32 0
%113 = load i32, i32* %112
%114 = mul nsw i32 %113, 1000
%115 = getelementptr inbounds %struct.timeval, %struct.timeval* %8, i32 0, i32 1
%116 = load i32, i32* %115
%117 = sdiv i32 %116, 1000
%118 = add nsw i32 %114, %117
%119 = sub nsw i32 %111, %118
%120 = sitofp i32 %119 to float
%121 = fpext float %120 to double
%122 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.7, i64 0, i64 0), double %121)
%123 = getelementptr inbounds %struct.rusage, %struct.rusage* %7, i32 0, i32 5
%124 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %123, i32 0, i32 0
%125 = load i32, i32* %124
%126 = mul nsw i32 %125, 1000
%127 = getelementptr inbounds %struct.rusage, %struct.rusage* %7, i32 0, i32 5
%128 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %127, i32 0, i32 1
%129 = load i32, i32* %128
%130 = sdiv i32 %129, 1000
%131 = add nsw i32 %126, %130
%132 = sitofp i32 %131 to x86_fp80
%133 = load x86_fp80, x86_fp80* %14
%134 = fsub x86_fp80 %132, %133
%135 = getelementptr inbounds %struct.rusage, %struct.rusage* %7, i32 0, i32 4
%136 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %135, i32 0, i32 0
%137 = load i32, i32* %136
%138 = mul nsw i32 %137, 1000
%139 = getelementptr inbounds %struct.rusage, %struct.rusage* %7, i32 0, i32 4
%140 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %139, i32 0, i32 1
%141 = load i32, i32* %140
%142 = sdiv i32 %141, 1000
%143 = add nsw i32 %138, %142
%144 = sitofp i32 %143 to x86_fp80
%145 = load x86_fp80, x86_fp80* %13
%146 = fsub x86_fp80 %144, %145
%147 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.8, i64 0, i64 0), x86_fp80 %134, x86_fp80 %146)
%148 = getelementptr inbounds %struct.rusage, %struct.rusage* %7, i32 0, i32 0
%149 = load i32, i32* %148
%150 = load i32, i32* %15
%151 = sub nsw i32 %149, %150
%152 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.9, i64 0, i64 0), i32 %151)
%153 = getelementptr inbounds %struct.rusage, %struct.rusage* %7, i32 0, i32 1
%154 = load i32, i32* %153
%155 = load i32, i32* %16
%156 = sub nsw i32 %154, %155
%157 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.10, i64 0, i64 0), i32 %156)
%158 = getelementptr inbounds %struct.rusage, %struct.rusage* %7, i32 0, i32 2
%159 = load i32, i32* %158
%160 = getelementptr inbounds %struct.rusage, %struct.rusage* %7, i32 0, i32 3
%161 = load i32, i32* %160
%162 = add nsw i32 %159, %161
%163 = load i32, i32* %18
%164 = load i32, i32* %17
%165 = add nsw i32 %163, %164
%166 = sub nsw i32 %162, %165
%167 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.11, i64 0, i64 0), i32 %166)
%168 = getelementptr inbounds %struct.rusage, %struct.rusage* %7, i32 0, i32 3
%169 = load i32, i32* %168
%170 = load i32, i32* %17
%171 = sub nsw i32 %169, %170
%172 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.12, i64 0, i64 0), i32 %171)
%173 = getelementptr inbounds %struct.rusage, %struct.rusage* %7, i32 0, i32 5
%174 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %173, i32 0, i32 0
%175 = load i32, i32* %174
%176 = mul nsw i32 %175, 1000
%177 = getelementptr inbounds %struct.rusage, %struct.rusage* %7, i32 0, i32 5
%178 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %177, i32 0, i32 1
%179 = load i32, i32* %178
%180 = sdiv i32 %179, 1000
%181 = add nsw i32 %176, %180
%182 = sitofp i32 %181 to x86_fp80
store x86_fp80 %182, x86_fp80* %13
%183 = getelementptr inbounds %struct.rusage, %struct.rusage* %7, i32 0, i32 4
%184 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %183, i32 0, i32 0
%185 = load i32, i32* %184
%186 = mul nsw i32 %185, 1000
%187 = getelementptr inbounds %struct.rusage, %struct.rusage* %7, i32 0, i32 4
%188 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %187, i32 0, i32 1
%189 = load i32, i32* %188
%190 = sdiv i32 %189, 1000
%191 = add nsw i32 %186, %190
%192 = sitofp i32 %191 to x86_fp80
store x86_fp80 %192, x86_fp80* %14
%193 = getelementptr inbounds %struct.rusage, %struct.rusage* %7, i32 0, i32 0
%194 = load i32, i32* %193
store i32 %194, i32* %15
%195 = getelementptr inbounds %struct.rusage, %struct.rusage* %7, i32 0, i32 1
%196 = load i32, i32* %195
store i32 %196, i32* %16
%197 = getelementptr inbounds %struct.rusage, %struct.rusage* %7, i32 0, i32 3
%198 = load i32, i32* %197
store i32 %198, i32* %17
%199 = getelementptr inbounds %struct.rusage, %struct.rusage* %7, i32 0, i32 2
%200 = load i32, i32* %199
store i32 %200, i32* %18
br label %201
201: ; preds = %103
br label %202
202: ; preds = %201, %72
br label %22
203: ; preds = %77
store i32 0, i32* %3
br label %204
204: ; preds = %203, %83
%205 = load i32, i32* %3
ret i32 %205
}

LLVM IR (-O2):
%struct.rusage = type { i32, i32, i32, i32, %struct.TYPE_4__, %struct.TYPE_3__ }
%struct.TYPE_4__ = type { i32, i32 }
%struct.TYPE_3__ = type { i32, i32 }
%struct.timeval = type { i32, i32 }
@.str = [4 x i8] c"==>\00"
@stdin = global i32 0
@.str.1 = [5 x i8] c" \09\0D\0A\00"
@errno = global i64 0
@.str.2 = [3 x i8] c"cd\00"
@stderr = global i32 0
@.str.3 = [27 x i8] c"directory does not exist.\0A\00"
@.str.4 = [5 x i8] c"exit\00"
@.str.5 = [14 x i8] c"Error forking\00"
@RUSAGE_CHILDREN = global i32 0
@.str.6 = [26 x i8] c"error in execvp somewhere\00"
@.str.7 = [54 x i8] c"\0AWall clock time in milliseconds: %0.3f milliseconds\0A\00"
@.str.8 = [58 x i8] c"CPU time: %ld milliseconds user, %ld milliseconds system\0A\00"
@.str.9 = [59 x i8] c"Number of times process was pre-empted involuntarily: %d \0A\00"
@.str.10 = [54 x i8] c"Number of times process voluntarily gave up CPU: %d \0A\00"
@.str.11 = [34 x i8] c"Total number of page faults: %d \0A\00"
@.str.12 = [59 x i8] c"Number of page faults able to be satisfied by kernel: %d \0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca %struct.rusage
%4 = alloca %struct.timeval
%5 = alloca %struct.timeval
%6 = alloca [128 x i8]
%7 = alloca [32 x i8*]
%8 = bitcast %struct.rusage* %3 to i8*
%9 = bitcast %struct.timeval* %4 to i8*
%10 = bitcast %struct.timeval* %5 to i8*
%11 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%12 = bitcast [32 x i8*]* %7 to i8*
%13 = getelementptr inbounds [32 x i8*], [32 x i8*]* %7, i64 0, i64 0
%14 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i64 0, i32 0
%15 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i64 0, i32 1
%16 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i64 0, i32 0
%17 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i64 0, i32 1
%18 = getelementptr inbounds %struct.rusage, %struct.rusage* %3, i64 0, i32 5, i32 0
%19 = getelementptr inbounds %struct.rusage, %struct.rusage* %3, i64 0, i32 5, i32 1
%20 = getelementptr inbounds %struct.rusage, %struct.rusage* %3, i64 0, i32 4, i32 0
%21 = getelementptr inbounds %struct.rusage, %struct.rusage* %3, i64 0, i32 4, i32 1
%22 = getelementptr inbounds %struct.rusage, %struct.rusage* %3, i64 0, i32 0
%23 = getelementptr inbounds %struct.rusage, %struct.rusage* %3, i64 0, i32 1
%24 = getelementptr inbounds %struct.rusage, %struct.rusage* %3, i64 0, i32 2
%25 = getelementptr inbounds %struct.rusage, %struct.rusage* %3, i64 0, i32 3
%26 = getelementptr inbounds [32 x i8*], [32 x i8*]* %7, i64 0, i64 1
br label %27
27: ; preds = %78, %2
%28 = phi x86_fp80 [ %137, %78 ], [ 0xK00000000000000000000, %2 ]
%29 = phi i32 [ %138, %78 ], [ 0, %2 ]
%30 = phi i32 [ %139, %78 ], [ 0, %2 ]
%31 = phi i32 [ %140, %78 ], [ 0, %2 ]
%32 = phi i32 [ %141, %78 ], [ 0, %2 ]
%33 = phi x86_fp80 [ %131, %78 ], [ 0xK00000000000000000000, %2 ]
br label %34
34: ; preds = %64, %27
br label %35
35: ; preds = %34, %35
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%37 = load i32, i32* @stdin
%38 = call i32 @fgets(i8* %11, i32 128, i32 %37)
%39 = call i8* @strtok(i8* %11, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
store i8* %39, i8** %13
%40 = icmp eq i8* %39, null
br i1 %40, label %35, label %41
41: ; preds = %35, %49
%42 = phi i64 [ %51, %49 ], [ 1, %35 ]
%43 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%44 = icmp eq i8* %43, null
br i1 %44, label %45, label %49
45: ; preds = %41
%46 = and i64 %42, 4294967295
%47 = getelementptr inbounds [32 x i8*], [32 x i8*]* %7, i64 0, i64 %46
store i8* null, i8** %47
%48 = load i8*, i8** %13
br label %53
49: ; preds = %41
%50 = getelementptr inbounds [32 x i8*], [32 x i8*]* %7, i64 0, i64 %42
store i8* %43, i8** %50
%51 = add nuw nsw i64 %42, 1
%52 = icmp eq i64 %51, 32
br i1 %52, label %53, label %41
53: ; preds = %49, %45
%54 = phi i8* [ %48, %45 ], [ %39, %49 ]
store i64 0, i64* @errno
%55 = call i64 @strcmp(i8* %54, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%56 = icmp eq i64 %55, 0
br i1 %56, label %57, label %67
57: ; preds = %53
%58 = load i8*, i8** %26
%59 = call i64 @chdir(i8* %58)
%60 = icmp eq i64 %59, 0
br i1 %60, label %65, label %61
61: ; preds = %57
%62 = load i32, i32* @stderr
%63 = call i32 @fprintf(i32 %62, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0))
br label %64
64: ; preds = %61, %65
br label %34
65: ; preds = %57
%66 = call i64 @chdir(i8* %58)
br label %64
67: ; preds = %53
%68 = call i64 @strcmp(i8* %39, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%69 = icmp eq i64 %68, 0
br i1 %69, label %151, label %70
70: ; preds = %67
%71 = call i32 @gettimeofday(%struct.timeval* %4, i32* null)
%72 = call i32 (...) @fork()
%73 = icmp eq i32 %72, -1
br i1 %73, label %74, label %76
74: ; preds = %70
%75 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0))
br label %151
76: ; preds = %70
%77 = icmp sgt i32 %72, 0
br i1 %77, label %78, label %142
78: ; preds = %76
%79 = call i32 @wait(i32 0)
%80 = load i32, i32* @RUSAGE_CHILDREN
%81 = call i32 @getrusage(i32 %80, %struct.rusage* %3)
%82 = call i32 @gettimeofday(%struct.timeval* %5, i32* null)
%83 = load i32, i32* %14
%84 = load i32, i32* %15
%85 = sdiv i32 %84, 1000
%86 = load i32, i32* %16
%87 = load i32, i32* %17
%88 = sdiv i32 %87, -1000
%89 = sub i32 %83, %86
%90 = mul i32 %89, 1000
%91 = add nsw i32 %88, %85
%92 = add i32 %91, %90
%93 = sitofp i32 %92 to float
%94 = fpext float %93 to double
%95 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @.str.7, i64 0, i64 0), double %94)
%96 = load i32, i32* %18
%97 = mul nsw i32 %96, 1000
%98 = load i32, i32* %19
%99 = sdiv i32 %98, 1000
%100 = add nsw i32 %99, %97
%101 = sitofp i32 %100 to x86_fp80
%102 = fsub x86_fp80 %101, %28
%103 = load i32, i32* %20
%104 = mul nsw i32 %103, 1000
%105 = load i32, i32* %21
%106 = sdiv i32 %105, 1000
%107 = add nsw i32 %106, %104
%108 = sitofp i32 %107 to x86_fp80
%109 = fsub x86_fp80 %108, %33
%110 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([58 x i8], [58 x i8]* @.str.8, i64 0, i64 0), x86_fp80 %102, x86_fp80 %109)
%111 = load i32, i32* %22
%112 = sub nsw i32 %111, %29
%113 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([59 x i8], [59 x i8]* @.str.9, i64 0, i64 0), i32 %112)
%114 = load i32, i32* %23
%115 = sub nsw i32 %114, %30
%116 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @.str.10, i64 0, i64 0), i32 %115)
%117 = load i32, i32* %24
%118 = load i32, i32* %25
%119 = add i32 %32, %31
%120 = sub i32 %117, %119
%121 = add i32 %120, %118
%122 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.11, i64 0, i64 0), i32 %121)
%123 = load i32, i32* %25
%124 = sub nsw i32 %123, %31
%125 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([59 x i8], [59 x i8]* @.str.12, i64 0, i64 0), i32 %124)
%126 = load i32, i32* %18
%127 = mul nsw i32 %126, 1000
%128 = load i32, i32* %19
%129 = sdiv i32 %128, 1000
%130 = add nsw i32 %129, %127
%131 = sitofp i32 %130 to x86_fp80
%132 = load i32, i32* %20
%133 = mul nsw i32 %132, 1000
%134 = load i32, i32* %21
%135 = sdiv i32 %134, 1000
%136 = add nsw i32 %135, %133
%137 = sitofp i32 %136 to x86_fp80
%138 = load i32, i32* %22
%139 = load i32, i32* %23
%140 = load i32, i32* %25
%141 = load i32, i32* %24
br label %27
142: ; preds = %76
%143 = bitcast [32 x i8*]* %7 to i8***
%144 = call i64 @execvp(i8* %39, i8*** %143)
%145 = icmp slt i64 %144, 0
br i1 %145, label %146, label %149
146: ; preds = %142
%147 = call i32 @perror(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i64 0, i64 0))
%148 = call i32 @exit(i32 1)
unreachable
149: ; preds = %142
%150 = call i32 @exit(i32 0)
unreachable
151: ; preds = %67, %74
%152 = phi i32 [ -1, %74 ], [ 0, %67 ]
ret i32 %152
}