#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*/ display_red();
int /*<<< orphan*/ displaycon_off();
int /*<<< orphan*/ displaycon_on();
int /*<<< orphan*/ draw_line();
unsigned char getc();
int /*<<< orphan*/ lcd_init();
int /*<<< orphan*/ lcd_off();
int /*<<< orphan*/ lcd_on();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ putc(unsigned char);
int /*<<< orphan*/ pwm_menu();
void lcd_test(void) {
  unsigned char c;
  static int lcdon = 0;
  static int blon = 0;
  static int dispon = 0;
  lcd_init();
  while (1) {
    printf("********LCD TEST MENU********\n\r");
    printf("[L] enable/disable LCD\n\r");
    printf("[B] enable/disable back light\n\r");
    printf("[C] enable/disable s3c6410 display controller\n\r");
    printf("[D] display color\n\r");
    printf("[I]  draw line\n\r");
    printf("[Q] quit\n\r");
    do {
      c = getc();
      if (c == '\n' || c == '\r') {
        printf("\n\r");
      } else {
        putc(c);
      }
    } while (c == '\n' || c == '\r');
    switch (c) {
    case 'l':
    case 'L': {
      if (lcdon) {
        lcd_off();
        printf("LCD off\n\r");
      } else {
        lcd_on();
        printf("LCD on\n\r");
      }
      lcdon = !lcdon;
      break;
    }
    case 'b':
    case 'B': {
      pwm_menu();
      break;
    }
    case 'c':
    case 'C': {
      if (dispon) {
        displaycon_off();
        printf("Display controller off\n\r");
      } else {
        displaycon_on();
        printf("Display controller on\n\r");
      }
      blon = !blon;
      break;
    }
    case 'd':
    case 'D': {
      display_red();
      break;
    }
    case 'i':
    case 'I': {
      draw_line();
      break;
    }
    case 'q':
    case 'Q': {
      return;
      break;
    }
    }
  }
}


