#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*/ logMsg(int, char *, char *, ...);
int strlen(char *);
int isColourOk(char *value) {
  if (strlen(value) != 6) {
    logMsg(4, "Attempt to change config colour value to %s - length must be %d",
           value, 6);
    return 0;
  } else {
    int i;
    char c;
    for (i = 0; i < 6; i++) {
      c = value[i];
      if (!((c >= '0' && c <= '9') || (c >= 'a' && c <= 'f'))) {
        logMsg(4,
               "Attempt to change config colour value to %s - characters must "
               "be 0-9 or a-f.",
               value);
        return 0;
      }
    }
  }
  return 1;
}


x86 assembly (clang, -O0):
<isColourOk>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x6,%eax
je     1166 <isColourOk+0x46>
mov    -0x10(%rbp),%rdx
mov    $0x4,%edi
lea    0xeb2(%rip),%rsi
mov    $0x6,%ecx
mov    $0x0,%al
call   1040 <logMsg@plt>
movl   $0x0,-0x4(%rbp)
jmp    11fb <isColourOk+0xdb>
movl   $0x0,-0x14(%rbp)
cmpl   $0x6,-0x14(%rbp)
jge    11ef <isColourOk+0xcf>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x15(%rbp)
movsbl -0x15(%rbp),%eax
cmp    $0x30,%eax
jl     119f <isColourOk+0x7f>
movsbl -0x15(%rbp),%eax
cmp    $0x39,%eax
jle    11dc <isColourOk+0xbc>
movsbl -0x15(%rbp),%eax
cmp    $0x61,%eax
jl     11b9 <isColourOk+0x99>
movsbl -0x15(%rbp),%eax
cmp    $0x66,%eax
jle    11dc <isColourOk+0xbc>
mov    -0x10(%rbp),%rdx
mov    $0x4,%edi
lea    0xe77(%rip),%rsi
mov    $0x0,%al
call   1040 <logMsg@plt>
movl   $0x0,-0x4(%rbp)
jmp    11fb <isColourOk+0xdb>
jmp    11e1 <isColourOk+0xc1>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    116d <isColourOk+0x4d>
jmp    11f4 <isColourOk+0xd4>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<isColourOk>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1030 <strlen@plt>
cmp    $0x6,%eax
jne    11b8 <isColourOk+0x98>
mov    (%rbx),%al
lea    -0x30(%rax),%ecx
cmp    $0xa,%cl
jb     1144 <isColourOk+0x24>
add    $0x9f,%al
cmp    $0x6,%al
jae    119e <isColourOk+0x7e>
mov    0x1(%rbx),%al
lea    -0x30(%rax),%ecx
cmp    $0xa,%cl
jb     1155 <isColourOk+0x35>
add    $0x9f,%al
cmp    $0x5,%al
ja     119e <isColourOk+0x7e>
mov    0x2(%rbx),%al
lea    -0x30(%rax),%ecx
cmp    $0xa,%cl
jb     1166 <isColourOk+0x46>
add    $0x9f,%al
cmp    $0x5,%al
ja     119e <isColourOk+0x7e>
mov    0x3(%rbx),%al
lea    -0x30(%rax),%ecx
cmp    $0xa,%cl
jb     1177 <isColourOk+0x57>
add    $0x9f,%al
cmp    $0x5,%al
ja     119e <isColourOk+0x7e>
mov    0x4(%rbx),%al
lea    -0x30(%rax),%ecx
cmp    $0xa,%cl
jb     1188 <isColourOk+0x68>
add    $0x9f,%al
cmp    $0x5,%al
ja     119e <isColourOk+0x7e>
mov    0x5(%rbx),%al
lea    -0x30(%rax),%ecx
mov    $0x1,%ebp
cmp    $0xa,%cl
jb     11d5 <isColourOk+0xb5>
add    $0x9f,%al
cmp    $0x6,%al
jb     11d5 <isColourOk+0xb5>
lea    0xe9b(%rip),%rsi
xor    %ebp,%ebp
mov    $0x4,%edi
mov    %rbx,%rdx
xor    %eax,%eax
call   1040 <logMsg@plt>
jmp    11d5 <isColourOk+0xb5>
lea    0xe41(%rip),%rsi
xor    %ebp,%ebp
mov    $0x4,%edi
mov    %rbx,%rdx
mov    $0x6,%ecx
xor    %eax,%eax
call   1040 <logMsg@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [64 x i8] c"Attempt to change config colour value to %s - length must be %d\00"
@.str.1 = [77 x i8] c"Attempt to change config colour value to %s - characters must be 0-9 or a-f.\00"
define i32 @isColourOk(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8
store i8* %0, i8** %3
%6 = load i8*, i8** %3
%7 = call i32 @strlen(i8* %6)
%8 = icmp ne i32 %7, 6
br i1 %8, label %9, label %12
9: ; preds = %1
%10 = load i8*, i8** %3
%11 = call i32 (i32, i8*, i8*, ...) @logMsg(i32 4, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str, i64 0, i64 0), i8* %10, i32 6)
store i32 0, i32* %2
br label %46
12: ; preds = %1
store i32 0, i32* %4
br label %13
13: ; preds = %41, %12
%14 = load i32, i32* %4
%15 = icmp slt i32 %14, 6
br i1 %15, label %16, label %44
16: ; preds = %13
%17 = load i8*, i8** %3
%18 = load i32, i32* %4
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %17, i64 %19
%21 = load i8, i8* %20
store i8 %21, i8* %5
%22 = load i8, i8* %5
%23 = sext i8 %22 to i32
%24 = icmp sge i32 %23, 48
br i1 %24, label %25, label %29
25: ; preds = %16
%26 = load i8, i8* %5
%27 = sext i8 %26 to i32
%28 = icmp sle i32 %27, 57
br i1 %28, label %40, label %29
29: ; preds = %25, %16
%30 = load i8, i8* %5
%31 = sext i8 %30 to i32
%32 = icmp sge i32 %31, 97
br i1 %32, label %33, label %37
33: ; preds = %29
%34 = load i8, i8* %5
%35 = sext i8 %34 to i32
%36 = icmp sle i32 %35, 102
br i1 %36, label %40, label %37
37: ; preds = %33, %29
%38 = load i8*, i8** %3
%39 = call i32 (i32, i8*, i8*, ...) @logMsg(i32 4, i8* getelementptr inbounds ([77 x i8], [77 x i8]* @.str.1, i64 0, i64 0), i8* %38)
store i32 0, i32* %2
br label %46
40: ; preds = %33, %25
br label %41
41: ; preds = %40
%42 = load i32, i32* %4
%43 = add nsw i32 %42, 1
store i32 %43, i32* %4
br label %13
44: ; preds = %13
br label %45
45: ; preds = %44
store i32 1, i32* %2
br label %46
46: ; preds = %45, %37, %9
%47 = load i32, i32* %2
ret i32 %47
}

