#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__ match(char const *, char *);
int get_color(const char *cat) {
  return cat == NULL           ? 0
         : match(cat, "class") ? 6
         : match(cat, "ec")    ? 7
         : match(cat, "work")  ? 8
                               : 9;
}


x86 assembly (clang, -O0):
<get_color>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    1131 <get_color+0x21>
xor    %eax,%eax
mov    %eax,-0xc(%rbp)
jmp    11b2 <get_color+0xa2>
mov    -0x8(%rbp),%rdi
lea    0xec4(%rip),%rsi
call   1030 <match@plt>
cmp    $0x0,%rax
je     1158 <get_color+0x48>
mov    $0x6,%eax
mov    %eax,-0x10(%rbp)
jmp    11ac <get_color+0x9c>
mov    -0x8(%rbp),%rdi
lea    0xea3(%rip),%rsi
call   1030 <match@plt>
cmp    $0x0,%rax
je     117f <get_color+0x6f>
mov    $0x7,%eax
mov    %eax,-0x14(%rbp)
jmp    11a6 <get_color+0x96>
mov    -0x8(%rbp),%rdi
lea    0xe7f(%rip),%rsi
call   1030 <match@plt>
mov    %rax,%rdx
mov    $0x9,%eax
mov    $0x8,%ecx
cmp    $0x0,%rdx
cmovne %ecx,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_color>:
push   %rbx
test   %rdi,%rdi
je     1134 <get_color+0x24>
mov    %rdi,%rbx
lea    0xee0(%rip),%rsi
call   1030 <match@plt>
mov    %rax,%rcx
mov    $0x6,%eax
test   %rcx,%rcx
je     1138 <get_color+0x28>
pop    %rbx
ret
xor    %eax,%eax
pop    %rbx
ret
lea    0xec7(%rip),%rsi
mov    %rbx,%rdi
call   1030 <match@plt>
mov    %rax,%rcx
mov    $0x7,%eax
test   %rcx,%rcx
jne    1132 <get_color+0x22>
lea    0xeae(%rip),%rsi
mov    %rbx,%rdi
call   1030 <match@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
sete   %al
or     $0x8,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [6 x i8] c"class\00"
@.str.1 = [3 x i8] c"ec\00"
@.str.2 = [5 x i8] c"work\00"
define i32 @get_color(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i8*, i8** %2
%4 = icmp eq i8* %3, null
br i1 %4, label %5, label %6
5: ; preds = %1
br label %26
6: ; preds = %1
%7 = load i8*, i8** %2
%8 = call i64 @match(i8* %7, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %11
10: ; preds = %6
br label %24
11: ; preds = %6
%12 = load i8*, i8** %2
%13 = call i64 @match(i8* %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %16
15: ; preds = %11
br label %22
16: ; preds = %11
%17 = load i8*, i8** %2
%18 = call i64 @match(i8* %17, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%19 = icmp ne i64 %18, 0
%20 = zext i1 %19 to i64
%21 = select i1 %19, i32 8, i32 9
br label %22
22: ; preds = %16, %15
%23 = phi i32 [ 7, %15 ], [ %21, %16 ]
br label %24
24: ; preds = %22, %10
%25 = phi i32 [ 6, %10 ], [ %23, %22 ]
br label %26
26: ; preds = %24, %5
%27 = phi i32 [ 0, %5 ], [ %25, %24 ]
ret i32 %27
}

LLVM IR (-O2):
@.str = [6 x i8] c"class\00"
@.str.1 = [3 x i8] c"ec\00"
@.str.2 = [5 x i8] c"work\00"
define i32 @get_color(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %13, label %3
3: ; preds = %1
%4 = tail call i64 @match(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 %6, label %13
6: ; preds = %3
%7 = tail call i64 @match(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %13
9: ; preds = %6
%10 = tail call i64 @match(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
%12 = select i1 %11, i32 9, i32 8
br label %13
13: ; preds = %3, %6, %9, %1
%14 = phi i32 [ 0, %1 ], [ 6, %3 ], [ %12, %9 ], [ 7, %6 ]
ret i32 %14
}