x86 assembly (clang, -O0):
<lcd_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   10b0 <lcd_init@plt>
lea    0xefa(%rip),%rdi
call   1040 <printf@plt>
lea    0xf0e(%rip),%rdi
call   1040 <printf@plt>
lea    0xf1b(%rip),%rdi
call   1040 <printf@plt>
lea    0xf2f(%rip),%rdi
call   1040 <printf@plt>
lea    0xf53(%rip),%rdi
call   1040 <printf@plt>
lea    0xf5b(%rip),%rdi
call   1040 <printf@plt>
lea    0xf60(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   10d0 <getc@plt>
mov    %al,-0x1(%rbp)
movzbl -0x1(%rbp),%eax
cmp    $0xa,%eax
je     1237 <lcd_test+0x87>
movzbl -0x1(%rbp),%eax
cmp    $0xd,%eax
jne    1248 <lcd_test+0x98>
lea    0xe9f(%rip),%rdi
call   1040 <printf@plt>
jmp    1251 <lcd_test+0xa1>
movzbl -0x1(%rbp),%edi
call   1060 <putc@plt>
jmp    1256 <lcd_test+0xa6>
movzbl -0x1(%rbp),%ecx
mov    $0x1,%al
cmp    $0xa,%ecx
mov    %al,-0x2(%rbp)
je     1275 <lcd_test+0xc5>
movzbl -0x1(%rbp),%eax
cmp    $0xd,%eax
sete   %al
mov    %al,-0x2(%rbp)
mov    -0x2(%rbp),%al
test   $0x1,%al
jne    1213 <lcd_test+0x63>
movzbl -0x1(%rbp),%eax
add    $0xffffffbe,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x2f,%eax
ja     137c <lcd_test+0x1cc>
mov    -0x10(%rbp),%rax
lea    0xd5f(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
cmpl   $0x0,0x2dcb(%rip)
je     12cf <lcd_test+0x11f>
mov    $0x0,%al
call   10c0 <lcd_off@plt>
lea    0xeb4(%rip),%rdi
call   1040 <printf@plt>
jmp    12e2 <lcd_test+0x132>
mov    $0x0,%al
call   1070 <lcd_on@plt>
lea    0xea6(%rip),%rdi
call   1040 <printf@plt>
cmpl   $0x0,0x2d93(%rip)
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,0x2d83(%rip)
jmp    137c <lcd_test+0x1cc>
mov    $0x0,%al
call   1080 <pwm_menu@plt>
jmp    137c <lcd_test+0x1cc>
cmpl   $0x0,0x2d73(%rip)
je     132f <lcd_test+0x17f>
mov    $0x0,%al
call   1030 <displaycon_off@plt>
lea    0xe67(%rip),%rdi
call   1040 <printf@plt>
jmp    1342 <lcd_test+0x192>
mov    $0x0,%al
call   1050 <displaycon_on@plt>
lea    0xe68(%rip),%rdi
call   1040 <printf@plt>
cmpl   $0x0,0x2d37(%rip)
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,0x2d27(%rip)
jmp    137c <lcd_test+0x1cc>
mov    $0x0,%al
call   10a0 <display_red@plt>
jmp    137c <lcd_test+0x1cc>
mov    $0x0,%al
call   1090 <draw_line@plt>
jmp    137c <lcd_test+0x1cc>
add    $0x10,%rsp
pop    %rbp
ret
jmp    11bf <lcd_test+0xf>

x86 assembly (clang, -O2):
<lcd_test>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %eax,%eax
call   10a0 <lcd_init@plt>
lea    0x1070(%rip),%rbx
lea    0x107d(%rip),%rbp
lea    0x1087(%rip),%r14
lea    0xfef(%rip),%r15
lea    0xe2b(%rip),%r13
cs nopw 0x0(%rax,%rax,1)
nop
lea    0xfb9(%rip),%rdi
call   1030 <printf@plt>
lea    0xfcd(%rip),%rdi
call   1030 <printf@plt>
lea    0xfda(%rip),%rdi
call   1030 <printf@plt>
lea    0xfee(%rip),%rdi
call   1030 <printf@plt>
mov    %rbx,%rdi
call   1030 <printf@plt>
mov    %rbp,%rdi
call   1030 <printf@plt>
mov    %r14,%rdi
call   1030 <printf@plt>
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   10c0 <getc@plt>
mov    %eax,%r12d
cmp    $0xd,%al
je     1244 <lcd_test+0xa4>
cmp    $0xa,%r12b
jne    1250 <lcd_test+0xb0>
mov    %r15,%rdi
call   1030 <printf@plt>
jmp    1259 <lcd_test+0xb9>
xchg   %ax,%ax
movzbl %r12b,%edi
call   1050 <putc@plt>
add    $0xf6,%r12b
movzbl %r12b,%eax
cmp    $0x67,%al
ja     11e0 <lcd_test+0x40>
movslq 0x0(%r13,%rax,4),%rax
add    %r13,%rax
jmp    *%rax
xor    %eax,%eax
call   1070 <pwm_menu@plt>
jmp    11e0 <lcd_test+0x40>
xor    %eax,%eax
call   1040 <displaycon_on@plt>
lea    0xfdf(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
cmpl   $0x0,0x2ddd(%rip)
sete   %al
mov    %eax,0x2dd4(%rip)
jmp    11e0 <lcd_test+0x40>
xor    %eax,%eax
call   1090 <display_red@plt>
jmp    11e0 <lcd_test+0x40>
xor    %eax,%eax
call   1080 <draw_line@plt>
jmp    11e0 <lcd_test+0x40>
cmpl   $0x0,0x2dac(%rip)
je     12da <lcd_test+0x13a>
xor    %eax,%eax
call   10b0 <lcd_off@plt>
lea    0xf81(%rip),%rdi
jmp    12e8 <lcd_test+0x148>
xor    %eax,%eax
call   1060 <lcd_on@plt>
lea    0xf7b(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
cmpl   $0x0,0x2d7e(%rip)
sete   %al
mov    %eax,0x2d75(%rip)
jmp    11e0 <lcd_test+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@lcd_test.lcdon = internal global i32 0
@lcd_test.blon = internal global i32 0
@lcd_test.dispon = internal global i32 0
@.str = [32 x i8] c"********LCD TEST MENU********\0A\0D\00"
@.str.1 = [25 x i8] c"[L] enable/disable LCD\0A\0D\00"
@.str.2 = [32 x i8] c"[B] enable/disable back light\0A\0D\00"
@.str.3 = [48 x i8] c"[C] enable/disable s3c6410 display controller\0A\0D\00"
@.str.4 = [20 x i8] c"[D] display color\0A\0D\00"
@.str.5 = [17 x i8] c"[I] draw line\0A\0D\00"
@.str.6 = [11 x i8] c"[Q] quit\0A\0D\00"
@.str.7 = [3 x i8] c"\0A\0D\00"
@.str.8 = [10 x i8] c"LCD off\0A\0D\00"
@.str.9 = [9 x i8] c"LCD on\0A\0D\00"
@.str.10 = [25 x i8] c"Display controller off\0A\0D\00"
@.str.11 = [24 x i8] c"Display controller on\0A\0D\00"
define void @lcd_test() {
%1 = alloca i8
%2 = call i32 (...) @lcd_init()
br label %3
3: ; preds = %0, %74
%4 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
%6 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
%7 = call i32 @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.3, i64 0, i64 0))
%8 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0))
%9 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0))
%10 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0))
br label %11
11: ; preds = %34, %3
%12 = call zeroext i8 (...) @getc()
store i8 %12, i8* %1
%13 = load i8, i8* %1
%14 = zext i8 %13 to i32
%15 = icmp eq i32 %14, 10
br i1 %15, label %20, label %16
16: ; preds = %11
%17 = load i8, i8* %1
%18 = zext i8 %17 to i32
%19 = icmp eq i32 %18, 13
br i1 %19, label %20, label %22
20: ; preds = %16, %11
%21 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
br label %25
22: ; preds = %16
%23 = load i8, i8* %1
%24 = call i32 @putc(i8 zeroext %23)
br label %25
25: ; preds = %22, %20
br label %26
26: ; preds = %25
%27 = load i8, i8* %1
%28 = zext i8 %27 to i32
%29 = icmp eq i32 %28, 10
br i1 %29, label %34, label %30
30: ; preds = %26
%31 = load i8, i8* %1
%32 = zext i8 %31 to i32
%33 = icmp eq i32 %32, 13
br label %34
34: ; preds = %30, %26
%35 = phi i1 [ true, %26 ], [ %33, %30 ]
br i1 %35, label %11, label %36
36: ; preds = %34
%37 = load i8, i8* %1
%38 = zext i8 %37 to i32
switch i32 %38, label %74 [
i32 108, label %39
i32 76, label %39
i32 98, label %53
i32 66, label %53
i32 99, label %55
i32 67, label %55
i32 100, label %69
i32 68, label %69
i32 105, label %71
i32 73, label %71
i32 113, label %73
i32 81, label %73
]
39: ; preds = %36, %36
%40 = load i32, i32* @lcd_test.lcdon
%41 = icmp ne i32 %40, 0
br i1 %41, label %42, label %45
42: ; preds = %39
%43 = call i32 (...) @lcd_off()
%44 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0))
br label %48
45: ; preds = %39
%46 = call i32 (...) @lcd_on()
%47 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.9, i64 0, i64 0))
br label %48
48: ; preds = %45, %42
%49 = load i32, i32* @lcd_test.lcdon
%50 = icmp ne i32 %49, 0
%51 = xor i1 %50, true
%52 = zext i1 %51 to i32
store i32 %52, i32* @lcd_test.lcdon
br label %74
53: ; preds = %36, %36
%54 = call i32 (...) @pwm_menu()
br label %74
55: ; preds = %36, %36
%56 = load i32, i32* @lcd_test.dispon
%57 = icmp ne i32 %56, 0
br i1 %57, label %58, label %61
58: ; preds = %55
%59 = call i32 (...) @displaycon_off()
%60 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.10, i64 0, i64 0))
br label %64
61: ; preds = %55
%62 = call i32 (...) @displaycon_on()
%63 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.11, i64 0, i64 0))
br label %64
64: ; preds = %61, %58
%65 = load i32, i32* @lcd_test.blon
%66 = icmp ne i32 %65, 0
%67 = xor i1 %66, true
%68 = zext i1 %67 to i32
store i32 %68, i32* @lcd_test.blon
br label %74
69: ; preds = %36, %36
%70 = call i32 (...) @display_red()
br label %74
71: ; preds = %36, %36
%72 = call i32 (...) @draw_line()
br label %74
73: ; preds = %36, %36
ret void
74: ; preds = %36, %71, %69, %64, %53, %48
br label %3
}

