#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*/ fscanf(int /*<<< orphan*/, char *, char *);
char getchar();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stdin;
char tolower(char);
int getPlay(void) {
  char play;
  printf("Do you want to play again?  Enter yes or no: ");
  fscanf(stdin, "%c", &play);
  while (tolower(play) != 'y' && tolower(play) != 'n') {
    while (getchar() != '\n')
      ;
    printf("Please enter yes or no: ");
    fscanf(stdin, "%c", &play);
  }
  while (getchar() != '\n')
    ;
  if (tolower(play) == 'y') {
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<getPlay>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xeb1(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e8d(%rip),%rax
mov    (%rax),%edi
lea    0xeca(%rip),%rsi
lea    -0x5(%rbp),%rdx
call   1040 <fscanf@plt>
movsbl -0x5(%rbp),%edi
call   1060 <tolower@plt>
movsbl %al,%ecx
xor    %eax,%eax
cmp    $0x79,%ecx
mov    %al,-0x6(%rbp)
je     119c <getPlay+0x5c>
movsbl -0x5(%rbp),%edi
call   1060 <tolower@plt>
movsbl %al,%eax
cmp    $0x6e,%eax
setne  %al
mov    %al,-0x6(%rbp)
mov    -0x6(%rbp),%al
test   $0x1,%al
jne    11ac <getPlay+0x6c>
jmp    11f3 <getPlay+0xb3>
jmp    11b1 <getPlay+0x71>
mov    $0x0,%al
call   1050 <getchar@plt>
movsbl %al,%eax
cmp    $0xa,%eax
je     11c9 <getPlay+0x89>
jmp    11b1 <getPlay+0x71>
lea    0xe61(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e0c(%rip),%rax
mov    (%rax),%edi
lea    0xe49(%rip),%rsi
lea    -0x5(%rbp),%rdx
call   1040 <fscanf@plt>
jmp    116d <getPlay+0x2d>
jmp    11f8 <getPlay+0xb8>
mov    $0x0,%al
call   1050 <getchar@plt>
movsbl %al,%eax
cmp    $0xa,%eax
je     1210 <getPlay+0xd0>
jmp    11f8 <getPlay+0xb8>
movsbl -0x5(%rbp),%edi
call   1060 <tolower@plt>
movsbl %al,%eax
cmp    $0x79,%eax
jne    1231 <getPlay+0xf1>
movl   $0x1,-0x4(%rbp)
jmp    1238 <getPlay+0xf8>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getPlay>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xeb1(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e8d(%rip),%r12
mov    (%r12),%edi
lea    0xec8(%rip),%rsi
lea    0x7(%rsp),%rdx
call   1040 <fscanf@plt>
movsbl 0x7(%rsp),%edi
call   1060 <tolower@plt>
cmp    $0x79,%al
je     11e0 <getPlay+0xa0>
lea    0xeac(%rip),%r14
lea    0xea2(%rip),%r15
lea    0x7(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsbl 0x7(%rsp),%edi
call   1060 <tolower@plt>
cmp    $0x6e,%al
je     11e0 <getPlay+0xa0>
xchg   %ax,%ax
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    $0xa,%al
jne    11b0 <getPlay+0x70>
mov    %r14,%rdi
call   1030 <printf@plt>
mov    (%r12),%edi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1040 <fscanf@plt>
movsbl 0x7(%rsp),%edi
call   1060 <tolower@plt>
cmp    $0x79,%al
jne    11a0 <getPlay+0x60>
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    $0xa,%al
jne    11e0 <getPlay+0xa0>
movsbl 0x7(%rsp),%edi
call   1060 <tolower@plt>
xor    %ecx,%ecx
cmp    $0x79,%al
sete   %cl
mov    %ecx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [46 x i8] c"Do you want to play again? Enter yes or no: \00"
@stdin = global i32 0
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [25 x i8] c"Please enter yes or no: \00"
define i32 @getPlay() {
%1 = alloca i32
%2 = alloca i8
%3 = call i32 @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0))
%4 = load i32, i32* @stdin
%5 = call i32 @fscanf(i32 %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %2)
br label %6
6: ; preds = %24, %0
%7 = load i8, i8* %2
%8 = call signext i8 @tolower(i8 signext %7)
%9 = sext i8 %8 to i32
%10 = icmp ne i32 %9, 121
br i1 %10, label %11, label %16
11: ; preds = %6
%12 = load i8, i8* %2
%13 = call signext i8 @tolower(i8 signext %12)
%14 = sext i8 %13 to i32
%15 = icmp ne i32 %14, 110
br label %16
16: ; preds = %11, %6
%17 = phi i1 [ false, %6 ], [ %15, %11 ]
br i1 %17, label %18, label %28
18: ; preds = %16
br label %19
19: ; preds = %23, %18
%20 = call signext i8 (...) @getchar()
%21 = sext i8 %20 to i32
%22 = icmp ne i32 %21, 10
br i1 %22, label %23, label %24
23: ; preds = %19
br label %19
24: ; preds = %19
%25 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
%26 = load i32, i32* @stdin
%27 = call i32 @fscanf(i32 %26, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %2)
br label %6
28: ; preds = %16
br label %29
29: ; preds = %33, %28
%30 = call signext i8 (...) @getchar()
%31 = sext i8 %30 to i32
%32 = icmp ne i32 %31, 10
br i1 %32, label %33, label %34
33: ; preds = %29
br label %29
34: ; preds = %29
%35 = load i8, i8* %2
%36 = call signext i8 @tolower(i8 signext %35)
%37 = sext i8 %36 to i32
%38 = icmp eq i32 %37, 121
br i1 %38, label %39, label %40
39: ; preds = %34
store i32 1, i32* %1
br label %41
40: ; preds = %34
store i32 0, i32* %1
br label %41
41: ; preds = %40, %39
%42 = load i32, i32* %1
ret i32 %42
}

LLVM IR (-O2):
@.str = [46 x i8] c"Do you want to play again? Enter yes or no: \00"
@stdin = global i32 0
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [25 x i8] c"Please enter yes or no: \00"
define i32 @getPlay() {
%1 = alloca i8
%2 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0))
%3 = load i32, i32* @stdin
%4 = call i32 @fscanf(i32 %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %1)
%5 = load i8, i8* %1
%6 = call signext i8 @tolower(i8 signext %5)
%7 = icmp eq i8 %6, 121
br i1 %7, label %22, label %8
8: ; preds = %0, %15
%9 = load i8, i8* %1
%10 = call signext i8 @tolower(i8 signext %9)
%11 = icmp eq i8 %10, 110
br i1 %11, label %22, label %12
12: ; preds = %8, %12
%13 = call signext i8 (...) @getchar()
%14 = icmp eq i8 %13, 10
br i1 %14, label %15, label %12
15: ; preds = %12
%16 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
%17 = load i32, i32* @stdin
%18 = call i32 @fscanf(i32 %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %1)
%19 = load i8, i8* %1
%20 = call signext i8 @tolower(i8 signext %19)
%21 = icmp eq i8 %20, 121
br i1 %21, label %22, label %8
22: ; preds = %8, %15, %0
br label %23
23: ; preds = %22, %23
%24 = call signext i8 (...) @getchar()
%25 = icmp eq i8 %24, 10
br i1 %25, label %26, label %23
26: ; preds = %23
%27 = load i8, i8* %1
%28 = call signext i8 @tolower(i8 signext %27)
%29 = icmp eq i8 %28, 121
%30 = zext i1 %29 to i32
ret i32 %30
}