#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();
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("[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 'q':
    case 'Q': {
      return;
      break;
    }
    }
  }
}


x86 assembly (clang, -O0):
<lcd_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1090 <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>
mov    $0x0,%al
call   10c0 <getc@plt>
mov    %al,-0x1(%rbp)
movzbl -0x1(%rbp),%eax
cmp    $0xa,%eax
je     122b <lcd_test+0x7b>
movzbl -0x1(%rbp),%eax
cmp    $0xd,%eax
jne    123c <lcd_test+0x8c>
lea    0xeab(%rip),%rdi
call   1040 <printf@plt>
jmp    1245 <lcd_test+0x95>
movzbl -0x1(%rbp),%edi
call   1060 <putc@plt>
jmp    124a <lcd_test+0x9a>
movzbl -0x1(%rbp),%ecx
mov    $0x1,%al
cmp    $0xa,%ecx
mov    %al,-0x2(%rbp)
je     1269 <lcd_test+0xb9>
movzbl -0x1(%rbp),%eax
cmp    $0xd,%eax
sete   %al
mov    %al,-0x2(%rbp)
mov    -0x2(%rbp),%al
test   $0x1,%al
jne    1207 <lcd_test+0x57>
movzbl -0x1(%rbp),%eax
add    $0xffffffbe,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x2f,%eax
ja     13ac <lcd_test+0x1fc>
mov    -0x10(%rbp),%rax
lea    0xd6b(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
cmpl   $0x0,0x2dd7(%rip)
je     12c3 <lcd_test+0x113>
mov    $0x0,%al
call   10b0 <lcd_off@plt>
lea    0xeaf(%rip),%rdi
call   1040 <printf@plt>
jmp    12d6 <lcd_test+0x126>
mov    $0x0,%al
call   1070 <lcd_on@plt>
lea    0xea1(%rip),%rdi
call   1040 <printf@plt>
cmpl   $0x0,0x2d9f(%rip)
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,0x2d8f(%rip)
jmp    13ac <lcd_test+0x1fc>
cmpl   $0x0,0x2d87(%rip)
je     1317 <lcd_test+0x167>
mov    $0x0,%al
call   10d0 <backlight_disable@plt>
lea    0xe6e(%rip),%rdi
call   1040 <printf@plt>
jmp    132a <lcd_test+0x17a>
mov    $0x0,%al
call   10a0 <backlight_enable@plt>
lea    0xe66(%rip),%rdi
call   1040 <printf@plt>
cmpl   $0x0,0x2d4f(%rip)
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,0x2d3f(%rip)
jmp    13ac <lcd_test+0x1fc>
cmpl   $0x0,0x2d37(%rip)
je     136b <lcd_test+0x1bb>
mov    $0x0,%al
call   1030 <displaycon_off@plt>
lea    0xe39(%rip),%rdi
call   1040 <printf@plt>
jmp    137e <lcd_test+0x1ce>
mov    $0x0,%al
call   1050 <displaycon_on@plt>
lea    0xe3a(%rip),%rdi
call   1040 <printf@plt>
cmpl   $0x0,0x2cfb(%rip)
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,0x2ceb(%rip)
jmp    13ac <lcd_test+0x1fc>
mov    $0x0,%al
call   1080 <display_red@plt>
jmp    13ac <lcd_test+0x1fc>
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   1080 <lcd_init@plt>
lea    0x1040(%rip),%r13
lea    0x1069(%rip),%rbx
lea    0x1076(%rip),%rbp
lea    0xfef(%rip),%r14
lea    0xe2b(%rip),%r12
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>
mov    %r13,%rdi
call   1030 <printf@plt>
mov    %rbx,%rdi
call   1030 <printf@plt>
mov    %rbp,%rdi
call   1030 <printf@plt>
nopl   0x0(%rax)
xor    %eax,%eax
call   10b0 <getc@plt>
mov    %eax,%r15d
cmp    $0xd,%al
je     1234 <lcd_test+0x94>
cmp    $0xa,%r15b
jne    1240 <lcd_test+0xa0>
mov    %r14,%rdi
call   1030 <printf@plt>
jmp    1249 <lcd_test+0xa9>
xchg   %ax,%ax
movzbl %r15b,%edi
call   1050 <putc@plt>
add    $0xf6,%r15b
movzbl %r15b,%eax
cmp    $0x67,%al
ja     11e0 <lcd_test+0x40>
movslq (%r12,%rax,4),%rax
add    %r12,%rax
jmp    *%rax
cmpl   $0x0,0x2e13(%rip)
je     12ac <lcd_test+0x10c>
xor    %eax,%eax
call   10c0 <backlight_disable@plt>
lea    0xfe6(%rip),%rdi
jmp    12c0 <lcd_test+0x120>
xor    %eax,%eax
call   1040 <displaycon_on@plt>
lea    0xff5(%rip),%rdi
jmp    12c0 <lcd_test+0x120>
xor    %eax,%eax
call   1070 <display_red@plt>
jmp    11e0 <lcd_test+0x40>
cmpl   $0x0,0x2dda(%rip)
je     12dc <lcd_test+0x13c>
xor    %eax,%eax
call   10a0 <lcd_off@plt>
lea    0xf9e(%rip),%rdi
jmp    12ea <lcd_test+0x14a>
xor    %eax,%eax
call   1090 <backlight_enable@plt>
lea    0xfb1(%rip),%rdi
nopw   0x0(%rax,%rax,1)
call   1030 <printf@plt>
xor    %eax,%eax
cmpl   $0x0,0x2daa(%rip)
sete   %al
mov    %eax,0x2da1(%rip)
jmp    11e0 <lcd_test+0x40>
xor    %eax,%eax
call   1060 <lcd_on@plt>
lea    0xf68(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
cmpl   $0x0,0x2d7c(%rip)
sete   %al
mov    %eax,0x2d73(%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 = [11 x i8] c"[Q] quit\0A\0D\00"
@.str.6 = [3 x i8] c"\0A\0D\00"
@.str.7 = [10 x i8] c"LCD off\0A\0D\00"
@.str.8 = [9 x i8] c"LCD on\0A\0D\00"
@.str.9 = [16 x i8] c"Backlight off\0A\0D\00"
@.str.10 = [15 x i8] c"Backlight on\0A\0D\00"
@.str.11 = [25 x i8] c"Display controller off\0A\0D\00"
@.str.12 = [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, %83
%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 ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0))
br label %10
10: ; preds = %33, %3
%11 = call zeroext i8 (...) @getc()
store i8 %11, i8* %1
%12 = load i8, i8* %1
%13 = zext i8 %12 to i32
%14 = icmp eq i32 %13, 10
br i1 %14, label %19, label %15
15: ; preds = %10
%16 = load i8, i8* %1
%17 = zext i8 %16 to i32
%18 = icmp eq i32 %17, 13
br i1 %18, label %19, label %21
19: ; preds = %15, %10
%20 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
br label %24
21: ; preds = %15
%22 = load i8, i8* %1
%23 = call i32 @putc(i8 zeroext %22)
br label %24
24: ; preds = %21, %19
br label %25
25: ; preds = %24
%26 = load i8, i8* %1
%27 = zext i8 %26 to i32
%28 = icmp eq i32 %27, 10
br i1 %28, label %33, label %29
29: ; preds = %25
%30 = load i8, i8* %1
%31 = zext i8 %30 to i32
%32 = icmp eq i32 %31, 13
br label %33
33: ; preds = %29, %25
%34 = phi i1 [ true, %25 ], [ %32, %29 ]
br i1 %34, label %10, label %35
35: ; preds = %33
%36 = load i8, i8* %1
%37 = zext i8 %36 to i32
switch i32 %37, label %83 [
i32 108, label %38
i32 76, label %38
i32 98, label %52
i32 66, label %52
i32 99, label %66
i32 67, label %66
i32 100, label %80
i32 68, label %80
i32 113, label %82
i32 81, label %82
]
38: ; preds = %35, %35
%39 = load i32, i32* @lcd_test.lcdon
%40 = icmp ne i32 %39, 0
br i1 %40, label %41, label %44
41: ; preds = %38
%42 = call i32 (...) @lcd_off()
%43 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0))
br label %47
44: ; preds = %38
%45 = call i32 (...) @lcd_on()
%46 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.8, i64 0, i64 0))
br label %47
47: ; preds = %44, %41
%48 = load i32, i32* @lcd_test.lcdon
%49 = icmp ne i32 %48, 0
%50 = xor i1 %49, true
%51 = zext i1 %50 to i32
store i32 %51, i32* @lcd_test.lcdon
br label %83
52: ; preds = %35, %35
%53 = load i32, i32* @lcd_test.blon
%54 = icmp ne i32 %53, 0
br i1 %54, label %55, label %58
55: ; preds = %52
%56 = call i32 (...) @backlight_disable()
%57 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.9, i64 0, i64 0))
br label %61
58: ; preds = %52
%59 = call i32 (...) @backlight_enable()
%60 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.10, i64 0, i64 0))
br label %61
61: ; preds = %58, %55
%62 = load i32, i32* @lcd_test.blon
%63 = icmp ne i32 %62, 0
%64 = xor i1 %63, true
%65 = zext i1 %64 to i32
store i32 %65, i32* @lcd_test.blon
br label %83
66: ; preds = %35, %35
%67 = load i32, i32* @lcd_test.dispon
%68 = icmp ne i32 %67, 0
br i1 %68, label %69, label %72
69: ; preds = %66
%70 = call i32 (...) @displaycon_off()
%71 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.11, i64 0, i64 0))
br label %75
72: ; preds = %66
%73 = call i32 (...) @displaycon_on()
%74 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.12, i64 0, i64 0))
br label %75
75: ; preds = %72, %69
%76 = load i32, i32* @lcd_test.blon
%77 = icmp ne i32 %76, 0
%78 = xor i1 %77, true
%79 = zext i1 %78 to i32
store i32 %79, i32* @lcd_test.blon
br label %83
80: ; preds = %35, %35
%81 = call i32 (...) @display_red()
br label %83
82: ; preds = %35, %35
ret void
83: ; preds = %35, %80, %75, %61, %47
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 = [11 x i8] c"[Q] quit\0A\0D\00"
@.str.6 = [3 x i8] c"\0A\0D\00"
@.str.7 = [10 x i8] c"LCD off\0A\0D\00"
@.str.8 = [9 x i8] c"LCD on\0A\0D\00"
@.str.9 = [16 x i8] c"Backlight off\0A\0D\00"
@.str.10 = [15 x i8] c"Backlight on\0A\0D\00"
@.str.12 = [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 = %51, %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 ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0))
br label %9
9: ; preds = %16, %2
%10 = tail call zeroext i8 (...) @getc()
switch i8 %10, label %13 [
i8 13, label %11
i8 10, label %11
]
11: ; preds = %9, %9
%12 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
br label %15
13: ; preds = %9
%14 = tail call i32 @putc(i8 zeroext %10)
br label %15
15: ; preds = %11, %13
switch i8 %10, label %51 [
i8 13, label %16
i8 10, label %16
i8 108, label %17
i8 76, label %17
i8 98, label %30
i8 66, label %30
i8 99, label %43
i8 67, label %43
i8 100, label %49
i8 68, label %49
i8 113, label %52
i8 81, label %52
]
16: ; preds = %15, %15
br label %9
17: ; preds = %15, %15
%18 = load i32, i32* @lcd_test.lcdon
%19 = icmp eq i32 %18, 0
br i1 %19, label %22, label %20
20: ; preds = %17
%21 = tail call i32 (...) @lcd_off()
br label %24
22: ; preds = %17
%23 = tail call i32 (...) @lcd_on()
br label %24
24: ; preds = %22, %20
%25 = phi i8* [ getelementptr inbounds ([9 x i8], [9 x i8]* @.str.8, i64 0, i64 0), %22 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0), %20 ]
%26 = tail call i32 @printf(i8* dereferenceable(1) %25)
%27 = load i32, i32* @lcd_test.lcdon
%28 = icmp eq i32 %27, 0
%29 = zext i1 %28 to i32
store i32 %29, i32* @lcd_test.lcdon
br label %51
30: ; preds = %15, %15
%31 = load i32, i32* @lcd_test.blon
%32 = icmp eq i32 %31, 0
br i1 %32, label %35, label %33
33: ; preds = %30
%34 = tail call i32 (...) @backlight_disable()
br label %37
35: ; preds = %30
%36 = tail call i32 (...) @backlight_enable()
br label %37
37: ; preds = %35, %33
%38 = phi i8* [ getelementptr inbounds ([15 x i8], [15 x i8]* @.str.10, i64 0, i64 0), %35 ], [ getelementptr inbounds ([16 x i8], [16 x i8]* @.str.9, i64 0, i64 0), %33 ]
%39 = tail call i32 @printf(i8* dereferenceable(1) %38)
%40 = load i32, i32* @lcd_test.blon
%41 = icmp eq i32 %40, 0
%42 = zext i1 %41 to i32
store i32 %42, i32* @lcd_test.blon
br label %51
43: ; preds = %15, %15
%44 = tail call i32 (...) @displaycon_on()
%45 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.12, i64 0, i64 0))
%46 = load i32, i32* @lcd_test.blon
%47 = icmp eq i32 %46, 0
%48 = zext i1 %47 to i32
store i32 %48, i32* @lcd_test.blon
br label %51
49: ; preds = %15, %15
%50 = tail call i32 (...) @display_red()
br label %51
51: ; preds = %15, %49, %43, %37, %24
br label %2
52: ; preds = %15, %15
ret void
}