#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*/ buf;

/* Variables and functions */
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stdin;
scalar_t__ strstr(char *, char *);
int readview() {
  int done = 0;
  char buf[32];
  while (!done) {
    printf("\nPlay black or white ? ");
    fgets(buf, sizeof(buf), stdin);
    if (strstr(buf, "black"))
      return 2;
    else if (strstr(buf, "white"))
      return 1;
    else if (strstr(buf, "part"))
      return -3;
    else if (strstr(buf, "quit") || strstr(buf, "exit"))
      return -4;
  }
  return done;
}


x86 assembly (clang, -O0):
<readview>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1155 <readview+0x25>
jmp    123e <readview+0x10e>
lea    0xea4(%rip),%rdi
call   1030 <printf@plt>
lea    -0x30(%rbp),%rdi
mov    0x2e7c(%rip),%rax
mov    (%rax),%edx
mov    $0x20,%esi
call   1040 <fgets@plt>
lea    -0x30(%rbp),%rdi
lea    0xe95(%rip),%rsi
call   1050 <strstr@plt>
cmp    $0x0,%rax
je     119e <readview+0x6e>
movl   $0x2,-0x4(%rbp)
jmp    1244 <readview+0x114>
lea    -0x30(%rbp),%rdi
lea    0xe75(%rip),%rsi
call   1050 <strstr@plt>
cmp    $0x0,%rax
je     11c4 <readview+0x94>
movl   $0x1,-0x4(%rbp)
jmp    1244 <readview+0x114>
lea    -0x30(%rbp),%rdi
lea    0xe55(%rip),%rsi
call   1050 <strstr@plt>
cmp    $0x0,%rax
je     11ea <readview+0xba>
movl   $0xfffffffd,-0x4(%rbp)
jmp    1244 <readview+0x114>
lea    -0x30(%rbp),%rdi
lea    0xe34(%rip),%rsi
call   1050 <strstr@plt>
cmp    $0x0,%rax
jne    121e <readview+0xee>
lea    -0x30(%rbp),%rdi
lea    0xe1f(%rip),%rsi
call   1050 <strstr@plt>
cmp    $0x0,%rax
je     122a <readview+0xfa>
movl   $0xfffffffc,-0x4(%rbp)
jmp    1244 <readview+0x114>
jmp    122f <readview+0xff>
jmp    1234 <readview+0x104>
jmp    1239 <readview+0x109>
jmp    113f <readview+0xf>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readview>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    0x2ea3(%rip),%r14
mov    %rsp,%rbx
lea    0xec9(%rip),%r15
lea    0xec8(%rip),%r12
lea    0xec7(%rip),%r13
mov    $0xfffffffc,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
lea    0xe89(%rip),%rdi
call   1030 <printf@plt>
mov    (%r14),%edx
mov    %rbx,%rdi
mov    $0x20,%esi
call   1040 <fgets@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1050 <strstr@plt>
test   %rax,%rax
jne    11e6 <readview+0xb6>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1050 <strstr@plt>
test   %rax,%rax
jne    11ed <readview+0xbd>
mov    %rbx,%rdi
mov    %r13,%rsi
call   1050 <strstr@plt>
test   %rax,%rax
jne    11f4 <readview+0xc4>
mov    %rbx,%rdi
lea    0xe63(%rip),%rsi
call   1050 <strstr@plt>
test   %rax,%rax
jne    11f9 <readview+0xc9>
mov    %rbx,%rdi
lea    0xe54(%rip),%rsi
call   1050 <strstr@plt>
test   %rax,%rax
je     1170 <readview+0x40>
jmp    11f9 <readview+0xc9>
mov    $0x2,%ebp
jmp    11f9 <readview+0xc9>
mov    $0x1,%ebp
jmp    11f9 <readview+0xc9>
mov    $0xfffffffd,%ebp
mov    %ebp,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [24 x i8] c"\0APlay black or white ? \00"
@stdin = global i32 0
@.str.1 = [6 x i8] c"black\00"
@.str.2 = [6 x i8] c"white\00"
@.str.3 = [5 x i8] c"part\00"
@.str.4 = [5 x i8] c"quit\00"
@.str.5 = [5 x i8] c"exit\00"
define i32 @readview() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [32 x i8]
store i32 0, i32* %2
br label %4
4: ; preds = %39, %0
%5 = load i32, i32* %2
%6 = icmp ne i32 %5, 0
%7 = xor i1 %6, true
br i1 %7, label %8, label %40
8: ; preds = %4
%9 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%10 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 0
%11 = load i32, i32* @stdin
%12 = call i32 @fgets(i8* %10, i32 32, i32 %11)
%13 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 0
%14 = call i64 @strstr(i8* %13, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %8
store i32 2, i32* %1
br label %42
17: ; preds = %8
%18 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 0
%19 = call i64 @strstr(i8* %18, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %17
store i32 1, i32* %1
br label %42
22: ; preds = %17
%23 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 0
%24 = call i64 @strstr(i8* %23, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%25 = icmp ne i64 %24, 0
br i1 %25, label %26, label %27
26: ; preds = %22
store i32 -3, i32* %1
br label %42
27: ; preds = %22
%28 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 0
%29 = call i64 @strstr(i8* %28, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%30 = icmp ne i64 %29, 0
br i1 %30, label %35, label %31
31: ; preds = %27
%32 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 0
%33 = call i64 @strstr(i8* %32, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%34 = icmp ne i64 %33, 0
br i1 %34, label %35, label %36
35: ; preds = %31, %27
store i32 -4, i32* %1
br label %42
36: ; preds = %31
br label %37
37: ; preds = %36
br label %38
38: ; preds = %37
br label %39
39: ; preds = %38
br label %4
40: ; preds = %4
%41 = load i32, i32* %2
store i32 %41, i32* %1
br label %42
42: ; preds = %40, %35, %26, %21, %16
%43 = load i32, i32* %1
ret i32 %43
}

LLVM IR (-O2):
@.str = [24 x i8] c"\0APlay black or white ? \00"
@stdin = global i32 0
@.str.1 = [6 x i8] c"black\00"
@.str.2 = [6 x i8] c"white\00"
@.str.3 = [5 x i8] c"part\00"
@.str.4 = [5 x i8] c"quit\00"
@.str.5 = [5 x i8] c"exit\00"
define i32 @readview() {
%1 = alloca [32 x i8]
%2 = getelementptr inbounds [32 x i8], [32 x i8]* %1, i64 0, i64 0
br label %3
3: ; preds = %18, %0
%4 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%5 = load i32, i32* @stdin
%6 = call i32 @fgets(i8* %2, i32 32, i32 %5)
%7 = call i64 @strstr(i8* %2, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %21
9: ; preds = %3
%10 = call i64 @strstr(i8* %2, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %21
12: ; preds = %9
%13 = call i64 @strstr(i8* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %21
15: ; preds = %12
%16 = call i64 @strstr(i8* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %15
%19 = call i64 @strstr(i8* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%20 = icmp eq i64 %19, 0
br i1 %20, label %3, label %21
21: ; preds = %15, %18, %12, %9, %3
%22 = phi i32 [ 2, %3 ], [ 1, %9 ], [ -3, %12 ], [ -4, %18 ], [ -4, %15 ]
ret i32 %22
}