LLVM IR (-O2):
@lcd_test.lcdon = internal unnamed_addr global i32 0
@lcd_test.blon = internal unnamed_addr global i32 0
@.str = [32 x i8] c"********LCD TEST MENU********\0A\0D\00"
@.str.1 = [25 x i8] c"[L] enable/disable LCD\0A\0D\00"
@.str.2 = [32 x i8] c"[B] enable/disable back light\0A\0D\00"
@.str.3 = [48 x i8] c"[C] enable/disable s3c6410 display controller\0A\0D\00"
@.str.4 = [20 x i8] c"[D] display color\0A\0D\00"
@.str.5 = [17 x i8] c"[I] draw line\0A\0D\00"
@.str.6 = [11 x i8] c"[Q] quit\0A\0D\00"
@.str.7 = [3 x i8] c"\0A\0D\00"
@.str.8 = [10 x i8] c"LCD off\0A\0D\00"
@.str.9 = [9 x i8] c"LCD on\0A\0D\00"
@.str.11 = [24 x i8] c"Display controller on\0A\0D\00"
define void @lcd_test() {
%1 = tail call i32 (...) @lcd_init()
br label %2
2: ; preds = %43, %0
%3 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
%5 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
%6 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str.3, i64 0, i64 0))
%7 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0))
%8 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0))
%9 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0))
br label %10
10: ; preds = %17, %2
%11 = tail call zeroext i8 (...) @getc()
switch i8 %11, label %14 [
i8 13, label %12
i8 10, label %12
]
12: ; preds = %10, %10
%13 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
br label %16
14: ; preds = %10
%15 = tail call i32 @putc(i8 zeroext %11)
br label %16
16: ; preds = %12, %14
switch i8 %11, label %43 [
i8 13, label %17
i8 10, label %17
i8 108, label %18
i8 76, label %18
i8 98, label %31
i8 66, label %31
i8 99, label %33
i8 67, label %33
i8 100, label %39
i8 68, label %39
i8 105, label %41
i8 73, label %41
i8 113, label %44
i8 81, label %44
]
17: ; preds = %16, %16
br label %10
18: ; preds = %16, %16
%19 = load i32, i32* @lcd_test.lcdon
%20 = icmp eq i32 %19, 0
br i1 %20, label %23, label %21
21: ; preds = %18
%22 = tail call i32 (...) @lcd_off()
br label %25
23: ; preds = %18
%24 = tail call i32 (...) @lcd_on()
br label %25
25: ; preds = %23, %21
%26 = phi i8* [ getelementptr inbounds ([9 x i8], [9 x i8]* @.str.9, i64 0, i64 0), %23 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0), %21 ]
%27 = tail call i32 @printf(i8* dereferenceable(1) %26)
%28 = load i32, i32* @lcd_test.lcdon
%29 = icmp eq i32 %28, 0
%30 = zext i1 %29 to i32
store i32 %30, i32* @lcd_test.lcdon
br label %43
31: ; preds = %16, %16
%32 = tail call i32 (...) @pwm_menu()
br label %43
33: ; preds = %16, %16
%34 = tail call i32 (...) @displaycon_on()
%35 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.11, i64 0, i64 0))
%36 = load i32, i32* @lcd_test.blon
%37 = icmp eq i32 %36, 0
%38 = zext i1 %37 to i32
store i32 %38, i32* @lcd_test.blon
br label %43
39: ; preds = %16, %16
%40 = tail call i32 (...) @display_red()
br label %43
41: ; preds = %16, %16
%42 = tail call i32 (...) @draw_line()
br label %43
43: ; preds = %16, %41, %39, %33, %31, %25
br label %2
44: ; preds = %16, %16
ret void
}