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

/* Variables and functions */
scalar_t__ CORE_CHECK();
int /*<<< orphan*/ CORE_CTRL(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ FORCEX_EXECUTION(char *);
int /*<<< orphan*/ bstop();
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ *getcwd(char *, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, char *);
scalar_t__ strcmp(char *, char *);
scalar_t__ system(char *);
int CMD_INIT() {
  printf("\x1B[37m"
         "[  "
         "\x1B[32m"
         "  "
         "\x1B[37m"
         "  ] clear\r");
  if (system("clear")) {
    printf("\x1B[37m"
           "["
           "\x1B[31m"
           "FAILED"
           "\x1B[37m"
           "] clear\n");
  } else {
    printf("\x1B[37m"
           "[  "
           "\x1B[32m"
           "OK"
           "\x1B[37m"
           "  ] clear\n");
  }
  printf("\x1B[37m"
         "[  "
         "\x1B[32m"
         "  "
         "\x1B[37m"
         "  ] core connection\r");
  if (CORE_CHECK()) {
    printf("\x1B[37m"
           "["
           "\x1B[31m"
           "FAILED"
           "\x1B[37m"
           "] core connetion\n");
  } else {
    printf("\x1B[37m"
           "[  "
           "\x1B[32m"
           "OK"
           "\x1B[37m"
           "  ] core connection\n");
  }
  printf("\x1B[37m"
         "[  "
         "\x1B[32m"
         "OK"
         "\x1B[37m"
         "  ] print color\n");
  printf("\x1B[37m"
         "[  "
         "\x1B[32m"
         "OK"
         "\x1B[37m"
         "  ] cmd limit var\n");
  char maxlen[5012];
  printf("\x1B[37m"
         "[  "
         "\x1B[32m"
         "OK"
         "\x1B[37m"
         "  ] cwd var\n");
  char cwd[100];
  printf("\x1B[37m"
         "[  "
         "\x1B[32m"
         "OK"
         "\x1B[37m"
         "  ] dir\n");
  char dir[1024];
  printf("\x1B[37m"
         "[  "
         "\x1B[32m"
         "OK"
         "\x1B[37m"
         "  ] nextfunction\n");
  int nextf;
  printf("\x1B[37m"
         "[  "
         "\x1B[32m"
         "OK"
         "\x1B[37m"
         "  ] nextfunction\n");
  int cmdlimiter = 0;
  printf("\x1B[37m"
         "[  "
         "\x1B[32m"
         "OK"
         "\x1B[37m"
         "  ] ForceXStarShell \n");
  for (;;) {
    if (getcwd(cwd, sizeof(cwd)) != NULL) {
      printf("%s>* ", cwd);
    } else {
      printf("No Dir>* ");
    }
    scanf("%s", maxlen);
    FORCEX_EXECUTION(maxlen);
    if (strcmp(maxlen, "halt") == 0) {
      printf("\x1B[37m"
             "[  "
             "\x1B[32m"
             "OK"
             "\x1B[37m"
             "  ] halt system\n");
      printf("\x1B[31m"
             "The system will HALT NOW!\n");
      exit(02);
    }
    if (strcmp(maxlen, "stop") == 0) {
      bstop();
      CORE_CTRL(0, 0);
    }
  }
}


x86 assembly (clang, -O0):
<CMD_INIT>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1820,%rsp
lea    0xe4e(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe5f(%rip),%rdi
call   1040 <system@plt>
cmp    $0x0,%rax
je     11e2 <CMD_INIT+0x42>
lea    0xe4f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    11f0 <CMD_INIT+0x50>
lea    0xe5b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe6c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1060 <CORE_CHECK@plt>
cmp    $0x0,%rax
je     1222 <CMD_INIT+0x82>
lea    0xe76(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1230 <CMD_INIT+0x90>
lea    0xe8b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xea6(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xebd(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xed6(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xee9(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xef8(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xeea(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x1818(%rbp)
lea    0xef8(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x1410(%rbp),%rdi
mov    $0x64,%esi
call   1070 <getcwd@plt>
cmp    $0x0,%rax
je     12d1 <CMD_INIT+0x131>
lea    -0x1410(%rbp),%rsi
lea    0xef2(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    12df <CMD_INIT+0x13f>
lea    0xee5(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x13a0(%rbp),%rsi
lea    0xeda(%rip),%rdi
call   10a0 <scanf@plt>
lea    -0x13a0(%rbp),%rdi
call   1090 <FORCEX_EXECUTION@plt>
lea    -0x13a0(%rbp),%rdi
lea    0xebe(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    1341 <CMD_INIT+0x1a1>
lea    0xead(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xec4(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x2,%edi
call   10b0 <exit@plt>
lea    -0x13a0(%rbp),%rdi
lea    0xec5(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    136e <CMD_INIT+0x1ce>
mov    $0x0,%al
call   1030 <bstop@plt>
xor    %esi,%esi
mov    %esi,%edi
call   10c0 <CORE_CTRL@plt>
jmp    129c <CMD_INIT+0xfc>

x86 assembly (clang, -O2):
<CMD_INIT>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1408,%rsp
lea    0xe38(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xea7(%rip),%rdi
call   1050 <system@plt>
test   %rax,%rax
lea    0xe80(%rip),%rax
lea    0xffd(%rip),%rdi
cmove  %rax,%rdi
call   1030 <puts@plt>
lea    0xe23(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
call   1070 <CORE_CHECK@plt>
test   %rax,%rax
lea    0xe6f(%rip),%rax
lea    0xfa7(%rip),%rdi
cmove  %rax,%rdi
call   1030 <puts@plt>
lea    0xe80(%rip),%rdi
call   1030 <puts@plt>
lea    0xe98(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb2(%rip),%rdi
call   1030 <puts@plt>
lea    0xec6(%rip),%rdi
call   1030 <puts@plt>
lea    0xed6(%rip),%rbx
mov    %rbx,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
lea    0xee4(%rip),%rdi
call   1030 <puts@plt>
mov    %rsp,%r12
lea    0xdd7(%rip),%r15
lea    0x70(%rsp),%rbx
lea    0xdce(%rip),%r13
lea    0xdcc(%rip),%rbp
lea    0xdad(%rip),%r14
nopl   0x0(%rax,%rax,1)
mov    %r12,%rdi
mov    $0x64,%esi
call   1080 <getcwd@plt>
test   %rax,%rax
je     12d0 <CMD_INIT+0x120>
mov    %r14,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    12de <CMD_INIT+0x12e>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    0xd77(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   10b0 <scanf@plt>
mov    %rbx,%rdi
call   10a0 <FORCEX_EXECUTION@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   1090 <strcmp@plt>
test   %rax,%rax
je     1326 <CMD_INIT+0x176>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1090 <strcmp@plt>
test   %rax,%rax
jne    12a0 <CMD_INIT+0xf0>
xor    %eax,%eax
call   1040 <bstop@plt>
xor    %edi,%edi
xor    %esi,%esi
call   10d0 <CORE_CTRL@plt>
jmp    12a0 <CMD_INIT+0xf0>
lea    0xe52(%rip),%rdi
call   1030 <puts@plt>
lea    0xe6a(%rip),%rdi
call   1030 <puts@plt>
mov    $0x2,%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
@.str = [31 x i8] c"\1B[37m[ \1B[32m \1B[37m ] clear\0D\00"
@.str.1 = [6 x i8] c"clear\00"
@.str.2 = [31 x i8] c"\1B[37m[\1B[31mFAILED\1B[37m] clear\0A\00"
@.str.3 = [31 x i8] c"\1B[37m[ \1B[32mOK\1B[37m ] clear\0A\00"
@.str.4 = [41 x i8] c"\1B[37m[ \1B[32m \1B[37m ] core connection\0D\00"
@.str.5 = [40 x i8] c"\1B[37m[\1B[31mFAILED\1B[37m] core connetion\0A\00"
@.str.6 = [41 x i8] c"\1B[37m[ \1B[32mOK\1B[37m ] core connection\0A\00"
@.str.7 = [37 x i8] c"\1B[37m[ \1B[32mOK\1B[37m ] print color\0A\00"
@.str.8 = [39 x i8] c"\1B[37m[ \1B[32mOK\1B[37m ] cmd limit var\0A\00"
@.str.9 = [33 x i8] c"\1B[37m[ \1B[32mOK\1B[37m ] cwd var\0A\00"
@.str.10 = [29 x i8] c"\1B[37m[ \1B[32mOK\1B[37m ] dir\0A\00"
@.str.11 = [38 x i8] c"\1B[37m[ \1B[32mOK\1B[37m ] nextfunction\0A\00"
@.str.12 = [42 x i8] c"\1B[37m[ \1B[32mOK\1B[37m ] ForceXStarShell \0A\00"
@.str.13 = [6 x i8] c"%s>* \00"
@.str.14 = [10 x i8] c"No Dir>* \00"
@.str.15 = [3 x i8] c"%s\00"
@.str.16 = [5 x i8] c"halt\00"
@.str.17 = [37 x i8] c"\1B[37m[ \1B[32mOK\1B[37m ] halt system\0A\00"
@.str.18 = [32 x i8] c"\1B[31mThe system will HALT NOW!\0A\00"
@.str.19 = [5 x i8] c"stop\00"
define i32 @CMD_INIT() {
%1 = alloca [5012 x i8]
%2 = alloca [100 x i8]
%3 = alloca [1024 x i8]
%4 = alloca i32
%5 = alloca i32
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%7 = call i64 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%8 = icmp ne i64 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %0
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0))
br label %13
11: ; preds = %0
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0))
br label %13
13: ; preds = %11, %9
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.4, i64 0, i64 0))
%15 = call i64 (...) @CORE_CHECK()
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %13
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.5, i64 0, i64 0))
br label %21
19: ; preds = %13
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.6, i64 0, i64 0))
br label %21
21: ; preds = %19, %17
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.7, i64 0, i64 0))
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.8, i64 0, i64 0))
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.9, i64 0, i64 0))
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.10, i64 0, i64 0))
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.11, i64 0, i64 0))
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.11, i64 0, i64 0))
store i32 0, i32* %5
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.12, i64 0, i64 0))
br label %29
29: ; preds = %57, %21
%30 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%31 = call i32* @getcwd(i8* %30, i32 100)
%32 = icmp ne i32* %31, null
br i1 %32, label %33, label %36
33: ; preds = %29
%34 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.13, i64 0, i64 0), i8* %34)
br label %38
36: ; preds = %29
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.14, i64 0, i64 0))
br label %38
38: ; preds = %36, %33
%39 = getelementptr inbounds [5012 x i8], [5012 x i8]* %1, i64 0, i64 0
%40 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.15, i64 0, i64 0), i8* %39)
%41 = getelementptr inbounds [5012 x i8], [5012 x i8]* %1, i64 0, i64 0
%42 = call i32 @FORCEX_EXECUTION(i8* %41)
%43 = getelementptr inbounds [5012 x i8], [5012 x i8]* %1, i64 0, i64 0
%44 = call i64 @strcmp(i8* %43, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.16, i64 0, i64 0))
%45 = icmp eq i64 %44, 0
br i1 %45, label %46, label %50
46: ; preds = %38
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.17, i64 0, i64 0))
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.18, i64 0, i64 0))
%49 = call i32 @exit(i32 2)
unreachable
50: ; preds = %38
%51 = getelementptr inbounds [5012 x i8], [5012 x i8]* %1, i64 0, i64 0
%52 = call i64 @strcmp(i8* %51, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.19, i64 0, i64 0))
%53 = icmp eq i64 %52, 0
br i1 %53, label %54, label %57
54: ; preds = %50
%55 = call i32 (...) @bstop()
%56 = call i32 @CORE_CTRL(i32 0, i32 0)
br label %57
57: ; preds = %54, %50
br label %29
}

