#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*/ abort();
int getch();
scalar_t__ islower(int);
char toupper(int);
char GetChar() {
  int c;
  c = getch();
  if (c < 0)
    abort();
  if (c == '\033') {
    if ((c = getch()) == '[') {
      c = getch();
      switch (c) {
      case 'A':
        c = 'U';
        break;
      case 'B':
        c = 'D';
        break;
      case 'C':
        c = 'R';
        break;
      case 'D':
        c = 'L';
        break;
      default:
        c = '?';
        break;
      }
    } else
      c = '?';
  }
  if (islower(c))
    return toupper(c);
  else
    return c;
}


x86 assembly (clang, -O0):
<GetChar>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1060 <getch@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jge    1163 <GetChar+0x23>
mov    $0x0,%al
call   1030 <abort@plt>
cmpl   $0x1b,-0x8(%rbp)
jne    11fb <GetChar+0xbb>
mov    $0x0,%al
call   1060 <getch@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x5b,%eax
jne    11ef <GetChar+0xaf>
xor    %eax,%eax
call   1060 <getch@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
add    $0xffffffbf,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x3,%eax
ja     11e3 <GetChar+0xa3>
mov    -0x10(%rbp),%rax
lea    0xe56(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x55,-0x8(%rbp)
jmp    11ea <GetChar+0xaa>
movl   $0x44,-0x8(%rbp)
jmp    11ea <GetChar+0xaa>
movl   $0x52,-0x8(%rbp)
jmp    11ea <GetChar+0xaa>
movl   $0x4c,-0x8(%rbp)
jmp    11ea <GetChar+0xaa>
movl   $0x3f,-0x8(%rbp)
jmp    11f6 <GetChar+0xb6>
movl   $0x3f,-0x8(%rbp)
jmp    11fb <GetChar+0xbb>
mov    -0x8(%rbp),%edi
call   1040 <islower@plt>
cmp    $0x0,%rax
je     121d <GetChar+0xdd>
mov    -0x8(%rbp),%edi
call   1050 <toupper@plt>
mov    %al,-0x1(%rbp)
jmp    1223 <GetChar+0xe3>
mov    -0x8(%rbp),%eax
mov    %al,-0x1(%rbp)
movsbl -0x1(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GetChar>:
push   %rbx
xor    %eax,%eax
call   1060 <getch@plt>
test   %eax,%eax
js     1197 <GetChar+0x57>
mov    %eax,%ebx
cmp    $0x1b,%eax
jne    117f <GetChar+0x3f>
xor    %eax,%eax
call   1060 <getch@plt>
mov    $0x3f,%ebx
cmp    $0x5b,%eax
jne    117f <GetChar+0x3f>
xor    %eax,%eax
call   1060 <getch@plt>
add    $0xffffffbf,%eax
cmp    $0x3,%eax
ja     117f <GetChar+0x3f>
cltq
lea    0xe84(%rip),%rcx
mov    (%rcx,%rax,4),%ebx
mov    %ebx,%edi
call   1040 <islower@plt>
test   %rax,%rax
je     1193 <GetChar+0x53>
mov    %ebx,%edi
pop    %rbx
jmp    1050 <toupper@plt>
mov    %ebx,%eax
pop    %rbx
ret
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
define signext i8 @GetChar() {
%1 = alloca i8
%2 = alloca i32
%3 = call i32 (...) @getch()
store i32 %3, i32* %2
%4 = load i32, i32* %2
%5 = icmp slt i32 %4, 0
br i1 %5, label %6, label %8
6: ; preds = %0
%7 = call i32 (...) @abort()
unreachable
8: ; preds = %0
%9 = load i32, i32* %2
%10 = icmp eq i32 %9, 27
br i1 %10, label %11, label %25
11: ; preds = %8
%12 = call i32 (...) @getch()
store i32 %12, i32* %2
%13 = icmp eq i32 %12, 91
br i1 %13, label %14, label %23
14: ; preds = %11
%15 = call i32 (...) @getch()
store i32 %15, i32* %2
%16 = load i32, i32* %2
switch i32 %16, label %21 [
i32 65, label %17
i32 66, label %18
i32 67, label %19
i32 68, label %20
]
17: ; preds = %14
store i32 85, i32* %2
br label %22
18: ; preds = %14
store i32 68, i32* %2
br label %22
19: ; preds = %14
store i32 82, i32* %2
br label %22
20: ; preds = %14
store i32 76, i32* %2
br label %22
21: ; preds = %14
store i32 63, i32* %2
br label %22
22: ; preds = %21, %20, %19, %18, %17
br label %24
23: ; preds = %11
store i32 63, i32* %2
br label %24
24: ; preds = %23, %22
br label %25
25: ; preds = %24, %8
%26 = load i32, i32* %2
%27 = call i64 @islower(i32 %26)
%28 = icmp ne i64 %27, 0
br i1 %28, label %29, label %32
29: ; preds = %25
%30 = load i32, i32* %2
%31 = call signext i8 @toupper(i32 %30)
store i8 %31, i8* %1
br label %35
32: ; preds = %25
%33 = load i32, i32* %2
%34 = trunc i32 %33 to i8
store i8 %34, i8* %1
br label %35
35: ; preds = %32, %29
%36 = load i8, i8* %1
ret i8 %36
}

LLVM IR (-O2):
@switch.table.GetChar = [4 x i32] [i32 85, i32 68, i32 82, i32 76]
define signext i8 @GetChar() {
%1 = tail call i32 (...) @getch()
%2 = icmp slt i32 %1, 0
br i1 %2, label %3, label %5
3: ; preds = %0
%4 = tail call i32 (...) @abort()
unreachable
5: ; preds = %0
%6 = icmp eq i32 %1, 27
br i1 %6, label %7, label %18
7: ; preds = %5
%8 = tail call i32 (...) @getch()
%9 = icmp eq i32 %8, 91
br i1 %9, label %10, label %18
10: ; preds = %7
%11 = tail call i32 (...) @getch()
%12 = add i32 %11, -65
%13 = icmp ult i32 %12, 4
br i1 %13, label %14, label %18
14: ; preds = %10
%15 = sext i32 %12 to i64
%16 = getelementptr inbounds [4 x i32], [4 x i32]* @switch.table.GetChar, i64 0, i64 %15
%17 = load i32, i32* %16
br label %18
18: ; preds = %10, %14, %7, %5
%19 = phi i32 [ %1, %5 ], [ 63, %7 ], [ %17, %14 ], [ 63, %10 ]
%20 = tail call i64 @islower(i32 %19)
%21 = icmp eq i64 %20, 0
br i1 %21, label %24, label %22
22: ; preds = %18
%23 = tail call signext i8 @toupper(i32 %19)
br label %26
24: ; preds = %18
%25 = trunc i32 %19 to i8
br label %26
26: ; preds = %24, %22
%27 = phi i8 [ %23, %22 ], [ %25, %24 ]
ret i8 %27
}