#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*/ exit(int);
int /*<<< orphan*/ genRandom(char *, int, int *);
int /*<<< orphan*/ getUserInput(char *);
int /*<<< orphan*/ *inLine();
int /*<<< orphan*/ nextPage(int, int *);
int /*<<< orphan*/ out();
int /*<<< orphan*/ previousPage(int, int *);
int /*<<< orphan*/ printSen();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ vend(char *, char ****, int);
void processSelection(char userInput[2], char strs[][6][3][12], int numPages,
                      int *page) {
  if (userInput[0] >= 'a' && userInput[0] <= 'z')
    userInput[0] = userInput[0] - 32;
  switch (userInput[0]) {
  case '<':
    previousPage(numPages, page);
    break;
  case '>':
    nextPage(numPages, page);
    break;
  case 'R':
    genRandom(userInput, numPages, page);
    processSelection(userInput, strs, numPages, page);
    break;
  case 'P':
    if (inLine() != NULL)
      printSen();
    break;
  case 'W':
    out();
    break;
  case 'X':
    exit(1);
  default:
    if (userInput[0] - 'A' <= 6 && userInput[1] - '0' <= 3) {
      vend(userInput, strs, *page);
    } else {
      printf("Invalid selection, please try again\n");
      getUserInput(userInput);
      processSelection(userInput, strs, numPages, page);
      return;
    }
  }
  return;
}


