#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 */
int /*<<< orphan*/ addnode(char *);
int /*<<< orphan*/ dirs();
int /*<<< orphan*/ freenode();
int /*<<< orphan*/ gets(char *);
int /*<<< orphan*/ initialization();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ pushd(char *);
int /*<<< orphan*/ sscanf(char *, char *, char *, char *);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ system(char *);
int main() {
  char inputstr[4096 + 1];
  char command[4096 + 1];
  char option[4096 + 1];
  initialization();
  addnode("/bin");
  addnode("/boot");
  addnode("/etc");
  addnode("/mnt");
  addnode("/tmp");
  addnode("/home");
  addnode("/lib");
  dirs();
  for (;;) {
    option[0] = '\0';
    gets(inputstr);
    sscanf(inputstr, "%s %s", command, option);
    if (strcmp(command, "pushd") == 0) {
      pushd(option);
      dirs();
    } else if (strcmp(command, "popd") == 0) {
      printf("unfinished");
    } else if (strcmp(command, "dirs") == 0) {
      dirs();
    } else if (strcmp(command, "exit") == 0) {
      break;
    } else
      system(inputstr);
  }
  freenode();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x3030,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1030 <initialization@plt>
lea    0xe40(%rip),%rdi
call   1050 <addnode@plt>
lea    0xe39(%rip),%rdi
call   1050 <addnode@plt>
lea    0xe33(%rip),%rdi
call   1050 <addnode@plt>
lea    0xe2c(%rip),%rdi
call   1050 <addnode@plt>
lea    0xe25(%rip),%rdi
call   1050 <addnode@plt>
lea    0xe1e(%rip),%rdi
call   1050 <addnode@plt>
lea    0xe18(%rip),%rdi
call   1050 <addnode@plt>
mov    $0x0,%al
call   10c0 <dirs@plt>
movb   $0x0,-0x3030(%rbp)
lea    -0x1010(%rbp),%rdi
call   10a0 <gets@plt>
lea    -0x1010(%rbp),%rdi
lea    -0x2020(%rbp),%rdx
lea    -0x3030(%rbp),%rcx
lea    0xde2(%rip),%rsi
call   10b0 <sscanf@plt>
lea    -0x2020(%rbp),%rdi
lea    0xdd5(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
jne    127d <main+0xdd>
lea    -0x3030(%rbp),%rdi
call   1080 <pushd@plt>
mov    $0x0,%al
call   10c0 <dirs@plt>
jmp    1311 <main+0x171>
lea    -0x2020(%rbp),%rdi
lea    0xda6(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
jne    12ab <main+0x10b>
lea    0xd95(%rip),%rdi
call   1070 <printf@plt>
jmp    130c <main+0x16c>
lea    -0x2020(%rbp),%rdi
lea    0xd88(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
jne    12d4 <main+0x134>
mov    $0x0,%al
call   10c0 <dirs@plt>
jmp    1307 <main+0x167>
lea    -0x2020(%rbp),%rdi
lea    0xd64(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
jne    12f6 <main+0x156>
jmp    1316 <main+0x176>
lea    -0x1010(%rbp),%rdi
call   1060 <system@plt>
jmp    1307 <main+0x167>
jmp    130c <main+0x16c>
jmp    1311 <main+0x171>
jmp    1214 <main+0x74>
mov    $0x0,%al
call   1040 <freenode@plt>
xor    %eax,%eax
add    $0x3030,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x3028,%rsp
xor    %eax,%eax
call   1030 <initialization@plt>
lea    0xe41(%rip),%rdi
call   1050 <addnode@plt>
lea    0xe3a(%rip),%rdi
call   1050 <addnode@plt>
lea    0xe34(%rip),%rdi
call   1050 <addnode@plt>
lea    0xe2d(%rip),%rdi
call   1050 <addnode@plt>
lea    0xe26(%rip),%rdi
call   1050 <addnode@plt>
lea    0xe1f(%rip),%rdi
call   1050 <addnode@plt>
lea    0xe19(%rip),%rdi
call   1050 <addnode@plt>
xor    %eax,%eax
call   10c0 <dirs@plt>
lea    0x2020(%rsp),%r15
lea    0xe03(%rip),%r14
lea    0x1010(%rsp),%rbx
mov    %rsp,%r12
lea    0xdf7(%rip),%r13
lea    0xdf6(%rip),%rbp
jmp    124c <main+0xac>
nopl   (%rax)
lea    0xdef(%rip),%rdi
call   1070 <printf@plt>
movb   $0x0,(%rsp)
mov    %r15,%rdi
call   10a0 <gets@plt>
mov    %r15,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
mov    %r12,%rcx
call   10b0 <sscanf@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   1090 <strcmp@plt>
test   %rax,%rax
je     12c0 <main+0x120>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1090 <strcmp@plt>
test   %rax,%rax
je     1240 <main+0xa0>
mov    %rbx,%rdi
lea    0xdae(%rip),%rsi
call   1090 <strcmp@plt>
test   %rax,%rax
je     12c8 <main+0x128>
mov    %rbx,%rdi
lea    0xd9f(%rip),%rsi
call   1090 <strcmp@plt>
test   %rax,%rax
je     12d4 <main+0x134>
mov    %r15,%rdi
call   1060 <system@plt>
jmp    124c <main+0xac>
nopl   0x0(%rax,%rax,1)
mov    %r12,%rdi
call   1080 <pushd@plt>
xor    %eax,%eax
call   10c0 <dirs@plt>
jmp    124c <main+0xac>
xor    %eax,%eax
call   1040 <freenode@plt>
xor    %eax,%eax
add    $0x3028,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"/bin\00"
@.str.1 = [6 x i8] c"/boot\00"
@.str.2 = [5 x i8] c"/etc\00"
@.str.3 = [5 x i8] c"/mnt\00"
@.str.4 = [5 x i8] c"/tmp\00"
@.str.5 = [6 x i8] c"/home\00"
@.str.6 = [5 x i8] c"/lib\00"
@.str.7 = [6 x i8] c"%s %s\00"
@.str.8 = [6 x i8] c"pushd\00"
@.str.9 = [5 x i8] c"popd\00"
@.str.10 = [11 x i8] c"unfinished\00"
@.str.11 = [5 x i8] c"dirs\00"
@.str.12 = [5 x i8] c"exit\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [4097 x i8]
%3 = alloca [4097 x i8]
%4 = alloca [4097 x i8]
store i32 0, i32* %1
%5 = call i32 (...) @initialization()
%6 = call i32 @addnode(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @addnode(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 @addnode(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%9 = call i32 @addnode(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%10 = call i32 @addnode(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%11 = call i32 @addnode(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%12 = call i32 @addnode(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%13 = call i32 (...) @dirs()
br label %14
14: ; preds = %52, %0
%15 = getelementptr inbounds [4097 x i8], [4097 x i8]* %4, i64 0, i64 0
store i8 0, i8* %15
%16 = getelementptr inbounds [4097 x i8], [4097 x i8]* %2, i64 0, i64 0
%17 = call i32 @gets(i8* %16)
%18 = getelementptr inbounds [4097 x i8], [4097 x i8]* %2, i64 0, i64 0
%19 = getelementptr inbounds [4097 x i8], [4097 x i8]* %3, i64 0, i64 0
%20 = getelementptr inbounds [4097 x i8], [4097 x i8]* %4, i64 0, i64 0
%21 = call i32 @sscanf(i8* %18, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), i8* %19, i8* %20)
%22 = getelementptr inbounds [4097 x i8], [4097 x i8]* %3, i64 0, i64 0
%23 = call i64 @strcmp(i8* %22, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0))
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %29
25: ; preds = %14
%26 = getelementptr inbounds [4097 x i8], [4097 x i8]* %4, i64 0, i64 0
%27 = call i32 @pushd(i8* %26)
%28 = call i32 (...) @dirs()
br label %52
29: ; preds = %14
%30 = getelementptr inbounds [4097 x i8], [4097 x i8]* %3, i64 0, i64 0
%31 = call i64 @strcmp(i8* %30, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0))
%32 = icmp eq i64 %31, 0
br i1 %32, label %33, label %35
33: ; preds = %29
%34 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.10, i64 0, i64 0))
br label %51
35: ; preds = %29
%36 = getelementptr inbounds [4097 x i8], [4097 x i8]* %3, i64 0, i64 0
%37 = call i64 @strcmp(i8* %36, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.11, i64 0, i64 0))
%38 = icmp eq i64 %37, 0
br i1 %38, label %39, label %41
39: ; preds = %35
%40 = call i32 (...) @dirs()
br label %50
41: ; preds = %35
%42 = getelementptr inbounds [4097 x i8], [4097 x i8]* %3, i64 0, i64 0
%43 = call i64 @strcmp(i8* %42, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0))
%44 = icmp eq i64 %43, 0
br i1 %44, label %45, label %46
45: ; preds = %41
br label %53
46: ; preds = %41
%47 = getelementptr inbounds [4097 x i8], [4097 x i8]* %2, i64 0, i64 0
%48 = call i32 @system(i8* %47)
br label %49
49: ; preds = %46
br label %50
50: ; preds = %49, %39
br label %51
51: ; preds = %50, %33
br label %52
52: ; preds = %51, %25
br label %14
53: ; preds = %45
%54 = call i32 (...) @freenode()
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"/bin\00"
@.str.1 = [6 x i8] c"/boot\00"
@.str.2 = [5 x i8] c"/etc\00"
@.str.3 = [5 x i8] c"/mnt\00"
@.str.4 = [5 x i8] c"/tmp\00"
@.str.5 = [6 x i8] c"/home\00"
@.str.6 = [5 x i8] c"/lib\00"
@.str.7 = [6 x i8] c"%s %s\00"
@.str.8 = [6 x i8] c"pushd\00"
@.str.9 = [5 x i8] c"popd\00"
@.str.10 = [11 x i8] c"unfinished\00"
@.str.11 = [5 x i8] c"dirs\00"
@.str.12 = [5 x i8] c"exit\00"
define i32 @main() {
%1 = alloca [4097 x i8]
%2 = alloca [4097 x i8]
%3 = alloca [4097 x i8]
%4 = getelementptr inbounds [4097 x i8], [4097 x i8]* %1, i64 0, i64 0
%5 = getelementptr inbounds [4097 x i8], [4097 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [4097 x i8], [4097 x i8]* %3, i64 0, i64 0
%7 = tail call i32 (...) @initialization()
%8 = tail call i32 @addnode(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%9 = tail call i32 @addnode(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%10 = tail call i32 @addnode(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%11 = tail call i32 @addnode(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%12 = tail call i32 @addnode(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%13 = tail call i32 @addnode(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%14 = tail call i32 @addnode(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%15 = tail call i32 (...) @dirs()
br label %16
16: ; preds = %29, %0
store i8 0, i8* %6
%17 = call i32 @gets(i8* %4)
%18 = call i32 @sscanf(i8* %4, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), i8* %5, i8* %6)
%19 = call i64 @strcmp(i8* %5, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0))
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %24
21: ; preds = %16
%22 = call i32 @pushd(i8* %6)
%23 = call i32 (...) @dirs()
br label %29
24: ; preds = %16
%25 = call i64 @strcmp(i8* %5, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0))
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %30
27: ; preds = %24
%28 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.10, i64 0, i64 0))
br label %29
29: ; preds = %27, %38, %33, %21
br label %16
30: ; preds = %24
%31 = call i64 @strcmp(i8* %5, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.11, i64 0, i64 0))
%32 = icmp eq i64 %31, 0
br i1 %32, label %33, label %35
33: ; preds = %30
%34 = call i32 (...) @dirs()
br label %29
35: ; preds = %30
%36 = call i64 @strcmp(i8* %5, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0))
%37 = icmp eq i64 %36, 0
br i1 %37, label %40, label %38
38: ; preds = %35
%39 = call i32 @system(i8* %4)
br label %29
40: ; preds = %35
%41 = call i32 (...) @freenode()
ret i32 0
}