#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*/ printf(char *);
char check_word(char *element) {
  if (*element == 'm' || *element == 'M') {
    *element = 0;
    return 0;
  } else if (*element == 'y' || *element == 'Y') {
    *element = 1;
    return 0;
  } else if (*element == 'r' || *element == 'R') {
    *element = 2;
    return 0;
  } else if (*element == 'g' || *element == 'G') {
    *element = 3;
    return 0;
  } else if (*element == 'b' || *element == 'B') {
    *element = 4;
    return 0;
  } else if (*element == 'c' || *element == 'C') {
    *element = 5;
    return 0;
  } else {
    printf("\nInvalid entry! Please re-enter valid word:\n");
    return 1;
  }
}


x86 assembly (clang, -O0):
<check_word>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x6d,%eax
je     113c <check_word+0x2c>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x4d,%eax
jne    114c <check_word+0x3c>
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
movb   $0x0,-0x1(%rbp)
jmp    124c <check_word+0x13c>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x79,%eax
je     116c <check_word+0x5c>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x59,%eax
jne    117c <check_word+0x6c>
mov    -0x10(%rbp),%rax
movb   $0x1,(%rax)
movb   $0x0,-0x1(%rbp)
jmp    124c <check_word+0x13c>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x72,%eax
je     119c <check_word+0x8c>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x52,%eax
jne    11ac <check_word+0x9c>
mov    -0x10(%rbp),%rax
movb   $0x2,(%rax)
movb   $0x0,-0x1(%rbp)
jmp    124c <check_word+0x13c>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x67,%eax
je     11cc <check_word+0xbc>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x47,%eax
jne    11dc <check_word+0xcc>
mov    -0x10(%rbp),%rax
movb   $0x3,(%rax)
movb   $0x0,-0x1(%rbp)
jmp    124c <check_word+0x13c>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x62,%eax
je     11fc <check_word+0xec>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x42,%eax
jne    120c <check_word+0xfc>
mov    -0x10(%rbp),%rax
movb   $0x4,(%rax)
movb   $0x0,-0x1(%rbp)
jmp    124c <check_word+0x13c>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x63,%eax
je     122c <check_word+0x11c>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x43,%eax
jne    123c <check_word+0x12c>
mov    -0x10(%rbp),%rax
movb   $0x5,(%rax)
movb   $0x0,-0x1(%rbp)
jmp    124c <check_word+0x13c>
lea    0xdbd(%rip),%rdi
call   1030 <printf@plt>
movb   $0x1,-0x1(%rbp)
movsbl -0x1(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_word>:
push   %rax
mov    (%rdi),%al
add    $0xbe,%al
cmp    $0x37,%al
ja     114c <check_word+0x3c>
movzbl %al,%eax
lea    0xedd(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movb   $0x4,(%rdi)
jmp    1148 <check_word+0x38>
movb   $0x5,(%rdi)
jmp    1148 <check_word+0x38>
movb   $0x3,(%rdi)
jmp    1148 <check_word+0x38>
movb   $0x0,(%rdi)
jmp    1148 <check_word+0x38>
movb   $0x2,(%rdi)
jmp    1148 <check_word+0x38>
movb   $0x1,(%rdi)
xor    %eax,%eax
pop    %rcx
ret
lea    0xf8d(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%al
pop    %rcx
ret

LLVM IR (-O0):
@.str = [45 x i8] c"\0AInvalid entry! Please re-enter valid word:\0A\00"
define signext i8 @check_word(i8* %0) {
%2 = alloca i8
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = load i8, i8* %4
%6 = sext i8 %5 to i32
%7 = icmp eq i32 %6, 109
br i1 %7, label %13, label %8
8: ; preds = %1
%9 = load i8*, i8** %3
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = icmp eq i32 %11, 77
br i1 %12, label %13, label %15
13: ; preds = %8, %1
%14 = load i8*, i8** %3
store i8 0, i8* %14
store i8 0, i8* %2
br label %77
15: ; preds = %8
%16 = load i8*, i8** %3
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = icmp eq i32 %18, 121
br i1 %19, label %25, label %20
20: ; preds = %15
%21 = load i8*, i8** %3
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = icmp eq i32 %23, 89
br i1 %24, label %25, label %27
25: ; preds = %20, %15
%26 = load i8*, i8** %3
store i8 1, i8* %26
store i8 0, i8* %2
br label %77
27: ; preds = %20
%28 = load i8*, i8** %3
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
%31 = icmp eq i32 %30, 114
br i1 %31, label %37, label %32
32: ; preds = %27
%33 = load i8*, i8** %3
%34 = load i8, i8* %33
%35 = sext i8 %34 to i32
%36 = icmp eq i32 %35, 82
br i1 %36, label %37, label %39
37: ; preds = %32, %27
%38 = load i8*, i8** %3
store i8 2, i8* %38
store i8 0, i8* %2
br label %77
39: ; preds = %32
%40 = load i8*, i8** %3
%41 = load i8, i8* %40
%42 = sext i8 %41 to i32
%43 = icmp eq i32 %42, 103
br i1 %43, label %49, label %44
44: ; preds = %39
%45 = load i8*, i8** %3
%46 = load i8, i8* %45
%47 = sext i8 %46 to i32
%48 = icmp eq i32 %47, 71
br i1 %48, label %49, label %51
49: ; preds = %44, %39
%50 = load i8*, i8** %3
store i8 3, i8* %50
store i8 0, i8* %2
br label %77
51: ; preds = %44
%52 = load i8*, i8** %3
%53 = load i8, i8* %52
%54 = sext i8 %53 to i32
%55 = icmp eq i32 %54, 98
br i1 %55, label %61, label %56
56: ; preds = %51
%57 = load i8*, i8** %3
%58 = load i8, i8* %57
%59 = sext i8 %58 to i32
%60 = icmp eq i32 %59, 66
br i1 %60, label %61, label %63
61: ; preds = %56, %51
%62 = load i8*, i8** %3
store i8 4, i8* %62
store i8 0, i8* %2
br label %77
63: ; preds = %56
%64 = load i8*, i8** %3
%65 = load i8, i8* %64
%66 = sext i8 %65 to i32
%67 = icmp eq i32 %66, 99
br i1 %67, label %73, label %68
68: ; preds = %63
%69 = load i8*, i8** %3
%70 = load i8, i8* %69
%71 = sext i8 %70 to i32
%72 = icmp eq i32 %71, 67
br i1 %72, label %73, label %75
73: ; preds = %68, %63
%74 = load i8*, i8** %3
store i8 5, i8* %74
store i8 0, i8* %2
br label %77
75: ; preds = %68
%76 = call i32 @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0))
store i8 1, i8* %2
br label %77
77: ; preds = %75, %73, %61, %49, %37, %25, %13
%78 = load i8, i8* %2
ret i8 %78
}

LLVM IR (-O2):
@str = [44 x i8] c"\0AInvalid entry! Please re-enter valid word:\00"
define signext i8 @check_word(i8* nocapture %0) {
%2 = load i8, i8* %0
switch i8 %2, label %9 [
i8 109, label %3
i8 77, label %3
i8 121, label %4
i8 89, label %4
i8 114, label %5
i8 82, label %5
i8 103, label %6
i8 71, label %6
i8 98, label %7
i8 66, label %7
i8 99, label %8
i8 67, label %8
]
3: ; preds = %1, %1
store i8 0, i8* %0
br label %11
4: ; preds = %1, %1
store i8 1, i8* %0
br label %11
5: ; preds = %1, %1
store i8 2, i8* %0
br label %11
6: ; preds = %1, %1
store i8 3, i8* %0
br label %11
7: ; preds = %1, %1
store i8 4, i8* %0
br label %11
8: ; preds = %1, %1
store i8 5, i8* %0
br label %11
9: ; preds = %1
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @str, i64 0, i64 0))
br label %11
11: ; preds = %9, %8, %7, %6, %5, %4, %3
%12 = phi i8 [ 0, %3 ], [ 0, %4 ], [ 0, %5 ], [ 0, %6 ], [ 0, %7 ], [ 0, %8 ], [ 1, %9 ]
ret i8 %12
}