#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 KBDget();
int /*<<< orphan*/ LCDbotLine();
int /*<<< orphan*/ LCDgotoxy(int, int /*<<< orphan*/);
int /*<<< orphan*/ LCDinit();
int /*<<< orphan*/ LCDput(int);
int /*<<< orphan*/ LCDtopLine();
int /*<<< orphan*/ delay_ms(int);
int main(void) {
  int i, j;
  volatile int state, k;
  int c, s;
  LCDinit();
  LCDtopLine();
  LCDput(' ');
  LCDput('H');
  LCDput('e');
  LCDput('l');
  LCDput('l');
  LCDput('o');
  LCDput(' ');
  LCDput('w');
  LCDput('o');
  LCDput('r');
  LCDput('l');
  LCDput('d');
  LCDput('!');
  LCDbotLine();
  j = 0;
  while (1 == 1) {
    while ((k = KBDget()) == -1) {
    };
    switch (k) {
    case 10:
      i = '*';
      break;
    case 11:
      i = '#';
      break;
    case 15:
      i = '0';
      break;
    default:
      i = k + 0x30;
    }
    LCDput(i);
    LCDput(0x20);
    j = j + 1;
    if (j == 5) {
      j = 0;
      LCDgotoxy(1, 0);
    }
    delay_ms(500);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1080 <LCDinit@plt>
mov    $0x0,%al
call   1040 <LCDtopLine@plt>
mov    $0x20,%edi
call   1030 <LCDput@plt>
mov    $0x48,%edi
call   1030 <LCDput@plt>
mov    $0x65,%edi
call   1030 <LCDput@plt>
mov    $0x6c,%edi
call   1030 <LCDput@plt>
mov    $0x6c,%edi
call   1030 <LCDput@plt>
mov    $0x6f,%edi
call   1030 <LCDput@plt>
mov    $0x20,%edi
call   1030 <LCDput@plt>
mov    $0x77,%edi
call   1030 <LCDput@plt>
mov    $0x6f,%edi
call   1030 <LCDput@plt>
mov    $0x72,%edi
call   1030 <LCDput@plt>
mov    $0x6c,%edi
call   1030 <LCDput@plt>
mov    $0x64,%edi
call   1030 <LCDput@plt>
mov    $0x21,%edi
call   1030 <LCDput@plt>
mov    $0x0,%al
call   1050 <LCDbotLine@plt>
movl   $0x0,-0xc(%rbp)
jmp    1222 <main+0xb2>
mov    $0x0,%al
call   1070 <KBDget@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
jne    123a <main+0xca>
jmp    1222 <main+0xb2>
mov    -0x14(%rbp),%eax
mov    %eax,-0x20(%rbp)
sub    $0xa,%eax
je     1270 <main+0x100>
jmp    124e <main+0xde>
mov    -0x20(%rbp),%eax
sub    $0xb,%eax
je     127c <main+0x10c>
jmp    125f <main+0xef>
mov    -0x20(%rbp),%eax
sub    $0xf,%eax
je     1288 <main+0x118>
jmp    1294 <main+0x124>
movl   $0x2a,-0x8(%rbp)
jmp    129d <main+0x12d>
movl   $0x23,-0x8(%rbp)
jmp    129d <main+0x12d>
movl   $0x30,-0x8(%rbp)
jmp    129d <main+0x12d>
mov    -0x14(%rbp),%eax
add    $0x30,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edi
call   1030 <LCDput@plt>
mov    $0x20,%edi
call   1030 <LCDput@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x5,-0xc(%rbp)
jne    12d5 <main+0x165>
movl   $0x0,-0xc(%rbp)
mov    $0x1,%edi
xor    %esi,%esi
call   1090 <LCDgotoxy@plt>
mov    $0x1f4,%edi
call   1060 <delay_ms@plt>
jmp    121d <main+0xad>

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
xor    %eax,%eax
call   1080 <LCDinit@plt>
xor    %eax,%eax
call   1040 <LCDtopLine@plt>
mov    $0x20,%edi
call   1030 <LCDput@plt>
mov    $0x48,%edi
call   1030 <LCDput@plt>
mov    $0x65,%edi
call   1030 <LCDput@plt>
mov    $0x6c,%edi
call   1030 <LCDput@plt>
mov    $0x6c,%edi
call   1030 <LCDput@plt>
mov    $0x6f,%edi
call   1030 <LCDput@plt>
mov    $0x20,%edi
call   1030 <LCDput@plt>
mov    $0x77,%edi
call   1030 <LCDput@plt>
mov    $0x6f,%edi
call   1030 <LCDput@plt>
mov    $0x72,%edi
call   1030 <LCDput@plt>
mov    $0x6c,%edi
call   1030 <LCDput@plt>
mov    $0x64,%edi
call   1030 <LCDput@plt>
mov    $0x21,%edi
call   1030 <LCDput@plt>
xor    %eax,%eax
call   1050 <LCDbotLine@plt>
xor    %ebx,%ebx
jmp    1240 <main+0xd0>
mov    $0x30,%edi
call   1030 <LCDput@plt>
mov    $0x20,%edi
call   1030 <LCDput@plt>
add    $0x1,%ebx
cmp    $0x5,%ebx
je     126a <main+0xfa>
mov    $0x1f4,%edi
call   1060 <delay_ms@plt>
cs nopw 0x0(%rax,%rax,1)
xor    %eax,%eax
call   1070 <KBDget@plt>
mov    %eax,0xc(%rsp)
cmp    $0xffffffff,%eax
je     1240 <main+0xd0>
mov    0xc(%rsp),%eax
cmp    $0xa,%eax
je     127a <main+0x10a>
cmp    $0xf,%eax
je     1210 <main+0xa0>
cmp    $0xb,%eax
jne    1281 <main+0x111>
mov    $0x23,%edi
jmp    1215 <main+0xa5>
xor    %ebx,%ebx
mov    $0x1,%edi
xor    %esi,%esi
call   1090 <LCDgotoxy@plt>
jmp    122c <main+0xbc>
mov    $0x2a,%edi
jmp    1215 <main+0xa5>
mov    0xc(%rsp),%edi
add    $0x30,%edi
jmp    1215 <main+0xa5>

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
%8 = call i32 (...) @LCDinit()
%9 = call i32 (...) @LCDtopLine()
%10 = call i32 @LCDput(i32 32)
%11 = call i32 @LCDput(i32 72)
%12 = call i32 @LCDput(i32 101)
%13 = call i32 @LCDput(i32 108)
%14 = call i32 @LCDput(i32 108)
%15 = call i32 @LCDput(i32 111)
%16 = call i32 @LCDput(i32 32)
%17 = call i32 @LCDput(i32 119)
%18 = call i32 @LCDput(i32 111)
%19 = call i32 @LCDput(i32 114)
%20 = call i32 @LCDput(i32 108)
%21 = call i32 @LCDput(i32 100)
%22 = call i32 @LCDput(i32 33)
%23 = call i32 (...) @LCDbotLine()
store i32 0, i32* %3
br label %24
24: ; preds = %0, %47
br label %25
25: ; preds = %28, %24
%26 = call i32 (...) @KBDget()
store volatile i32 %26, i32* %5
%27 = icmp eq i32 %26, -1
br i1 %27, label %28, label %29
28: ; preds = %25
br label %25
29: ; preds = %25
%30 = load volatile i32, i32* %5
switch i32 %30, label %34 [
i32 10, label %31
i32 11, label %32
i32 15, label %33
]
31: ; preds = %29
store i32 42, i32* %2
br label %37
32: ; preds = %29
store i32 35, i32* %2
br label %37
33: ; preds = %29
store i32 48, i32* %2
br label %37
34: ; preds = %29
%35 = load volatile i32, i32* %5
%36 = add nsw i32 %35, 48
store i32 %36, i32* %2
br label %37
37: ; preds = %34, %33, %32, %31
%38 = load i32, i32* %2
%39 = call i32 @LCDput(i32 %38)
%40 = call i32 @LCDput(i32 32)
%41 = load i32, i32* %3
%42 = add nsw i32 %41, 1
store i32 %42, i32* %3
%43 = load i32, i32* %3
%44 = icmp eq i32 %43, 5
br i1 %44, label %45, label %47
45: ; preds = %37
store i32 0, i32* %3
%46 = call i32 @LCDgotoxy(i32 1, i32 0)
br label %47
47: ; preds = %45, %37
%48 = call i32 @delay_ms(i32 500)
br label %24
}

LLVM IR (-O2):
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (...) @LCDinit()
%4 = tail call i32 (...) @LCDtopLine()
%5 = tail call i32 @LCDput(i32 32)
%6 = tail call i32 @LCDput(i32 72)
%7 = tail call i32 @LCDput(i32 101)
%8 = tail call i32 @LCDput(i32 108)
%9 = tail call i32 @LCDput(i32 108)
%10 = tail call i32 @LCDput(i32 111)
%11 = tail call i32 @LCDput(i32 32)
%12 = tail call i32 @LCDput(i32 119)
%13 = tail call i32 @LCDput(i32 111)
%14 = tail call i32 @LCDput(i32 114)
%15 = tail call i32 @LCDput(i32 108)
%16 = tail call i32 @LCDput(i32 100)
%17 = tail call i32 @LCDput(i32 33)
%18 = tail call i32 (...) @LCDbotLine()
br label %19
19: ; preds = %39, %0
%20 = phi i32 [ 0, %0 ], [ %40, %39 ]
br label %21
21: ; preds = %21, %19
%22 = tail call i32 (...) @KBDget()
store volatile i32 %22, i32* %1
%23 = icmp eq i32 %22, -1
br i1 %23, label %21, label %24
24: ; preds = %21
%25 = load volatile i32, i32* %1
switch i32 %25, label %28 [
i32 10, label %31
i32 11, label %26
i32 15, label %27
]
26: ; preds = %24
br label %31
27: ; preds = %24
br label %31
28: ; preds = %24
%29 = load volatile i32, i32* %1
%30 = add nsw i32 %29, 48
br label %31
31: ; preds = %24, %28, %27, %26
%32 = phi i32 [ %30, %28 ], [ 48, %27 ], [ 35, %26 ], [ 42, %24 ]
%33 = tail call i32 @LCDput(i32 %32)
%34 = tail call i32 @LCDput(i32 32)
%35 = add nsw i32 %20, 1
%36 = icmp eq i32 %35, 5
br i1 %36, label %37, label %39
37: ; preds = %31
%38 = tail call i32 @LCDgotoxy(i32 1, i32 0)
br label %39
39: ; preds = %37, %31
%40 = phi i32 [ 0, %37 ], [ %35, %31 ]
%41 = tail call i32 @delay_ms(i32 500)
br label %19
}