#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 getview() {
  int n;
  int color = 0;
  while (!color) {
    printf("\ntype b/w to select your color: ");
    n = tolower(getchar());
    if (n == 'b')
      color = 2;
    else if (n == 'w')
      color = 1;
    else if (n == 'q')
      break;
    while (n != '\n' && n != EOF)
      n = getchar();
  }
  return color;
}


x86 assembly (clang, -O0):
<getview>:
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 <getview+0x25>
jmp    1201 <getview+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   $0x62,-0x4(%rbp)
jne    1188 <getview+0x58>
movl   $0x2,-0x8(%rbp)
jmp    11b7 <getview+0x87>
cmpl   $0x77,-0x4(%rbp)
jne    119e <getview+0x6e>
movl   $0x1,-0x8(%rbp)
jmp    11b2 <getview+0x82>
cmpl   $0x71,-0x4(%rbp)
jne    11ad <getview+0x7d>
jmp    1201 <getview+0xd1>
jmp    11b2 <getview+0x82>
jmp    11b7 <getview+0x87>
jmp    11bc <getview+0x8c>
xor    %eax,%eax
cmpl   $0xa,-0x4(%rbp)
mov    %al,-0x9(%rbp)
je     11dd <getview+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 <getview+0xbd>
jmp    11fc <getview+0xcc>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x4(%rbp)
jmp    11bc <getview+0x8c>
jmp    113f <getview+0xf>
mov    -0x8(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getview>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
lea    0xec2(%rip),%r14
mov    0x2ea3(%rip),%rbx
xor    %r15d,%r15d
jmp    1155 <getview+0x25>
nopw   0x0(%rax,%rax,1)
test   %bpl,%bpl
je     11c2 <getview+0x92>
mov    %r14,%rdi
call   1030 <printf@plt>
xor    %ebp,%ebp
xor    %eax,%eax
call   1040 <getchar@plt>
mov    %eax,%edi
call   1050 <tolower@plt>
cmp    $0x62,%eax
je     1190 <getview+0x60>
cmp    $0x77,%eax
je     11a0 <getview+0x70>
cmp    $0x71,%eax
je     11c2 <getview+0x92>
xor    %r15d,%r15d
mov    $0x1,%bpl
jmp    11b7 <getview+0x87>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    $0x2,%r15d
jmp    11b7 <getview+0x87>
nopl   0x0(%rax,%rax,1)
mov    $0x1,%r15d
xor    %ebp,%ebp
jmp    11b7 <getview+0x87>
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    $0xa,%eax
je     1150 <getview+0x20>
cmp    (%rbx),%eax
jne    11b0 <getview+0x80>
jmp    1150 <getview+0x20>
mov    %r15d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [33 x i8] c"\0Atype b/w to select your color: \00"
@EOF = global i32 0
define i32 @getview() {
%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 ([33 x i8], [33 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, 98
br i1 %12, label %13, label %14
13: ; preds = %7
store i32 2, i32* %2
br label %24
14: ; preds = %7
%15 = load i32, i32* %1
%16 = icmp eq i32 %15, 119
br i1 %16, label %17, label %18
17: ; preds = %14
store i32 1, 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 = [33 x i8] c"\0Atype b/w to select your color: \00"
@EOF = global i32 0
define i32 @getview() {
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 ([33 x i8], [33 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 98, label %9
i32 119, 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 [ 2, %2 ], [ 0, %8 ], [ 1, %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
}