#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 int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ F_OK;
int access(char *, int /*<<< orphan*/);
int /*<<< orphan*/ changeDirectory(char **);
scalar_t__ executeCommand(char **);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ perror(char *);
scalar_t__ strcmp(char *, char *);
char **tokenize(char *);
void runFile(char **tokens) {
  if (access(tokens[1], F_OK) == -1) {
    perror("Error");
    return;
  }
  char buf[1000];
  char **listOfTokens;
  FILE *fp;
  fp = fopen(tokens[1], "rw");
  while (fgets(buf, 1000, fp) != NULL) {
    listOfTokens = tokenize(buf);
    if (strcmp(listOfTokens[0], "cd") == 0) {
      changeDirectory(listOfTokens);
    } else if (strcmp(listOfTokens[0], "run") == 0)
      runFile(listOfTokens);
    else if (executeCommand(listOfTokens) == 0)
      break;
  }
}


x86 assembly (clang, -O0):
<runFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x400,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2e2a(%rip),%rax
mov    (%rax),%esi
call   1080 <access@plt>
cmp    $0xffffffff,%eax
jne    11cf <runFile+0x3f>
lea    0xe3b(%rip),%rdi
call   10a0 <perror@plt>
jmp    12ab <runFile+0x11b>
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe28(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x400(%rbp)
lea    -0x3f0(%rbp),%rdi
mov    -0x400(%rbp),%rdx
mov    $0x3e8,%esi
call   1040 <fgets@plt>
cmp    $0x0,%rax
je     12ab <runFile+0x11b>
lea    -0x3f0(%rbp),%rdi
call   1060 <tokenize@plt>
mov    %rax,-0x3f8(%rbp)
mov    -0x3f8(%rbp),%rax
mov    (%rax),%rdi
lea    0xdd9(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    1250 <runFile+0xc0>
mov    -0x3f8(%rbp),%rdi
call   1070 <changeDirectory@plt>
jmp    12a6 <runFile+0x116>
mov    -0x3f8(%rbp),%rax
mov    (%rax),%rdi
lea    0xdab(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    1281 <runFile+0xf1>
mov    -0x3f8(%rbp),%rdi
call   10b0 <runFile@plt>
jmp    12a1 <runFile+0x111>
mov    -0x3f8(%rbp),%rdi
call   1030 <executeCommand@plt>
cmp    $0x0,%rax
jne    129c <runFile+0x10c>
jmp    12ab <runFile+0x11b>
jmp    12a1 <runFile+0x111>
jmp    12a6 <runFile+0x116>
jmp    11ea <runFile+0x5a>
add    $0x400,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<runFile>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x3f0,%rsp
mov    %rdi,%rbx
mov    0x8(%rdi),%rdi
mov    0x2e2a(%rip),%rax
mov    (%rax),%esi
call   1080 <access@plt>
cmp    $0xffffffff,%eax
je     1278 <runFile+0xe8>
mov    0x8(%rbx),%rdi
lea    0xe3d(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,%r14
mov    %rsp,%rdi
mov    $0x3e8,%esi
mov    %rax,%rdx
call   1040 <fgets@plt>
test   %rax,%rax
je     1267 <runFile+0xd7>
mov    %rsp,%r13
lea    0xe15(%rip),%r15
lea    0xe11(%rip),%r12
jmp    121d <runFile+0x8d>
nopl   (%rax)
mov    %rbx,%rdi
call   1070 <changeDirectory@plt>
mov    %r13,%rdi
mov    $0x3e8,%esi
mov    %r14,%rdx
call   1040 <fgets@plt>
test   %rax,%rax
je     1267 <runFile+0xd7>
mov    %r13,%rdi
call   1060 <tokenize@plt>
mov    %rax,%rbx
mov    (%rax),%rdi
mov    %r15,%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     1200 <runFile+0x70>
mov    (%rbx),%rdi
mov    %r12,%rsi
call   1050 <strcmp@plt>
mov    %rbx,%rdi
test   %rax,%rax
je     1260 <runFile+0xd0>
call   1030 <executeCommand@plt>
test   %rax,%rax
jne    1208 <runFile+0x78>
jmp    1267 <runFile+0xd7>
nopw   0x0(%rax,%rax,1)
call   10b0 <runFile@plt>
jmp    1208 <runFile+0x78>
add    $0x3f0,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
lea    0xd81(%rip),%rdi
add    $0x3f0,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    10a0 <perror@plt>

LLVM IR (-O0):
@F_OK = global i32 0
@.str = [6 x i8] c"Error\00"
@.str.1 = [3 x i8] c"rw\00"
@.str.2 = [3 x i8] c"cd\00"
@.str.3 = [4 x i8] c"run\00"
define void @runFile(i8** %0) {
%2 = alloca i8**
%3 = alloca [1000 x i8]
%4 = alloca i8**
%5 = alloca i32*
store i8** %0, i8*** %2
%6 = load i8**, i8*** %2
%7 = getelementptr inbounds i8*, i8** %6, i64 1
%8 = load i8*, i8** %7
%9 = load i32, i32* @F_OK
%10 = call i32 @access(i8* %8, i32 %9)
%11 = icmp eq i32 %10, -1
br i1 %11, label %12, label %14
12: ; preds = %1
%13 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
br label %51
14: ; preds = %1
%15 = load i8**, i8*** %2
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = call i32* @fopen(i8* %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %18, i32** %5
br label %19
19: ; preds = %50, %14
%20 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%21 = load i32*, i32** %5
%22 = call i32* @fgets(i8* %20, i32 1000, i32* %21)
%23 = icmp ne i32* %22, null
br i1 %23, label %24, label %51
24: ; preds = %19
%25 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%26 = call i8** @tokenize(i8* %25)
store i8** %26, i8*** %4
%27 = load i8**, i8*** %4
%28 = getelementptr inbounds i8*, i8** %27, i64 0
%29 = load i8*, i8** %28
%30 = call i64 @strcmp(i8* %29, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%31 = icmp eq i64 %30, 0
br i1 %31, label %32, label %35
32: ; preds = %24
%33 = load i8**, i8*** %4
%34 = call i32 @changeDirectory(i8** %33)
br label %50
35: ; preds = %24
%36 = load i8**, i8*** %4
%37 = getelementptr inbounds i8*, i8** %36, i64 0
%38 = load i8*, i8** %37
%39 = call i64 @strcmp(i8* %38, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%40 = icmp eq i64 %39, 0
br i1 %40, label %41, label %43
41: ; preds = %35
%42 = load i8**, i8*** %4
br label %49
43: ; preds = %35
%44 = load i8**, i8*** %4
%45 = call i64 @executeCommand(i8** %44)
%46 = icmp eq i64 %45, 0
br i1 %46, label %47, label %48
47: ; preds = %43
br label %51
48: ; preds = %43
br label %49
49: ; preds = %48, %41
br label %50
50: ; preds = %49, %32
br label %19
51: ; preds = %12, %47, %19
ret void
}

LLVM IR (-O2):
@F_OK = global i32 0
@.str = [6 x i8] c"Error\00"
@.str.1 = [3 x i8] c"rw\00"
@.str.2 = [3 x i8] c"cd\00"
@.str.3 = [4 x i8] c"run\00"
define void @runFile(i8** nocapture %0) {
%2 = alloca [1000 x i8]
%3 = getelementptr inbounds i8*, i8** %0, i64 1
%4 = load i8*, i8** %3
%5 = load i32, i32* @F_OK
%6 = tail call i32 @access(i8* %4, i32 %5)
%7 = icmp eq i32 %6, -1
br i1 %7, label %8, label %10
8: ; preds = %1
%9 = tail call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
br label %35
10: ; preds = %1
%11 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 0
%12 = load i8*, i8** %3
%13 = tail call i32* @fopen(i8* %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%14 = call i32* @fgets(i8* %11, i32 1000, i32* %13)
%15 = icmp eq i32* %14, null
br i1 %15, label %34, label %16
16: ; preds = %10, %31
%17 = call i8** @tokenize(i8* %11)
%18 = load i8*, i8** %17
%19 = call i64 @strcmp(i8* %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %16
%22 = call i32 @changeDirectory(i8** %17)
br label %31
23: ; preds = %16
%24 = load i8*, i8** %17
%25 = call i64 @strcmp(i8* %24, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %28
27: ; preds = %23
br label %31
28: ; preds = %23
%29 = call i64 @executeCommand(i8** %17)
%30 = icmp eq i64 %29, 0
br i1 %30, label %34, label %31
31: ; preds = %27, %28, %21
%32 = call i32* @fgets(i8* %11, i32 1000, i32* %13)
%33 = icmp eq i32* %32, null
br i1 %33, label %34, label %16
34: ; preds = %31, %28, %10
br label %35
35: ; preds = %34, %8
ret void
}