#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 */

/* Variables and functions */
scalar_t__ strcmp(char *, char *);
int assessment(char **array) {
  int i = 0;
  if (array[0] == NULL) {
    return 5;
  } else if (strcmp(array[0], "#") == 0) {
    return 5;
  } else if (strcmp(array[0], "exit") == 0) {
    return 0;
  } else if (strcmp(array[0], "cd") == 0) {
    return 1;
  } else if (strcmp(array[0], "status") == 0) {
    return 2;
  } else {
    while (array[i] != NULL) {
      if (strcmp(array[i], "&") == 0) {
        array[i] = NULL;
        return 4;
      }
      i++;
    }
    return 3;
  }
}


x86 assembly (clang, -O0):
<assessment>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
jne    113d <assessment+0x2d>
movl   $0x5,-0x4(%rbp)
jmp    124c <assessment+0x13c>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xeb5(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1166 <assessment+0x56>
movl   $0x5,-0x4(%rbp)
jmp    124c <assessment+0x13c>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xe8e(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    118f <assessment+0x7f>
movl   $0x0,-0x4(%rbp)
jmp    124c <assessment+0x13c>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xe6a(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    11b8 <assessment+0xa8>
movl   $0x1,-0x4(%rbp)
jmp    124c <assessment+0x13c>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xe44(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    11e1 <assessment+0xd1>
movl   $0x2,-0x4(%rbp)
jmp    124c <assessment+0x13c>
jmp    11e6 <assessment+0xd6>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     1245 <assessment+0x135>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe05(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1237 <assessment+0x127>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movq   $0x0,(%rax,%rcx,8)
movl   $0x4,-0x4(%rbp)
jmp    124c <assessment+0x13c>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11e6 <assessment+0xd6>
movl   $0x3,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<assessment>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    (%rdi),%rdi
mov    $0x5,%r15d
test   %rdi,%rdi
je     11e2 <assessment+0xd2>
lea    0xecd(%rip),%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11e2 <assessment+0xd2>
mov    (%rbx),%rdi
lea    0xeb7(%rip),%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11bd <assessment+0xad>
mov    (%rbx),%rdi
lea    0xea8(%rip),%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11c2 <assessment+0xb2>
mov    (%rbx),%rdi
lea    0xe97(%rip),%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11ca <assessment+0xba>
mov    (%rbx),%rdi
mov    $0x3,%r15d
test   %rdi,%rdi
je     11e2 <assessment+0xd2>
xor    %ebp,%ebp
lea    0xe7d(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r14,%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11d2 <assessment+0xc2>
mov    0x8(%rbx,%rbp,8),%rdi
add    $0x1,%rbp
test   %rdi,%rdi
jne    11a0 <assessment+0x90>
jmp    11e2 <assessment+0xd2>
xor    %r15d,%r15d
jmp    11e2 <assessment+0xd2>
mov    $0x1,%r15d
jmp    11e2 <assessment+0xd2>
mov    $0x2,%r15d
jmp    11e2 <assessment+0xd2>
mov    %ebp,%eax
movq   $0x0,(%rbx,%rax,8)
mov    $0x4,%r15d
mov    %r15d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"#\00"
@.str.1 = [5 x i8] c"exit\00"
@.str.2 = [3 x i8] c"cd\00"
@.str.3 = [7 x i8] c"status\00"
@.str.4 = [2 x i8] c"&\00"
define i32 @assessment(i8** %0) {
%2 = alloca i32
%3 = alloca i8**
%4 = alloca i32
store i8** %0, i8*** %3
store i32 0, i32* %4
%5 = load i8**, i8*** %3
%6 = getelementptr inbounds i8*, i8** %5, i64 0
%7 = load i8*, i8** %6
%8 = icmp eq i8* %7, null
br i1 %8, label %9, label %10
9: ; preds = %1
store i32 5, i32* %2
br label %63
10: ; preds = %1
%11 = load i8**, i8*** %3
%12 = getelementptr inbounds i8*, i8** %11, i64 0
%13 = load i8*, i8** %12
%14 = call i64 @strcmp(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %10
store i32 5, i32* %2
br label %63
17: ; preds = %10
%18 = load i8**, i8*** %3
%19 = getelementptr inbounds i8*, i8** %18, i64 0
%20 = load i8*, i8** %19
%21 = call i64 @strcmp(i8* %20, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %24
23: ; preds = %17
store i32 0, i32* %2
br label %63
24: ; preds = %17
%25 = load i8**, i8*** %3
%26 = getelementptr inbounds i8*, i8** %25, i64 0
%27 = load i8*, i8** %26
%28 = call i64 @strcmp(i8* %27, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%29 = icmp eq i64 %28, 0
br i1 %29, label %30, label %31
30: ; preds = %24
store i32 1, i32* %2
br label %63
31: ; preds = %24
%32 = load i8**, i8*** %3
%33 = getelementptr inbounds i8*, i8** %32, i64 0
%34 = load i8*, i8** %33
%35 = call i64 @strcmp(i8* %34, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%36 = icmp eq i64 %35, 0
br i1 %36, label %37, label %38
37: ; preds = %31
store i32 2, i32* %2
br label %63
38: ; preds = %31
br label %39
39: ; preds = %59, %38
%40 = load i8**, i8*** %3
%41 = load i32, i32* %4
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i8*, i8** %40, i64 %42
%44 = load i8*, i8** %43
%45 = icmp ne i8* %44, null
br i1 %45, label %46, label %62
46: ; preds = %39
%47 = load i8**, i8*** %3
%48 = load i32, i32* %4
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds i8*, i8** %47, i64 %49
%51 = load i8*, i8** %50
%52 = call i64 @strcmp(i8* %51, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%53 = icmp eq i64 %52, 0
br i1 %53, label %54, label %59
54: ; preds = %46
%55 = load i8**, i8*** %3
%56 = load i32, i32* %4
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds i8*, i8** %55, i64 %57
store i8* null, i8** %58
store i32 4, i32* %2
br label %63
59: ; preds = %46
%60 = load i32, i32* %4
%61 = add nsw i32 %60, 1
store i32 %61, i32* %4
br label %39
62: ; preds = %39
store i32 3, i32* %2
br label %63
63: ; preds = %62, %54, %37, %30, %23, %16, %9
%64 = load i32, i32* %2
ret i32 %64
}

LLVM IR (-O2):
@.str = [2 x i8] c"#\00"
@.str.1 = [5 x i8] c"exit\00"
@.str.2 = [3 x i8] c"cd\00"
@.str.3 = [7 x i8] c"status\00"
@.str.4 = [2 x i8] c"&\00"
define i32 @assessment(i8** nocapture %0) {
%2 = load i8*, i8** %0
%3 = icmp eq i8* %2, null
br i1 %3, label %35, label %4
4: ; preds = %1
%5 = tail call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i64 %5, 0
br i1 %6, label %35, label %7
7: ; preds = %4
%8 = load i8*, i8** %0
%9 = tail call i64 @strcmp(i8* %8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
br i1 %10, label %35, label %11
11: ; preds = %7
%12 = load i8*, i8** %0
%13 = tail call i64 @strcmp(i8* %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%14 = icmp eq i64 %13, 0
br i1 %14, label %35, label %15
15: ; preds = %11
%16 = load i8*, i8** %0
%17 = tail call i64 @strcmp(i8* %16, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %35, label %19
19: ; preds = %15
%20 = load i8*, i8** %0
%21 = icmp eq i8* %20, null
br i1 %21, label %35, label %22
22: ; preds = %19, %30
%23 = phi i64 [ %31, %30 ], [ 0, %19 ]
%24 = phi i8* [ %33, %30 ], [ %20, %19 ]
%25 = tail call i64 @strcmp(i8* %24, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %30
27: ; preds = %22
%28 = and i64 %23, 4294967295
%29 = getelementptr inbounds i8*, i8** %0, i64 %28
store i8* null, i8** %29
br label %35
30: ; preds = %22
%31 = add nuw i64 %23, 1
%32 = getelementptr inbounds i8*, i8** %0, i64 %31
%33 = load i8*, i8** %32
%34 = icmp eq i8* %33, null
br i1 %34, label %35, label %22
35: ; preds = %30, %19, %15, %11, %7, %4, %1, %27
%36 = phi i32 [ 4, %27 ], [ 5, %1 ], [ 5, %4 ], [ 0, %7 ], [ 1, %11 ], [ 2, %15 ], [ 3, %19 ], [ 3, %30 ]
ret i32 %36
}