#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 */
unsigned char _getch();
unsigned char handleUser() {
  unsigned char c;
  do {
    c = _getch();
    if (c == 27) {
      c = _getch();
      if (c == 91) {
        c = _getch();
        return c;
      }
    } else if (c == 10) {
      return c;
    }
  } while (c != 'e');
  return c;
}


x86 assembly (clang, -O0):
<handleUser>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1030 <_getch@plt>
mov    %al,-0x2(%rbp)
movzbl -0x2(%rbp),%eax
cmp    $0x1b,%eax
jne    1160 <handleUser+0x50>
mov    $0x0,%al
call   1030 <_getch@plt>
mov    %al,-0x2(%rbp)
movzbl -0x2(%rbp),%eax
cmp    $0x5b,%eax
jne    115b <handleUser+0x4b>
mov    $0x0,%al
call   1030 <_getch@plt>
mov    %al,-0x2(%rbp)
mov    -0x2(%rbp),%al
mov    %al,-0x1(%rbp)
jmp    1195 <handleUser+0x85>
jmp    117d <handleUser+0x6d>
movzbl -0x2(%rbp),%eax
cmp    $0xa,%eax
jne    1178 <handleUser+0x68>
mov    -0x2(%rbp),%al
mov    %al,-0x1(%rbp)
jmp    1195 <handleUser+0x85>
jmp    117d <handleUser+0x6d>
jmp    1182 <handleUser+0x72>
movzbl -0x2(%rbp),%eax
cmp    $0x65,%eax
jne    1118 <handleUser+0x8>
mov    -0x2(%rbp),%al
mov    %al,-0x1(%rbp)
movzbl -0x1(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<handleUser>:
push   %rax
jmp    112f <handleUser+0x1f>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %eax,%eax
call   1030 <_getch@plt>
cmp    $0x5b,%al
je     1144 <handleUser+0x34>
cmp    $0x65,%al
je     1140 <handleUser+0x30>
xor    %eax,%eax
call   1030 <_getch@plt>
cmp    $0x1b,%al
je     1120 <handleUser+0x10>
cmp    $0xa,%al
jne    112b <handleUser+0x1b>
pop    %rcx
ret
mov    $0x65,%al
pop    %rcx
ret
xor    %eax,%eax
pop    %rcx
jmp    1030 <_getch@plt>

LLVM IR (-O0):
define zeroext i8 @handleUser() {
%1 = alloca i8
%2 = alloca i8
br label %3
3: ; preds = %25, %0
%4 = call zeroext i8 (...) @_getch()
store i8 %4, i8* %2
%5 = load i8, i8* %2
%6 = zext i8 %5 to i32
%7 = icmp eq i32 %6, 27
br i1 %7, label %8, label %17
8: ; preds = %3
%9 = call zeroext i8 (...) @_getch()
store i8 %9, i8* %2
%10 = load i8, i8* %2
%11 = zext i8 %10 to i32
%12 = icmp eq i32 %11, 91
br i1 %12, label %13, label %16
13: ; preds = %8
%14 = call zeroext i8 (...) @_getch()
store i8 %14, i8* %2
%15 = load i8, i8* %2
store i8 %15, i8* %1
br label %31
16: ; preds = %8
br label %24
17: ; preds = %3
%18 = load i8, i8* %2
%19 = zext i8 %18 to i32
%20 = icmp eq i32 %19, 10
br i1 %20, label %21, label %23
21: ; preds = %17
%22 = load i8, i8* %2
store i8 %22, i8* %1
br label %31
23: ; preds = %17
br label %24
24: ; preds = %23, %16
br label %25
25: ; preds = %24
%26 = load i8, i8* %2
%27 = zext i8 %26 to i32
%28 = icmp ne i32 %27, 101
br i1 %28, label %3, label %29
29: ; preds = %25
%30 = load i8, i8* %2
store i8 %30, i8* %1
br label %31
31: ; preds = %29, %21, %13
%32 = load i8, i8* %1
ret i8 %32
}

LLVM IR (-O2):
define zeroext i8 @handleUser() {
br label %1
1: ; preds = %8, %0
%2 = tail call zeroext i8 (...) @_getch()
switch i8 %2, label %8 [
i8 27, label %3
i8 10, label %11
]
3: ; preds = %1
%4 = tail call zeroext i8 (...) @_getch()
%5 = icmp eq i8 %4, 91
br i1 %5, label %6, label %8
6: ; preds = %3
%7 = tail call zeroext i8 (...) @_getch()
br label %11
8: ; preds = %1, %3
%9 = phi i8 [ %4, %3 ], [ %2, %1 ]
%10 = icmp eq i8 %9, 101
br i1 %10, label %11, label %1
11: ; preds = %8, %1, %6
%12 = phi i8 [ %7, %6 ], [ 101, %8 ], [ %2, %1 ]
ret i8 %12
}