x86 assembly (clang, -O0):
<processSelection>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x61,%eax
jl     11f9 <processSelection+0x49>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x7a,%eax
jg     11f9 <processSelection+0x49>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
sub    $0x20,%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %cl,(%rax)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
add    $0xffffffc4,%eax
mov    %eax,%ecx
mov    %rcx,-0x28(%rbp)
sub    $0x1c,%eax
ja     12a4 <processSelection+0xf4>
mov    -0x28(%rbp),%rax
lea    0xde3(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x14(%rbp),%edi
mov    -0x20(%rbp),%rsi
call   1050 <previousPage@plt>
jmp    1316 <processSelection+0x166>
mov    -0x14(%rbp),%edi
mov    -0x20(%rbp),%rsi
call   1070 <nextPage@plt>
jmp    1316 <processSelection+0x166>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x20(%rbp),%rdx
call   1090 <genRandom@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x20(%rbp),%rcx
call   1030 <processSelection@plt>
jmp    1316 <processSelection+0x166>
mov    $0x0,%al
call   1060 <inLine@plt>
cmp    $0x0,%rax
je     1289 <processSelection+0xd9>
mov    $0x0,%al
call   10d0 <printSen@plt>
jmp    1316 <processSelection+0x166>
mov    $0x0,%al
call   10c0 <out@plt>
jmp    1316 <processSelection+0x166>
mov    $0x1,%edi
call   10b0 <exit@plt>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
sub    $0x41,%eax
cmp    $0x6,%eax
jg     12e3 <processSelection+0x133>
mov    -0x8(%rbp),%rax
movsbl 0x1(%rax),%eax
sub    $0x30,%eax
cmp    $0x3,%eax
jg     12e3 <processSelection+0x133>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%rax
mov    (%rax),%edx
call   10a0 <vend@plt>
jmp    1311 <processSelection+0x161>
lea    0xd8a(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%rdi
call   1080 <getUserInput@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x20(%rbp),%rcx
call   1030 <processSelection@plt>
jmp    131b <processSelection+0x16b>
jmp    1316 <processSelection+0x166>
jmp    131b <processSelection+0x16b>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<processSelection>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r15
mov    %edx,%r13d
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xeb6(%rip),%r12
lea    0xe3b(%rip),%rbp
jmp    11e0 <processSelection+0x40>
nopw   0x0(%rax,%rax,1)
mov    %r12,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1070 <getUserInput@plt>
movzbl (%rbx),%eax
lea    -0x61(%rax),%ecx
cmp    $0x19,%cl
ja     11ef <processSelection+0x4f>
add    $0xe0,%al
mov    %al,(%rbx)
movsbl %al,%ecx
add    $0xffffffc4,%ecx
cmp    $0x1c,%ecx
ja     1220 <processSelection+0x80>
movslq 0x0(%rbp,%rcx,4),%rcx
add    %rbp,%rcx
jmp    *%rcx
mov    %rbx,%rdi
mov    %r13d,%esi
mov    %r15,%rdx
call   1080 <genRandom@plt>
jmp    11e0 <processSelection+0x40>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
cmp    $0x47,%al
jg     11d0 <processSelection+0x30>
cmpb   $0x33,0x1(%rbx)
jg     11d0 <processSelection+0x30>
mov    (%r15),%edx
mov    %rbx,%rdi
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1090 <vend@plt>
mov    %r13d,%edi
mov    %r15,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <previousPage@plt>
mov    %r13d,%edi
mov    %r15,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <nextPage@plt>
xor    %eax,%eax
call   1050 <inLine@plt>
test   %rax,%rax
je     12ae <processSelection+0x10e>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    10c0 <printSen@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    10b0 <out@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0x1,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@.str = [37 x i8] c"Invalid selection, please try again\0A\00"
define void @processSelection(i8* %0, [6 x [3 x [12 x i8]]]* %1, i32 %2, i32* %3) {
%5 = alloca i8*
%6 = alloca [6 x [3 x [12 x i8]]]*
%7 = alloca i32
%8 = alloca i32*
store i8* %0, i8** %5
store [6 x [3 x [12 x i8]]]* %1, [6 x [3 x [12 x i8]]]** %6
store i32 %2, i32* %7
store i32* %3, i32** %8
%9 = load i8*, i8** %5
%10 = getelementptr inbounds i8, i8* %9, i64 0
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
%13 = icmp sge i32 %12, 97
br i1 %13, label %14, label %29
14: ; preds = %4
%15 = load i8*, i8** %5
%16 = getelementptr inbounds i8, i8* %15, i64 0
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = icmp sle i32 %18, 122
br i1 %19, label %20, label %29
20: ; preds = %14
%21 = load i8*, i8** %5
%22 = getelementptr inbounds i8, i8* %21, i64 0
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = sub nsw i32 %24, 32
%26 = trunc i32 %25 to i8
%27 = load i8*, i8** %5
%28 = getelementptr inbounds i8, i8* %27, i64 0
store i8 %26, i8* %28
br label %29
29: ; preds = %20, %14, %4
%30 = load i8*, i8** %5
%31 = getelementptr inbounds i8, i8* %30, i64 0
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
switch i32 %33, label %61 [
i32 60, label %34
i32 62, label %38
i32 82, label %42
i32 80, label %51
i32 87, label %57
i32 88, label %59
]
34: ; preds = %29
%35 = load i32, i32* %7
%36 = load i32*, i32** %8
%37 = call i32 @previousPage(i32 %35, i32* %36)
br label %91
38: ; preds = %29
%39 = load i32, i32* %7
%40 = load i32*, i32** %8
%41 = call i32 @nextPage(i32 %39, i32* %40)
br label %91
42: ; preds = %29
%43 = load i8*, i8** %5
%44 = load i32, i32* %7
%45 = load i32*, i32** %8
%46 = call i32 @genRandom(i8* %43, i32 %44, i32* %45)
%47 = load i8*, i8** %5
%48 = load [6 x [3 x [12 x i8]]]*, [6 x [3 x [12 x i8]]]** %6
%49 = load i32, i32* %7
%50 = load i32*, i32** %8
br label %91
51: ; preds = %29
%52 = call i32* (...) @inLine()
%53 = icmp ne i32* %52, null
br i1 %53, label %54, label %56
54: ; preds = %51
%55 = call i32 (...) @printSen()
br label %56
56: ; preds = %54, %51
br label %91
57: ; preds = %29
%58 = call i32 (...) @out()
br label %91
59: ; preds = %29
%60 = call i32 @exit(i32 1)
unreachable
61: ; preds = %29
%62 = load i8*, i8** %5
%63 = getelementptr inbounds i8, i8* %62, i64 0
%64 = load i8, i8* %63
%65 = sext i8 %64 to i32
%66 = sub nsw i32 %65, 65
%67 = icmp sle i32 %66, 6
br i1 %67, label %68, label %82
68: ; preds = %61
%69 = load i8*, i8** %5
%70 = getelementptr inbounds i8, i8* %69, i64 1
%71 = load i8, i8* %70
%72 = sext i8 %71 to i32
%73 = sub nsw i32 %72, 48
%74 = icmp sle i32 %73, 3
br i1 %74, label %75, label %82
75: ; preds = %68
%76 = load i8*, i8** %5
%77 = load [6 x [3 x [12 x i8]]]*, [6 x [3 x [12 x i8]]]** %6
%78 = bitcast [6 x [3 x [12 x i8]]]* %77 to i8****
%79 = load i32*, i32** %8
%80 = load i32, i32* %79
%81 = call i32 @vend(i8* %76, i8**** %78, i32 %80)
br label %90
82: ; preds = %68, %61
%83 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
%84 = load i8*, i8** %5
%85 = call i32 @getUserInput(i8* %84)
%86 = load i8*, i8** %5
%87 = load [6 x [3 x [12 x i8]]]*, [6 x [3 x [12 x i8]]]** %6
%88 = load i32, i32* %7
%89 = load i32*, i32** %8
br label %92
90: ; preds = %75
br label %91
91: ; preds = %90, %57, %56, %42, %38, %34
br label %92
92: ; preds = %91, %82
ret void
}

LLVM IR (-O2):
@str = [36 x i8] c"Invalid selection, please try again\00"
define void @processSelection(i8* %0, [6 x [3 x [12 x i8]]]* %1, i32 %2, i32* %3) {
%5 = getelementptr inbounds i8, i8* %0, i64 1
br label %6
6: ; preds = %21, %4
%7 = load i8, i8* %0
%8 = add i8 %7, -97
%9 = icmp ult i8 %8, 26
br i1 %9, label %10, label %12
10: ; preds = %6
%11 = add nsw i8 %7, -32
store i8 %11, i8* %0
br label %12
12: ; preds = %10, %6
%13 = phi i8 [ %11, %10 ], [ %7, %6 ]
%14 = sext i8 %13 to i32
switch i32 %14, label %31 [
i32 60, label %15
i32 62, label %17
i32 82, label %19
i32 80, label %22
i32 87, label %27
i32 88, label %29
]
15: ; preds = %12
%16 = tail call i32 @previousPage(i32 %2, i32* %3)
br label %43
17: ; preds = %12
%18 = tail call i32 @nextPage(i32 %2, i32* %3)
br label %43
19: ; preds = %12
%20 = tail call i32 @genRandom(i8* %0, i32 %2, i32* %3)
br label %21
21: ; preds = %19, %40
br label %6
22: ; preds = %12
%23 = tail call i32* (...) @inLine()
%24 = icmp eq i32* %23, null
br i1 %24, label %43, label %25
25: ; preds = %22
%26 = tail call i32 (...) @printSen()
br label %43
27: ; preds = %12
%28 = tail call i32 (...) @out()
br label %43
29: ; preds = %12
%30 = tail call i32 @exit(i32 1)
unreachable
31: ; preds = %12
%32 = icmp slt i8 %13, 72
br i1 %32, label %33, label %40
33: ; preds = %31
%34 = load i8, i8* %5
%35 = icmp slt i8 %34, 52
br i1 %35, label %36, label %40
36: ; preds = %33
%37 = bitcast [6 x [3 x [12 x i8]]]* %1 to i8****
%38 = load i32, i32* %3
%39 = tail call i32 @vend(i8* %0, i8**** %37, i32 %38)
br label %43
40: ; preds = %33, %31
%41 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str, i64 0, i64 0))
%42 = tail call i32 @getUserInput(i8* %0)
br label %21
43: ; preds = %15, %17, %27, %36, %25, %22
ret void
}