#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*/ fclose(int /*<<< orphan*/ *);
scalar_t__ feof(int /*<<< orphan*/ *);
char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *, char);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ scanf(char *, char *);
void greet(void) {
  char answer;
  puts("DO YOU NEED INSTRUCTIONS ON HOW TO PLAY THE GAME Y/N: ");
  do {
    scanf("%c", &answer);
    if (answer == 'y' || answer == 'Y') {
      FILE *fp = fopen("instructions.txt", "r");
      if (fp == NULL) {
        puts("Error: could not find instructions.txt");
        return;
      }
      while (1) {
        char c = fgetc(fp);
        if (feof(fp))
          break;
        else if (c == '\"')
          continue;
        else
          printf("%c", c);
      }
      fclose(fp);
      return;
    } else if (answer == 'n' || answer == 'N') {
      return;
    } else {
      puts("INVALID SELECTION. PLEASE ENTER 'y' OR 'n'");
    }
  } while ((answer != 'y' || answer != 'Y') ||
           (answer != 'n' || answer != 'N'));
  return;
}


x86 assembly (clang, -O0):
<greet>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xe81(%rip),%rdi
call   1030 <puts@plt>
lea    0xeac(%rip),%rdi
lea    -0x1(%rbp),%rsi
call   1080 <scanf@plt>
movsbl -0x1(%rbp),%eax
cmp    $0x79,%eax
je     11ae <greet+0x3e>
movsbl -0x1(%rbp),%eax
cmp    $0x59,%eax
jne    1244 <greet+0xd4>
lea    0xe9d(%rip),%rdi
lea    0xe7e(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11e1 <greet+0x71>
lea    0xe65(%rip),%rdi
call   1030 <puts@plt>
jmp    12d2 <greet+0x162>
jmp    11e6 <greet+0x76>
mov    -0x10(%rbp),%rdi
call   1060 <fgetc@plt>
mov    %al,-0x11(%rbp)
mov    -0x10(%rbp),%rdi
call   1070 <feof@plt>
cmp    $0x0,%rax
je     120a <greet+0x9a>
jmp    1236 <greet+0xc6>
movsbl -0x11(%rbp),%eax
cmp    $0x22,%eax
jne    121c <greet+0xac>
jmp    11e6 <greet+0x76>
lea    0xe14(%rip),%rdi
movsbl -0x11(%rbp),%esi
call   1050 <printf@plt>
jmp    1231 <greet+0xc1>
jmp    11e6 <greet+0x76>
mov    -0x10(%rbp),%rdi
call   1040 <fclose@plt>
jmp    12d2 <greet+0x162>
movsbl -0x1(%rbp),%eax
cmp    $0x6e,%eax
je     125e <greet+0xee>
movsbl -0x1(%rbp),%eax
cmp    $0x4e,%eax
jne    1263 <greet+0xf3>
jmp    12d2 <greet+0x162>
lea    0xdf9(%rip),%rdi
call   1030 <puts@plt>
jmp    1274 <greet+0x104>
jmp    1279 <greet+0x109>
movsbl -0x1(%rbp),%ecx
mov    $0x1,%al
cmp    $0x79,%ecx
mov    %al,-0x12(%rbp)
jne    12c2 <greet+0x152>
movsbl -0x1(%rbp),%ecx
mov    $0x1,%al
cmp    $0x59,%ecx
mov    %al,-0x12(%rbp)
jne    12c2 <greet+0x152>
movsbl -0x1(%rbp),%ecx
mov    $0x1,%al
cmp    $0x6e,%ecx
mov    %al,-0x13(%rbp)
jne    12bc <greet+0x14c>
movsbl -0x1(%rbp),%eax
cmp    $0x4e,%eax
setne  %al
mov    %al,-0x13(%rbp)
mov    -0x13(%rbp),%al
mov    %al,-0x12(%rbp)
mov    -0x12(%rbp),%al
test   $0x1,%al
jne    1184 <greet+0x14>
jmp    12d2 <greet+0x162>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<greet>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xe80(%rip),%rdi
call   1030 <puts@plt>
lea    0xeab(%rip),%r14
lea    0xf(%rsp),%rbx
lea    0xecb(%rip),%r15
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1080 <scanf@plt>
movzbl 0xf(%rsp),%eax
and    $0xdf,%al
cmp    $0x4e,%al
je     120c <greet+0x9c>
cmp    $0x59,%al
je     11c4 <greet+0x54>
mov    %r15,%rdi
call   1030 <puts@plt>
jmp    11a0 <greet+0x30>
lea    0xe87(%rip),%rdi
lea    0xe68(%rip),%rsi
call   1090 <fopen@plt>
test   %rax,%rax
je     1200 <greet+0x90>
mov    %rax,%r15
mov    %rax,%rdi
call   1060 <fgetc@plt>
mov    %eax,%ebx
mov    %r15,%rdi
call   1070 <feof@plt>
test   %rax,%rax
je     1216 <greet+0xa6>
mov    %r15,%rdi
call   1040 <fclose@plt>
jmp    120c <greet+0x9c>
lea    0xe35(%rip),%rdi
call   1030 <puts@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
lea    0xe1a(%rip),%r14
jmp    1237 <greet+0xc7>
nop
mov    %r15,%rdi
call   1060 <fgetc@plt>
mov    %eax,%ebx
mov    %r15,%rdi
call   1070 <feof@plt>
test   %rax,%rax
jne    11f6 <greet+0x86>
cmp    $0x22,%bl
je     1220 <greet+0xb0>
movsbl %bl,%esi
mov    %r14,%rdi
call   1050 <printf@plt>
jmp    1220 <greet+0xb0>

LLVM IR (-O0):
@.str = [55 x i8] c"DO YOU NEED INSTRUCTIONS ON HOW TO PLAY THE GAME Y/N: \00"
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [17 x i8] c"instructions.txt\00"
@.str.3 = [2 x i8] c"r\00"
@.str.4 = [39 x i8] c"Error: could not find instructions.txt\00"
@.str.5 = [43 x i8] c"INVALID SELECTION. PLEASE ENTER 'y' OR 'n'\00"
define void @greet() {
%1 = alloca i8
%2 = alloca i32*
%3 = alloca i8
%4 = call i32 @puts(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str, i64 0, i64 0))
br label %5
5: ; preds = %72, %0
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %1)
%7 = load i8, i8* %1
%8 = sext i8 %7 to i32
%9 = icmp eq i32 %8, 121
br i1 %9, label %14, label %10
10: ; preds = %5
%11 = load i8, i8* %1
%12 = sext i8 %11 to i32
%13 = icmp eq i32 %12, 89
br i1 %13, label %14, label %41
14: ; preds = %10, %5
%15 = call i32* @fopen(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %15, i32** %2
%16 = load i32*, i32** %2
%17 = icmp eq i32* %16, null
br i1 %17, label %18, label %20
18: ; preds = %14
%19 = call i32 @puts(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.4, i64 0, i64 0))
br label %75
20: ; preds = %14
br label %21
21: ; preds = %20, %32, %37
%22 = load i32*, i32** %2
%23 = call signext i8 @fgetc(i32* %22)
store i8 %23, i8* %3
%24 = load i32*, i32** %2
%25 = call i64 @feof(i32* %24)
%26 = icmp ne i64 %25, 0
br i1 %26, label %27, label %28
27: ; preds = %21
br label %38
28: ; preds = %21
%29 = load i8, i8* %3
%30 = sext i8 %29 to i32
%31 = icmp eq i32 %30, 34
br i1 %31, label %32, label %33
32: ; preds = %28
br label %21
33: ; preds = %28
%34 = load i8, i8* %3
%35 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8 signext %34)
br label %36
36: ; preds = %33
br label %37
37: ; preds = %36
br label %21
38: ; preds = %27
%39 = load i32*, i32** %2
%40 = call i32 @fclose(i32* %39)
br label %75
41: ; preds = %10
%42 = load i8, i8* %1
%43 = sext i8 %42 to i32
%44 = icmp eq i32 %43, 110
br i1 %44, label %49, label %45
45: ; preds = %41
%46 = load i8, i8* %1
%47 = sext i8 %46 to i32
%48 = icmp eq i32 %47, 78
br i1 %48, label %49, label %50
49: ; preds = %45, %41
br label %75
50: ; preds = %45
%51 = call i32 @puts(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.5, i64 0, i64 0))
br label %52
52: ; preds = %50
br label %53
53: ; preds = %52
br label %54
54: ; preds = %53
%55 = load i8, i8* %1
%56 = sext i8 %55 to i32
%57 = icmp ne i32 %56, 121
br i1 %57, label %72, label %58
58: ; preds = %54
%59 = load i8, i8* %1
%60 = sext i8 %59 to i32
%61 = icmp ne i32 %60, 89
br i1 %61, label %72, label %62
62: ; preds = %58
%63 = load i8, i8* %1
%64 = sext i8 %63 to i32
%65 = icmp ne i32 %64, 110
br i1 %65, label %70, label %66
66: ; preds = %62
%67 = load i8, i8* %1
%68 = sext i8 %67 to i32
%69 = icmp ne i32 %68, 78
br label %70
70: ; preds = %66, %62
%71 = phi i1 [ true, %62 ], [ %69, %66 ]
br label %72
72: ; preds = %70, %58, %54
%73 = phi i1 [ true, %58 ], [ true, %54 ], [ %71, %70 ]
br i1 %73, label %5, label %74
74: ; preds = %72
br label %75
75: ; preds = %74, %49, %38, %18
ret void
}

