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

/* Variables and functions */
int /*<<< orphan*/ SIGINT;
int /*<<< orphan*/ SIG_IGN;
int /*<<< orphan*/ chdir(char *);
int /*<<< orphan*/ execve(char *, char **, char **);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fork();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, ...);
int /*<<< orphan*/ free(char *);
char *getcwd(int /*<<< orphan*/ *, int);
char *getenv(char *);
char *malloc(int);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ read(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ signal(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcat(char *, char const *);
int /*<<< orphan*/ strcmp(char *, char *);
int strlen(char const *);
int /*<<< orphan*/ wait(int *);
int main(int argc, char **argv) {
  signal(SIGINT, SIG_IGN);
  char buf[100];
  chdir("/");
  while (1) {
    fprintf(stderr, "[ %s : %s ] # ", getenv("USER"), getcwd(NULL, 50));
    memset(buf, 0, 100);
    read(0, buf, 100);
    char *tokens[20], *p = buf;
    int i = 0;
    tokens[0] = p;
    if (*p == '\n')
      continue;
    while (*p != '\n' && i < 20) {
      if (*p == ' ') {
        *p = '\0';
        ++p;
        if (*p == '\"') {
          *p = '\0';
          tokens[++i] = ++p;
          --p;
          while (*++p && *p != '\"')
            ;
          *p = '\0';
          ++p;
          continue;
        }
        if (*p != '\n')
          tokens[++i] = p;
      } else
        ++p;
    }
    tokens[++i] = NULL;
    if (*p == '\n') {
      *p = '\0';
      *++p = '\0';
    }
    if (!strcmp(tokens[0], "cd")) {
      if (tokens[1][0] == '/') {
        chdir(tokens[1]);
      } else {
        char *cwd = getcwd(NULL, 50);
        char *path = malloc(strlen(cwd) + strlen(tokens[1]) + 1);
        strcat(path, cwd);
        strcat(path + strlen(cwd), tokens[1]);
        free(cwd);
        chdir(path);
        free(path);
      }
      continue;
    }
    const char *bin = "/bin/";
    if (!fork()) {
      char _pname[strlen(bin) + strlen(tokens[0]) + 1];
      memset(_pname, 0, sizeof(_pname));
      strcat(_pname, bin);
      strcat(_pname + strlen(bin), tokens[0]);
      char *pname = _pname;
      extern char **environ;
      execve(pname, &tokens[1], environ);
      fprintf(stderr, "%s : command not found\n", tokens[0]);
      exit(0);
      for (;;)
        ;
    }
    int stat;
    wait(&stat);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1a0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2dc8(%rip),%rax
mov    (%rax),%edi
mov    0x2db7(%rip),%rax
mov    (%rax),%esi
call   10c0 <signal@plt>
lea    0xde4(%rip),%rdi
call   1060 <chdir@plt>
mov    0x2d85(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x174(%rbp)
lea    0xdbd(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x170(%rbp)
xor    %eax,%eax
mov    %eax,%edi
mov    $0x32,%esi
call   1080 <getcwd@plt>
mov    -0x174(%rbp),%edi
mov    -0x170(%rbp),%rdx
mov    %rax,%rcx
lea    0xd7d(%rip),%rsi
mov    $0x0,%al
call   10d0 <fprintf@plt>
lea    -0x80(%rbp),%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   1070 <memset@plt>
lea    -0x80(%rbp),%rsi
xor    %edi,%edi
mov    $0x64,%edx
call   1090 <read@plt>
lea    -0x80(%rbp),%rax
mov    %rax,-0x128(%rbp)
movl   $0x0,-0x12c(%rbp)
mov    -0x128(%rbp),%rax
mov    %rax,-0x120(%rbp)
mov    -0x128(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
jne    12e5 <main+0xe5>
jmp    123c <main+0x3c>
jmp    12ea <main+0xea>
mov    -0x128(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0xa,%ecx
mov    %al,-0x175(%rbp)
je     1315 <main+0x115>
cmpl   $0x14,-0x12c(%rbp)
setl   %al
mov    %al,-0x175(%rbp)
mov    -0x175(%rbp),%al
test   $0x1,%al
jne    1328 <main+0x128>
jmp    1479 <main+0x279>
mov    -0x128(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
jne    1462 <main+0x262>
mov    -0x128(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x128(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x128(%rbp)
mov    -0x128(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x22,%eax
jne    142a <main+0x22a>
mov    -0x128(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x128(%rbp),%rcx
add    $0x1,%rcx
mov    %rcx,-0x128(%rbp)
mov    -0x12c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x12c(%rbp)
cltq
mov    %rcx,-0x120(%rbp,%rax,8)
ff
mov    -0x128(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x128(%rbp)
mov    -0x128(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x128(%rbp)
movsbl 0x1(%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x176(%rbp)
je     13f1 <main+0x1f1>
mov    -0x128(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x22,%eax
setne  %al
mov    %al,-0x176(%rbp)
mov    -0x176(%rbp),%al
test   $0x1,%al
jne    1404 <main+0x204>
jmp    1409 <main+0x209>
jmp    13b1 <main+0x1b1>
mov    -0x128(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x128(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x128(%rbp)
jmp    12ea <main+0xea>
mov    -0x128(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
je     145d <main+0x25d>
mov    -0x128(%rbp),%rcx
mov    -0x12c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x12c(%rbp)
cltq
mov    %rcx,-0x120(%rbp,%rax,8)
ff
jmp    1474 <main+0x274>
mov    -0x128(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x128(%rbp)
jmp    12ea <main+0xea>
mov    -0x12c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x12c(%rbp)
cltq
movq   $0x0,-0x120(%rbp,%rax,8)
mov    -0x128(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
jne    14cc <main+0x2cc>
mov    -0x128(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x128(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x128(%rbp)
movb   $0x0,0x1(%rax)
mov    -0x120(%rbp),%rdi
lea    0xb3a(%rip),%rsi
call   10b0 <strcmp@plt>
cmp    $0x0,%eax
jne    15c4 <main+0x3c4>
mov    -0x118(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
jne    150c <main+0x30c>
mov    -0x118(%rbp),%rdi
call   1060 <chdir@plt>
jmp    15bf <main+0x3bf>
xor    %eax,%eax
mov    %eax,%edi
mov    $0x32,%esi
call   1080 <getcwd@plt>
mov    %rax,-0x138(%rbp)
mov    -0x138(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x184(%rbp)
mov    -0x118(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x184(%rbp),%edi
add    %eax,%edi
add    $0x1,%edi
call   10e0 <malloc@plt>
mov    %rax,-0x140(%rbp)
mov    -0x140(%rbp),%rdi
mov    -0x138(%rbp),%rsi
call   10f0 <strcat@plt>
mov    -0x140(%rbp),%rax
mov    %rax,-0x180(%rbp)
mov    -0x138(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x180(%rbp),%rdi
cltq
add    %rax,%rdi
mov    -0x118(%rbp),%rsi
call   10f0 <strcat@plt>
mov    -0x138(%rbp),%rdi
call   1040 <free@plt>
mov    -0x140(%rbp),%rdi
call   1060 <chdir@plt>
mov    -0x140(%rbp),%rdi
call   1040 <free@plt>
jmp    123c <main+0x3c>
lea    0xa4c(%rip),%rax
mov    %rax,-0x148(%rbp)
mov    $0x0,%al
call   1120 <fork@plt>
cmp    $0x0,%eax
jne    16d0 <main+0x4d0>
mov    -0x148(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x194(%rbp)
mov    -0x120(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x194(%rbp),%ecx
mov    %eax,%edx
mov    %ecx,%eax
mov    %edx,%ecx
lea    0x1(%rax,%rcx,1),%eax
mov    %rsp,%rcx
mov    %rcx,-0x150(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x190(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x158(%rbp)
mov    %eax,%edx
xor    %esi,%esi
call   1070 <memset@plt>
mov    -0x190(%rbp),%rdi
mov    -0x148(%rbp),%rsi
call   10f0 <strcat@plt>
mov    -0x148(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x190(%rbp),%rdi
cltq
add    %rax,%rdi
mov    -0x120(%rbp),%rsi
call   10f0 <strcat@plt>
mov    -0x190(%rbp),%rax
mov    %rax,-0x160(%rbp)
mov    -0x160(%rbp),%rdi
lea    -0x120(%rbp),%rsi
add    $0x8,%rsi
mov    0x2935(%rip),%rax
mov    (%rax),%rdx
call   10a0 <execve@plt>
mov    0x2916(%rip),%rax
mov    (%rax),%edi
mov    -0x120(%rbp),%rdx
lea    0x95b(%rip),%rsi
mov    $0x0,%al
call   10d0 <fprintf@plt>
xor    %edi,%edi
call   1100 <exit@plt>
lea    -0x164(%rbp),%rdi
call   1110 <wait@plt>
jmp    123c <main+0x3c>

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x118,%rsp
mov    0x2dcd(%rip),%rax
mov    (%rax),%edi
mov    0x2dbc(%rip),%rax
mov    (%rax),%esi
call   10c0 <signal@plt>
lea    0xde9(%rip),%rdi
call   1060 <chdir@plt>
mov    0x2d8a(%rip),%r15
lea    0xdca(%rip),%r12
lea    -0x140(%rbp),%r13
jmp    12d0 <main+0xd0>
xor    %edi,%edi
mov    $0x32,%esi
call   1080 <getcwd@plt>
mov    %rax,%r14
mov    %rax,%rdi
call   1050 <strlen@plt>
mov    %r15,%r12
mov    %eax,%r15d
mov    %rbx,%rdi
call   1050 <strlen@plt>
lea    (%r15,%rax,1),%edi
add    $0x1,%edi
call   10e0 <malloc@plt>
mov    %rax,%r15
mov    %rax,%rdi
mov    %r14,%rsi
call   10f0 <strcat@plt>
mov    %r14,%rdi
call   1050 <strlen@plt>
movslq %eax,%rdi
add    %r15,%rdi
mov    %rbx,%rsi
call   10f0 <strcat@plt>
mov    %r14,%rdi
call   1040 <free@plt>
mov    %r15,%rdi
call   1060 <chdir@plt>
mov    %r15,%rdi
mov    %r12,%r15
lea    0xd4c(%rip),%r12
call   1040 <free@plt>
nopl   0x0(%rax,%rax,1)
mov    (%r15),%r14d
mov    %r12,%rdi
call   1030 <getenv@plt>
mov    %rax,%rbx
xor    %edi,%edi
mov    $0x32,%esi
call   1080 <getcwd@plt>
mov    %r14d,%edi
lea    0xd0c(%rip),%rsi
mov    %rbx,%rdx
mov    %rax,%rcx
xor    %eax,%eax
call   10d0 <fprintf@plt>
mov    %r13,%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   1070 <memset@plt>
xor    %edi,%edi
mov    %r13,%rsi
mov    $0x64,%edx
call   1090 <read@plt>
mov    %r13,-0xd0(%rbp)
mov    -0x140(%rbp),%dl
cmp    $0xa,%dl
je     12d0 <main+0xd0>
xor    %ecx,%ecx
mov    %r13,%rax
cs nopw 0x0(%rax,%rax,1)
cmp    $0x20,%dl
jne    1390 <main+0x190>
movb   $0x0,(%rax)
lea    0x1(%rax),%rdx
mov    0x1(%rax),%bl
cmp    $0xa,%bl
je     13a1 <main+0x1a1>
movslq %ecx,%rsi
cmp    $0x22,%bl
jne    1396 <main+0x196>
movb   $0x0,0x1(%rax)
add    $0x2,%rax
lea    0x1(%rsi),%ecx
mov    %rax,-0xc8(%rbp,%rsi,8)
ff
nop
movzbl (%rax),%edx
add    $0x1,%rax
cmp    $0x22,%dl
je     1380 <main+0x180>
test   %dl,%dl
jne    1370 <main+0x170>
movb   $0x0,-0x1(%rax)
jmp    13a4 <main+0x1a4>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%rax
jmp    13a4 <main+0x1a4>
lea    0x1(%rsi),%ecx
mov    %rdx,-0xc8(%rbp,%rsi,8)
ff
mov    %rdx,%rax
mov    (%rax),%dl
cmp    $0xa,%dl
je     13b0 <main+0x1b0>
cmp    $0x13,%ecx
jle    1340 <main+0x140>
movslq %ecx,%rcx
movq   $0x0,-0xc8(%rbp,%rcx,8)
cmpb   $0xa,(%rax)
jne    13c9 <main+0x1c9>
movw   $0x0,(%rax)
mov    -0xd0(%rbp),%r14
mov    %r14,%rdi
lea    0xc3a(%rip),%rsi
call   10b0 <strcmp@plt>
test   %eax,%eax
je     13fc <main+0x1fc>
xor    %eax,%eax
call   1120 <fork@plt>
test   %eax,%eax
je     1419 <main+0x219>
lea    -0x2c(%rbp),%rdi
call   1110 <wait@plt>
jmp    12d0 <main+0xd0>
mov    -0xc8(%rbp),%rbx
cmpb   $0x2f,(%rbx)
jne    1251 <main+0x51>
mov    %rbx,%rdi
call   1060 <chdir@plt>
jmp    12d0 <main+0xd0>
mov    %r15,%r12
lea    0xbf4(%rip),%r15
mov    %r15,%rdi
call   1050 <strlen@plt>
mov    %eax,%ebx
mov    %r14,%rdi
call   1050 <strlen@plt>
lea    (%rbx,%rax,1),%edx
add    $0x1,%edx
lea    0xf(%rdx),%rax
and    $0xfffffffffffffff0,%rax
mov    %rsp,%rbx
sub    %rax,%rbx
mov    %rbx,%rsp
mov    %rbx,%rdi
xor    %esi,%esi
call   1070 <memset@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   10f0 <strcat@plt>
mov    %r15,%rdi
call   1050 <strlen@plt>
movslq %eax,%rdi
add    %rbx,%rdi
mov    %r14,%rsi
call   10f0 <strcat@plt>
mov    0x2b5a(%rip),%rax
mov    (%rax),%rdx
mov    %rbx,%rdi
lea    -0xc8(%rbp),%rsi
call   10a0 <execve@plt>
mov    (%r12),%edi
mov    -0xd0(%rbp),%rdx
lea    0xb7b(%rip),%rsi
xor    %eax,%eax
call   10d0 <fprintf@plt>
xor    %edi,%edi
call   1100 <exit@plt>

LLVM IR (-O0):
@SIGINT = global i32 0
@SIG_IGN = global i32 0
@.str = [2 x i8] c"/\00"
@stderr = global i32 0
@.str.1 = [15 x i8] c"[ %s : %s ] # \00"
@.str.2 = [5 x i8] c"USER\00"
@.str.3 = [3 x i8] c"cd\00"
@.str.4 = [6 x i8] c"/bin/\00"
@environ = external global i8**
@.str.5 = [24 x i8] c"%s : command not found\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [100 x i8]
%7 = alloca [20 x i8*]
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i64
%15 = alloca i8*
%16 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%17 = load i32, i32* @SIGINT
%18 = load i32, i32* @SIG_IGN
%19 = call i32 @signal(i32 %17, i32 %18)
%20 = call i32 @chdir(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %21
21: ; preds = %2, %37, %162, %197
%22 = load i32, i32* @stderr
%23 = call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%24 = call i8* @getcwd(i32* null, i32 50)
%25 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %22, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %23, i8* %24)
%26 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%27 = call i32 @memset(i8* %26, i32 0, i32 100)
%28 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%29 = call i32 @read(i32 0, i8* %28, i32 100)
%30 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
store i8* %30, i8** %8
store i32 0, i32* %9
%31 = load i8*, i8** %8
%32 = getelementptr inbounds [20 x i8*], [20 x i8*]* %7, i64 0, i64 0
store i8* %31, i8** %32
%33 = load i8*, i8** %8
%34 = load i8, i8* %33
%35 = sext i8 %34 to i32
%36 = icmp eq i32 %35, 10
br i1 %36, label %37, label %38
37: ; preds = %21
br label %21
38: ; preds = %21
br label %39
39: ; preds = %105, %86, %38
%40 = load i8*, i8** %8
%41 = load i8, i8* %40
%42 = sext i8 %41 to i32
%43 = icmp ne i32 %42, 10
br i1 %43, label %44, label %47
44: ; preds = %39
%45 = load i32, i32* %9
%46 = icmp slt i32 %45, 20
br label %47
47: ; preds = %44, %39
%48 = phi i1 [ false, %39 ], [ %46, %44 ]
br i1 %48, label %49, label %106
49: ; preds = %47
%50 = load i8*, i8** %8
%51 = load i8, i8* %50
%52 = sext i8 %51 to i32
%53 = icmp eq i32 %52, 32
br i1 %53, label %54, label %102
54: ; preds = %49
%55 = load i8*, i8** %8
store i8 0, i8* %55
%56 = load i8*, i8** %8
%57 = getelementptr inbounds i8, i8* %56, i32 1
store i8* %57, i8** %8
%58 = load i8*, i8** %8
%59 = load i8, i8* %58
%60 = sext i8 %59 to i32
%61 = icmp eq i32 %60, 34
br i1 %61, label %62, label %90
62: ; preds = %54
%63 = load i8*, i8** %8
store i8 0, i8* %63
%64 = load i8*, i8** %8
%65 = getelementptr inbounds i8, i8* %64, i32 1
store i8* %65, i8** %8
%66 = load i32, i32* %9
%67 = add nsw i32 %66, 1
store i32 %67, i32* %9
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds [20 x i8*], [20 x i8*]* %7, i64 0, i64 %68
store i8* %65, i8** %69
%70 = load i8*, i8** %8
%71 = getelementptr inbounds i8, i8* %70, i32 -1
store i8* %71, i8** %8
br label %72
72: ; preds = %85, %62
%73 = load i8*, i8** %8
%74 = getelementptr inbounds i8, i8* %73, i32 1
store i8* %74, i8** %8
%75 = load i8, i8* %74
%76 = sext i8 %75 to i32
%77 = icmp ne i32 %76, 0
br i1 %77, label %78, label %83
78: ; preds = %72
%79 = load i8*, i8** %8
%80 = load i8, i8* %79
%81 = sext i8 %80 to i32
%82 = icmp ne i32 %81, 34
br label %83
83: ; preds = %78, %72
%84 = phi i1 [ false, %72 ], [ %82, %78 ]
br i1 %84, label %85, label %86
85: ; preds = %83
br label %72
86: ; preds = %83
%87 = load i8*, i8** %8
store i8 0, i8* %87
%88 = load i8*, i8** %8
%89 = getelementptr inbounds i8, i8* %88, i32 1
store i8* %89, i8** %8
br label %39
90: ; preds = %54
%91 = load i8*, i8** %8
%92 = load i8, i8* %91
%93 = sext i8 %92 to i32
%94 = icmp ne i32 %93, 10
br i1 %94, label %95, label %101
95: ; preds = %90
%96 = load i8*, i8** %8
%97 = load i32, i32* %9
%98 = add nsw i32 %97, 1
store i32 %98, i32* %9
%99 = sext i32 %98 to i64
%100 = getelementptr inbounds [20 x i8*], [20 x i8*]* %7, i64 0, i64 %99
store i8* %96, i8** %100
br label %101
101: ; preds = %95, %90
br label %105
102: ; preds = %49
%103 = load i8*, i8** %8
%104 = getelementptr inbounds i8, i8* %103, i32 1
store i8* %104, i8** %8
br label %105
105: ; preds = %102, %101
br label %39
106: ; preds = %47
%107 = load i32, i32* %9
%108 = add nsw i32 %107, 1
store i32 %108, i32* %9
%109 = sext i32 %108 to i64
%110 = getelementptr inbounds [20 x i8*], [20 x i8*]* %7, i64 0, i64 %109
store i8* null, i8** %110
%111 = load i8*, i8** %8
%112 = load i8, i8* %111
%113 = sext i8 %112 to i32
%114 = icmp eq i32 %113, 10
br i1 %114, label %115, label %119
115: ; preds = %106
%116 = load i8*, i8** %8
store i8 0, i8* %116
%117 = load i8*, i8** %8
%118 = getelementptr inbounds i8, i8* %117, i32 1
store i8* %118, i8** %8
store i8 0, i8* %118
br label %119
119: ; preds = %115, %106
%120 = getelementptr inbounds [20 x i8*], [20 x i8*]* %7, i64 0, i64 0
%121 = load i8*, i8** %120
%122 = call i32 @strcmp(i8* %121, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%123 = icmp ne i32 %122, 0
br i1 %123, label %163, label %124
124: ; preds = %119
%125 = getelementptr inbounds [20 x i8*], [20 x i8*]* %7, i64 0, i64 1
%126 = load i8*, i8** %125
%127 = getelementptr inbounds i8, i8* %126, i64 0
%128 = load i8, i8* %127
%129 = sext i8 %128 to i32
%130 = icmp eq i32 %129, 47
br i1 %130, label %131, label %135
131: ; preds = %124
%132 = getelementptr inbounds [20 x i8*], [20 x i8*]* %7, i64 0, i64 1
%133 = load i8*, i8** %132
%134 = call i32 @chdir(i8* %133)
br label %162
135: ; preds = %124
%136 = call i8* @getcwd(i32* null, i32 50)
store i8* %136, i8** %10
%137 = load i8*, i8** %10
%138 = call i32 @strlen(i8* %137)
%139 = getelementptr inbounds [20 x i8*], [20 x i8*]* %7, i64 0, i64 1
%140 = load i8*, i8** %139
%141 = call i32 @strlen(i8* %140)
%142 = add nsw i32 %138, %141
%143 = add nsw i32 %142, 1
%144 = call i8* @malloc(i32 %143)
store i8* %144, i8** %11
%145 = load i8*, i8** %11
%146 = load i8*, i8** %10
%147 = call i32 @strcat(i8* %145, i8* %146)
%148 = load i8*, i8** %11
%149 = load i8*, i8** %10
%150 = call i32 @strlen(i8* %149)
%151 = sext i32 %150 to i64
%152 = getelementptr inbounds i8, i8* %148, i64 %151
%153 = getelementptr inbounds [20 x i8*], [20 x i8*]* %7, i64 0, i64 1
%154 = load i8*, i8** %153
%155 = call i32 @strcat(i8* %152, i8* %154)
%156 = load i8*, i8** %10
%157 = call i32 @free(i8* %156)
%158 = load i8*, i8** %11
%159 = call i32 @chdir(i8* %158)
%160 = load i8*, i8** %11
%161 = call i32 @free(i8* %160)
br label %162
162: ; preds = %135, %131
br label %21
163: ; preds = %119
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8** %12
%164 = call i32 (...) @fork()
%165 = icmp ne i32 %164, 0
br i1 %165, label %197, label %166
166: ; preds = %163
%167 = load i8*, i8** %12
%168 = call i32 @strlen(i8* %167)
%169 = getelementptr inbounds [20 x i8*], [20 x i8*]* %7, i64 0, i64 0
%170 = load i8*, i8** %169
%171 = call i32 @strlen(i8* %170)
%172 = add nsw i32 %168, %171
%173 = add nsw i32 %172, 1
%174 = zext i32 %173 to i64
%175 = call i8* @llvm.stacksave()
store i8* %175, i8** %13
%176 = alloca i8, i64 %174
store i64 %174, i64* %14
%177 = trunc i64 %174 to i32
%178 = call i32 @memset(i8* %176, i32 0, i32 %177)
%179 = load i8*, i8** %12
%180 = call i32 @strcat(i8* %176, i8* %179)
%181 = load i8*, i8** %12
%182 = call i32 @strlen(i8* %181)
%183 = sext i32 %182 to i64
%184 = getelementptr inbounds i8, i8* %176, i64 %183
%185 = getelementptr inbounds [20 x i8*], [20 x i8*]* %7, i64 0, i64 0
%186 = load i8*, i8** %185
%187 = call i32 @strcat(i8* %184, i8* %186)
store i8* %176, i8** %15
%188 = load i8*, i8** %15
%189 = getelementptr inbounds [20 x i8*], [20 x i8*]* %7, i64 0, i64 1
%190 = load i8**, i8*** @environ
%191 = call i32 @execve(i8* %188, i8** %189, i8** %190)
%192 = load i32, i32* @stderr
%193 = getelementptr inbounds [20 x i8*], [20 x i8*]* %7, i64 0, i64 0
%194 = load i8*, i8** %193
%195 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %192, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0), i8* %194)
%196 = call i32 @exit(i32 0)
unreachable
197: ; preds = %163
%198 = call i32 @wait(i32* %16)
br label %21
}

LLVM IR (-O2):
@SIGINT = global i32 0
@SIG_IGN = global i32 0
@.str = [2 x i8] c"/\00"
@stderr = global i32 0
@.str.1 = [15 x i8] c"[ %s : %s ] # \00"
@.str.2 = [5 x i8] c"USER\00"
@.str.3 = [3 x i8] c"cd\00"
@.str.4 = [6 x i8] c"/bin/\00"
@environ = external global i8**
@.str.5 = [24 x i8] c"%s : command not found\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [100 x i8]
%4 = alloca [20 x i8*]
%5 = alloca i32
%6 = load i32, i32* @SIGINT
%7 = load i32, i32* @SIG_IGN
%8 = tail call i32 @signal(i32 %6, i32 %7)
%9 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%10 = tail call i32 @chdir(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%11 = bitcast [20 x i8*]* %4 to i8*
%12 = getelementptr inbounds [20 x i8*], [20 x i8*]* %4, i64 0, i64 0
%13 = bitcast i32* %5 to i8*
%14 = getelementptr inbounds [20 x i8*], [20 x i8*]* %4, i64 0, i64 1
br label %15
15: ; preds = %113, %2
%16 = load i32, i32* @stderr
%17 = call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%18 = call i8* @getcwd(i32* null, i32 50)
%19 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %17, i8* %18)
%20 = call i32 @memset(i8* %9, i32 0, i32 100)
%21 = call i32 @read(i32 0, i8* %9, i32 100)
store i8* %9, i8** %12
%22 = load i8, i8* %9
%23 = icmp eq i8 %22, 10
br i1 %23, label %113, label %31
24: ; preds = %54, %50, %36, %48
%25 = phi i32 [ %41, %48 ], [ %51, %50 ], [ %33, %54 ], [ %33, %36 ]
%26 = phi i8* [ %49, %48 ], [ %37, %50 ], [ %55, %54 ], [ %37, %36 ]
%27 = load i8, i8* %26
%28 = icmp ne i8 %27, 10
%29 = icmp slt i32 %25, 20
%30 = select i1 %28, i1 %29, i1 false
br i1 %30, label %31, label %56
31: ; preds = %15, %24
%32 = phi i8* [ %26, %24 ], [ %9, %15 ]
%33 = phi i32 [ %25, %24 ], [ 0, %15 ]
%34 = phi i8 [ %27, %24 ], [ %22, %15 ]
%35 = icmp eq i8 %34, 32
br i1 %35, label %36, label %54
36: ; preds = %31
store i8 0, i8* %32
%37 = getelementptr inbounds i8, i8* %32, i64 1
%38 = load i8, i8* %37
switch i8 %38, label %50 [
i8 34, label %39
i8 10, label %24
]
39: ; preds = %36
store i8 0, i8* %37
%40 = getelementptr inbounds i8, i8* %32, i64 2
%41 = add nsw i32 %33, 1
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [20 x i8*], [20 x i8*]* %4, i64 0, i64 %42
store i8* %40, i8** %43
br label %44
44: ; preds = %44, %39
%45 = phi i8* [ %37, %39 ], [ %46, %44 ]
%46 = getelementptr inbounds i8, i8* %45, i64 1
%47 = load i8, i8* %46
switch i8 %47, label %44 [
i8 0, label %48
i8 34, label %48
]
48: ; preds = %44, %44
store i8 0, i8* %46
%49 = getelementptr inbounds i8, i8* %45, i64 2
br label %24
50: ; preds = %36
%51 = add nsw i32 %33, 1
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds [20 x i8*], [20 x i8*]* %4, i64 0, i64 %52
store i8* %37, i8** %53
br label %24
54: ; preds = %31
%55 = getelementptr inbounds i8, i8* %32, i64 1
br label %24
56: ; preds = %24
%57 = add nsw i32 %25, 1
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds [20 x i8*], [20 x i8*]* %4, i64 0, i64 %58
store i8* null, i8** %59
%60 = load i8, i8* %26
%61 = icmp eq i8 %60, 10
br i1 %61, label %62, label %64
62: ; preds = %56
store i8 0, i8* %26
%63 = getelementptr inbounds i8, i8* %26, i64 1
store i8 0, i8* %63
br label %64
64: ; preds = %62, %56
%65 = load i8*, i8** %12
%66 = call i32 @strcmp(i8* dereferenceable(1) %65, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%67 = icmp eq i32 %66, 0
br i1 %67, label %68, label %89
68: ; preds = %64
%69 = load i8*, i8** %14
%70 = load i8, i8* %69
%71 = icmp eq i8 %70, 47
br i1 %71, label %72, label %74
72: ; preds = %68
%73 = call i32 @chdir(i8* %69)
br label %113
74: ; preds = %68
%75 = call i8* @getcwd(i32* null, i32 50)
%76 = call i32 @strlen(i8* %75)
%77 = call i32 @strlen(i8* %69)
%78 = add i32 %76, 1
%79 = add i32 %78, %77
%80 = call i8* @malloc(i32 %79)
%81 = call i32 @strcat(i8* %80, i8* %75)
%82 = call i32 @strlen(i8* %75)
%83 = sext i32 %82 to i64
%84 = getelementptr inbounds i8, i8* %80, i64 %83
%85 = call i32 @strcat(i8* %84, i8* %69)
%86 = call i32 @free(i8* %75)
%87 = call i32 @chdir(i8* %80)
%88 = call i32 @free(i8* %80)
br label %113
89: ; preds = %64
%90 = call i32 (...) @fork()
%91 = icmp eq i32 %90, 0
br i1 %91, label %92, label %111
92: ; preds = %89
%93 = call i32 @strlen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%94 = call i32 @strlen(i8* %65)
%95 = add i32 %93, 1
%96 = add i32 %95, %94
%97 = zext i32 %96 to i64
%98 = alloca i8, i64 %97
%99 = call i32 @memset(i8* %98, i32 0, i32 %96)
%100 = call i32 @strcat(i8* %98, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%101 = call i32 @strlen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%102 = sext i32 %101 to i64
%103 = getelementptr inbounds i8, i8* %98, i64 %102
%104 = call i32 @strcat(i8* %103, i8* %65)
%105 = load i8**, i8*** @environ
%106 = call i32 @execve(i8* %98, i8** %14, i8** %105)
%107 = load i32, i32* @stderr
%108 = load i8*, i8** %12
%109 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %107, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0), i8* %108)
%110 = call i32 @exit(i32 0)
unreachable
111: ; preds = %89
%112 = call i32 @wait(i32* %5)
br label %113
113: ; preds = %72, %74, %15, %111
br label %15
}