#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 */
typedef int /*<<< orphan*/ uint32_t;

/* Variables and functions */
int get_named_color(char const *, int /*<<< orphan*/ *);
int parse_hex_color(char const *, int /*<<< orphan*/ *);
scalar_t__ strncmp(char const *, char *, int);
bool color_parse(const char *str, uint32_t *val) {
  if (strncmp(str, "rgba(", 5) == 0) {
    return false;
  } else if (strncmp(str, "rgb(", 4) == 0) {
    return false;
  } else if (strncmp(str, "hsla(", 5) == 0) {
    return false;
  } else if (strncmp(str, "hsl(", 4) == 0) {
    return false;
  } else if (*str == '#') {
    return parse_hex_color(str, val);
  }
  return get_named_color(str, val);
}


x86 assembly (clang, -O0):
<color_parse>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xeb5(%rip),%rsi
mov    $0x5,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    116b <color_parse+0x3b>
movl   $0x0,-0x4(%rbp)
jmp    1235 <color_parse+0x105>
mov    -0x10(%rbp),%rdi
lea    0xe90(%rip),%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    1196 <color_parse+0x66>
movl   $0x0,-0x4(%rbp)
jmp    1235 <color_parse+0x105>
mov    -0x10(%rbp),%rdi
lea    0xe6a(%rip),%rsi
mov    $0x5,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    11c1 <color_parse+0x91>
movl   $0x0,-0x4(%rbp)
jmp    1235 <color_parse+0x105>
mov    -0x10(%rbp),%rdi
lea    0xe45(%rip),%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    11ec <color_parse+0xbc>
movl   $0x0,-0x4(%rbp)
jmp    1235 <color_parse+0x105>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x23,%eax
jne    1211 <color_parse+0xe1>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <parse_hex_color@plt>
mov    %eax,-0x4(%rbp)
jmp    1235 <color_parse+0x105>
jmp    1216 <color_parse+0xe6>
jmp    121b <color_parse+0xeb>
jmp    1220 <color_parse+0xf0>
jmp    1225 <color_parse+0xf5>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <get_named_color@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<color_parse>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xebf(%rip),%rsi
mov    $0x5,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     11b2 <color_parse+0x82>
lea    0xeaf(%rip),%rsi
mov    %rbx,%rdi
mov    $0x4,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     11b2 <color_parse+0x82>
lea    0xe9b(%rip),%rsi
mov    %rbx,%rdi
mov    $0x5,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     11b2 <color_parse+0x82>
lea    0xe88(%rip),%rsi
mov    %rbx,%rdi
mov    $0x4,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     11b2 <color_parse+0x82>
cmpb   $0x23,(%rbx)
jne    11bc <color_parse+0x8c>
mov    %rbx,%rdi
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1050 <parse_hex_color@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    %rbx,%rdi
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <get_named_color@plt>

LLVM IR (-O0):
@.str = [6 x i8] c"rgba(\00"
@.str.1 = [5 x i8] c"rgb(\00"
@.str.2 = [6 x i8] c"hsla(\00"
@.str.3 = [5 x i8] c"hsl(\00"
define i32 @color_parse(i8* %0, i32* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32*
store i8* %0, i8** %4
store i32* %1, i32** %5
%6 = load i8*, i8** %4
%7 = call i64 @strncmp(i8* %6, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 5)
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %10
9: ; preds = %2
store i32 0, i32* %3
br label %42
10: ; preds = %2
%11 = load i8*, i8** %4
%12 = call i64 @strncmp(i8* %11, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 4)
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %10
store i32 0, i32* %3
br label %42
15: ; preds = %10
%16 = load i8*, i8** %4
%17 = call i64 @strncmp(i8* %16, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 5)
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %15
store i32 0, i32* %3
br label %42
20: ; preds = %15
%21 = load i8*, i8** %4
%22 = call i64 @strncmp(i8* %21, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 4)
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %20
store i32 0, i32* %3
br label %42
25: ; preds = %20
%26 = load i8*, i8** %4
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp eq i32 %28, 35
br i1 %29, label %30, label %34
30: ; preds = %25
%31 = load i8*, i8** %4
%32 = load i32*, i32** %5
%33 = call i32 @parse_hex_color(i8* %31, i32* %32)
store i32 %33, i32* %3
br label %42
34: ; preds = %25
br label %35
35: ; preds = %34
br label %36
36: ; preds = %35
br label %37
37: ; preds = %36
br label %38
38: ; preds = %37
%39 = load i8*, i8** %4
%40 = load i32*, i32** %5
%41 = call i32 @get_named_color(i8* %39, i32* %40)
store i32 %41, i32* %3
br label %42
42: ; preds = %38, %30, %24, %19, %14, %9
%43 = load i32, i32* %3
ret i32 %43
}

LLVM IR (-O2):
@.str = [6 x i8] c"rgba(\00"
@.str.1 = [5 x i8] c"rgb(\00"
@.str.2 = [6 x i8] c"hsla(\00"
@.str.3 = [5 x i8] c"hsl(\00"
define i32 @color_parse(i8* %0, i32* %1) {
%3 = tail call i64 @strncmp(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 5)
%4 = icmp eq i64 %3, 0
br i1 %4, label %21, label %5
5: ; preds = %2
%6 = tail call i64 @strncmp(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 4)
%7 = icmp eq i64 %6, 0
br i1 %7, label %21, label %8
8: ; preds = %5
%9 = tail call i64 @strncmp(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 5)
%10 = icmp eq i64 %9, 0
br i1 %10, label %21, label %11
11: ; preds = %8
%12 = tail call i64 @strncmp(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 4)
%13 = icmp eq i64 %12, 0
br i1 %13, label %21, label %14
14: ; preds = %11
%15 = load i8, i8* %0
%16 = icmp eq i8 %15, 35
br i1 %16, label %17, label %19
17: ; preds = %14
%18 = tail call i32 @parse_hex_color(i8* %0, i32* %1)
br label %21
19: ; preds = %14
%20 = tail call i32 @get_named_color(i8* %0, i32* %1)
br label %21
21: ; preds = %11, %8, %5, %2, %19, %17
%22 = phi i32 [ %18, %17 ], [ %20, %19 ], [ 0, %2 ], [ 0, %5 ], [ 0, %8 ], [ 0, %11 ]
ret i32 %22
}