#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__ strcasecmp(char *, char *);
short color_name_to_z_colour(char *colour_name) {
  if (colour_name == NULL) {
    return -1;
  } else if (strcasecmp(colour_name, "black") == 0) {
    return 2;
  } else if (strcasecmp(colour_name, "red") == 0) {
    return 3;
  } else if (strcasecmp(colour_name, "green") == 0) {
    return 4;
  } else if (strcasecmp(colour_name, "yellow") == 0) {
    return 5;
  } else if (strcasecmp(colour_name, "blue") == 0) {
    return 6;
  } else if (strcasecmp(colour_name, "magenta") == 0) {
    return 7;
  } else if (strcasecmp(colour_name, "cyan") == 0) {
    return 8;
  } else if (strcasecmp(colour_name, "white") == 0) {
    return 9;
  } else {
    return -1;
  }
}


x86 assembly (clang, -O0):
<color_name_to_z_colour>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1132 <color_name_to_z_colour+0x22>
movw   $0xffff,-0x2(%rbp)
jmp    1260 <color_name_to_z_colour+0x150>
mov    -0x10(%rbp),%rdi
lea    0xec3(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    1157 <color_name_to_z_colour+0x47>
movw   $0x2,-0x2(%rbp)
jmp    1260 <color_name_to_z_colour+0x150>
mov    -0x10(%rbp),%rdi
lea    0xea4(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    117c <color_name_to_z_colour+0x6c>
movw   $0x3,-0x2(%rbp)
jmp    1260 <color_name_to_z_colour+0x150>
mov    -0x10(%rbp),%rdi
lea    0xe83(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    11a1 <color_name_to_z_colour+0x91>
movw   $0x4,-0x2(%rbp)
jmp    1260 <color_name_to_z_colour+0x150>
mov    -0x10(%rbp),%rdi
lea    0xe64(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    11c6 <color_name_to_z_colour+0xb6>
movw   $0x5,-0x2(%rbp)
jmp    1260 <color_name_to_z_colour+0x150>
mov    -0x10(%rbp),%rdi
lea    0xe46(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    11eb <color_name_to_z_colour+0xdb>
movw   $0x6,-0x2(%rbp)
jmp    1260 <color_name_to_z_colour+0x150>
mov    -0x10(%rbp),%rdi
lea    0xe26(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    1210 <color_name_to_z_colour+0x100>
movw   $0x7,-0x2(%rbp)
jmp    1260 <color_name_to_z_colour+0x150>
mov    -0x10(%rbp),%rdi
lea    0xe09(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    1235 <color_name_to_z_colour+0x125>
movw   $0x8,-0x2(%rbp)
jmp    1260 <color_name_to_z_colour+0x150>
mov    -0x10(%rbp),%rdi
lea    0xde9(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    125a <color_name_to_z_colour+0x14a>
movw   $0x9,-0x2(%rbp)
jmp    1260 <color_name_to_z_colour+0x150>
movw   $0xffff,-0x2(%rbp)
movswl -0x2(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<color_name_to_z_colour>:
push   %rbx
test   %rdi,%rdi
je     11c7 <color_name_to_z_colour+0xb7>
mov    %rdi,%rbx
lea    0xedc(%rip),%rsi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     11cd <color_name_to_z_colour+0xbd>
lea    0xecd(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     11d3 <color_name_to_z_colour+0xc3>
lea    0xeb9(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     11d9 <color_name_to_z_colour+0xc9>
lea    0xeab(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     11df <color_name_to_z_colour+0xcf>
lea    0xe9e(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     11e5 <color_name_to_z_colour+0xd5>
lea    0xe8f(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     11eb <color_name_to_z_colour+0xdb>
lea    0xe83(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     11f1 <color_name_to_z_colour+0xe1>
lea    0xe74(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
neg    %rax
sbb    %eax,%eax
or     $0x9,%eax
pop    %rbx
ret
mov    $0xffff,%ax
pop    %rbx
ret
mov    $0x2,%ax
pop    %rbx
ret
mov    $0x3,%ax
pop    %rbx
ret
mov    $0x4,%ax
pop    %rbx
ret
mov    $0x5,%ax
pop    %rbx
ret
mov    $0x6,%ax
pop    %rbx
ret
mov    $0x7,%ax
pop    %rbx
ret
mov    $0x8,%ax
pop    %rbx
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 = [7 x i8] c"yellow\00"
@.str.4 = [5 x i8] c"blue\00"
@.str.5 = [8 x i8] c"magenta\00"
@.str.6 = [5 x i8] c"cyan\00"
@.str.7 = [6 x i8] c"white\00"
define signext i16 @color_name_to_z_colour(i8* %0) {
%2 = alloca i16
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = icmp eq i8* %4, null
br i1 %5, label %6, label %7
6: ; preds = %1
store i16 -1, i16* %2
br label %48
7: ; preds = %1
%8 = load i8*, i8** %3
%9 = call i64 @strcasecmp(i8* %8, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %12
11: ; preds = %7
store i16 2, i16* %2
br label %48
12: ; preds = %7
%13 = load i8*, i8** %3
%14 = call i64 @strcasecmp(i8* %13, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %12
store i16 3, i16* %2
br label %48
17: ; preds = %12
%18 = load i8*, i8** %3
%19 = call i64 @strcasecmp(i8* %18, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %17
store i16 4, i16* %2
br label %48
22: ; preds = %17
%23 = load i8*, i8** %3
%24 = call i64 @strcasecmp(i8* %23, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %27
26: ; preds = %22
store i16 5, i16* %2
br label %48
27: ; preds = %22
%28 = load i8*, i8** %3
%29 = call i64 @strcasecmp(i8* %28, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %32
31: ; preds = %27
store i16 6, i16* %2
br label %48
32: ; preds = %27
%33 = load i8*, i8** %3
%34 = call i64 @strcasecmp(i8* %33, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
%35 = icmp eq i64 %34, 0
br i1 %35, label %36, label %37
36: ; preds = %32
store i16 7, i16* %2
br label %48
37: ; preds = %32
%38 = load i8*, i8** %3
%39 = call i64 @strcasecmp(i8* %38, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%40 = icmp eq i64 %39, 0
br i1 %40, label %41, label %42
41: ; preds = %37
store i16 8, i16* %2
br label %48
42: ; preds = %37
%43 = load i8*, i8** %3
%44 = call i64 @strcasecmp(i8* %43, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0))
%45 = icmp eq i64 %44, 0
br i1 %45, label %46, label %47
46: ; preds = %42
store i16 9, i16* %2
br label %48
47: ; preds = %42
store i16 -1, i16* %2
br label %48
48: ; preds = %47, %46, %41, %36, %31, %26, %21, %16, %11, %6
%49 = load i16, i16* %2
ret i16 %49
}

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 = [7 x i8] c"yellow\00"
@.str.4 = [5 x i8] c"blue\00"
@.str.5 = [8 x i8] c"magenta\00"
@.str.6 = [5 x i8] c"cyan\00"
@.str.7 = [6 x i8] c"white\00"
define signext i16 @color_name_to_z_colour(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %28, label %3
3: ; preds = %1
%4 = tail call i64 @strcasecmp(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i64 %4, 0
br i1 %5, label %28, label %6
6: ; preds = %3
%7 = tail call i64 @strcasecmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
br i1 %8, label %28, label %9
9: ; preds = %6
%10 = tail call i64 @strcasecmp(i8* %0, 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 %28, label %12
12: ; preds = %9
%13 = tail call i64 @strcasecmp(i8* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%14 = icmp eq i64 %13, 0
br i1 %14, label %28, label %15
15: ; preds = %12
%16 = tail call i64 @strcasecmp(i8* %0, 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 %28, label %18
18: ; preds = %15
%19 = tail call i64 @strcasecmp(i8* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
%20 = icmp eq i64 %19, 0
br i1 %20, label %28, label %21
21: ; preds = %18
%22 = tail call i64 @strcasecmp(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
br i1 %23, label %28, label %24
24: ; preds = %21
%25 = tail call i64 @strcasecmp(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0))
%26 = icmp eq i64 %25, 0
%27 = select i1 %26, i16 9, i16 -1
br label %28
28: ; preds = %24, %21, %18, %15, %12, %9, %6, %3, %1
%29 = phi i16 [ -1, %1 ], [ 2, %3 ], [ 3, %6 ], [ 4, %9 ], [ 5, %12 ], [ 6, %15 ], [ 7, %18 ], [ 8, %21 ], [ %27, %24 ]
ret i16 %29
}