#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*/ KeyBrd_Close();
char KeyBrd_Getch();
scalar_t__ KeyBrd_Hit();
int /*<<< orphan*/ Main_Init();
int /*<<< orphan*/ Uart_Close();
int /*<<< orphan*/ Uart_Print(char *);
int /*<<< orphan*/ printf(char *);
int main(void) {
  char i;
  char Key_Data;
  char Uart_Data;
  Main_Init();
  printf("Irda Test Pgm..\n");
  printf("Irda Speed : 2400 BPS\n");
  printf("Q key : Exit Pgm..\n");
  while (1) {
    if (KeyBrd_Hit()) {
      Key_Data = KeyBrd_Getch();
      if (Key_Data == 'q')
        break;
      if (Key_Data == 'i')
        Uart_Print("move pwm  20  20\n");
      if (Key_Data == 'j')
        Uart_Print("move pwm -40  40\n");
      if (Key_Data == 'l')
        Uart_Print("move pwm  40 -40\n");
      if (Key_Data == ',')
        Uart_Print("move pwm -40 -40\n");
      if (Key_Data == 'k')
        Uart_Print("move pwm   0   0\n");
    }
  }
  Uart_Close();
  KeyBrd_Close();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1060 <Main_Init@plt>
lea    0xe73(%rip),%rdi
call   1040 <printf@plt>
lea    0xe78(%rip),%rdi
call   1040 <printf@plt>
lea    0xe83(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1080 <KeyBrd_Hit@plt>
cmp    $0x0,%rax
je     1259 <main+0xe9>
mov    $0x0,%al
call   1090 <KeyBrd_Getch@plt>
mov    %al,-0x6(%rbp)
movsbl -0x6(%rbp),%eax
cmp    $0x71,%eax
jne    11d7 <main+0x67>
jmp    125e <main+0xee>
movsbl -0x6(%rbp),%eax
cmp    $0x69,%eax
jne    11f0 <main+0x80>
lea    0xe51(%rip),%rdi
call   1050 <Uart_Print@plt>
movsbl -0x6(%rbp),%eax
cmp    $0x6a,%eax
jne    1209 <main+0x99>
lea    0xe4a(%rip),%rdi
call   1050 <Uart_Print@plt>
movsbl -0x6(%rbp),%eax
cmp    $0x6c,%eax
jne    1222 <main+0xb2>
lea    0xe43(%rip),%rdi
call   1050 <Uart_Print@plt>
movsbl -0x6(%rbp),%eax
cmp    $0x2c,%eax
jne    123b <main+0xcb>
lea    0xe3c(%rip),%rdi
call   1050 <Uart_Print@plt>
movsbl -0x6(%rbp),%eax
cmp    $0x6b,%eax
jne    1254 <main+0xe4>
lea    0xe35(%rip),%rdi
call   1050 <Uart_Print@plt>
jmp    1259 <main+0xe9>
jmp    11aa <main+0x3a>
mov    $0x0,%al
call   1030 <Uart_Close@plt>
mov    $0x0,%al
call   1070 <KeyBrd_Close@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %eax,%eax
call   1060 <Main_Init@plt>
lea    0xef5(%rip),%rdi
call   1030 <puts@plt>
lea    0xef9(%rip),%rdi
call   1030 <puts@plt>
lea    0xf03(%rip),%rdi
call   1030 <puts@plt>
lea    0xe77(%rip),%r15
lea    0xea6(%rip),%r14
lea    0xe45(%rip),%rbx
lea    0xe74(%rip),%r12
lea    0xea3(%rip),%r13
lea    0xe78(%rip),%rbp
jmp    11da <main+0x6a>
mov    %r13,%rdi
call   1050 <Uart_Print@plt>
xor    %eax,%eax
call   1080 <KeyBrd_Hit@plt>
test   %rax,%rax
je     11da <main+0x6a>
xor    %eax,%eax
call   1090 <KeyBrd_Getch@plt>
lea    -0x69(%rax),%ecx
cmp    $0x8,%cl
ja     120e <main+0x9e>
movzbl %cl,%eax
movslq (%rbx,%rax,4),%rax
add    %rbx,%rax
mov    %r15,%rdi
jmp    *%rax
mov    %r12,%rdi
call   1050 <Uart_Print@plt>
jmp    11da <main+0x6a>
cmp    $0x2c,%al
jne    11da <main+0x6a>
mov    %r14,%rdi
call   1050 <Uart_Print@plt>
jmp    11da <main+0x6a>
mov    %rbp,%rdi
call   1050 <Uart_Print@plt>
jmp    11da <main+0x6a>
xor    %eax,%eax
call   1040 <Uart_Close@plt>
xor    %eax,%eax
call   1070 <KeyBrd_Close@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [17 x i8] c"Irda Test Pgm..\0A\00"
@.str.1 = [23 x i8] c"Irda Speed : 2400 BPS\0A\00"
@.str.2 = [20 x i8] c"Q key : Exit Pgm..\0A\00"
@.str.3 = [18 x i8] c"move pwm 20 20\0A\00"
@.str.4 = [18 x i8] c"move pwm -40 40\0A\00"
@.str.5 = [18 x i8] c"move pwm 40 -40\0A\00"
@.str.6 = [18 x i8] c"move pwm -40 -40\0A\00"
@.str.7 = [18 x i8] c"move pwm 0 0\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca i8
%4 = alloca i8
store i32 0, i32* %1
%5 = call i32 (...) @Main_Init()
%6 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
br label %9
9: ; preds = %0, %49
%10 = call i64 (...) @KeyBrd_Hit()
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %49
12: ; preds = %9
%13 = call signext i8 (...) @KeyBrd_Getch()
store i8 %13, i8* %3
%14 = load i8, i8* %3
%15 = sext i8 %14 to i32
%16 = icmp eq i32 %15, 113
br i1 %16, label %17, label %18
17: ; preds = %12
br label %50
18: ; preds = %12
%19 = load i8, i8* %3
%20 = sext i8 %19 to i32
%21 = icmp eq i32 %20, 105
br i1 %21, label %22, label %24
22: ; preds = %18
%23 = call i32 @Uart_Print(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
br label %24
24: ; preds = %22, %18
%25 = load i8, i8* %3
%26 = sext i8 %25 to i32
%27 = icmp eq i32 %26, 106
br i1 %27, label %28, label %30
28: ; preds = %24
%29 = call i32 @Uart_Print(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0))
br label %30
30: ; preds = %28, %24
%31 = load i8, i8* %3
%32 = sext i8 %31 to i32
%33 = icmp eq i32 %32, 108
br i1 %33, label %34, label %36
34: ; preds = %30
%35 = call i32 @Uart_Print(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0))
br label %36
36: ; preds = %34, %30
%37 = load i8, i8* %3
%38 = sext i8 %37 to i32
%39 = icmp eq i32 %38, 44
br i1 %39, label %40, label %42
40: ; preds = %36
%41 = call i32 @Uart_Print(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0))
br label %42
42: ; preds = %40, %36
%43 = load i8, i8* %3
%44 = sext i8 %43 to i32
%45 = icmp eq i32 %44, 107
br i1 %45, label %46, label %48
46: ; preds = %42
%47 = call i32 @Uart_Print(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0))
br label %48
48: ; preds = %46, %42
br label %49
49: ; preds = %48, %9
br label %9
50: ; preds = %17
%51 = call i32 (...) @Uart_Close()
%52 = call i32 (...) @KeyBrd_Close()
ret i32 0
}

