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


x86 assembly (clang, -O0):
<chk_html_colorcode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x6,%eax
je     114a <chk_html_colorcode+0x2a>
movl   $0xffffffff,-0x4(%rbp)
jmp    119c <chk_html_colorcode+0x7c>
movl   $0x0,-0x14(%rbp)
cmpl   $0x6,-0x14(%rbp)
jge    1195 <chk_html_colorcode+0x75>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <isxdigit@plt>
cmp    $0x0,%rax
jne    1182 <chk_html_colorcode+0x62>
movl   $0xffffffff,-0x4(%rbp)
jmp    119c <chk_html_colorcode+0x7c>
jmp    1187 <chk_html_colorcode+0x67>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1151 <chk_html_colorcode+0x31>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<chk_html_colorcode>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1030 <strlen@plt>
mov    $0xffffffff,%ebp
cmp    $0x6,%eax
jne    1189 <chk_html_colorcode+0x69>
movsbl (%rbx),%edi
call   1040 <isxdigit@plt>
test   %rax,%rax
je     1189 <chk_html_colorcode+0x69>
movsbl 0x1(%rbx),%edi
call   1040 <isxdigit@plt>
test   %rax,%rax
je     1189 <chk_html_colorcode+0x69>
movsbl 0x2(%rbx),%edi
call   1040 <isxdigit@plt>
test   %rax,%rax
je     1189 <chk_html_colorcode+0x69>
movsbl 0x3(%rbx),%edi
call   1040 <isxdigit@plt>
test   %rax,%rax
je     1189 <chk_html_colorcode+0x69>
movsbl 0x4(%rbx),%edi
call   1040 <isxdigit@plt>
test   %rax,%rax
je     1189 <chk_html_colorcode+0x69>
movsbl 0x5(%rbx),%edi
call   1040 <isxdigit@plt>
cmp    $0x1,%rax
sbb    %ebp,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

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