#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*/ changeDisplayColor();
int /*<<< orphan*/ disableLCDBackLight();
int /*<<< orphan*/ disableLCDDisplay();
int /*<<< orphan*/ disableLCDPower();
int /*<<< orphan*/ enableLCDBackLight();
int /*<<< orphan*/ enableLCDDisplay();
int /*<<< orphan*/ enableLCDPower();
int /*<<< orphan*/ initLCD();
int /*<<< orphan*/ initUART();
char uartGetc();
int /*<<< orphan*/ uartPutc(char);
int /*<<< orphan*/ uartPuts(char *);
int main(void) {
  initUART();
  initLCD();
  char input;
  while (1) {
    uartPuts("----------------------------------------\n");
    uartPuts("This program test the LCD!\n");
    uartPuts("Please choose:\n");
    uartPuts("-[a] Enable LCD Power\n");
    uartPuts("-[b] Disable LCD Power\n");
    uartPuts("-[c] Enable LCD BackLight\n");
    uartPuts("-[d] Disable LCD BackLight\n");
    uartPuts("-[e] Enable LCD Display\n");
    uartPuts("-[f] Disable LCD Display\n");
    uartPuts("-[g] Change LCD Display Color\n");
    uartPuts("----------------------------------------\n");
    uartPuts(" >> ");
    input = uartGetc();
    uartPutc(input);
    uartPuts("\n\n");
    switch (input) {
    case 'a':
      enableLCDPower();
      break;
    case 'b':
      disableLCDPower();
      break;
    case 'c':
      enableLCDBackLight();
      break;
    case 'd':
      disableLCDBackLight();
      break;
    case 'e':
      enableLCDDisplay();
      break;
    case 'f':
      disableLCDDisplay();
      break;
    case 'g':
      changeDisplayColor();
      break;
    default:
      break;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1040 <initUART@plt>
mov    $0x0,%al
call   10d0 <initLCD@plt>
lea    0xe38(%rip),%rdi
mov    %rdi,-0x18(%rbp)
call   1050 <uartPuts@plt>
lea    0xe52(%rip),%rdi
call   1050 <uartPuts@plt>
lea    0xe62(%rip),%rdi
call   1050 <uartPuts@plt>
lea    0xe66(%rip),%rdi
call   1050 <uartPuts@plt>
lea    0xe71(%rip),%rdi
call   1050 <uartPuts@plt>
lea    0xe7d(%rip),%rdi
call   1050 <uartPuts@plt>
lea    0xe8c(%rip),%rdi
call   1050 <uartPuts@plt>
lea    0xe9c(%rip),%rdi
call   1050 <uartPuts@plt>
lea    0xea9(%rip),%rdi
call   1050 <uartPuts@plt>
lea    0xeb7(%rip),%rdi
call   1050 <uartPuts@plt>
mov    -0x18(%rbp),%rdi
call   1050 <uartPuts@plt>
lea    0xec1(%rip),%rdi
call   1050 <uartPuts@plt>
xor    %eax,%eax
call   10e0 <uartGetc@plt>
mov    %al,-0x5(%rbp)
movsbl -0x5(%rbp),%edi
call   1030 <uartPutc@plt>
lea    0xea7(%rip),%rdi
call   1050 <uartPuts@plt>
movsbl -0x5(%rbp),%eax
add    $0xffffff9f,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x6,%eax
ja     130b <main+0x14b>
mov    -0x10(%rbp),%rax
lea    0xd52(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x0,%al
call   10a0 <enableLCDPower@plt>
jmp    1310 <main+0x150>
mov    $0x0,%al
call   10b0 <disableLCDPower@plt>
jmp    1310 <main+0x150>
mov    $0x0,%al
call   1070 <enableLCDBackLight@plt>
jmp    1310 <main+0x150>
mov    $0x0,%al
call   1090 <disableLCDBackLight@plt>
jmp    1310 <main+0x150>
mov    $0x0,%al
call   1060 <enableLCDDisplay@plt>
jmp    1310 <main+0x150>
mov    $0x0,%al
call   10c0 <disableLCDDisplay@plt>
jmp    1310 <main+0x150>
mov    $0x0,%al
call   1080 <changeDisplayColor@plt>
jmp    1310 <main+0x150>
jmp    1310 <main+0x150>
jmp    11dd <main+0x1d>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %eax,%eax
call   1040 <initUART@plt>
xor    %eax,%eax
call   10d0 <initLCD@plt>
lea    0xe3c(%rip),%rbx
lea    0xf24(%rip),%r13
lea    0xf3c(%rip),%rbp
lea    0xf3a(%rip),%r14
lea    0xe04(%rip),%r12
jmp    1210 <main+0x50>
xor    %eax,%eax
call   1060 <enableLCDDisplay@plt>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbx,%rdi
call   1050 <uartPuts@plt>
lea    0xe27(%rip),%rdi
call   1050 <uartPuts@plt>
lea    0xe37(%rip),%rdi
call   1050 <uartPuts@plt>
lea    0xe3b(%rip),%rdi
call   1050 <uartPuts@plt>
lea    0xe46(%rip),%rdi
call   1050 <uartPuts@plt>
lea    0xe52(%rip),%rdi
call   1050 <uartPuts@plt>
lea    0xe61(%rip),%rdi
call   1050 <uartPuts@plt>
lea    0xe71(%rip),%rdi
call   1050 <uartPuts@plt>
lea    0xe7e(%rip),%rdi
call   1050 <uartPuts@plt>
mov    %r13,%rdi
call   1050 <uartPuts@plt>
mov    %rbx,%rdi
call   1050 <uartPuts@plt>
mov    %rbp,%rdi
call   1050 <uartPuts@plt>
xor    %eax,%eax
call   10e0 <uartGetc@plt>
movsbl %al,%r15d
mov    %r15d,%edi
call   1030 <uartPutc@plt>
mov    %r14,%rdi
call   1050 <uartPuts@plt>
add    $0xffffff9f,%r15d
cmp    $0x6,%r15d
ja     1210 <main+0x50>
movslq (%r12,%r15,4),%rax
add    %r12,%rax
jmp    *%rax
xor    %eax,%eax
call   10a0 <enableLCDPower@plt>
jmp    1210 <main+0x50>
xor    %eax,%eax
call   1070 <enableLCDBackLight@plt>
jmp    1210 <main+0x50>
xor    %eax,%eax
call   1090 <disableLCDBackLight@plt>
jmp    1210 <main+0x50>
xor    %eax,%eax
call   10b0 <disableLCDPower@plt>
jmp    1210 <main+0x50>
xor    %eax,%eax
call   10c0 <disableLCDDisplay@plt>
jmp    1210 <main+0x50>
xor    %eax,%eax
call   1080 <changeDisplayColor@plt>
jmp    1210 <main+0x50>

LLVM IR (-O0):
@.str = [42 x i8] c"----------------------------------------\0A\00"
@.str.1 = [28 x i8] c"This program test the LCD!\0A\00"
@.str.2 = [16 x i8] c"Please choose:\0A\00"
@.str.3 = [23 x i8] c"-[a] Enable LCD Power\0A\00"
@.str.4 = [24 x i8] c"-[b] Disable LCD Power\0A\00"
@.str.5 = [27 x i8] c"-[c] Enable LCD BackLight\0A\00"
@.str.6 = [28 x i8] c"-[d] Disable LCD BackLight\0A\00"
@.str.7 = [25 x i8] c"-[e] Enable LCD Display\0A\00"
@.str.8 = [26 x i8] c"-[f] Disable LCD Display\0A\00"
@.str.9 = [31 x i8] c"-[g] Change LCD Display Color\0A\00"
@.str.10 = [5 x i8] c" >> \00"
@.str.11 = [3 x i8] c"\0A\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
store i32 0, i32* %1
%3 = call i32 (...) @initUART()
%4 = call i32 (...) @initLCD()
br label %5
5: ; preds = %0, %39
%6 = call i32 @uartPuts(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @uartPuts(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 @uartPuts(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%9 = call i32 @uartPuts(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0))
%10 = call i32 @uartPuts(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0))
%11 = call i32 @uartPuts(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0))
%12 = call i32 @uartPuts(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0))
%13 = call i32 @uartPuts(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.7, i64 0, i64 0))
%14 = call i32 @uartPuts(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.8, i64 0, i64 0))
%15 = call i32 @uartPuts(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.9, i64 0, i64 0))
%16 = call i32 @uartPuts(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0))
%17 = call i32 @uartPuts(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0))
%18 = call signext i8 (...) @uartGetc()
store i8 %18, i8* %2
%19 = load i8, i8* %2
%20 = call i32 @uartPutc(i8 signext %19)
%21 = call i32 @uartPuts(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0))
%22 = load i8, i8* %2
%23 = sext i8 %22 to i32
switch i32 %23, label %38 [
i32 97, label %24
i32 98, label %26
i32 99, label %28
i32 100, label %30
i32 101, label %32
i32 102, label %34
i32 103, label %36
]
24: ; preds = %5
%25 = call i32 (...) @enableLCDPower()
br label %39
26: ; preds = %5
%27 = call i32 (...) @disableLCDPower()
br label %39
28: ; preds = %5
%29 = call i32 (...) @enableLCDBackLight()
br label %39
30: ; preds = %5
%31 = call i32 (...) @disableLCDBackLight()
br label %39
32: ; preds = %5
%33 = call i32 (...) @enableLCDDisplay()
br label %39
34: ; preds = %5
%35 = call i32 (...) @disableLCDDisplay()
br label %39
36: ; preds = %5
%37 = call i32 (...) @changeDisplayColor()
br label %39
38: ; preds = %5
br label %39
39: ; preds = %38, %36, %34, %32, %30, %28, %26, %24
br label %5
}

