#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*/ strcpy(char *, char const *);
scalar_t__ strtoul(char *, int /*<<< orphan*/ *, int);
void Hex2RGB(char const aHexRGB[8], unsigned char aoResultRGB[3]) {
  char lColorChannel[8];
  if (aoResultRGB) {
    if (aHexRGB) {
      strcpy(lColorChannel, aHexRGB);
      aoResultRGB[2] = (unsigned char)strtoul(lColorChannel + 5, NULL, 16);
      lColorChannel[5] = '\0';
      aoResultRGB[1] = (unsigned char)strtoul(lColorChannel + 3, NULL, 16);
      lColorChannel[3] = '\0';
      aoResultRGB[0] = (unsigned char)strtoul(lColorChannel + 1, NULL, 16);
    } else {
      aoResultRGB[0] = 0;
      aoResultRGB[1] = 0;
      aoResultRGB[2] = 0;
    }
  }
}


x86 assembly (clang, -O0):
<Hex2RGB>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     11d8 <Hex2RGB+0xb8>
cmpq   $0x0,-0x8(%rbp)
je     11bc <Hex2RGB+0x9c>
lea    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0x18(%rbp),%rdi
add    $0x5,%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0x10,%edx
call   1040 <strtoul@plt>
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x2(%rax)
movb   $0x0,-0x13(%rbp)
lea    -0x18(%rbp),%rdi
add    $0x3,%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0x10,%edx
call   1040 <strtoul@plt>
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x1(%rax)
movb   $0x0,-0x15(%rbp)
lea    -0x18(%rbp),%rdi
add    $0x1,%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0x10,%edx
call   1040 <strtoul@plt>
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,(%rax)
jmp    11d3 <Hex2RGB+0xb3>
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rax
movb   $0x0,0x1(%rax)
mov    -0x10(%rbp),%rax
movb   $0x0,0x2(%rax)
jmp    11d8 <Hex2RGB+0xb8>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Hex2RGB>:
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
test   %rsi,%rsi
je     118f <Hex2RGB+0x6f>
mov    %rdi,%rsi
test   %rdi,%rdi
je     1186 <Hex2RGB+0x66>
lea    0x8(%rsp),%rdi
call   1030 <strcpy@plt>
lea    0xd(%rsp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1040 <strtoul@plt>
mov    %al,0x2(%rbx)
movb   $0x0,0xd(%rsp)
lea    0xb(%rsp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1040 <strtoul@plt>
mov    %al,0x1(%rbx)
movb   $0x0,0xb(%rsp)
lea    0x9(%rsp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1040 <strtoul@plt>
mov    %al,(%rbx)
jmp    118f <Hex2RGB+0x6f>
movw   $0x0,(%rbx)
movb   $0x0,0x2(%rbx)
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define void @Hex2RGB(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca [8 x i8]
store i8* %0, i8** %3
store i8* %1, i8** %4
%6 = load i8*, i8** %4
%7 = icmp ne i8* %6, null
br i1 %7, label %8, label %43
8: ; preds = %2
%9 = load i8*, i8** %3
%10 = icmp ne i8* %9, null
br i1 %10, label %11, label %35
11: ; preds = %8
%12 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 0
%13 = load i8*, i8** %3
%14 = call i32 @strcpy(i8* %12, i8* %13)
%15 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 0
%16 = getelementptr inbounds i8, i8* %15, i64 5
%17 = call i64 @strtoul(i8* %16, i32* null, i32 16)
%18 = trunc i64 %17 to i8
%19 = load i8*, i8** %4
%20 = getelementptr inbounds i8, i8* %19, i64 2
store i8 %18, i8* %20
%21 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 5
store i8 0, i8* %21
%22 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 0
%23 = getelementptr inbounds i8, i8* %22, i64 3
%24 = call i64 @strtoul(i8* %23, i32* null, i32 16)
%25 = trunc i64 %24 to i8
%26 = load i8*, i8** %4
%27 = getelementptr inbounds i8, i8* %26, i64 1
store i8 %25, i8* %27
%28 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 3
store i8 0, i8* %28
%29 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 0
%30 = getelementptr inbounds i8, i8* %29, i64 1
%31 = call i64 @strtoul(i8* %30, i32* null, i32 16)
%32 = trunc i64 %31 to i8
%33 = load i8*, i8** %4
%34 = getelementptr inbounds i8, i8* %33, i64 0
store i8 %32, i8* %34
br label %42
35: ; preds = %8
%36 = load i8*, i8** %4
%37 = getelementptr inbounds i8, i8* %36, i64 0
store i8 0, i8* %37
%38 = load i8*, i8** %4
%39 = getelementptr inbounds i8, i8* %38, i64 1
store i8 0, i8* %39
%40 = load i8*, i8** %4
%41 = getelementptr inbounds i8, i8* %40, i64 2
store i8 0, i8* %41
br label %42
42: ; preds = %35, %11
br label %43
43: ; preds = %42, %2
ret void
}

LLVM IR (-O2):
define void @Hex2RGB(i8* %0, i8* writeonly %1) {
%3 = alloca [8 x i8]
%4 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 0
%5 = icmp eq i8* %1, null
br i1 %5, label %24, label %6
6: ; preds = %2
%7 = icmp eq i8* %0, null
br i1 %7, label %21, label %8
8: ; preds = %6
%9 = call i32 @strcpy(i8* %4, i8* %0)
%10 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 5
%11 = call i64 @strtoul(i8* nocapture %10, i32* null, i32 16)
%12 = trunc i64 %11 to i8
%13 = getelementptr inbounds i8, i8* %1, i64 2
store i8 %12, i8* %13
store i8 0, i8* %10
%14 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 3
%15 = call i64 @strtoul(i8* nocapture %14, i32* null, i32 16)
%16 = trunc i64 %15 to i8
%17 = getelementptr inbounds i8, i8* %1, i64 1
store i8 %16, i8* %17
store i8 0, i8* %14
%18 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 1
%19 = call i64 @strtoul(i8* nocapture %18, i32* null, i32 16)
%20 = trunc i64 %19 to i8
store i8 %20, i8* %1
br label %24
21: ; preds = %6
store i8 0, i8* %1
%22 = getelementptr inbounds i8, i8* %1, i64 1
store i8 0, i8* %22
%23 = getelementptr inbounds i8, i8* %1, i64 2
store i8 0, i8* %23
br label %24
24: ; preds = %8, %21, %2
ret void
}