#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*/ backlight_disable();
int /*<<< orphan*/ backlight_enable();
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);
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': {
      if (blon) {
        backlight_disable();
        printf("Backlight off\n\r");
      } else {
        backlight_enable();
        printf("Backlight on\n\r");
      }
      blon = !blon;
      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   10a0 <lcd_init@plt>
lea    0xeea(%rip),%rdi
call   1040 <printf@plt>
lea    0xefe(%rip),%rdi
call   1040 <printf@plt>
lea    0xf0b(%rip),%rdi
call   1040 <printf@plt>
lea    0xf1f(%rip),%rdi
call   1040 <printf@plt>
lea    0xf43(%rip),%rdi
call   1040 <printf@plt>
lea    0xf4b(%rip),%rdi
call   1040 <printf@plt>
lea    0xf50(%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     1247 <lcd_test+0x87>
movzbl -0x1(%rbp),%eax
cmp    $0xd,%eax
jne    1258 <lcd_test+0x98>
lea    0xe8f(%rip),%rdi
call   1040 <printf@plt>
jmp    1261 <lcd_test+0xa1>
movzbl -0x1(%rbp),%edi
call   1060 <putc@plt>
jmp    1266 <lcd_test+0xa6>
movzbl -0x1(%rbp),%ecx
mov    $0x1,%al
cmp    $0xa,%ecx
mov    %al,-0x2(%rbp)
je     1285 <lcd_test+0xc5>
movzbl -0x1(%rbp),%eax
cmp    $0xd,%eax
sete   %al
mov    %al,-0x2(%rbp)
mov    -0x2(%rbp),%al
test   $0x1,%al
jne    1223 <lcd_test+0x63>
movzbl -0x1(%rbp),%eax
add    $0xffffffbe,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x2f,%eax
ja     13d4 <lcd_test+0x214>
mov    -0x10(%rbp),%rax
lea    0xd4f(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
cmpl   $0x0,0x2dc3(%rip)
je     12df <lcd_test+0x11f>
mov    $0x0,%al
call   10c0 <lcd_off@plt>
lea    0xea4(%rip),%rdi
call   1040 <printf@plt>
jmp    12f2 <lcd_test+0x132>
mov    $0x0,%al
call   1070 <lcd_on@plt>
lea    0xe96(%rip),%rdi
call   1040 <printf@plt>
cmpl   $0x0,0x2d8b(%rip)
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,0x2d7b(%rip)
jmp    13d4 <lcd_test+0x214>
cmpl   $0x0,0x2d73(%rip)
je     1333 <lcd_test+0x173>
mov    $0x0,%al
call   10e0 <backlight_disable@plt>
lea    0xe63(%rip),%rdi
call   1040 <printf@plt>
jmp    1346 <lcd_test+0x186>
mov    $0x0,%al
call   10b0 <backlight_enable@plt>
lea    0xe5b(%rip),%rdi
call   1040 <printf@plt>
cmpl   $0x0,0x2d3b(%rip)
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,0x2d2b(%rip)
jmp    13d4 <lcd_test+0x214>
cmpl   $0x0,0x2d23(%rip)
je     1387 <lcd_test+0x1c7>
mov    $0x0,%al
call   1030 <displaycon_off@plt>
lea    0xe2e(%rip),%rdi
call   1040 <printf@plt>
jmp    139a <lcd_test+0x1da>
mov    $0x0,%al
call   1050 <displaycon_on@plt>
lea    0xe2f(%rip),%rdi
call   1040 <printf@plt>
cmpl   $0x0,0x2ce7(%rip)
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,0x2cd7(%rip)
jmp    13d4 <lcd_test+0x214>
mov    $0x0,%al
call   1090 <display_red@plt>
jmp    13d4 <lcd_test+0x214>
mov    $0x0,%al
call   1080 <draw_line@plt>
jmp    13d4 <lcd_test+0x214>
add    $0x10,%rsp
pop    %rbp
ret
jmp    11cf <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   1090 <lcd_init@plt>
lea    0x1060(%rip),%rbx
lea    0x106d(%rip),%rbp
lea    0x1077(%rip),%r14
lea    0xfdf(%rip),%r15
lea    0xe1b(%rip),%r13
cs nopw 0x0(%rax,%rax,1)
nop
lea    0xfa9(%rip),%rdi
call   1030 <printf@plt>
lea    0xfbd(%rip),%rdi
call   1030 <printf@plt>
lea    0xfca(%rip),%rdi
call   1030 <printf@plt>
lea    0xfde(%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     1254 <lcd_test+0xa4>
cmp    $0xa,%r12b
jne    1260 <lcd_test+0xb0>
mov    %r15,%rdi
call   1030 <printf@plt>
jmp    1269 <lcd_test+0xb9>
xchg   %ax,%ax
movzbl %r12b,%edi
call   1050 <putc@plt>
add    $0xf6,%r12b
movzbl %r12b,%eax
cmp    $0x67,%al
ja     11f0 <lcd_test+0x40>
movslq 0x0(%r13,%rax,4),%rax
add    %r13,%rax
jmp    *%rax
cmpl   $0x0,0x2df6(%rip)
je     12dd <lcd_test+0x12d>
xor    %eax,%eax
call   10d0 <backlight_disable@plt>
lea    0xfd2(%rip),%rdi
jmp    12f0 <lcd_test+0x140>
xor    %eax,%eax
call   1040 <displaycon_on@plt>
lea    0xfe1(%rip),%rdi
jmp    12f0 <lcd_test+0x140>
xor    %eax,%eax
call   1080 <display_red@plt>
jmp    11f0 <lcd_test+0x40>
xor    %eax,%eax
call   1070 <draw_line@plt>
jmp    11f0 <lcd_test+0x40>
cmpl   $0x0,0x2db1(%rip)
je     130c <lcd_test+0x15c>
xor    %eax,%eax
call   10b0 <lcd_off@plt>
lea    0xf7e(%rip),%rdi
jmp    131a <lcd_test+0x16a>
xor    %eax,%eax
call   10a0 <backlight_enable@plt>
lea    0xf91(%rip),%rdi
nopl   0x0(%rax,%rax,1)
call   1030 <printf@plt>
xor    %eax,%eax
cmpl   $0x0,0x2d82(%rip)
sete   %al
mov    %eax,0x2d79(%rip)
jmp    11f0 <lcd_test+0x40>
xor    %eax,%eax
call   1060 <lcd_on@plt>
lea    0xf49(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
cmpl   $0x0,0x2d54(%rip)
sete   %al
mov    %eax,0x2d4b(%rip)
jmp    11f0 <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 = [16 x i8] c"Backlight off\0A\0D\00"
@.str.11 = [15 x i8] c"Backlight on\0A\0D\00"
@.str.12 = [25 x i8] c"Display controller off\0A\0D\00"
@.str.13 = [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, %86
%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 %86 [
i32 108, label %39
i32 76, label %39
i32 98, label %53
i32 66, label %53
i32 99, label %67
i32 67, label %67
i32 100, label %81
i32 68, label %81
i32 105, label %83
i32 73, label %83
i32 113, label %85
i32 81, label %85
]
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 %86
53: ; preds = %36, %36
%54 = load i32, i32* @lcd_test.blon
%55 = icmp ne i32 %54, 0
br i1 %55, label %56, label %59
56: ; preds = %53
%57 = call i32 (...) @backlight_disable()
%58 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.10, i64 0, i64 0))
br label %62
59: ; preds = %53
%60 = call i32 (...) @backlight_enable()
%61 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.11, i64 0, i64 0))
br label %62
62: ; preds = %59, %56
%63 = load i32, i32* @lcd_test.blon
%64 = icmp ne i32 %63, 0
%65 = xor i1 %64, true
%66 = zext i1 %65 to i32
store i32 %66, i32* @lcd_test.blon
br label %86
67: ; preds = %36, %36
%68 = load i32, i32* @lcd_test.dispon
%69 = icmp ne i32 %68, 0
br i1 %69, label %70, label %73
70: ; preds = %67
%71 = call i32 (...) @displaycon_off()
%72 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.12, i64 0, i64 0))
br label %76
73: ; preds = %67
%74 = call i32 (...) @displaycon_on()
%75 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.13, i64 0, i64 0))
br label %76
76: ; preds = %73, %70
%77 = load i32, i32* @lcd_test.blon
%78 = icmp ne i32 %77, 0
%79 = xor i1 %78, true
%80 = zext i1 %79 to i32
store i32 %80, i32* @lcd_test.blon
br label %86
81: ; preds = %36, %36
%82 = call i32 (...) @display_red()
br label %86
83: ; preds = %36, %36
%84 = call i32 (...) @draw_line()
br label %86
85: ; preds = %36, %36
ret void
86: ; preds = %36, %83, %81, %76, %62, %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.10 = [16 x i8] c"Backlight off\0A\0D\00"
@.str.11 = [15 x i8] c"Backlight on\0A\0D\00"
@.str.13 = [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 = %54, %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 %54 [
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 %44
i8 67, label %44
i8 100, label %50
i8 68, label %50
i8 105, label %52
i8 73, label %52
i8 113, label %55
i8 81, label %55
]
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 %54
31: ; preds = %16, %16
%32 = load i32, i32* @lcd_test.blon
%33 = icmp eq i32 %32, 0
br i1 %33, label %36, label %34
34: ; preds = %31
%35 = tail call i32 (...) @backlight_disable()
br label %38
36: ; preds = %31
%37 = tail call i32 (...) @backlight_enable()
br label %38
38: ; preds = %36, %34
%39 = phi i8* [ getelementptr inbounds ([15 x i8], [15 x i8]* @.str.11, i64 0, i64 0), %36 ], [ getelementptr inbounds ([16 x i8], [16 x i8]* @.str.10, i64 0, i64 0), %34 ]
%40 = tail call i32 @printf(i8* dereferenceable(1) %39)
%41 = load i32, i32* @lcd_test.blon
%42 = icmp eq i32 %41, 0
%43 = zext i1 %42 to i32
store i32 %43, i32* @lcd_test.blon
br label %54
44: ; preds = %16, %16
%45 = tail call i32 (...) @displaycon_on()
%46 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.13, i64 0, i64 0))
%47 = load i32, i32* @lcd_test.blon
%48 = icmp eq i32 %47, 0
%49 = zext i1 %48 to i32
store i32 %49, i32* @lcd_test.blon
br label %54
50: ; preds = %16, %16
%51 = tail call i32 (...) @display_red()
br label %54
52: ; preds = %16, %16
%53 = tail call i32 (...) @draw_line()
br label %54
54: ; preds = %16, %52, %50, %44, %38, %25
br label %2
55: ; preds = %16, %16
ret void
}