LLVM IR (-O2):
@.str = [55 x i8] c"DO YOU NEED INSTRUCTIONS ON HOW TO PLAY THE GAME Y/N: \00"
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [17 x i8] c"instructions.txt\00"
@.str.3 = [2 x i8] c"r\00"
@.str.4 = [39 x i8] c"Error: could not find instructions.txt\00"
@.str.5 = [43 x i8] c"INVALID SELECTION. PLEASE ENTER 'y' OR 'n'\00"
define void @greet() {
%1 = alloca i8
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @.str, i64 0, i64 0))
br label %3
3: ; preds = %27, %0
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %1)
%5 = load i8, i8* %1
%6 = and i8 %5, -33
switch i8 %6, label %27 [
i8 89, label %7
i8 78, label %29
]
7: ; preds = %3
%8 = call i32* @fopen(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%9 = icmp eq i32* %8, null
br i1 %9, label %14, label %10
10: ; preds = %7
%11 = call signext i8 @fgetc(i32* %8)
%12 = call i64 @feof(i32* %8)
%13 = icmp eq i64 %12, 0
br i1 %13, label %16, label %25
14: ; preds = %7
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.4, i64 0, i64 0))
br label %29
16: ; preds = %10, %21
%17 = phi i8 [ %22, %21 ], [ %11, %10 ]
%18 = icmp eq i8 %17, 34
br i1 %18, label %21, label %19
19: ; preds = %16
%20 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8 signext %17)
br label %21
21: ; preds = %16, %19
%22 = call signext i8 @fgetc(i32* %8)
%23 = call i64 @feof(i32* %8)
%24 = icmp eq i64 %23, 0
br i1 %24, label %16, label %25
25: ; preds = %21, %10
%26 = call i32 @fclose(i32* %8)
br label %29
27: ; preds = %3
%28 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.5, i64 0, i64 0))
br label %3
29: ; preds = %3, %14, %25
ret void
}