LLVM IR (-O2):
@.str = [64 x i8] c"Attempt to change config colour value to %s - length must be %d\00"
@.str.1 = [77 x i8] c"Attempt to change config colour value to %s - characters must be 0-9 or a-f.\00"
define i32 @isColourOk(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = icmp eq i32 %2, 6
br i1 %3, label %4, label %11
4: ; preds = %1
%5 = load i8, i8* %0
%6 = add i8 %5, -48
%7 = icmp ult i8 %6, 10
%8 = add i8 %5, -97
%9 = icmp ult i8 %8, 6
%10 = or i1 %7, %9
br i1 %10, label %13, label %53
11: ; preds = %1
%12 = tail call i32 (i32, i8*, i8*, ...) @logMsg(i32 4, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str, i64 0, i64 0), i8* %0, i32 6)
br label %55
13: ; preds = %4
%14 = getelementptr inbounds i8, i8* %0, i64 1
%15 = load i8, i8* %14
%16 = add i8 %15, -48
%17 = icmp ult i8 %16, 10
%18 = add i8 %15, -97
%19 = icmp ult i8 %18, 6
%20 = or i1 %17, %19
br i1 %20, label %21, label %53
21: ; preds = %13
%22 = getelementptr inbounds i8, i8* %0, i64 2
%23 = load i8, i8* %22
%24 = add i8 %23, -48
%25 = icmp ult i8 %24, 10
%26 = add i8 %23, -97
%27 = icmp ult i8 %26, 6
%28 = or i1 %25, %27
br i1 %28, label %29, label %53
29: ; preds = %21
%30 = getelementptr inbounds i8, i8* %0, i64 3
%31 = load i8, i8* %30
%32 = add i8 %31, -48
%33 = icmp ult i8 %32, 10
%34 = add i8 %31, -97
%35 = icmp ult i8 %34, 6
%36 = or i1 %33, %35
br i1 %36, label %37, label %53
37: ; preds = %29
%38 = getelementptr inbounds i8, i8* %0, i64 4
%39 = load i8, i8* %38
%40 = add i8 %39, -48
%41 = icmp ult i8 %40, 10
%42 = add i8 %39, -97
%43 = icmp ult i8 %42, 6
%44 = or i1 %41, %43
br i1 %44, label %45, label %53
45: ; preds = %37
%46 = getelementptr inbounds i8, i8* %0, i64 5
%47 = load i8, i8* %46
%48 = add i8 %47, -48
%49 = icmp ult i8 %48, 10
%50 = add i8 %47, -97
%51 = icmp ult i8 %50, 6
%52 = or i1 %49, %51
br i1 %52, label %55, label %53
53: ; preds = %45, %37, %29, %21, %13, %4
%54 = tail call i32 (i32, i8*, i8*, ...) @logMsg(i32 4, i8* getelementptr inbounds ([77 x i8], [77 x i8]* @.str.1, i64 0, i64 0), i8* %0)
br label %55
55: ; preds = %53, %45, %11
%56 = phi i32 [ 0, %11 ], [ 0, %53 ], [ 1, %45 ]
ret i32 %56
}