#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*/ OS_Kill();
int /*<<< orphan*/ UART1_InString(char *, int);
int /*<<< orphan*/ UART1_OutString(char *);
int /*<<< orphan*/ term1_EnterDebug();
int /*<<< orphan*/ term1_ML();
int /*<<< orphan*/ term1_MR();
int /*<<< orphan*/ term1_help();
void term1_main() {
  unsigned char length;
  char inBuff[(100 + 1)];
  UART1_OutString("\n\n\rWelcome to Serial Command Line Interface!\n\rYou are "
                  "on the RS232 port");
  while (1) {
    UART1_OutString("\n\rCLI> ");
    UART1_InString(inBuff, 99);
    for (length = 0; inBuff[length] != 0 && length < 100; length++)
      if ((inBuff[length] >= 97) && (inBuff[length] <= 122))
        inBuff[length] -= 32;
    if (inBuff[0] == 'H')
      term1_help();
    else if (length == 2 && inBuff[0] == 'M' && inBuff[1] == 'R')
      term1_MR();
    else if (length == 2 && inBuff[0] == 'M' && inBuff[1] == 'L')
      term1_ML();
    else if (length == 2 && inBuff[0] == 'E' && inBuff[1] == 'D')
      term1_EnterDebug();
    else if (inBuff[0] == 'Q') {
      UART1_OutString("\n\rBYE!\n\r");
      break;
    } else
      UART1_OutString("\n\n\rUnrecognized Command. RTFM and try again.");
  }
  OS_Kill();
}


