#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 EOF;
int getchar();
int /*<<< orphan*/ printf(char *);
int tolower(int);
int getgame() {
  int n;
  int game = 0;
  while (!game) {
    printf("\nload board or play new game l/p ? ");
    n = tolower(getchar());
    if (n == 'p')
      game = 1;
    else if (n == 'l')
      game = 2;
    else if (n == 'q')
      break;
    while (n != '\n' && n != EOF)
      n = getchar();
  }
  return game;
}


x86 assembly (clang, -O0):
<getgame>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1155 <getgame+0x25>
jmp    1201 <getgame+0xd1>
lea    0xea4(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,%edi
call   1050 <tolower@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x70,-0x4(%rbp)
jne    1188 <getgame+0x58>
movl   $0x1,-0x8(%rbp)
jmp    11b7 <getgame+0x87>
cmpl   $0x6c,-0x4(%rbp)
jne    119e <getgame+0x6e>
movl   $0x2,-0x8(%rbp)
jmp    11b2 <getgame+0x82>
cmpl   $0x71,-0x4(%rbp)
jne    11ad <getgame+0x7d>
jmp    1201 <getgame+0xd1>
jmp    11b2 <getgame+0x82>
jmp    11b7 <getgame+0x87>
jmp    11bc <getgame+0x8c>
xor    %eax,%eax
cmpl   $0xa,-0x4(%rbp)
mov    %al,-0x9(%rbp)
je     11dd <getgame+0xad>
mov    -0x4(%rbp),%eax
mov    0x2e13(%rip),%rcx
cmp    (%rcx),%eax
setne  %al
mov    %al,-0x9(%rbp)
mov    -0x9(%rbp),%al
test   $0x1,%al
jne    11ed <getgame+0xbd>
jmp    11fc <getgame+0xcc>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x4(%rbp)
jmp    11bc <getgame+0x8c>
jmp    113f <getgame+0xf>
mov    -0x8(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getgame>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
lea    0xec1(%rip),%r14
mov    0x2ea2(%rip),%rbx
xor    %ebp,%ebp
jmp    1155 <getgame+0x25>
nopw   0x0(%rax,%rax,1)
test   %r15b,%r15b
je     11b2 <getgame+0x82>
mov    %ebp,%r12d
mov    %r14,%rdi
call   1030 <printf@plt>
xor    %r15d,%r15d
xor    %eax,%eax
call   1040 <getchar@plt>
mov    %eax,%edi
call   1050 <tolower@plt>
cmp    $0x6c,%eax
je     1190 <getgame+0x60>
mov    $0x1,%ebp
cmp    $0x70,%eax
je     11a7 <getgame+0x77>
mov    %r12d,%ebp
cmp    $0x71,%eax
je     11b2 <getgame+0x82>
xor    %ebp,%ebp
mov    $0x1,%r15b
jmp    11a7 <getgame+0x77>
nop
mov    $0x2,%ebp
xor    %r15d,%r15d
jmp    11a7 <getgame+0x77>
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    $0xa,%eax
je     1150 <getgame+0x20>
cmp    (%rbx),%eax
jne    11a0 <getgame+0x70>
jmp    1150 <getgame+0x20>
mov    %ebp,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [36 x i8] c"\0Aload board or play new game l/p ? \00"
@EOF = global i32 0
define i32 @getgame() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %2
br label %3
3: ; preds = %36, %0
%4 = load i32, i32* %2
%5 = icmp ne i32 %4, 0
%6 = xor i1 %5, true
br i1 %6, label %7, label %37
7: ; preds = %3
%8 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
%9 = call i32 (...) @getchar()
%10 = call i32 @tolower(i32 %9)
store i32 %10, i32* %1
%11 = load i32, i32* %1
%12 = icmp eq i32 %11, 112
br i1 %12, label %13, label %14
13: ; preds = %7
store i32 1, i32* %2
br label %24
14: ; preds = %7
%15 = load i32, i32* %1
%16 = icmp eq i32 %15, 108
br i1 %16, label %17, label %18
17: ; preds = %14
store i32 2, i32* %2
br label %23
18: ; preds = %14
%19 = load i32, i32* %1
%20 = icmp eq i32 %19, 113
br i1 %20, label %21, label %22
21: ; preds = %18
br label %37
22: ; preds = %18
br label %23
23: ; preds = %22, %17
br label %24
24: ; preds = %23, %13
br label %25
25: ; preds = %34, %24
%26 = load i32, i32* %1
%27 = icmp ne i32 %26, 10
br i1 %27, label %28, label %32
28: ; preds = %25
%29 = load i32, i32* %1
%30 = load i32, i32* @EOF
%31 = icmp ne i32 %29, %30
br label %32
32: ; preds = %28, %25
%33 = phi i1 [ false, %25 ], [ %31, %28 ]
br i1 %33, label %34, label %36
34: ; preds = %32
%35 = call i32 (...) @getchar()
store i32 %35, i32* %1
br label %25
36: ; preds = %32
br label %3
37: ; preds = %21, %3
%38 = load i32, i32* %2
ret i32 %38
}

LLVM IR (-O2):
@.str = [36 x i8] c"\0Aload board or play new game l/p ? \00"
@EOF = global i32 0
define i32 @getgame() {
br label %2
1: ; preds = %16, %9
br i1 %10, label %2, label %22
2: ; preds = %0, %1
%3 = phi i32 [ 0, %0 ], [ %11, %1 ]
%4 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
%5 = tail call i32 (...) @getchar()
%6 = tail call i32 @tolower(i32 %5)
switch i32 %6, label %8 [
i32 112, label %9
i32 108, label %7
i32 113, label %22
]
7: ; preds = %2
br label %9
8: ; preds = %2
br label %9
9: ; preds = %2, %8, %7
%10 = phi i1 [ false, %2 ], [ true, %8 ], [ false, %7 ]
%11 = phi i32 [ 1, %2 ], [ 0, %8 ], [ 2, %7 ]
%12 = icmp ne i32 %6, 10
%13 = load i32, i32* @EOF
%14 = icmp ne i32 %6, %13
%15 = select i1 %12, i1 %14, i1 false
br i1 %15, label %16, label %1
16: ; preds = %9, %16
%17 = tail call i32 (...) @getchar()
%18 = icmp ne i32 %17, 10
%19 = load i32, i32* @EOF
%20 = icmp ne i32 %17, %19
%21 = select i1 %18, i1 %20, i1 false
br i1 %21, label %16, label %1
22: ; preds = %2, %1
%23 = phi i32 [ %3, %2 ], [ %11, %1 ]
ret i32 %23
}