#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*/ sscanf(char *, char *, unsigned int *);
void parse_color(const char *string, double output[3]) {
  char r[2] = {string[1], string[2]};
  char g[2] = {string[3], string[4]};
  char b[2] = {string[5], string[6]};
  unsigned a[3];
  sscanf(r, "%02x", a);
  sscanf(g, "%02x", a + 1);
  sscanf(b, "%02x", a + 2);
  output[0] = a[0] / 255.0;
  output[1] = a[1] / 255.0;
  output[2] = a[2] / 255.0;
}


x86 assembly (clang, -O0):
<parse_color>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    0x1(%rax),%al
mov    %al,-0x12(%rbp)
mov    -0x8(%rbp),%rax
mov    0x2(%rax),%al
mov    %al,-0x11(%rbp)
mov    -0x8(%rbp),%rax
mov    0x3(%rax),%al
mov    %al,-0x14(%rbp)
mov    -0x8(%rbp),%rax
mov    0x4(%rax),%al
mov    %al,-0x13(%rbp)
mov    -0x8(%rbp),%rax
mov    0x5(%rax),%al
mov    %al,-0x16(%rbp)
mov    -0x8(%rbp),%rax
mov    0x6(%rax),%al
mov    %al,-0x15(%rbp)
lea    0xea5(%rip),%rsi
mov    %rsi,-0x30(%rbp)
lea    -0x12(%rbp),%rdi
lea    -0x24(%rbp),%rdx
call   1030 <sscanf@plt>
mov    -0x30(%rbp),%rsi
lea    -0x20(%rbp),%rdx
lea    -0x14(%rbp),%rdi
call   1030 <sscanf@plt>
mov    -0x30(%rbp),%rsi
lea    -0x1c(%rbp),%rdx
lea    -0x16(%rbp),%rdi
call   1030 <sscanf@plt>
mov    -0x24(%rbp),%eax
cvtsi2sd %rax,%xmm0
movsd  0xe5a(%rip),%xmm1
divsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x20(%rbp),%eax
cvtsi2sd %rax,%xmm0
divsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x8(%rax)
mov    -0x1c(%rbp),%eax
cvtsi2sd %rax,%xmm0
movsd  0xe29(%rip),%xmm1
divsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x10(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_color>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r14
mov    0x1(%rdi),%al
mov    %al,0x6(%rsp)
mov    0x2(%rdi),%al
mov    %al,0x7(%rsp)
mov    0x3(%rdi),%al
mov    %al,0x4(%rsp)
mov    0x4(%rdi),%al
mov    %al,0x5(%rsp)
mov    0x5(%rdi),%al
mov    %al,0x2(%rsp)
mov    0x6(%rdi),%al
mov    %al,0x3(%rsp)
lea    0xedd(%rip),%rbx
lea    0x6(%rsp),%rdi
lea    0x8(%rsp),%rdx
mov    %rbx,%rsi
call   1030 <sscanf@plt>
lea    0xc(%rsp),%rdx
lea    0x4(%rsp),%rdi
mov    %rbx,%rsi
call   1030 <sscanf@plt>
lea    0x10(%rsp),%rdx
lea    0x2(%rsp),%rdi
mov    %rbx,%rsi
call   1030 <sscanf@plt>
movsd  0x8(%rsp),%xmm0
xorpd  %xmm1,%xmm1
unpcklps %xmm1,%xmm0
movapd 0xe6a(%rip),%xmm1
orpd   %xmm1,%xmm0
subpd  %xmm1,%xmm0
divpd  0xe6a(%rip),%xmm0
movupd %xmm0,(%r14)
mov    0x10(%rsp),%eax
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
divsd  0xe61(%rip),%xmm0
movsd  %xmm0,0x10(%r14)
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%02x\00"
define void @parse_color(i8* %0, double* %1) {
%3 = alloca i8*
%4 = alloca double*
%5 = alloca [2 x i8]
%6 = alloca [2 x i8]
%7 = alloca [2 x i8]
%8 = alloca [3 x i32]
store i8* %0, i8** %3
store double* %1, double** %4
%9 = getelementptr inbounds [2 x i8], [2 x i8]* %5, i64 0, i64 0
%10 = load i8*, i8** %3
%11 = getelementptr inbounds i8, i8* %10, i64 1
%12 = load i8, i8* %11
store i8 %12, i8* %9
%13 = getelementptr inbounds i8, i8* %9, i64 1
%14 = load i8*, i8** %3
%15 = getelementptr inbounds i8, i8* %14, i64 2
%16 = load i8, i8* %15
store i8 %16, i8* %13
%17 = getelementptr inbounds [2 x i8], [2 x i8]* %6, i64 0, i64 0
%18 = load i8*, i8** %3
%19 = getelementptr inbounds i8, i8* %18, i64 3
%20 = load i8, i8* %19
store i8 %20, i8* %17
%21 = getelementptr inbounds i8, i8* %17, i64 1
%22 = load i8*, i8** %3
%23 = getelementptr inbounds i8, i8* %22, i64 4
%24 = load i8, i8* %23
store i8 %24, i8* %21
%25 = getelementptr inbounds [2 x i8], [2 x i8]* %7, i64 0, i64 0
%26 = load i8*, i8** %3
%27 = getelementptr inbounds i8, i8* %26, i64 5
%28 = load i8, i8* %27
store i8 %28, i8* %25
%29 = getelementptr inbounds i8, i8* %25, i64 1
%30 = load i8*, i8** %3
%31 = getelementptr inbounds i8, i8* %30, i64 6
%32 = load i8, i8* %31
store i8 %32, i8* %29
%33 = getelementptr inbounds [2 x i8], [2 x i8]* %5, i64 0, i64 0
%34 = getelementptr inbounds [3 x i32], [3 x i32]* %8, i64 0, i64 0
%35 = call i32 @sscanf(i8* %33, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32* %34)
%36 = getelementptr inbounds [2 x i8], [2 x i8]* %6, i64 0, i64 0
%37 = getelementptr inbounds [3 x i32], [3 x i32]* %8, i64 0, i64 0
%38 = getelementptr inbounds i32, i32* %37, i64 1
%39 = call i32 @sscanf(i8* %36, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32* %38)
%40 = getelementptr inbounds [2 x i8], [2 x i8]* %7, i64 0, i64 0
%41 = getelementptr inbounds [3 x i32], [3 x i32]* %8, i64 0, i64 0
%42 = getelementptr inbounds i32, i32* %41, i64 2
%43 = call i32 @sscanf(i8* %40, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32* %42)
%44 = getelementptr inbounds [3 x i32], [3 x i32]* %8, i64 0, i64 0
%45 = load i32, i32* %44
%46 = uitofp i32 %45 to double
%47 = fdiv double %46, 2.550000e+02
%48 = load double*, double** %4
%49 = getelementptr inbounds double, double* %48, i64 0
store double %47, double* %49
%50 = getelementptr inbounds [3 x i32], [3 x i32]* %8, i64 0, i64 1
%51 = load i32, i32* %50
%52 = uitofp i32 %51 to double
%53 = fdiv double %52, 2.550000e+02
%54 = load double*, double** %4
%55 = getelementptr inbounds double, double* %54, i64 1
store double %53, double* %55
%56 = getelementptr inbounds [3 x i32], [3 x i32]* %8, i64 0, i64 2
%57 = load i32, i32* %56
%58 = uitofp i32 %57 to double
%59 = fdiv double %58, 2.550000e+02
%60 = load double*, double** %4
%61 = getelementptr inbounds double, double* %60, i64 2
store double %59, double* %61
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"%02x\00"
define void @parse_color(i8* nocapture %0, double* nocapture writeonly %1) {
%3 = alloca [2 x i8]
%4 = alloca [2 x i8]
%5 = alloca [2 x i8]
%6 = alloca [3 x i32]
%7 = getelementptr inbounds [2 x i8], [2 x i8]* %3, i64 0, i64 0
%8 = getelementptr inbounds i8, i8* %0, i64 1
%9 = load i8, i8* %8
store i8 %9, i8* %7
%10 = getelementptr inbounds [2 x i8], [2 x i8]* %3, i64 0, i64 1
%11 = getelementptr inbounds i8, i8* %0, i64 2
%12 = load i8, i8* %11
store i8 %12, i8* %10
%13 = getelementptr inbounds [2 x i8], [2 x i8]* %4, i64 0, i64 0
%14 = getelementptr inbounds i8, i8* %0, i64 3
%15 = load i8, i8* %14
store i8 %15, i8* %13
%16 = getelementptr inbounds [2 x i8], [2 x i8]* %4, i64 0, i64 1
%17 = getelementptr inbounds i8, i8* %0, i64 4
%18 = load i8, i8* %17
store i8 %18, i8* %16
%19 = getelementptr inbounds [2 x i8], [2 x i8]* %5, i64 0, i64 0
%20 = getelementptr inbounds i8, i8* %0, i64 5
%21 = load i8, i8* %20
store i8 %21, i8* %19
%22 = getelementptr inbounds [2 x i8], [2 x i8]* %5, i64 0, i64 1
%23 = getelementptr inbounds i8, i8* %0, i64 6
%24 = load i8, i8* %23
store i8 %24, i8* %22
%25 = bitcast [3 x i32]* %6 to i8*
%26 = getelementptr inbounds [3 x i32], [3 x i32]* %6, i64 0, i64 0
%27 = call i32 @sscanf(i8* %7, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32* %26)
%28 = getelementptr inbounds [3 x i32], [3 x i32]* %6, i64 0, i64 1
%29 = call i32 @sscanf(i8* %13, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32* %28)
%30 = getelementptr inbounds [3 x i32], [3 x i32]* %6, i64 0, i64 2
%31 = call i32 @sscanf(i8* %19, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32* %30)
%32 = bitcast [3 x i32]* %6 to <2 x i32>*
%33 = load <2 x i32>, <2 x i32>* %32
%34 = uitofp <2 x i32> %33 to <2 x double>
%35 = fdiv <2 x double> %34, <double 2.550000e+02, double 2.550000e+02>
%36 = bitcast double* %1 to <2 x double>*
store <2 x double> %35, <2 x double>* %36
%37 = load i32, i32* %30
%38 = uitofp i32 %37 to double
%39 = fdiv double %38, 2.550000e+02
%40 = getelementptr inbounds double, double* %1, i64 2
store double %39, double* %40
ret void
}