#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 */
scalar_t__ strcmp(char *, char *);
char tolower(char);
int getcolor(char *value) {
  int num;
  for (num = 0; value[num] != 0; num++)
    value[num] = tolower(value[num]);
  if (strcmp(value, "black") == 0)
    return 2;
  if (strcmp(value, "red") == 0)
    return 3;
  if (strcmp(value, "green") == 0)
    return 4;
  if (strcmp(value, "blue") == 0)
    return 6;
  if (strcmp(value, "magenta") == 0)
    return 7;
  if (strcmp(value, "cyan") == 0)
    return 8;
  if (strcmp(value, "white") == 0)
    return 9;
  if (strcmp(value, "purple") == 0)
    return 7;
  if (strcmp(value, "violet") == 0)
    return 7;
  if (strcmp(value, "aqua") == 0)
    return 8;
  return -1;
}


x86 assembly (clang, -O0):
<getcolor>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     1174 <getcolor+0x54>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <tolower@plt>
mov    %al,%dl
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1133 <getcolor+0x13>
mov    -0x10(%rbp),%rdi
lea    0xe81(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    119a <getcolor+0x7a>
movl   $0x2,-0x4(%rbp)
jmp    12f7 <getcolor+0x1d7>
mov    -0x10(%rbp),%rdi
lea    0xe61(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    11c0 <getcolor+0xa0>
movl   $0x3,-0x4(%rbp)
jmp    12f7 <getcolor+0x1d7>
mov    -0x10(%rbp),%rdi
lea    0xe3f(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    11e6 <getcolor+0xc6>
movl   $0x4,-0x4(%rbp)
jmp    12f7 <getcolor+0x1d7>
mov    -0x10(%rbp),%rdi
lea    0xe1f(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    120c <getcolor+0xec>
movl   $0x6,-0x4(%rbp)
jmp    12f7 <getcolor+0x1d7>
mov    -0x10(%rbp),%rdi
lea    0xdfe(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1232 <getcolor+0x112>
movl   $0x7,-0x4(%rbp)
jmp    12f7 <getcolor+0x1d7>
mov    -0x10(%rbp),%rdi
lea    0xde0(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1258 <getcolor+0x138>
movl   $0x8,-0x4(%rbp)
jmp    12f7 <getcolor+0x1d7>
mov    -0x10(%rbp),%rdi
lea    0xdbf(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    127e <getcolor+0x15e>
movl   $0x9,-0x4(%rbp)
jmp    12f7 <getcolor+0x1d7>
mov    -0x10(%rbp),%rdi
lea    0xd9f(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    12a4 <getcolor+0x184>
movl   $0x7,-0x4(%rbp)
jmp    12f7 <getcolor+0x1d7>
mov    -0x10(%rbp),%rdi
lea    0xd80(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    12ca <getcolor+0x1aa>
movl   $0x7,-0x4(%rbp)
jmp    12f7 <getcolor+0x1d7>
mov    -0x10(%rbp),%rdi
lea    0xd61(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    12f0 <getcolor+0x1d0>
movl   $0x8,-0x4(%rbp)
jmp    12f7 <getcolor+0x1d7>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getcolor>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    (%rdi),%al
test   %al,%al
je     1147 <getcolor+0x27>
lea    0x1(%rbx),%rbp
movsbl %al,%edi
call   1040 <tolower@plt>
mov    %al,-0x1(%rbp)
movzbl 0x0(%rbp),%eax
add    $0x1,%rbp
test   %al,%al
jne    1130 <getcolor+0x10>
lea    0xeb2(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     122d <getcolor+0x10d>
lea    0xea0(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1234 <getcolor+0x114>
lea    0xe8c(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     123b <getcolor+0x11b>
lea    0xe7a(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1242 <getcolor+0x122>
lea    0xe67(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
mov    $0x7,%ebp
test   %rax,%rax
je     1255 <getcolor+0x135>
lea    0xe52(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1249 <getcolor+0x129>
lea    0xe43(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1250 <getcolor+0x130>
lea    0xe35(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1255 <getcolor+0x135>
lea    0xe28(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1255 <getcolor+0x135>
lea    0xe1b(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
neg    %rax
sbb    %ebp,%ebp
or     $0x8,%ebp
jmp    1255 <getcolor+0x135>
mov    $0x2,%ebp
jmp    1255 <getcolor+0x135>
mov    $0x3,%ebp
jmp    1255 <getcolor+0x135>
mov    $0x4,%ebp
jmp    1255 <getcolor+0x135>
mov    $0x6,%ebp
jmp    1255 <getcolor+0x135>
mov    $0x8,%ebp
jmp    1255 <getcolor+0x135>
mov    $0x9,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"black\00"
@.str.1 = [4 x i8] c"red\00"
@.str.2 = [6 x i8] c"green\00"
@.str.3 = [5 x i8] c"blue\00"
@.str.4 = [8 x i8] c"magenta\00"
@.str.5 = [5 x i8] c"cyan\00"
@.str.6 = [6 x i8] c"white\00"
@.str.7 = [7 x i8] c"purple\00"
@.str.8 = [7 x i8] c"violet\00"
@.str.9 = [5 x i8] c"aqua\00"
define i32 @getcolor(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
store i32 0, i32* %4
br label %5
5: ; preds = %24, %1
%6 = load i8*, i8** %3
%7 = load i32, i32* %4
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds i8, i8* %6, i64 %8
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %27
13: ; preds = %5
%14 = load i8*, i8** %3
%15 = load i32, i32* %4
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8, i8* %14, i64 %16
%18 = load i8, i8* %17
%19 = call signext i8 @tolower(i8 signext %18)
%20 = load i8*, i8** %3
%21 = load i32, i32* %4
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8, i8* %20, i64 %22
store i8 %19, i8* %23
br label %24
24: ; preds = %13
%25 = load i32, i32* %4
%26 = add nsw i32 %25, 1
store i32 %26, i32* %4
br label %5
27: ; preds = %5
%28 = load i8*, i8** %3
%29 = call i64 @strcmp(i8* %28, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %32
31: ; preds = %27
store i32 2, i32* %2
br label %78
32: ; preds = %27
%33 = load i8*, i8** %3
%34 = call i64 @strcmp(i8* %33, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%35 = icmp eq i64 %34, 0
br i1 %35, label %36, label %37
36: ; preds = %32
store i32 3, i32* %2
br label %78
37: ; preds = %32
%38 = load i8*, i8** %3
%39 = call i64 @strcmp(i8* %38, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%40 = icmp eq i64 %39, 0
br i1 %40, label %41, label %42
41: ; preds = %37
store i32 4, i32* %2
br label %78
42: ; preds = %37
%43 = load i8*, i8** %3
%44 = call i64 @strcmp(i8* %43, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%45 = icmp eq i64 %44, 0
br i1 %45, label %46, label %47
46: ; preds = %42
store i32 6, i32* %2
br label %78
47: ; preds = %42
%48 = load i8*, i8** %3
%49 = call i64 @strcmp(i8* %48, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
%50 = icmp eq i64 %49, 0
br i1 %50, label %51, label %52
51: ; preds = %47
store i32 7, i32* %2
br label %78
52: ; preds = %47
%53 = load i8*, i8** %3
%54 = call i64 @strcmp(i8* %53, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%55 = icmp eq i64 %54, 0
br i1 %55, label %56, label %57
56: ; preds = %52
store i32 8, i32* %2
br label %78
57: ; preds = %52
%58 = load i8*, i8** %3
%59 = call i64 @strcmp(i8* %58, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
%60 = icmp eq i64 %59, 0
br i1 %60, label %61, label %62
61: ; preds = %57
store i32 9, i32* %2
br label %78
62: ; preds = %57
%63 = load i8*, i8** %3
%64 = call i64 @strcmp(i8* %63, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0))
%65 = icmp eq i64 %64, 0
br i1 %65, label %66, label %67
66: ; preds = %62
store i32 7, i32* %2
br label %78
67: ; preds = %62
%68 = load i8*, i8** %3
%69 = call i64 @strcmp(i8* %68, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0))
%70 = icmp eq i64 %69, 0
br i1 %70, label %71, label %72
71: ; preds = %67
store i32 7, i32* %2
br label %78
72: ; preds = %67
%73 = load i8*, i8** %3
%74 = call i64 @strcmp(i8* %73, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0))
%75 = icmp eq i64 %74, 0
br i1 %75, label %76, label %77
76: ; preds = %72
store i32 8, i32* %2
br label %78
77: ; preds = %72
store i32 -1, i32* %2
br label %78
78: ; preds = %77, %76, %71, %66, %61, %56, %51, %46, %41, %36, %31
%79 = load i32, i32* %2
ret i32 %79
}

LLVM IR (-O2):
@.str = [6 x i8] c"black\00"
@.str.1 = [4 x i8] c"red\00"
@.str.2 = [6 x i8] c"green\00"
@.str.3 = [5 x i8] c"blue\00"
@.str.4 = [8 x i8] c"magenta\00"
@.str.5 = [5 x i8] c"cyan\00"
@.str.6 = [6 x i8] c"white\00"
@.str.7 = [7 x i8] c"purple\00"
@.str.8 = [7 x i8] c"violet\00"
@.str.9 = [5 x i8] c"aqua\00"
define i32 @getcolor(i8* %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %13, label %4
4: ; preds = %1, %4
%5 = phi i64 [ %9, %4 ], [ 0, %1 ]
%6 = phi i8 [ %11, %4 ], [ %2, %1 ]
%7 = phi i8* [ %10, %4 ], [ %0, %1 ]
%8 = tail call signext i8 @tolower(i8 signext %6)
store i8 %8, i8* %7
%9 = add nuw i64 %5, 1
%10 = getelementptr inbounds i8, i8* %0, i64 %9
%11 = load i8, i8* %10
%12 = icmp eq i8 %11, 0
br i1 %12, label %13, label %4
13: ; preds = %4, %1
%14 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %44, label %16
16: ; preds = %13
%17 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %44, label %19
19: ; preds = %16
%20 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%21 = icmp eq i64 %20, 0
br i1 %21, label %44, label %22
22: ; preds = %19
%23 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%24 = icmp eq i64 %23, 0
br i1 %24, label %44, label %25
25: ; preds = %22
%26 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
%27 = icmp eq i64 %26, 0
br i1 %27, label %44, label %28
28: ; preds = %25
%29 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%30 = icmp eq i64 %29, 0
br i1 %30, label %44, label %31
31: ; preds = %28
%32 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
%33 = icmp eq i64 %32, 0
br i1 %33, label %44, label %34
34: ; preds = %31
%35 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0))
%36 = icmp eq i64 %35, 0
br i1 %36, label %44, label %37
37: ; preds = %34
%38 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0))
%39 = icmp eq i64 %38, 0
br i1 %39, label %44, label %40
40: ; preds = %37
%41 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0))
%42 = icmp eq i64 %41, 0
%43 = select i1 %42, i32 8, i32 -1
br label %44
44: ; preds = %40, %37, %34, %31, %28, %25, %22, %19, %16, %13
%45 = phi i32 [ 2, %13 ], [ 3, %16 ], [ 4, %19 ], [ 6, %22 ], [ 7, %25 ], [ 8, %28 ], [ 9, %31 ], [ 7, %34 ], [ 7, %37 ], [ %43, %40 ]
ret i32 %45
}