#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fillArr(char ****, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ getUserInput(char *);
int /*<<< orphan*/ *importFile(char *);
int /*<<< orphan*/ printMachine(char ****, int, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ processSelection(char *, char ****, int, int *);
int setPages(int /*<<< orphan*/ *);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(int argc, char *argv[]) {
  int numPages;
  int currentPage = 0;
  char userInput[2];
  FILE *inputFile;
  if (argc != 2) {
    printf("File required\nUsage: ./a.out input.txt\n");
    exit(1);
  }
  inputFile = importFile(argv[1]);
  numPages = setPages(inputFile);
  fclose(inputFile);
  inputFile = importFile(argv[1]);
  char strs[numPages][6][3][12];
  fillArr(strs, numPages, inputFile);
  fclose(inputFile);
  srand(time(NULL));
  while (userInput[0] != 'X') {
    if (userInput[0] != 'P' && userInput[0] != 'W')
      printMachine(strs, numPages, currentPage);
    getUserInput(userInput);
    processSelection(userInput, strs, numPages, &currentPage);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     11ed <main+0x3d>
lea    0xe22(%rip),%rdi
call   1060 <printf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1080 <importFile@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
call   10b0 <setPages@plt>
mov    %eax,-0x14(%rbp)
mov    -0x28(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1080 <importFile@plt>
mov    %rax,-0x28(%rbp)
mov    -0x14(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x30(%rbp)
imul   $0xd8,%rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x40(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x38(%rbp)
mov    -0x14(%rbp),%esi
mov    -0x28(%rbp),%rdx
call   1070 <fillArr@plt>
mov    -0x28(%rbp),%rdi
call   1050 <fclose@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10c0 <time@plt>
mov    %eax,%edi
call   1090 <srand@plt>
movsbl -0x1a(%rbp),%eax
cmp    $0x58,%eax
je     12cb <main+0x11b>
movsbl -0x1a(%rbp),%eax
cmp    $0x50,%eax
je     12a9 <main+0xf9>
movsbl -0x1a(%rbp),%eax
cmp    $0x57,%eax
je     12a9 <main+0xf9>
mov    -0x40(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
call   1030 <printMachine@plt>
lea    -0x1a(%rbp),%rdi
call   10a0 <getUserInput@plt>
mov    -0x40(%rbp),%rsi
lea    -0x1a(%rbp),%rdi
mov    -0x14(%rbp),%edx
lea    -0x18(%rbp),%rcx
call   1040 <processSelection@plt>
jmp    1273 <main+0xc3>
movl   $0x0,-0x4(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
movl   $0x0,-0x30(%rbp)
cmp    $0x2,%edi
jne    129d <main+0xed>
mov    %rsi,%r15
mov    0x8(%rsi),%rdi
call   1080 <importFile@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   10b0 <setPages@plt>
mov    %eax,%r14d
mov    %rbx,%rdi
call   1060 <fclose@plt>
mov    0x8(%r15),%rdi
call   1080 <importFile@plt>
mov    %rax,%rbx
mov    %rsp,%r13
mov    %r14d,%eax
mov    %rsp,%r15
imul   $0xd8,%rax,%rax
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r15
mov    %r15,%rsp
mov    %r15,%rdi
mov    %r14d,%esi
mov    %rbx,%rdx
call   1070 <fillArr@plt>
mov    %rbx,%rdi
call   1060 <fclose@plt>
xor    %edi,%edi
call   10c0 <time@plt>
mov    %eax,%edi
call   1090 <srand@plt>
lea    -0x2a(%rbp),%rbx
lea    -0x30(%rbp),%r12
jmp    1269 <main+0xb9>
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   10a0 <getUserInput@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r14d,%edx
mov    %r12,%rcx
call   1040 <processSelection@plt>
movzbl -0x2a(%rbp),%eax
cmp    $0x50,%al
je     1250 <main+0xa0>
cmp    $0x57,%al
je     1250 <main+0xa0>
cmp    $0x58,%al
je     1289 <main+0xd9>
mov    -0x30(%rbp),%edx
mov    %r15,%rdi
mov    %r14d,%esi
call   1030 <printMachine@plt>
jmp    1250 <main+0xa0>
mov    %r13,%rsp
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd5c(%rip),%rdi
call   1050 <puts@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>

LLVM IR (-O0):
@.str = [40 x i8] c"File required\0AUsage: ./a.out input.txt\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca [2 x i8]
%9 = alloca i32*
%10 = alloca i8*
%11 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %7
%12 = load i32, i32* %4
%13 = icmp ne i32 %12, 2
br i1 %13, label %14, label %17
14: ; preds = %2
%15 = call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0))
%16 = call i32 @exit(i32 1)
unreachable
17: ; preds = %2
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = call i32* @importFile(i8* %20)
store i32* %21, i32** %9
%22 = load i32*, i32** %9
%23 = call i32 @setPages(i32* %22)
store i32 %23, i32* %6
%24 = load i32*, i32** %9
%25 = call i32 @fclose(i32* %24)
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 1
%28 = load i8*, i8** %27
%29 = call i32* @importFile(i8* %28)
store i32* %29, i32** %9
%30 = load i32, i32* %6
%31 = zext i32 %30 to i64
%32 = call i8* @llvm.stacksave()
store i8* %32, i8** %10
%33 = alloca [6 x [3 x [12 x i8]]], i64 %31
store i64 %31, i64* %11
%34 = bitcast [6 x [3 x [12 x i8]]]* %33 to i8****
%35 = load i32, i32* %6
%36 = load i32*, i32** %9
%37 = call i32 @fillArr(i8**** %34, i32 %35, i32* %36)
%38 = load i32*, i32** %9
%39 = call i32 @fclose(i32* %38)
%40 = call i32 @time(i32* null)
%41 = call i32 @srand(i32 %40)
br label %42
42: ; preds = %62, %17
%43 = getelementptr inbounds [2 x i8], [2 x i8]* %8, i64 0, i64 0
%44 = load i8, i8* %43
%45 = sext i8 %44 to i32
%46 = icmp ne i32 %45, 88
br i1 %46, label %47, label %69
47: ; preds = %42
%48 = getelementptr inbounds [2 x i8], [2 x i8]* %8, i64 0, i64 0
%49 = load i8, i8* %48
%50 = sext i8 %49 to i32
%51 = icmp ne i32 %50, 80
br i1 %51, label %52, label %62
52: ; preds = %47
%53 = getelementptr inbounds [2 x i8], [2 x i8]* %8, i64 0, i64 0
%54 = load i8, i8* %53
%55 = sext i8 %54 to i32
%56 = icmp ne i32 %55, 87
br i1 %56, label %57, label %62
57: ; preds = %52
%58 = bitcast [6 x [3 x [12 x i8]]]* %33 to i8****
%59 = load i32, i32* %6
%60 = load i32, i32* %7
%61 = call i32 @printMachine(i8**** %58, i32 %59, i32 %60)
br label %62
62: ; preds = %57, %52, %47
%63 = getelementptr inbounds [2 x i8], [2 x i8]* %8, i64 0, i64 0
%64 = call i32 @getUserInput(i8* %63)
%65 = getelementptr inbounds [2 x i8], [2 x i8]* %8, i64 0, i64 0
%66 = bitcast [6 x [3 x [12 x i8]]]* %33 to i8****
%67 = load i32, i32* %6
%68 = call i32 @processSelection(i8* %65, i8**** %66, i32 %67, i32* %7)
br label %42
69: ; preds = %42
store i32 0, i32* %3
%70 = load i8*, i8** %10
%71 = load i32, i32* %3
ret i32 %71
}

LLVM IR (-O2):
@str = [39 x i8] c"File required\0AUsage: ./a.out input.txt\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca [2 x i8]
%5 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%6 = getelementptr inbounds [2 x i8], [2 x i8]* %4, i64 0, i64 0
%7 = icmp eq i32 %0, 2
br i1 %7, label %11, label %8
8: ; preds = %2
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str, i64 0, i64 0))
%10 = tail call i32 @exit(i32 1)
unreachable
11: ; preds = %2
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = load i8*, i8** %12
%14 = tail call i32* @importFile(i8* %13)
%15 = tail call i32 @setPages(i32* %14)
%16 = tail call i32 @fclose(i32* %14)
%17 = load i8*, i8** %12
%18 = tail call i32* @importFile(i8* %17)
%19 = zext i32 %15 to i64
%20 = tail call i8* @llvm.stacksave()
%21 = mul nuw nsw i64 %19, 27
%22 = alloca i8***, i64 %21
%23 = call i32 @fillArr(i8**** %22, i32 %15, i32* %18)
%24 = call i32 @fclose(i32* %18)
%25 = call i32 @time(i32* null)
%26 = call i32 @srand(i32 %25)
br label %27
27: ; preds = %32, %11
%28 = load i8, i8* %6
switch i8 %28, label %29 [
i8 88, label %35
i8 87, label %32
i8 80, label %32
]
29: ; preds = %27
%30 = load i32, i32* %3
%31 = call i32 @printMachine(i8**** %22, i32 %15, i32 %30)
br label %32
32: ; preds = %27, %27, %29
%33 = call i32 @getUserInput(i8* %6)
%34 = call i32 @processSelection(i8* %6, i8**** %22, i32 %15, i32* %3)
br label %27
35: ; preds = %27
ret i32 0
}