#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 atoi(char *);
scalar_t__ isdigit(char);
int /*<<< orphan*/ strcasecmp(char *, char *);
int colname2int(char col[]) {
  if (isdigit(col[0]))
    return atoi(col);
  if (!strcasecmp(col, "black"))
    return 0;
  if (!strcasecmp(col, "red"))
    return 1;
  if (!strcasecmp(col, "green"))
    return 2;
  if (!strcasecmp(col, "yellow"))
    return 3;
  if (!strcasecmp(col, "blue"))
    return 4;
  if (!strcasecmp(col, "magenta"))
    return 5;
  if (!strcasecmp(col, "cyan"))
    return 6;
  if (!strcasecmp(col, "white"))
    return 7;
  return -1;
}


x86 assembly (clang, -O0):
<colname2int>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1040 <isdigit@plt>
cmp    $0x0,%rax
je     1163 <colname2int+0x33>
mov    -0x10(%rbp),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x4(%rbp)
jmp    1292 <colname2int+0x162>
mov    -0x10(%rbp),%rdi
lea    0xe92(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%eax
jne    1188 <colname2int+0x58>
movl   $0x0,-0x4(%rbp)
jmp    1292 <colname2int+0x162>
mov    -0x10(%rbp),%rdi
lea    0xe73(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%eax
jne    11ad <colname2int+0x7d>
movl   $0x1,-0x4(%rbp)
jmp    1292 <colname2int+0x162>
mov    -0x10(%rbp),%rdi
lea    0xe52(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%eax
jne    11d2 <colname2int+0xa2>
movl   $0x2,-0x4(%rbp)
jmp    1292 <colname2int+0x162>
mov    -0x10(%rbp),%rdi
lea    0xe33(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%eax
jne    11f7 <colname2int+0xc7>
movl   $0x3,-0x4(%rbp)
jmp    1292 <colname2int+0x162>
mov    -0x10(%rbp),%rdi
lea    0xe15(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%eax
jne    121c <colname2int+0xec>
movl   $0x4,-0x4(%rbp)
jmp    1292 <colname2int+0x162>
mov    -0x10(%rbp),%rdi
lea    0xdf5(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%eax
jne    1241 <colname2int+0x111>
movl   $0x5,-0x4(%rbp)
jmp    1292 <colname2int+0x162>
mov    -0x10(%rbp),%rdi
lea    0xdd8(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%eax
jne    1266 <colname2int+0x136>
movl   $0x6,-0x4(%rbp)
jmp    1292 <colname2int+0x162>
mov    -0x10(%rbp),%rdi
lea    0xdb8(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%eax
jne    128b <colname2int+0x15b>
movl   $0x7,-0x4(%rbp)
jmp    1292 <colname2int+0x162>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<colname2int>:
push   %rbx
mov    %rdi,%rbx
movsbl (%rdi),%edi
call   1040 <isdigit@plt>
test   %rax,%rax
je     114a <colname2int+0x1a>
mov    %rbx,%rdi
pop    %rbx
jmp    1050 <atoi@plt>
lea    0xeaf(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %eax,%eax
je     11eb <colname2int+0xbb>
lea    0xe9e(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %eax,%eax
je     11ef <colname2int+0xbf>
lea    0xe8f(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %eax,%eax
je     11f6 <colname2int+0xc6>
lea    0xe82(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %eax,%eax
je     11fd <colname2int+0xcd>
lea    0xe76(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %eax,%eax
je     1204 <colname2int+0xd4>
lea    0xe68(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %eax,%eax
je     120b <colname2int+0xdb>
lea    0xe5d(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %eax,%eax
je     1212 <colname2int+0xe2>
lea    0xe4f(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
neg    %eax
sbb    %eax,%eax
or     $0x7,%eax
pop    %rbx
ret
xor    %eax,%eax
pop    %rbx
ret
mov    $0x1,%eax
pop    %rbx
ret
mov    $0x2,%eax
pop    %rbx
ret
mov    $0x3,%eax
pop    %rbx
ret
mov    $0x4,%eax
pop    %rbx
ret
mov    $0x5,%eax
pop    %rbx
ret
mov    $0x6,%eax
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 i32 @colname2int(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = getelementptr inbounds i8, i8* %4, i64 0
%6 = load i8, i8* %5
%7 = call i64 @isdigit(i8 signext %6)
%8 = icmp ne i64 %7, 0
br i1 %8, label %9, label %12
9: ; preds = %1
%10 = load i8*, i8** %3
%11 = call i32 @atoi(i8* %10)
store i32 %11, i32* %2
br label %53
12: ; preds = %1
%13 = load i8*, i8** %3
%14 = call i32 @strcasecmp(i8* %13, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%15 = icmp ne i32 %14, 0
br i1 %15, label %17, label %16
16: ; preds = %12
store i32 0, i32* %2
br label %53
17: ; preds = %12
%18 = load i8*, i8** %3
%19 = call i32 @strcasecmp(i8* %18, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%20 = icmp ne i32 %19, 0
br i1 %20, label %22, label %21
21: ; preds = %17
store i32 1, i32* %2
br label %53
22: ; preds = %17
%23 = load i8*, i8** %3
%24 = call i32 @strcasecmp(i8* %23, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%25 = icmp ne i32 %24, 0
br i1 %25, label %27, label %26
26: ; preds = %22
store i32 2, i32* %2
br label %53
27: ; preds = %22
%28 = load i8*, i8** %3
%29 = call i32 @strcasecmp(i8* %28, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%30 = icmp ne i32 %29, 0
br i1 %30, label %32, label %31
31: ; preds = %27
store i32 3, i32* %2
br label %53
32: ; preds = %27
%33 = load i8*, i8** %3
%34 = call i32 @strcasecmp(i8* %33, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%35 = icmp ne i32 %34, 0
br i1 %35, label %37, label %36
36: ; preds = %32
store i32 4, i32* %2
br label %53
37: ; preds = %32
%38 = load i8*, i8** %3
%39 = call i32 @strcasecmp(i8* %38, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
%40 = icmp ne i32 %39, 0
br i1 %40, label %42, label %41
41: ; preds = %37
store i32 5, i32* %2
br label %53
42: ; preds = %37
%43 = load i8*, i8** %3
%44 = call i32 @strcasecmp(i8* %43, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%45 = icmp ne i32 %44, 0
br i1 %45, label %47, label %46
46: ; preds = %42
store i32 6, i32* %2
br label %53
47: ; preds = %42
%48 = load i8*, i8** %3
%49 = call i32 @strcasecmp(i8* %48, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0))
%50 = icmp ne i32 %49, 0
br i1 %50, label %52, label %51
51: ; preds = %47
store i32 7, i32* %2
br label %53
52: ; preds = %47
store i32 -1, i32* %2
br label %53
53: ; preds = %52, %51, %46, %41, %36, %31, %26, %21, %16, %9
%54 = load i32, i32* %2
ret i32 %54
}

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 i32 @colname2int(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = tail call i64 @isdigit(i8 signext %2)
%4 = icmp eq i64 %3, 0
br i1 %4, label %7, label %5
5: ; preds = %1
%6 = tail call i32 @atoi(i8* %0)
br label %32
7: ; preds = %1
%8 = tail call i32 @strcasecmp(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i32 %8, 0
br i1 %9, label %32, label %10
10: ; preds = %7
%11 = tail call i32 @strcasecmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp eq i32 %11, 0
br i1 %12, label %32, label %13
13: ; preds = %10
%14 = tail call i32 @strcasecmp(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%15 = icmp eq i32 %14, 0
br i1 %15, label %32, label %16
16: ; preds = %13
%17 = tail call i32 @strcasecmp(i8* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%18 = icmp eq i32 %17, 0
br i1 %18, label %32, label %19
19: ; preds = %16
%20 = tail call i32 @strcasecmp(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%21 = icmp eq i32 %20, 0
br i1 %21, label %32, label %22
22: ; preds = %19
%23 = tail call i32 @strcasecmp(i8* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
%24 = icmp eq i32 %23, 0
br i1 %24, label %32, label %25
25: ; preds = %22
%26 = tail call i32 @strcasecmp(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%27 = icmp eq i32 %26, 0
br i1 %27, label %32, label %28
28: ; preds = %25
%29 = tail call i32 @strcasecmp(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0))
%30 = icmp eq i32 %29, 0
%31 = select i1 %30, i32 7, i32 -1
br label %32
32: ; preds = %28, %25, %22, %19, %16, %13, %10, %7, %5
%33 = phi i32 [ %6, %5 ], [ 0, %7 ], [ 1, %10 ], [ 2, %13 ], [ 3, %16 ], [ 4, %19 ], [ 5, %22 ], [ 6, %25 ], [ %31, %28 ]
ret i32 %33
}