#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 GetKey(int);
int GetKeyArrows(void) {
  int ch = 0;
  ch = GetKey(64 | 32);
  if (ch == 27) {
    ch = GetKey(0);
    if (ch == '[') {
      ch = GetKey(0);
      if (ch == 'A')
        return 1001;
      else if (ch == 'B')
        return 1002;
      else if (ch == 'C')
        return 1003;
      else if (ch == 'D')
        return 1004;
      else
        return ch;
    } else
      return ch;
  }
  return ch;
}


x86 assembly (clang, -O0):
<GetKeyArrows>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x8(%rbp)
mov    $0x60,%edi
call   1030 <GetKey@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x1b,-0x8(%rbp)
jne    11c2 <GetKeyArrows+0xb2>
xor    %edi,%edi
call   1030 <GetKey@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x5b,-0x8(%rbp)
jne    11b7 <GetKeyArrows+0xa7>
xor    %edi,%edi
call   1030 <GetKey@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x41,-0x8(%rbp)
jne    116a <GetKeyArrows+0x5a>
movl   $0x3e9,-0x4(%rbp)
jmp    11c8 <GetKeyArrows+0xb8>
cmpl   $0x42,-0x8(%rbp)
jne    1180 <GetKeyArrows+0x70>
movl   $0x3ea,-0x4(%rbp)
jmp    11c8 <GetKeyArrows+0xb8>
cmpl   $0x43,-0x8(%rbp)
jne    1196 <GetKeyArrows+0x86>
movl   $0x3eb,-0x4(%rbp)
jmp    11c8 <GetKeyArrows+0xb8>
cmpl   $0x44,-0x8(%rbp)
jne    11ac <GetKeyArrows+0x9c>
movl   $0x3ec,-0x4(%rbp)
jmp    11c8 <GetKeyArrows+0xb8>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11c8 <GetKeyArrows+0xb8>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11c8 <GetKeyArrows+0xb8>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GetKeyArrows>:
push   %rax
mov    $0x60,%edi
call   1030 <GetKey@plt>
cmp    $0x1b,%eax
jne    1144 <GetKeyArrows+0x34>
xor    %edi,%edi
call   1030 <GetKey@plt>
cmp    $0x5b,%eax
jne    1144 <GetKeyArrows+0x34>
xor    %edi,%edi
call   1030 <GetKey@plt>
mov    %eax,%ecx
lea    -0x41(%rcx),%edx
lea    0x3a8(%rcx),%eax
cmp    $0x4,%edx
cmovae %ecx,%eax
pop    %rcx
ret

LLVM IR (-O0):
define i32 @GetKeyArrows() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %2
%3 = call i32 @GetKey(i32 96)
store i32 %3, i32* %2
%4 = load i32, i32* %2
%5 = icmp eq i32 %4, 27
br i1 %5, label %6, label %31
6: ; preds = %0
%7 = call i32 @GetKey(i32 0)
store i32 %7, i32* %2
%8 = load i32, i32* %2
%9 = icmp eq i32 %8, 91
br i1 %9, label %10, label %29
10: ; preds = %6
%11 = call i32 @GetKey(i32 0)
store i32 %11, i32* %2
%12 = load i32, i32* %2
%13 = icmp eq i32 %12, 65
br i1 %13, label %14, label %15
14: ; preds = %10
store i32 1001, i32* %1
br label %33
15: ; preds = %10
%16 = load i32, i32* %2
%17 = icmp eq i32 %16, 66
br i1 %17, label %18, label %19
18: ; preds = %15
store i32 1002, i32* %1
br label %33
19: ; preds = %15
%20 = load i32, i32* %2
%21 = icmp eq i32 %20, 67
br i1 %21, label %22, label %23
22: ; preds = %19
store i32 1003, i32* %1
br label %33
23: ; preds = %19
%24 = load i32, i32* %2
%25 = icmp eq i32 %24, 68
br i1 %25, label %26, label %27
26: ; preds = %23
store i32 1004, i32* %1
br label %33
27: ; preds = %23
%28 = load i32, i32* %2
store i32 %28, i32* %1
br label %33
29: ; preds = %6
%30 = load i32, i32* %2
store i32 %30, i32* %1
br label %33
31: ; preds = %0
%32 = load i32, i32* %2
store i32 %32, i32* %1
br label %33
33: ; preds = %31, %29, %27, %26, %22, %18, %14
%34 = load i32, i32* %1
ret i32 %34
}

LLVM IR (-O2):
define i32 @GetKeyArrows() {
%1 = tail call i32 @GetKey(i32 96)
%2 = icmp eq i32 %1, 27
br i1 %2, label %3, label %12
3: ; preds = %0
%4 = tail call i32 @GetKey(i32 0)
%5 = icmp eq i32 %4, 91
br i1 %5, label %6, label %12
6: ; preds = %3
%7 = tail call i32 @GetKey(i32 0)
%8 = add i32 %7, -65
%9 = icmp ult i32 %8, 4
%10 = add i32 %7, 936
%11 = select i1 %9, i32 %10, i32 %7
br label %12
12: ; preds = %6, %0, %3
%13 = phi i32 [ %4, %3 ], [ %1, %0 ], [ %11, %6 ]
ret i32 %13
}