void RGB2XYZ(unsigned char B, unsigned char G, unsigned char R, double *X,
             double *Y, double *Z) {
  *X = (double)(0.412453 * R) + (double)(0.357580 * G) + (double)(0.180423 * B);
  *Y = (double)(0.212671 * R) + (double)(0.715160 * G) + (double)(0.072169 * B);
  *Z = (double)(0.019334 * R) + (double)(0.119193 * G) + (double)(0.950227 * B);
}


x86 assembly (clang, -O0):
<RGB2XYZ>:
push   %rbp
mov    %rsp,%rbp
mov    %dl,%al
mov    %sil,%dl
mov    %dil,%sil
mov    %sil,-0x1(%rbp)
mov    %dl,-0x2(%rbp)
mov    %al,-0x3(%rbp)
mov    %rcx,-0x10(%rbp)
mov    %r8,-0x18(%rbp)
mov    %r9,-0x20(%rbp)
movzbl -0x3(%rbp),%eax
cvtsi2sd %eax,%xmm1
movzbl -0x2(%rbp),%eax
cvtsi2sd %eax,%xmm2
movsd  0xf06(%rip),%xmm0
mulsd  %xmm2,%xmm0
movsd  0xef2(%rip),%xmm2
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movzbl -0x1(%rbp),%eax
cvtsi2sd %eax,%xmm0
movsd  0xed2(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
movzbl -0x3(%rbp),%eax
cvtsi2sd %eax,%xmm1
movzbl -0x2(%rbp),%eax
cvtsi2sd %eax,%xmm2
movsd  0xea2(%rip),%xmm0
mulsd  %xmm2,%xmm0
movsd  0xe8e(%rip),%xmm2
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movzbl -0x1(%rbp),%eax
cvtsi2sd %eax,%xmm0
movsd  0xe6e(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
movzbl -0x3(%rbp),%eax
cvtsi2sd %eax,%xmm1
movzbl -0x2(%rbp),%eax
cvtsi2sd %eax,%xmm2
movsd  0xe3e(%rip),%xmm0
mulsd  %xmm2,%xmm0
movsd  0xe2a(%rip),%xmm2
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movzbl -0x1(%rbp),%eax
cvtsi2sd %eax,%xmm0
movsd  0xe0a(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<RGB2XYZ>:
cvtsi2sd %edx,%xmm0
cvtsi2sd %esi,%xmm1
movsd  0xef0(%rip),%xmm2
mulsd  %xmm1,%xmm2
movsd  0xeec(%rip),%xmm3
mulsd  %xmm0,%xmm3
addsd  %xmm2,%xmm3
xorps  %xmm2,%xmm2
cvtsi2sd %edi,%xmm2
movsd  0xedd(%rip),%xmm4
mulsd  %xmm2,%xmm4
addsd  %xmm3,%xmm4
movsd  %xmm4,(%rcx)
movsd  0xed1(%rip),%xmm3
mulsd  %xmm1,%xmm3
movsd  0xecd(%rip),%xmm4
mulsd  %xmm0,%xmm4
addsd  %xmm3,%xmm4
movsd  0xec5(%rip),%xmm3
mulsd  %xmm2,%xmm3
addsd  %xmm4,%xmm3
mulsd  0xebd(%rip),%xmm1
movsd  %xmm3,(%r8)
mulsd  0xeb8(%rip),%xmm0
addsd  %xmm1,%xmm0
mulsd  0xeb4(%rip),%xmm2
addsd  %xmm0,%xmm2
movsd  %xmm2,(%r9)
ret

LLVM IR (-O0):
define void @RGB2XYZ(i8 zeroext %0, i8 zeroext %1, i8 zeroext %2, double* %3, double* %4, double* %5) {
%7 = alloca i8
%8 = alloca i8
%9 = alloca i8
%10 = alloca double*
%11 = alloca double*
%12 = alloca double*
store i8 %0, i8* %7
store i8 %1, i8* %8
store i8 %2, i8* %9
store double* %3, double** %10
store double* %4, double** %11
store double* %5, double** %12
%13 = load i8, i8* %9
%14 = zext i8 %13 to i32
%15 = sitofp i32 %14 to double
%16 = load i8, i8* %8
%17 = zext i8 %16 to i32
%18 = sitofp i32 %17 to double
%19 = fmul double 3.575800e-01, %18
%20 = call double @llvm.fmuladd.f64(double 4.124530e-01, double %15, double %19)
%21 = load i8, i8* %7
%22 = zext i8 %21 to i32
%23 = sitofp i32 %22 to double
%24 = call double @llvm.fmuladd.f64(double 1.804230e-01, double %23, double %20)
%25 = load double*, double** %10
store double %24, double* %25
%26 = load i8, i8* %9
%27 = zext i8 %26 to i32
%28 = sitofp i32 %27 to double
%29 = load i8, i8* %8
%30 = zext i8 %29 to i32
%31 = sitofp i32 %30 to double
%32 = fmul double 7.151600e-01, %31
%33 = call double @llvm.fmuladd.f64(double 2.126710e-01, double %28, double %32)
%34 = load i8, i8* %7
%35 = zext i8 %34 to i32
%36 = sitofp i32 %35 to double
%37 = call double @llvm.fmuladd.f64(double 0x3FB279AAE6C8F755, double %36, double %33)
%38 = load double*, double** %11
store double %37, double* %38
%39 = load i8, i8* %9
%40 = zext i8 %39 to i32
%41 = sitofp i32 %40 to double
%42 = load i8, i8* %8
%43 = zext i8 %42 to i32
%44 = sitofp i32 %43 to double
%45 = fmul double 1.191930e-01, %44
%46 = call double @llvm.fmuladd.f64(double 1.933400e-02, double %41, double %45)
%47 = load i8, i8* %7
%48 = zext i8 %47 to i32
%49 = sitofp i32 %48 to double
%50 = call double @llvm.fmuladd.f64(double 9.502270e-01, double %49, double %46)
%51 = load double*, double** %12
store double %50, double* %51
ret void
}

LLVM IR (-O2):
define void @RGB2XYZ(i8 zeroext %0, i8 zeroext %1, i8 zeroext %2, double* nocapture writeonly %3, double* nocapture writeonly %4, double* nocapture writeonly %5) {
%7 = uitofp i8 %2 to double
%8 = uitofp i8 %1 to double
%9 = fmul double %8, 3.575800e-01
%10 = tail call double @llvm.fmuladd.f64(double %7, double 4.124530e-01, double %9)
%11 = uitofp i8 %0 to double
%12 = tail call double @llvm.fmuladd.f64(double %11, double 1.804230e-01, double %10)
store double %12, double* %3
%13 = fmul double %8, 7.151600e-01
%14 = tail call double @llvm.fmuladd.f64(double %7, double 2.126710e-01, double %13)
%15 = tail call double @llvm.fmuladd.f64(double %11, double 0x3FB279AAE6C8F755, double %14)
store double %15, double* %4
%16 = fmul double %8, 1.191930e-01
%17 = tail call double @llvm.fmuladd.f64(double %7, double 1.933400e-02, double %16)
%18 = tail call double @llvm.fmuladd.f64(double %11, double 9.502270e-01, double %17)
store double %18, double* %5
ret void
}