#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 /*<<< orphan*/ isxdigit(char const);
int strlen(char const *);
int valid_rgb_color(const char *color) {
  int i;
  if (!color || strlen(color) != 7 || color[0] != '#')
    return 0;
  for (i = 1; i < 7; i++) {
    if (!isxdigit(color[i]))
      return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<valid_rgb_color>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1159 <valid_rgb_color+0x39>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x7,%eax
jne    1159 <valid_rgb_color+0x39>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x23,%eax
je     1165 <valid_rgb_color+0x45>
movl   $0x0,-0x4(%rbp)
jmp    11b6 <valid_rgb_color+0x96>
movl   $0x1,-0x14(%rbp)
cmpl   $0x7,-0x14(%rbp)
jge    11af <valid_rgb_color+0x8f>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <isxdigit@plt>
cmp    $0x0,%eax
jne    119c <valid_rgb_color+0x7c>
movl   $0x0,-0x4(%rbp)
jmp    11b6 <valid_rgb_color+0x96>
jmp    11a1 <valid_rgb_color+0x81>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    116c <valid_rgb_color+0x4c>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<valid_rgb_color>:
push   %rbp
push   %rbx
push   %rax
xor    %ebp,%ebp
test   %rdi,%rdi
je     118e <valid_rgb_color+0x6e>
mov    %rdi,%rbx
call   1030 <strlen@plt>
cmp    $0x7,%eax
jne    118e <valid_rgb_color+0x6e>
cmpb   $0x23,(%rbx)
jne    118e <valid_rgb_color+0x6e>
movsbl 0x1(%rbx),%edi
call   1040 <isxdigit@plt>
test   %eax,%eax
je     118e <valid_rgb_color+0x6e>
movsbl 0x2(%rbx),%edi
call   1040 <isxdigit@plt>
test   %eax,%eax
je     118e <valid_rgb_color+0x6e>
movsbl 0x3(%rbx),%edi
call   1040 <isxdigit@plt>
test   %eax,%eax
je     118e <valid_rgb_color+0x6e>
movsbl 0x4(%rbx),%edi
call   1040 <isxdigit@plt>
test   %eax,%eax
je     118e <valid_rgb_color+0x6e>
movsbl 0x5(%rbx),%edi
call   1040 <isxdigit@plt>
test   %eax,%eax
je     118e <valid_rgb_color+0x6e>
movsbl 0x6(%rbx),%edi
call   1040 <isxdigit@plt>
xor    %ebp,%ebp
test   %eax,%eax
setne  %bpl
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @valid_rgb_color(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = icmp ne i8* %5, null
br i1 %6, label %7, label %17
7: ; preds = %1
%8 = load i8*, i8** %3
%9 = call i32 @strlen(i8* %8)
%10 = icmp ne i32 %9, 7
br i1 %10, label %17, label %11
11: ; preds = %7
%12 = load i8*, i8** %3
%13 = getelementptr inbounds i8, i8* %12, i64 0
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp ne i32 %15, 35
br i1 %16, label %17, label %18
17: ; preds = %11, %7, %1
store i32 0, i32* %2
br label %36
18: ; preds = %11
store i32 1, i32* %4
br label %19
19: ; preds = %32, %18
%20 = load i32, i32* %4
%21 = icmp slt i32 %20, 7
br i1 %21, label %22, label %35
22: ; preds = %19
%23 = load i8*, i8** %3
%24 = load i32, i32* %4
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %23, i64 %25
%27 = load i8, i8* %26
%28 = call i32 @isxdigit(i8 signext %27)
%29 = icmp ne i32 %28, 0
br i1 %29, label %31, label %30
30: ; preds = %22
store i32 0, i32* %2
br label %36
31: ; preds = %22
br label %32
32: ; preds = %31
%33 = load i32, i32* %4
%34 = add nsw i32 %33, 1
store i32 %34, i32* %4
br label %19
35: ; preds = %19
store i32 1, i32* %2
br label %36
36: ; preds = %35, %30, %17
%37 = load i32, i32* %2
ret i32 %37
}

LLVM IR (-O2):
define i32 @valid_rgb_color(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %40, label %3
3: ; preds = %1
%4 = tail call i32 @strlen(i8* %0)
%5 = icmp eq i32 %4, 7
br i1 %5, label %6, label %40
6: ; preds = %3
%7 = load i8, i8* %0
%8 = icmp eq i8 %7, 35
br i1 %8, label %9, label %40
9: ; preds = %6
%10 = getelementptr inbounds i8, i8* %0, i64 1
%11 = load i8, i8* %10
%12 = tail call i32 @isxdigit(i8 signext %11)
%13 = icmp eq i32 %12, 0
br i1 %13, label %40, label %14
14: ; preds = %9
%15 = getelementptr inbounds i8, i8* %0, i64 2
%16 = load i8, i8* %15
%17 = tail call i32 @isxdigit(i8 signext %16)
%18 = icmp eq i32 %17, 0
br i1 %18, label %40, label %19
19: ; preds = %14
%20 = getelementptr inbounds i8, i8* %0, i64 3
%21 = load i8, i8* %20
%22 = tail call i32 @isxdigit(i8 signext %21)
%23 = icmp eq i32 %22, 0
br i1 %23, label %40, label %24
24: ; preds = %19
%25 = getelementptr inbounds i8, i8* %0, i64 4
%26 = load i8, i8* %25
%27 = tail call i32 @isxdigit(i8 signext %26)
%28 = icmp eq i32 %27, 0
br i1 %28, label %40, label %29
29: ; preds = %24
%30 = getelementptr inbounds i8, i8* %0, i64 5
%31 = load i8, i8* %30
%32 = tail call i32 @isxdigit(i8 signext %31)
%33 = icmp eq i32 %32, 0
br i1 %33, label %40, label %34
34: ; preds = %29
%35 = getelementptr inbounds i8, i8* %0, i64 6
%36 = load i8, i8* %35
%37 = tail call i32 @isxdigit(i8 signext %36)
%38 = icmp ne i32 %37, 0
%39 = zext i1 %38 to i32
br label %40
40: ; preds = %34, %9, %14, %19, %24, %29, %1, %3, %6
%41 = phi i32 [ 0, %6 ], [ 0, %3 ], [ 0, %1 ], [ 0, %9 ], [ 0, %14 ], [ 0, %19 ], [ 0, %24 ], [ 0, %29 ], [ %39, %34 ]
ret i32 %41
}