#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*/ displayendmessage(int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int input();
int endinput(int endofsession) {
  displayendmessage(endofsession);
  for (;;) {
    switch (input()) {
    case '\n':
      return 0;
    case 'N':
      return 0;
    case 'R':
      return -1;
    case 'P':
      return -2;
    case 'q':
      exit(0);
    case 'Q':
      exit(0);
    }
  }
}


x86 assembly (clang, -O0):
<endinput>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%edi
call   1030 <displayendmessage@plt>
xor    %eax,%eax
call   1040 <input@plt>
mov    %eax,%ecx
mov    %ecx,-0xc(%rbp)
sub    $0xa,%eax
je     11b2 <endinput+0x82>
jmp    115d <endinput+0x2d>
mov    -0xc(%rbp),%eax
sub    $0x4e,%eax
je     11be <endinput+0x8e>
jmp    116e <endinput+0x3e>
mov    -0xc(%rbp),%eax
sub    $0x50,%eax
je     11d6 <endinput+0xa6>
jmp    117f <endinput+0x4f>
mov    -0xc(%rbp),%eax
sub    $0x51,%eax
je     11e9 <endinput+0xb9>
jmp    1190 <endinput+0x60>
mov    -0xc(%rbp),%eax
sub    $0x52,%eax
je     11ca <endinput+0x9a>
jmp    11a1 <endinput+0x71>
mov    -0xc(%rbp),%eax
sub    $0x71,%eax
je     11e2 <endinput+0xb2>
jmp    11f0 <endinput+0xc0>
movl   $0x0,-0x4(%rbp)
jmp    11f5 <endinput+0xc5>
movl   $0x0,-0x4(%rbp)
jmp    11f5 <endinput+0xc5>
movl   $0xffffffff,-0x4(%rbp)
jmp    11f5 <endinput+0xc5>
movl   $0xfffffffe,-0x4(%rbp)
jmp    11f5 <endinput+0xc5>
xor    %edi,%edi
call   1050 <exit@plt>
xor    %edi,%edi
call   1050 <exit@plt>
jmp    1143 <endinput+0x13>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<endinput>:
push   %rbx
call   1030 <displayendmessage@plt>
lea    0xec3(%rip),%rbx
jmp    1145 <endinput+0x15>
nop
cmp    $0xa,%eax
je     115d <endinput+0x2d>
xor    %eax,%eax
call   1040 <input@plt>
lea    -0x4e(%rax),%ecx
cmp    $0x23,%ecx
ja     1140 <endinput+0x10>
movslq (%rbx,%rcx,4),%rax
add    %rbx,%rax
jmp    *%rax
xor    %eax,%eax
pop    %rbx
ret
mov    $0xfffffffe,%eax
pop    %rbx
ret
mov    $0xffffffff,%eax
pop    %rbx
ret
xor    %edi,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
define i32 @endinput(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
%5 = call i32 @displayendmessage(i32 %4)
br label %6
6: ; preds = %16, %1
%7 = call i32 (...) @input()
switch i32 %7, label %16 [
i32 10, label %8
i32 78, label %9
i32 82, label %10
i32 80, label %11
i32 113, label %12
i32 81, label %14
]
8: ; preds = %6
store i32 0, i32* %2
br label %17
9: ; preds = %6
store i32 0, i32* %2
br label %17
10: ; preds = %6
store i32 -1, i32* %2
br label %17
11: ; preds = %6
store i32 -2, i32* %2
br label %17
12: ; preds = %6
%13 = call i32 @exit(i32 0)
unreachable
14: ; preds = %6
%15 = call i32 @exit(i32 0)
unreachable
16: ; preds = %6
br label %6
17: ; preds = %11, %10, %9, %8
%18 = load i32, i32* %2
ret i32 %18
}

LLVM IR (-O2):
define i32 @endinput(i32 %0) {
%2 = tail call i32 @displayendmessage(i32 %0)
br label %3
3: ; preds = %3, %1
%4 = tail call i32 (...) @input()
switch i32 %4, label %3 [
i32 10, label %9
i32 78, label %9
i32 82, label %10
i32 80, label %11
i32 113, label %5
i32 81, label %7
]
5: ; preds = %3
%6 = tail call i32 @exit(i32 0)
unreachable
7: ; preds = %3
%8 = tail call i32 @exit(i32 0)
unreachable
9: ; preds = %3, %3
br label %11
10: ; preds = %3
br label %11
11: ; preds = %3, %10, %9
%12 = phi i32 [ 0, %9 ], [ -1, %10 ], [ -2, %3 ]
ret i32 %12
}