LLVM IR (-O2):
@.str = [31 x i8] c"\1B[37m[ \1B[32m \1B[37m ] clear\0D\00"
@.str.1 = [6 x i8] c"clear\00"
@.str.4 = [41 x i8] c"\1B[37m[ \1B[32m \1B[37m ] core connection\0D\00"
@.str.13 = [6 x i8] c"%s>* \00"
@.str.14 = [10 x i8] c"No Dir>* \00"
@.str.15 = [3 x i8] c"%s\00"
@.str.16 = [5 x i8] c"halt\00"
@.str.19 = [5 x i8] c"stop\00"
@str = [30 x i8] c"\1B[37m[ \1B[32mOK\1B[37m ] clear\00"
@str.20 = [40 x i8] c"\1B[37m[ \1B[32mOK\1B[37m ] core connection\00"
@str.21 = [36 x i8] c"\1B[37m[ \1B[32mOK\1B[37m ] print color\00"
@str.22 = [38 x i8] c"\1B[37m[ \1B[32mOK\1B[37m ] cmd limit var\00"
@str.23 = [32 x i8] c"\1B[37m[ \1B[32mOK\1B[37m ] cwd var\00"
@str.24 = [28 x i8] c"\1B[37m[ \1B[32mOK\1B[37m ] dir\00"
@str.26 = [37 x i8] c"\1B[37m[ \1B[32mOK\1B[37m ] nextfunction\00"
@str.27 = [41 x i8] c"\1B[37m[ \1B[32mOK\1B[37m ] ForceXStarShell \00"
@str.28 = [36 x i8] c"\1B[37m[ \1B[32mOK\1B[37m ] halt system\00"
@str.29 = [31 x i8] c"\1B[31mThe system will HALT NOW!\00"
@str.30 = [39 x i8] c"\1B[37m[\1B[31mFAILED\1B[37m] core connetion\00"
@str.31 = [30 x i8] c"\1B[37m[\1B[31mFAILED\1B[37m] clear\00"
define i32 @CMD_INIT() {
%1 = alloca [5012 x i8]
%2 = alloca [100 x i8]
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%4 = tail call i64 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%5 = icmp eq i64 %4, 0
%6 = select i1 %5, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @str, i64 0, i64 0), i8* getelementptr inbounds ([30 x i8], [30 x i8]* @str.31, i64 0, i64 0)
%7 = tail call i32 @puts(i8* dereferenceable(1) %6)
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.4, i64 0, i64 0))
%9 = tail call i64 (...) @CORE_CHECK()
%10 = icmp eq i64 %9, 0
%11 = select i1 %10, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @str.20, i64 0, i64 0), i8* getelementptr inbounds ([39 x i8], [39 x i8]* @str.30, i64 0, i64 0)
%12 = tail call i32 @puts(i8* dereferenceable(1) %11)
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str.21, i64 0, i64 0))
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str.22, i64 0, i64 0))
%15 = getelementptr inbounds [5012 x i8], [5012 x i8]* %1, i64 0, i64 0
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.23, i64 0, i64 0))
%17 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%18 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.24, i64 0, i64 0))
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.26, i64 0, i64 0))
%20 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.26, i64 0, i64 0))
%21 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str.27, i64 0, i64 0))
br label %22
22: ; preds = %44, %0
%23 = call i32* @getcwd(i8* %17, i32 100)
%24 = icmp eq i32* %23, null
br i1 %24, label %27, label %25
25: ; preds = %22
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.13, i64 0, i64 0), i8* %17)
br label %29
27: ; preds = %22
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.14, i64 0, i64 0))
br label %29
29: ; preds = %27, %25
%30 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.15, i64 0, i64 0), i8* %15)
%31 = call i32 @FORCEX_EXECUTION(i8* %15)
%32 = call i64 @strcmp(i8* %15, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.16, i64 0, i64 0))
%33 = icmp eq i64 %32, 0
br i1 %33, label %34, label %38
34: ; preds = %29
%35 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str.28, i64 0, i64 0))
%36 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.29, i64 0, i64 0))
%37 = call i32 @exit(i32 2)
unreachable
38: ; preds = %29
%39 = call i64 @strcmp(i8* %15, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.19, i64 0, i64 0))
%40 = icmp eq i64 %39, 0
br i1 %40, label %41, label %44
41: ; preds = %38
%42 = call i32 (...) @bstop()
%43 = call i32 @CORE_CTRL(i32 0, i32 0)
br label %44
44: ; preds = %41, %38
br label %22
}