x86 assembly (clang, -O0):
<term1_main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
lea    0xe7e(%rip),%rdi
call   1050 <UART1_OutString@plt>
lea    0xeba(%rip),%rdi
call   1050 <UART1_OutString@plt>
lea    -0x70(%rbp),%rdi
mov    $0x63,%esi
call   1030 <UART1_InString@plt>
movb   $0x0,-0x1(%rbp)
movzbl -0x1(%rbp),%eax
movsbl -0x70(%rbp,%rax,1),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x71(%rbp)
je     11c9 <term1_main+0x59>
movzbl -0x1(%rbp),%eax
cmp    $0x64,%eax
setl   %al
mov    %al,-0x71(%rbp)
mov    -0x71(%rbp),%al
test   $0x1,%al
jne    11d9 <term1_main+0x69>
jmp    121f <term1_main+0xaf>
movzbl -0x1(%rbp),%eax
movsbl -0x70(%rbp,%rax,1),%eax
cmp    $0x61,%eax
jl     120d <term1_main+0x9d>
movzbl -0x1(%rbp),%eax
movsbl -0x70(%rbp,%rax,1),%eax
cmp    $0x7a,%eax
jg     120d <term1_main+0x9d>
movzbl -0x1(%rbp),%eax
movsbl -0x70(%rbp,%rax,1),%ecx
sub    $0x20,%ecx
mov    %cl,-0x70(%rbp,%rax,1)
jmp    1212 <term1_main+0xa2>
mov    -0x1(%rbp),%al
add    $0x1,%al
mov    %al,-0x1(%rbp)
jmp    11a5 <term1_main+0x35>
movsbl -0x70(%rbp),%eax
cmp    $0x48,%eax
jne    1238 <term1_main+0xc8>
mov    $0x0,%al
call   1060 <term1_help@plt>
jmp    130f <term1_main+0x19f>
movzbl -0x1(%rbp),%eax
cmp    $0x2,%eax
jne    126b <term1_main+0xfb>
movsbl -0x70(%rbp),%eax
cmp    $0x4d,%eax
jne    126b <term1_main+0xfb>
movsbl -0x6f(%rbp),%eax
cmp    $0x52,%eax
jne    126b <term1_main+0xfb>
mov    $0x0,%al
call   1080 <term1_MR@plt>
jmp    130a <term1_main+0x19a>
movzbl -0x1(%rbp),%eax
cmp    $0x2,%eax
jne    129e <term1_main+0x12e>
movsbl -0x70(%rbp),%eax
cmp    $0x4d,%eax
jne    129e <term1_main+0x12e>
movsbl -0x6f(%rbp),%eax
cmp    $0x4c,%eax
jne    129e <term1_main+0x12e>
mov    $0x0,%al
call   1090 <term1_ML@plt>
jmp    1305 <term1_main+0x195>
movzbl -0x1(%rbp),%eax
cmp    $0x2,%eax
jne    12d1 <term1_main+0x161>
movsbl -0x70(%rbp),%eax
cmp    $0x45,%eax
jne    12d1 <term1_main+0x161>
movsbl -0x6f(%rbp),%eax
cmp    $0x44,%eax
jne    12d1 <term1_main+0x161>
mov    $0x0,%al
call   1070 <term1_EnterDebug@plt>
jmp    1300 <term1_main+0x190>
movsbl -0x70(%rbp),%eax
cmp    $0x51,%eax
jne    12ef <term1_main+0x17f>
lea    0xd6b(%rip),%rdi
call   1050 <UART1_OutString@plt>
jmp    1314 <term1_main+0x1a4>
lea    0xd63(%rip),%rdi
call   1050 <UART1_OutString@plt>
jmp    1300 <term1_main+0x190>
jmp    1305 <term1_main+0x195>
jmp    130a <term1_main+0x19a>
jmp    130f <term1_main+0x19f>
jmp    1187 <term1_main+0x17>
mov    $0x0,%al
call   1040 <OS_Kill@plt>
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<term1_main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x68,%rsp
lea    0xe7e(%rip),%rdi
call   1050 <UART1_OutString@plt>
lea    0xeba(%rip),%r14
mov    %rsp,%r12
lea    0xec1(%rip),%r15
jmp    11b8 <term1_main+0x48>
cmp    $0x51,%bl
je     1289 <term1_main+0x119>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r15,%rdi
call   1050 <UART1_OutString@plt>
mov    %r14,%rdi
call   1050 <UART1_OutString@plt>
mov    %r12,%rdi
mov    $0x63,%esi
call   1030 <UART1_InString@plt>
mov    (%rsp),%cl
test   %cl,%cl
je     11b0 <term1_main+0x40>
xor    %edx,%edx
cs nopw 0x0(%rax,%rax,1)
lea    -0x61(%rcx),%eax
cmp    $0x19,%al
ja     11ed <term1_main+0x7d>
add    $0xe0,%cl
mov    %cl,(%rsp,%rdx,1)
lea    0x1(%rdx),%rax
movzbl 0x1(%rsp,%rdx,1),%ecx
test   %cl,%cl
je     1203 <term1_main+0x93>
cmp    $0x63,%rdx
mov    %rax,%rdx
jb     11e0 <term1_main+0x70>
mov    (%rsp),%bl
cmp    $0x48,%bl
jne    1220 <term1_main+0xb0>
xor    %eax,%eax
call   1060 <term1_help@plt>
jmp    11b8 <term1_main+0x48>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %eax,%edx
xor    $0x2,%dl
mov    %ebx,%ecx
xor    $0x4d,%cl
or     %dl,%cl
sete   %cl
mov    0x1(%rsp),%sil
jne    1248 <term1_main+0xd8>
cmp    $0x52,%sil
jne    1248 <term1_main+0xd8>
xor    %eax,%eax
call   1080 <term1_MR@plt>
jmp    11b8 <term1_main+0x48>
cmp    $0x4c,%sil
sete   %dl
and    %dl,%cl
cmp    $0x1,%cl
jne    1262 <term1_main+0xf2>
xor    %eax,%eax
call   1090 <term1_ML@plt>
jmp    11b8 <term1_main+0x48>
cmp    $0x2,%al
jne    119a <term1_main+0x2a>
cmp    $0x45,%bl
jne    119a <term1_main+0x2a>
cmp    $0x44,%sil
jne    119a <term1_main+0x2a>
xor    %eax,%eax
call   1070 <term1_EnterDebug@plt>
jmp    11b8 <term1_main+0x48>
lea    0xdc0(%rip),%rdi
call   1050 <UART1_OutString@plt>
xor    %eax,%eax
call   1040 <OS_Kill@plt>
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [72 x i8] c"\0A\0A\0DWelcome to Serial Command Line Interface!\0A\0DYou are on the RS232 port\00"
@.str.1 = [8 x i8] c"\0A\0DCLI> \00"
@.str.2 = [9 x i8] c"\0A\0DBYE!\0A\0D\00"
@.str.3 = [45 x i8] c"\0A\0A\0DUnrecognized Command. RTFM and try again.\00"
define void @term1_main() {
%1 = alloca i8
%2 = alloca [101 x i8]
%3 = call i32 @UART1_OutString(i8* getelementptr inbounds ([72 x i8], [72 x i8]* @.str, i64 0, i64 0))
br label %4
4: ; preds = %0, %115
%5 = call i32 @UART1_OutString(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%6 = getelementptr inbounds [101 x i8], [101 x i8]* %2, i64 0, i64 0
%7 = call i32 @UART1_InString(i8* %6, i32 99)
store i8 0, i8* %1
br label %8
8: ; preds = %44, %4
%9 = load i8, i8* %1
%10 = zext i8 %9 to i64
%11 = getelementptr inbounds [101 x i8], [101 x i8]* %2, i64 0, i64 %10
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %19
15: ; preds = %8
%16 = load i8, i8* %1
%17 = zext i8 %16 to i32
%18 = icmp slt i32 %17, 100
br label %19
19: ; preds = %15, %8
%20 = phi i1 [ false, %8 ], [ %18, %15 ]
br i1 %20, label %21, label %47
21: ; preds = %19
%22 = load i8, i8* %1
%23 = zext i8 %22 to i64
%24 = getelementptr inbounds [101 x i8], [101 x i8]* %2, i64 0, i64 %23
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp sge i32 %26, 97
br i1 %27, label %28, label %43
28: ; preds = %21
%29 = load i8, i8* %1
%30 = zext i8 %29 to i64
%31 = getelementptr inbounds [101 x i8], [101 x i8]* %2, i64 0, i64 %30
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = icmp sle i32 %33, 122
br i1 %34, label %35, label %43
35: ; preds = %28
%36 = load i8, i8* %1
%37 = zext i8 %36 to i64
%38 = getelementptr inbounds [101 x i8], [101 x i8]* %2, i64 0, i64 %37
%39 = load i8, i8* %38
%40 = sext i8 %39 to i32
%41 = sub nsw i32 %40, 32
%42 = trunc i32 %41 to i8
store i8 %42, i8* %38
br label %43
43: ; preds = %35, %28, %21
br label %44
44: ; preds = %43
%45 = load i8, i8* %1
%46 = add i8 %45, 1
store i8 %46, i8* %1
br label %8
47: ; preds = %19
%48 = getelementptr inbounds [101 x i8], [101 x i8]* %2, i64 0, i64 0
%49 = load i8, i8* %48
%50 = sext i8 %49 to i32
%51 = icmp eq i32 %50, 72
br i1 %51, label %52, label %54
52: ; preds = %47
%53 = call i32 (...) @term1_help()
br label %115
54: ; preds = %47
%55 = load i8, i8* %1
%56 = zext i8 %55 to i32
%57 = icmp eq i32 %56, 2
br i1 %57, label %58, label %70
58: ; preds = %54
%59 = getelementptr inbounds [101 x i8], [101 x i8]* %2, i64 0, i64 0
%60 = load i8, i8* %59
%61 = sext i8 %60 to i32
%62 = icmp eq i32 %61, 77
br i1 %62, label %63, label %70
63: ; preds = %58
%64 = getelementptr inbounds [101 x i8], [101 x i8]* %2, i64 0, i64 1
%65 = load i8, i8* %64
%66 = sext i8 %65 to i32
%67 = icmp eq i32 %66, 82
br i1 %67, label %68, label %70
68: ; preds = %63
%69 = call i32 (...) @term1_MR()
br label %114
70: ; preds = %63, %58, %54
%71 = load i8, i8* %1
%72 = zext i8 %71 to i32
%73 = icmp eq i32 %72, 2
br i1 %73, label %74, label %86
74: ; preds = %70
%75 = getelementptr inbounds [101 x i8], [101 x i8]* %2, i64 0, i64 0
%76 = load i8, i8* %75
%77 = sext i8 %76 to i32
%78 = icmp eq i32 %77, 77
br i1 %78, label %79, label %86
79: ; preds = %74
%80 = getelementptr inbounds [101 x i8], [101 x i8]* %2, i64 0, i64 1
%81 = load i8, i8* %80
%82 = sext i8 %81 to i32
%83 = icmp eq i32 %82, 76
br i1 %83, label %84, label %86
84: ; preds = %79
%85 = call i32 (...) @term1_ML()
br label %113
86: ; preds = %79, %74, %70
%87 = load i8, i8* %1
%88 = zext i8 %87 to i32
%89 = icmp eq i32 %88, 2
br i1 %89, label %90, label %102
90: ; preds = %86
%91 = getelementptr inbounds [101 x i8], [101 x i8]* %2, i64 0, i64 0
%92 = load i8, i8* %91
%93 = sext i8 %92 to i32
%94 = icmp eq i32 %93, 69
br i1 %94, label %95, label %102
95: ; preds = %90
%96 = getelementptr inbounds [101 x i8], [101 x i8]* %2, i64 0, i64 1
%97 = load i8, i8* %96
%98 = sext i8 %97 to i32
%99 = icmp eq i32 %98, 68
br i1 %99, label %100, label %102
100: ; preds = %95
%101 = call i32 (...) @term1_EnterDebug()
br label %112
102: ; preds = %95, %90, %86
%103 = getelementptr inbounds [101 x i8], [101 x i8]* %2, i64 0, i64 0
%104 = load i8, i8* %103
%105 = sext i8 %104 to i32
%106 = icmp eq i32 %105, 81
br i1 %106, label %107, label %109
107: ; preds = %102
%108 = call i32 @UART1_OutString(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
br label %116
109: ; preds = %102
%110 = call i32 @UART1_OutString(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.3, i64 0, i64 0))
br label %111
111: ; preds = %109
br label %112
112: ; preds = %111, %100
br label %113
113: ; preds = %112, %84
br label %114
114: ; preds = %113, %68
br label %115
115: ; preds = %114, %52
br label %4
116: ; preds = %107
%117 = call i32 (...) @OS_Kill()
ret void
}

LLVM IR (-O2):
@.str = [72 x i8] c"\0A\0A\0DWelcome to Serial Command Line Interface!\0A\0DYou are on the RS232 port\00"
@.str.1 = [8 x i8] c"\0A\0DCLI> \00"
@.str.2 = [9 x i8] c"\0A\0DBYE!\0A\0D\00"
@.str.3 = [45 x i8] c"\0A\0A\0DUnrecognized Command. RTFM and try again.\00"
define void @term1_main() {
%1 = alloca [101 x i8]
%2 = getelementptr inbounds [101 x i8], [101 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @UART1_OutString(i8* getelementptr inbounds ([72 x i8], [72 x i8]* @.str, i64 0, i64 0))
%4 = getelementptr inbounds [101 x i8], [101 x i8]* %1, i64 0, i64 1
br label %5
5: ; preds = %40, %0
%6 = call i32 @UART1_OutString(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 @UART1_InString(i8* %2, i32 99)
%8 = load i8, i8* %2
%9 = icmp eq i8 %8, 0
br i1 %9, label %58, label %10
10: ; preds = %5, %18
%11 = phi i64 [ %19, %18 ], [ 0, %5 ]
%12 = phi i8 [ %21, %18 ], [ %8, %5 ]
%13 = phi i8* [ %20, %18 ], [ %2, %5 ]
%14 = add i8 %12, -97
%15 = icmp ult i8 %14, 26
br i1 %15, label %16, label %18
16: ; preds = %10
%17 = add nsw i8 %12, -32
store i8 %17, i8* %13
br label %18
18: ; preds = %10, %16
%19 = add nuw nsw i64 %11, 1
%20 = getelementptr inbounds [101 x i8], [101 x i8]* %1, i64 0, i64 %19
%21 = load i8, i8* %20
%22 = icmp ne i8 %21, 0
%23 = icmp ult i64 %11, 99
%24 = select i1 %22, i1 %23, i1 false
br i1 %24, label %10, label %25
25: ; preds = %18
%26 = load i8, i8* %2
%27 = icmp eq i8 %26, 72
br i1 %27, label %28, label %30
28: ; preds = %25
%29 = call i32 (...) @term1_help()
br label %40
30: ; preds = %25
%31 = trunc i64 %19 to i8
%32 = icmp eq i8 %31, 2
%33 = icmp eq i8 %26, 77
%34 = select i1 %32, i1 %33, i1 false
%35 = load i8, i8* %4
%36 = icmp eq i8 %35, 82
%37 = select i1 %34, i1 %36, i1 false
br i1 %37, label %38, label %41
38: ; preds = %30
%39 = call i32 (...) @term1_MR()
br label %40
40: ; preds = %38, %51, %58, %44, %28
br label %5
41: ; preds = %30
%42 = icmp eq i8 %35, 76
%43 = select i1 %34, i1 %42, i1 false
br i1 %43, label %44, label %46
44: ; preds = %41
%45 = call i32 (...) @term1_ML()
br label %40
46: ; preds = %41
%47 = icmp eq i8 %26, 69
%48 = select i1 %32, i1 %47, i1 false
%49 = icmp eq i8 %35, 68
%50 = select i1 %48, i1 %49, i1 false
br i1 %50, label %51, label %53
51: ; preds = %46
%52 = call i32 (...) @term1_EnterDebug()
br label %40
53: ; preds = %46
%54 = icmp eq i8 %26, 81
br i1 %54, label %55, label %58
55: ; preds = %53
%56 = call i32 @UART1_OutString(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%57 = call i32 (...) @OS_Kill()
ret void
58: ; preds = %5, %53
%59 = call i32 @UART1_OutString(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.3, i64 0, i64 0))
br label %40
}