#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__ get_color_from_name(char const *, unsigned int *);
int strlen(char const *);
long strtol(char const *, char **, int);
bool parse_color(const char *param, unsigned int *color) {
  if (get_color_from_name(param, color)) {
    return true;
  }
  if (strlen(param) == 6) {
    char *endptr = (char *)param;
    long int tmp_number = strtol(param, &endptr, 16);
    if (param == endptr) {
      return false;
    }
    *color = (unsigned int)tmp_number;
    return true;
  }
  return false;
}


x86 assembly (clang, -O0):
<parse_color>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <get_color_from_name@plt>
cmp    $0x0,%rax
je     1163 <parse_color+0x33>
movl   $0x1,-0x4(%rbp)
jmp    11cc <parse_color+0x9c>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x6,%eax
jne    11c5 <parse_color+0x95>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x20(%rbp),%rsi
mov    $0x10,%edx
call   1040 <strtol@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
cmp    -0x20(%rbp),%rax
jne    11ad <parse_color+0x7d>
movl   $0x0,-0x4(%rbp)
jmp    11cc <parse_color+0x9c>
mov    -0x28(%rbp),%rax
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    11cc <parse_color+0x9c>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_color>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
call   1050 <get_color_from_name@plt>
mov    %rax,%rcx
mov    $0x1,%eax
test   %rcx,%rcx
jne    1183 <parse_color+0x53>
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x6,%ecx
jne    1183 <parse_color+0x53>
mov    %rbx,(%rsp)
mov    %rsp,%rsi
mov    %rbx,%rdi
mov    $0x10,%edx
call   1040 <strtol@plt>
cmp    %rbx,(%rsp)
je     1181 <parse_color+0x51>
mov    %eax,(%r14)
mov    $0x1,%eax
jmp    1183 <parse_color+0x53>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @parse_color(i8* %0, i32* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i64
store i8* %0, i8** %4
store i32* %1, i32** %5
%8 = load i8*, i8** %4
%9 = load i32*, i32** %5
%10 = call i64 @get_color_from_name(i8* %8, i32* %9)
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %2
store i32 1, i32* %3
br label %30
13: ; preds = %2
%14 = load i8*, i8** %4
%15 = call i32 @strlen(i8* %14)
%16 = icmp eq i32 %15, 6
br i1 %16, label %17, label %29
17: ; preds = %13
%18 = load i8*, i8** %4
store i8* %18, i8** %6
%19 = load i8*, i8** %4
%20 = call i64 @strtol(i8* %19, i8** %6, i32 16)
store i64 %20, i64* %7
%21 = load i8*, i8** %4
%22 = load i8*, i8** %6
%23 = icmp eq i8* %21, %22
br i1 %23, label %24, label %25
24: ; preds = %17
store i32 0, i32* %3
br label %30
25: ; preds = %17
%26 = load i64, i64* %7
%27 = trunc i64 %26 to i32
%28 = load i32*, i32** %5
store i32 %27, i32* %28
store i32 1, i32* %3
br label %30
29: ; preds = %13
store i32 0, i32* %3
br label %30
30: ; preds = %29, %25, %24, %12
%31 = load i32, i32* %3
ret i32 %31
}

LLVM IR (-O2):
define i32 @parse_color(i8* %0, i32* %1) {
%3 = alloca i8*
%4 = tail call i64 @get_color_from_name(i8* %0, i32* %1)
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %18
6: ; preds = %2
%7 = tail call i32 @strlen(i8* %0)
%8 = icmp eq i32 %7, 6
br i1 %8, label %9, label %18
9: ; preds = %6
%10 = bitcast i8** %3 to i8*
store i8* %0, i8** %3
%11 = call i64 @strtol(i8* %0, i8** %3, i32 16)
%12 = load i8*, i8** %3
%13 = icmp eq i8* %12, %0
br i1 %13, label %16, label %14
14: ; preds = %9
%15 = trunc i64 %11 to i32
store i32 %15, i32* %1
br label %16
16: ; preds = %9, %14
%17 = phi i32 [ 1, %14 ], [ 0, %9 ]
br label %18
18: ; preds = %6, %2, %16
%19 = phi i32 [ %17, %16 ], [ 1, %2 ], [ 0, %6 ]
ret i32 %19
}