LLVM IR (-O2):
@.str.3 = [18 x i8] c"move pwm 20 20\0A\00"
@.str.4 = [18 x i8] c"move pwm -40 40\0A\00"
@.str.5 = [18 x i8] c"move pwm 40 -40\0A\00"
@.str.6 = [18 x i8] c"move pwm -40 -40\0A\00"
@.str.7 = [18 x i8] c"move pwm 0 0\0A\00"
@str = [16 x i8] c"Irda Test Pgm..\00"
@str.8 = [22 x i8] c"Irda Speed : 2400 BPS\00"
@str.9 = [19 x i8] c"Q key : Exit Pgm..\00"
define i32 @main() {
%1 = tail call i32 (...) @Main_Init()
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str, i64 0, i64 0))
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.8, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.9, i64 0, i64 0))
br label %5
5: ; preds = %17, %0
%6 = tail call i64 (...) @KeyBrd_Hit()
%7 = icmp eq i64 %6, 0
br i1 %7, label %17, label %8
8: ; preds = %5
%9 = tail call signext i8 (...) @KeyBrd_Getch()
switch i8 %9, label %17 [
i8 113, label %18
i8 105, label %14
i8 106, label %10
i8 108, label %11
i8 44, label %12
i8 107, label %13
]
10: ; preds = %8
br label %14
11: ; preds = %8
br label %14
12: ; preds = %8
br label %14
13: ; preds = %8
br label %14
14: ; preds = %8, %13, %10, %11, %12
%15 = phi i8* [ getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0), %12 ], [ getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), %11 ], [ getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), %10 ], [ getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0), %13 ], [ getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), %8 ]
%16 = tail call i32 @Uart_Print(i8* %15)
br label %17
17: ; preds = %14, %8, %5
br label %5
18: ; preds = %8
%19 = tail call i32 (...) @Uart_Close()
%20 = tail call i32 (...) @KeyBrd_Close()
ret i32 0
}