LLVM IR (-O2):
@.str = [42 x i8] c"----------------------------------------\0A\00"
@.str.1 = [28 x i8] c"This program test the LCD!\0A\00"
@.str.2 = [16 x i8] c"Please choose:\0A\00"
@.str.3 = [23 x i8] c"-[a] Enable LCD Power\0A\00"
@.str.4 = [24 x i8] c"-[b] Disable LCD Power\0A\00"
@.str.5 = [27 x i8] c"-[c] Enable LCD BackLight\0A\00"
@.str.6 = [28 x i8] c"-[d] Disable LCD BackLight\0A\00"
@.str.7 = [25 x i8] c"-[e] Enable LCD Display\0A\00"
@.str.8 = [26 x i8] c"-[f] Disable LCD Display\0A\00"
@.str.9 = [31 x i8] c"-[g] Change LCD Display Color\0A\00"
@.str.10 = [5 x i8] c" >> \00"
@.str.11 = [3 x i8] c"\0A\0A\00"
define i32 @main() {
%1 = tail call i32 (...) @initUART()
%2 = tail call i32 (...) @initLCD()
br label %3
3: ; preds = %20, %0
%4 = tail call i32 @uartPuts(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0))
%5 = tail call i32 @uartPuts(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
%6 = tail call i32 @uartPuts(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%7 = tail call i32 @uartPuts(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0))
%8 = tail call i32 @uartPuts(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0))
%9 = tail call i32 @uartPuts(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0))
%10 = tail call i32 @uartPuts(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0))
%11 = tail call i32 @uartPuts(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.7, i64 0, i64 0))
%12 = tail call i32 @uartPuts(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.8, i64 0, i64 0))
%13 = tail call i32 @uartPuts(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.9, i64 0, i64 0))
%14 = tail call i32 @uartPuts(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0))
%15 = tail call i32 @uartPuts(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0))
%16 = tail call signext i8 (...) @uartGetc()
%17 = tail call i32 @uartPutc(i8 signext %16)
%18 = tail call i32 @uartPuts(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0))
%19 = sext i8 %16 to i32
switch i32 %19, label %20 [
i32 97, label %21
i32 98, label %23
i32 99, label %25
i32 100, label %27
i32 101, label %29
i32 102, label %31
i32 103, label %33
]
20: ; preds = %3, %33, %31, %29, %27, %25, %23, %21
br label %3
21: ; preds = %3
%22 = tail call i32 (...) @enableLCDPower()
br label %20
23: ; preds = %3
%24 = tail call i32 (...) @disableLCDPower()
br label %20
25: ; preds = %3
%26 = tail call i32 (...) @enableLCDBackLight()
br label %20
27: ; preds = %3
%28 = tail call i32 (...) @disableLCDBackLight()
br label %20
29: ; preds = %3
%30 = tail call i32 (...) @enableLCDDisplay()
br label %20
31: ; preds = %3
%32 = tail call i32 (...) @disableLCDDisplay()
br label %20
33: ; preds = %3
%34 = tail call i32 (...) @changeDisplayColor()
br label %20
}