#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 EOF;
int /*<<< orphan*/ lcmd_delayus_(int);
int lcmd_getchar_();
int lcmd_getkb(void) {
  int c = lcmd_getchar_();
  if (c == 27) {
    do {
      lcmd_delayus_(1000);
      c = lcmd_getchar_();
      if (c == EOF)
        c = 27;
      else if ((c == 79) || (c == 91))
        continue;
      else if (c == 65)
        c = 0x48e0;
      else if (c == 66)
        c = 0x50e0;
      else if (c == 67)
        c = 0x4de0;
      else if (c == 68)
        c = 0x4be0;
      else if (c == 72)
        c = 0x47e0;
      else if (c == 75)
        c = 0x4fe0;
      else if (c == 80)
        c = 0x3b00;
      else if (c == 81)
        c = 0x3c00;
      else if (c == 82)
        c = 0x3d00;
      else if (c == 83)
        c = 0x3e00;
      else
        c = EOF;
      break;
    } while (1);
  }
  return c;
}


x86 assembly (clang, -O0):
<lcmd_getkb>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1040 <lcmd_getchar_@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x1b,-0x4(%rbp)
jne    12c4 <lcmd_getkb+0x1a4>
jmp    1141 <lcmd_getkb+0x21>
mov    $0x3e8,%edi
call   1030 <lcmd_delayus_@plt>
mov    $0x0,%al
call   1040 <lcmd_getchar_@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    0x2e89(%rip),%rcx
cmp    (%rcx),%eax
jne    1173 <lcmd_getkb+0x53>
movl   $0x1b,-0x4(%rbp)
jmp    12ab <lcmd_getkb+0x18b>
cmpl   $0x4f,-0x4(%rbp)
je     1187 <lcmd_getkb+0x67>
cmpl   $0x5b,-0x4(%rbp)
jne    118c <lcmd_getkb+0x6c>
jmp    12b0 <lcmd_getkb+0x190>
cmpl   $0x41,-0x4(%rbp)
jne    11a2 <lcmd_getkb+0x82>
movl   $0x48e0,-0x4(%rbp)
jmp    12a1 <lcmd_getkb+0x181>
cmpl   $0x42,-0x4(%rbp)
jne    11b8 <lcmd_getkb+0x98>
movl   $0x50e0,-0x4(%rbp)
jmp    129c <lcmd_getkb+0x17c>
cmpl   $0x43,-0x4(%rbp)
jne    11ce <lcmd_getkb+0xae>
movl   $0x4de0,-0x4(%rbp)
jmp    1297 <lcmd_getkb+0x177>
cmpl   $0x44,-0x4(%rbp)
jne    11e4 <lcmd_getkb+0xc4>
movl   $0x4be0,-0x4(%rbp)
jmp    1292 <lcmd_getkb+0x172>
cmpl   $0x48,-0x4(%rbp)
jne    11fa <lcmd_getkb+0xda>
movl   $0x47e0,-0x4(%rbp)
jmp    128d <lcmd_getkb+0x16d>
cmpl   $0x4b,-0x4(%rbp)
jne    1210 <lcmd_getkb+0xf0>
movl   $0x4fe0,-0x4(%rbp)
jmp    1288 <lcmd_getkb+0x168>
cmpl   $0x50,-0x4(%rbp)
jne    1226 <lcmd_getkb+0x106>
movl   $0x3b00,-0x4(%rbp)
jmp    1283 <lcmd_getkb+0x163>
cmpl   $0x51,-0x4(%rbp)
jne    123c <lcmd_getkb+0x11c>
movl   $0x3c00,-0x4(%rbp)
jmp    127e <lcmd_getkb+0x15e>
cmpl   $0x52,-0x4(%rbp)
jne    1252 <lcmd_getkb+0x132>
movl   $0x3d00,-0x4(%rbp)
jmp    1279 <lcmd_getkb+0x159>
cmpl   $0x53,-0x4(%rbp)
jne    1268 <lcmd_getkb+0x148>
movl   $0x3e00,-0x4(%rbp)
jmp    1274 <lcmd_getkb+0x154>
mov    0x2d79(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1279 <lcmd_getkb+0x159>
jmp    127e <lcmd_getkb+0x15e>
jmp    1283 <lcmd_getkb+0x163>
jmp    1288 <lcmd_getkb+0x168>
jmp    128d <lcmd_getkb+0x16d>
jmp    1292 <lcmd_getkb+0x172>
jmp    1297 <lcmd_getkb+0x177>
jmp    129c <lcmd_getkb+0x17c>
jmp    12a1 <lcmd_getkb+0x181>
jmp    12a6 <lcmd_getkb+0x186>
jmp    12ab <lcmd_getkb+0x18b>
jmp    12bf <lcmd_getkb+0x19f>
mov    $0x1,%al
test   $0x1,%al
jne    1141 <lcmd_getkb+0x21>
jmp    12bf <lcmd_getkb+0x19f>
jmp    12c4 <lcmd_getkb+0x1a4>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lcmd_getkb>:
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1040 <lcmd_getchar_@plt>
cmp    $0x1b,%eax
jne    1154 <lcmd_getkb+0x34>
mov    $0x3e8,%edi
call   1030 <lcmd_delayus_@plt>
xor    %eax,%eax
call   1040 <lcmd_getchar_@plt>
mov    0x2ea0(%rip),%r14
mov    (%r14),%edx
cmp    %edx,%eax
jne    115c <lcmd_getkb+0x3c>
mov    $0x1b,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    %eax,%ecx
lea    0xe9b(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
nop
add    $0xffffffbf,%ecx
cmp    $0x1a,%ecx
ja     11b7 <lcmd_getkb+0x97>
mov    $0x48e0,%eax
movslq (%rbx,%rcx,4),%rcx
add    %rbx,%rcx
jmp    *%rcx
mov    $0x3e8,%edi
call   1030 <lcmd_delayus_@plt>
xor    %eax,%eax
call   1040 <lcmd_getchar_@plt>
mov    %eax,%ecx
mov    (%r14),%edx
cmp    %edx,%eax
jne    1170 <lcmd_getkb+0x50>
jmp    114f <lcmd_getkb+0x2f>
mov    $0x50e0,%eax
jmp    1154 <lcmd_getkb+0x34>
mov    $0x4de0,%eax
jmp    1154 <lcmd_getkb+0x34>
mov    $0x4be0,%eax
jmp    1154 <lcmd_getkb+0x34>
mov    %edx,%eax
jmp    1154 <lcmd_getkb+0x34>
mov    $0x47e0,%eax
jmp    1154 <lcmd_getkb+0x34>
mov    $0x4fe0,%eax
jmp    1154 <lcmd_getkb+0x34>
mov    $0x3b00,%eax
jmp    1154 <lcmd_getkb+0x34>
mov    $0x3c00,%eax
jmp    1154 <lcmd_getkb+0x34>
mov    $0x3d00,%eax
jmp    1154 <lcmd_getkb+0x34>
mov    $0x3e00,%eax
jmp    1154 <lcmd_getkb+0x34>

LLVM IR (-O0):
@EOF = global i32 0
define i32 @lcmd_getkb() {
%1 = alloca i32
%2 = call i32 (...) @lcmd_getchar_()
store i32 %2, i32* %1
%3 = load i32, i32* %1
%4 = icmp eq i32 %3, 27
br i1 %4, label %5, label %76
5: ; preds = %0
br label %6
6: ; preds = %74, %5
%7 = call i32 @lcmd_delayus_(i32 1000)
%8 = call i32 (...) @lcmd_getchar_()
store i32 %8, i32* %1
%9 = load i32, i32* %1
%10 = load i32, i32* @EOF
%11 = icmp eq i32 %9, %10
br i1 %11, label %12, label %13
12: ; preds = %6
store i32 27, i32* %1
br label %73
13: ; preds = %6
%14 = load i32, i32* %1
%15 = icmp eq i32 %14, 79
br i1 %15, label %19, label %16
16: ; preds = %13
%17 = load i32, i32* %1
%18 = icmp eq i32 %17, 91
br i1 %18, label %19, label %20
19: ; preds = %16, %13
br label %74
20: ; preds = %16
%21 = load i32, i32* %1
%22 = icmp eq i32 %21, 65
br i1 %22, label %23, label %24
23: ; preds = %20
store i32 18656, i32* %1
br label %71
24: ; preds = %20
%25 = load i32, i32* %1
%26 = icmp eq i32 %25, 66
br i1 %26, label %27, label %28
27: ; preds = %24
store i32 20704, i32* %1
br label %70
28: ; preds = %24
%29 = load i32, i32* %1
%30 = icmp eq i32 %29, 67
br i1 %30, label %31, label %32
31: ; preds = %28
store i32 19936, i32* %1
br label %69
32: ; preds = %28
%33 = load i32, i32* %1
%34 = icmp eq i32 %33, 68
br i1 %34, label %35, label %36
35: ; preds = %32
store i32 19424, i32* %1
br label %68
36: ; preds = %32
%37 = load i32, i32* %1
%38 = icmp eq i32 %37, 72
br i1 %38, label %39, label %40
39: ; preds = %36
store i32 18400, i32* %1
br label %67
40: ; preds = %36
%41 = load i32, i32* %1
%42 = icmp eq i32 %41, 75
br i1 %42, label %43, label %44
43: ; preds = %40
store i32 20448, i32* %1
br label %66
44: ; preds = %40
%45 = load i32, i32* %1
%46 = icmp eq i32 %45, 80
br i1 %46, label %47, label %48
47: ; preds = %44
store i32 15104, i32* %1
br label %65
48: ; preds = %44
%49 = load i32, i32* %1
%50 = icmp eq i32 %49, 81
br i1 %50, label %51, label %52
51: ; preds = %48
store i32 15360, i32* %1
br label %64
52: ; preds = %48
%53 = load i32, i32* %1
%54 = icmp eq i32 %53, 82
br i1 %54, label %55, label %56
55: ; preds = %52
store i32 15616, i32* %1
br label %63
56: ; preds = %52
%57 = load i32, i32* %1
%58 = icmp eq i32 %57, 83
br i1 %58, label %59, label %60
59: ; preds = %56
store i32 15872, i32* %1
br label %62
60: ; preds = %56
%61 = load i32, i32* @EOF
store i32 %61, i32* %1
br label %62
62: ; preds = %60, %59
br label %63
63: ; preds = %62, %55
br label %64
64: ; preds = %63, %51
br label %65
65: ; preds = %64, %47
br label %66
66: ; preds = %65, %43
br label %67
67: ; preds = %66, %39
br label %68
68: ; preds = %67, %35
br label %69
69: ; preds = %68, %31
br label %70
70: ; preds = %69, %27
br label %71
71: ; preds = %70, %23
br label %72
72: ; preds = %71
br label %73
73: ; preds = %72, %12
br label %75
74: ; preds = %19
br i1 true, label %6, label %75
75: ; preds = %74, %73
br label %76
76: ; preds = %75, %0
%77 = load i32, i32* %1
ret i32 %77
}

LLVM IR (-O2):
@EOF = global i32 0
define i32 @lcmd_getkb() {
%1 = tail call i32 (...) @lcmd_getchar_()
%2 = icmp eq i32 %1, 27
br i1 %2, label %3, label %27
3: ; preds = %0
%4 = tail call i32 @lcmd_delayus_(i32 1000)
%5 = tail call i32 (...) @lcmd_getchar_()
%6 = load i32, i32* @EOF
%7 = icmp eq i32 %5, %6
br i1 %7, label %21, label %8
8: ; preds = %3, %11
%9 = phi i32 [ %14, %11 ], [ %6, %3 ]
%10 = phi i32 [ %13, %11 ], [ %5, %3 ]
switch i32 %10, label %20 [
i32 91, label %11
i32 79, label %11
i32 65, label %21
i32 66, label %23
i32 67, label %24
i32 68, label %25
i32 72, label %26
i32 75, label %27
i32 80, label %16
i32 81, label %17
i32 82, label %18
i32 83, label %19
]
11: ; preds = %8, %8
%12 = tail call i32 @lcmd_delayus_(i32 1000)
%13 = tail call i32 (...) @lcmd_getchar_()
%14 = load i32, i32* @EOF
%15 = icmp eq i32 %13, %14
br i1 %15, label %21, label %8
16: ; preds = %8
br label %27
17: ; preds = %8
br label %27
18: ; preds = %8
br label %27
19: ; preds = %8
br label %27
20: ; preds = %8
br label %27
21: ; preds = %8, %11, %3
%22 = phi i32 [ 27, %3 ], [ 27, %11 ], [ 18656, %8 ]
br label %27
23: ; preds = %8
br label %27
24: ; preds = %8
br label %27
25: ; preds = %8
br label %27
26: ; preds = %8
br label %27
27: ; preds = %8, %26, %25, %24, %23, %21, %17, %19, %20, %18, %16, %0
%28 = phi i32 [ 15104, %16 ], [ 15360, %17 ], [ 15616, %18 ], [ 15872, %19 ], [ %9, %20 ], [ %1, %0 ], [ %22, %21 ], [ 20704, %23 ], [ 19936, %24 ], [ 19424, %25 ], [ 18400, %26 ], [ 20448, %8 ]
ret i32 %28
}